UNPKG

2.93 kBJavaScriptView Raw
1"use strict";
2var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6 return c > 3 && r && Object.defineProperty(target, key, r), r;
7};
8var TypeScriptSource_1;
9Object.defineProperty(exports, "__esModule", { value: true });
10const ts = require("typescript");
11const _ts = require("../../../ts-internal");
12const component_1 = require("../../component");
13const options_1 = require("../options");
14const declaration_1 = require("../declaration");
15let TypeScriptSource = TypeScriptSource_1 = class TypeScriptSource extends options_1.OptionsComponent {
16 initialize() {
17 this.declarations = [];
18 for (let declaration of _ts.optionDeclarations) {
19 if (!TypeScriptSource_1.IGNORED.includes(declaration.name)) {
20 this.addTSOption(declaration);
21 }
22 }
23 }
24 getOptionDeclarations() {
25 return this.declarations;
26 }
27 addTSOption(option) {
28 const param = {
29 name: option.name,
30 short: option.shortName,
31 help: option.description ? option.description.key : '',
32 scope: declaration_1.ParameterScope.TypeScript,
33 component: this.componentName
34 };
35 switch (option.type) {
36 case 'number':
37 param.type = declaration_1.ParameterType.Number;
38 break;
39 case 'boolean':
40 param.type = declaration_1.ParameterType.Boolean;
41 break;
42 case 'string':
43 param.type = declaration_1.ParameterType.String;
44 break;
45 case 'list':
46 param.type = declaration_1.ParameterType.Array;
47 break;
48 default:
49 param.type = declaration_1.ParameterType.Map;
50 param.map = option.type;
51 if (option['error']) {
52 const error = _ts.createCompilerDiagnostic(option['error']);
53 param.mapError = ts.flattenDiagnosticMessageText(error.messageText, ', ');
54 }
55 }
56 this.declarations.push(param);
57 }
58};
59TypeScriptSource.IGNORED = [
60 'out', 'version', 'help',
61 'watch', 'declaration', 'declarationDir', 'declarationMap', 'mapRoot',
62 'sourceMap', 'inlineSources', 'removeComments'
63];
64TypeScriptSource = TypeScriptSource_1 = __decorate([
65 component_1.Component({ name: 'options:typescript' })
66], TypeScriptSource);
67exports.TypeScriptSource = TypeScriptSource;
68//# sourceMappingURL=typescript.js.map
\No newline at end of file