1 | "use strict";
|
2 | var __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 | };
|
8 | var TypeScriptSource_1;
|
9 | Object.defineProperty(exports, "__esModule", { value: true });
|
10 | const ts = require("typescript");
|
11 | const _ts = require("../../../ts-internal");
|
12 | const component_1 = require("../../component");
|
13 | const options_1 = require("../options");
|
14 | const declaration_1 = require("../declaration");
|
15 | let 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 | };
|
59 | TypeScriptSource.IGNORED = [
|
60 | 'out', 'version', 'help',
|
61 | 'watch', 'declaration', 'declarationDir', 'declarationMap', 'mapRoot',
|
62 | 'sourceMap', 'inlineSources', 'removeComments'
|
63 | ];
|
64 | TypeScriptSource = TypeScriptSource_1 = __decorate([
|
65 | component_1.Component({ name: 'options:typescript' })
|
66 | ], TypeScriptSource);
|
67 | exports.TypeScriptSource = TypeScriptSource;
|
68 |
|
\ | No newline at end of file |