@teambit/typescript 0.0.881 → 0.0.883
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cmds/check-types.cmd.js +0 -21
- package/dist/cmds/check-types.cmd.js.map +1 -1
- package/dist/cmds/write-tsconfig.cmd.js +2 -25
- package/dist/cmds/write-tsconfig.cmd.js.map +1 -1
- package/dist/dedupe-path.spec.js +6 -8
- package/dist/dedupe-path.spec.js.map +1 -1
- package/dist/exceptions/index.js +0 -3
- package/dist/exceptions/index.js.map +1 -1
- package/dist/exceptions/transformer-not-found.js +0 -7
- package/dist/exceptions/transformer-not-found.js.map +1 -1
- package/dist/export-identifier.js +0 -3
- package/dist/export-identifier.js.map +1 -1
- package/dist/export-list.js +0 -4
- package/dist/export-list.js.map +1 -1
- package/dist/index.js +0 -9
- package/dist/index.js.map +1 -1
- package/dist/schema-extractor-context.js +16 -120
- package/dist/schema-extractor-context.js.map +1 -1
- package/dist/schema-transformer.plugin.js +0 -8
- package/dist/schema-transformer.plugin.js.map +1 -1
- package/dist/transformers/binding-element.js +0 -23
- package/dist/transformers/binding-element.js.map +1 -1
- package/dist/transformers/class-deceleration.js +2 -34
- package/dist/transformers/class-deceleration.js.map +1 -1
- package/dist/transformers/enum-declaration.js +0 -16
- package/dist/transformers/enum-declaration.js.map +1 -1
- package/dist/transformers/export-declaration.js +8 -47
- package/dist/transformers/export-declaration.js.map +1 -1
- package/dist/transformers/function-declaration.js +2 -19
- package/dist/transformers/function-declaration.js.map +1 -1
- package/dist/transformers/index.js +0 -30
- package/dist/transformers/index.js.map +1 -1
- package/dist/transformers/interface-declaration.js +0 -25
- package/dist/transformers/interface-declaration.js.map +1 -1
- package/dist/transformers/source-file-transformer.js +3 -24
- package/dist/transformers/source-file-transformer.js.map +1 -1
- package/dist/transformers/type-alias.js +0 -23
- package/dist/transformers/type-alias.js.map +1 -1
- package/dist/transformers/utils/class-element-to-schema.js +0 -35
- package/dist/transformers/utils/class-element-to-schema.js.map +1 -1
- package/dist/transformers/utils/get-params.js +6 -33
- package/dist/transformers/utils/get-params.js.map +1 -1
- package/dist/transformers/utils/jsdoc-to-doc-schema.js +4 -49
- package/dist/transformers/utils/jsdoc-to-doc-schema.js.map +1 -1
- package/dist/transformers/utils/parse-type-from-quick-info.js +4 -16
- package/dist/transformers/utils/parse-type-from-quick-info.js.map +1 -1
- package/dist/transformers/utils/to-function-like-schema.js +0 -15
- package/dist/transformers/utils/to-function-like-schema.js.map +1 -1
- package/dist/transformers/utils/type-element-to-schema.js +0 -37
- package/dist/transformers/utils/type-element-to-schema.js.map +1 -1
- package/dist/transformers/utils/type-node-to-schema.js +5 -71
- package/dist/transformers/utils/type-node-to-schema.js.map +1 -1
- package/dist/transformers/variable-declaration.js +0 -30
- package/dist/transformers/variable-declaration.js.map +1 -1
- package/dist/transformers/variable-statement.js +0 -22
- package/dist/transformers/variable-statement.js.map +1 -1
- package/dist/tsconfig-writer.js +8 -58
- package/dist/tsconfig-writer.js.map +1 -1
- package/dist/typescript.aspect.js +0 -5
- package/dist/typescript.aspect.js.map +1 -1
- package/dist/typescript.compiler.js +16 -83
- package/dist/typescript.compiler.js.map +1 -1
- package/dist/typescript.compiler.spec.js +0 -25
- package/dist/typescript.compiler.spec.js.map +1 -1
- package/dist/typescript.composition.js +0 -6
- package/dist/typescript.composition.js.map +1 -1
- package/dist/typescript.extractor.js +6 -50
- package/dist/typescript.extractor.js.map +1 -1
- package/dist/typescript.main.runtime.js +10 -114
- package/dist/typescript.main.runtime.js.map +1 -1
- package/dist/typescript.parser.js +3 -30
- package/dist/typescript.parser.js.map +1 -1
- package/dist/typescript.parser.spec.js +0 -22
- package/dist/typescript.parser.spec.js.map +1 -1
- package/package-tar/teambit-typescript-0.0.883.tgz +0 -0
- package/package.json +12 -12
- package/{preview-1666409808293.js → preview-1666582798766.js} +2 -2
- package/package-tar/teambit-typescript-0.0.881.tgz +0 -0
|
@@ -63,104 +63,74 @@ Object.defineProperty(exports, "VariableStatementTransformer", {
|
|
|
63
63
|
return _variableStatement().VariableStatementTransformer;
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
|
-
|
|
67
66
|
function _exportDeclaration() {
|
|
68
67
|
const data = require("./export-declaration");
|
|
69
|
-
|
|
70
68
|
_exportDeclaration = function () {
|
|
71
69
|
return data;
|
|
72
70
|
};
|
|
73
|
-
|
|
74
71
|
return data;
|
|
75
72
|
}
|
|
76
|
-
|
|
77
73
|
function _functionDeclaration() {
|
|
78
74
|
const data = require("./function-declaration");
|
|
79
|
-
|
|
80
75
|
_functionDeclaration = function () {
|
|
81
76
|
return data;
|
|
82
77
|
};
|
|
83
|
-
|
|
84
78
|
return data;
|
|
85
79
|
}
|
|
86
|
-
|
|
87
80
|
function _variableStatement() {
|
|
88
81
|
const data = require("./variable-statement");
|
|
89
|
-
|
|
90
82
|
_variableStatement = function () {
|
|
91
83
|
return data;
|
|
92
84
|
};
|
|
93
|
-
|
|
94
85
|
return data;
|
|
95
86
|
}
|
|
96
|
-
|
|
97
87
|
function _variableDeclaration() {
|
|
98
88
|
const data = require("./variable-declaration");
|
|
99
|
-
|
|
100
89
|
_variableDeclaration = function () {
|
|
101
90
|
return data;
|
|
102
91
|
};
|
|
103
|
-
|
|
104
92
|
return data;
|
|
105
93
|
}
|
|
106
|
-
|
|
107
94
|
function _sourceFileTransformer() {
|
|
108
95
|
const data = require("./source-file-transformer");
|
|
109
|
-
|
|
110
96
|
_sourceFileTransformer = function () {
|
|
111
97
|
return data;
|
|
112
98
|
};
|
|
113
|
-
|
|
114
99
|
return data;
|
|
115
100
|
}
|
|
116
|
-
|
|
117
101
|
function _typeAlias() {
|
|
118
102
|
const data = require("./type-alias");
|
|
119
|
-
|
|
120
103
|
_typeAlias = function () {
|
|
121
104
|
return data;
|
|
122
105
|
};
|
|
123
|
-
|
|
124
106
|
return data;
|
|
125
107
|
}
|
|
126
|
-
|
|
127
108
|
function _classDeceleration() {
|
|
128
109
|
const data = require("./class-deceleration");
|
|
129
|
-
|
|
130
110
|
_classDeceleration = function () {
|
|
131
111
|
return data;
|
|
132
112
|
};
|
|
133
|
-
|
|
134
113
|
return data;
|
|
135
114
|
}
|
|
136
|
-
|
|
137
115
|
function _interfaceDeclaration() {
|
|
138
116
|
const data = require("./interface-declaration");
|
|
139
|
-
|
|
140
117
|
_interfaceDeclaration = function () {
|
|
141
118
|
return data;
|
|
142
119
|
};
|
|
143
|
-
|
|
144
120
|
return data;
|
|
145
121
|
}
|
|
146
|
-
|
|
147
122
|
function _enumDeclaration() {
|
|
148
123
|
const data = require("./enum-declaration");
|
|
149
|
-
|
|
150
124
|
_enumDeclaration = function () {
|
|
151
125
|
return data;
|
|
152
126
|
};
|
|
153
|
-
|
|
154
127
|
return data;
|
|
155
128
|
}
|
|
156
|
-
|
|
157
129
|
function _bindingElement() {
|
|
158
130
|
const data = require("./binding-element");
|
|
159
|
-
|
|
160
131
|
_bindingElement = function () {
|
|
161
132
|
return data;
|
|
162
133
|
};
|
|
163
|
-
|
|
164
134
|
return data;
|
|
165
135
|
}
|
|
166
136
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { ExportDeclaration } from './export-declaration';\nexport { FunctionDeclaration } from './function-declaration';\nexport { VariableStatementTransformer } from './variable-statement';\nexport { VariableDeclaration } from './variable-declaration';\nexport { SourceFileTransformer } from './source-file-transformer';\nexport { TypeAliasTransformer } from './type-alias';\nexport { ClassDecelerationTransformer } from './class-deceleration';\nexport { InterfaceDeclarationTransformer } from './interface-declaration';\nexport { EnumDeclarationTransformer } from './enum-declaration';\nexport { BindingElementTransformer } from './binding-element';\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { ExportDeclaration } from './export-declaration';\nexport { FunctionDeclaration } from './function-declaration';\nexport { VariableStatementTransformer } from './variable-statement';\nexport { VariableDeclaration } from './variable-declaration';\nexport { SourceFileTransformer } from './source-file-transformer';\nexport { TypeAliasTransformer } from './type-alias';\nexport { ClassDecelerationTransformer } from './class-deceleration';\nexport { InterfaceDeclarationTransformer } from './interface-declaration';\nexport { EnumDeclarationTransformer } from './enum-declaration';\nexport { BindingElementTransformer } from './binding-element';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA"}
|
|
@@ -1,91 +1,66 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
require("core-js/modules/es.promise.js");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.InterfaceDeclarationTransformer = void 0;
|
|
11
|
-
|
|
12
9
|
function _typescript() {
|
|
13
10
|
const data = require("typescript");
|
|
14
|
-
|
|
15
11
|
_typescript = function () {
|
|
16
12
|
return data;
|
|
17
13
|
};
|
|
18
|
-
|
|
19
14
|
return data;
|
|
20
15
|
}
|
|
21
|
-
|
|
22
16
|
function _pMapSeries() {
|
|
23
17
|
const data = _interopRequireDefault(require("p-map-series"));
|
|
24
|
-
|
|
25
18
|
_pMapSeries = function () {
|
|
26
19
|
return data;
|
|
27
20
|
};
|
|
28
|
-
|
|
29
21
|
return data;
|
|
30
22
|
}
|
|
31
|
-
|
|
32
23
|
function _semanticsEntities() {
|
|
33
24
|
const data = require("@teambit/semantics.entities.semantic-schema");
|
|
34
|
-
|
|
35
25
|
_semanticsEntities = function () {
|
|
36
26
|
return data;
|
|
37
27
|
};
|
|
38
|
-
|
|
39
28
|
return data;
|
|
40
29
|
}
|
|
41
|
-
|
|
42
30
|
function _exportIdentifier() {
|
|
43
31
|
const data = require("../export-identifier");
|
|
44
|
-
|
|
45
32
|
_exportIdentifier = function () {
|
|
46
33
|
return data;
|
|
47
34
|
};
|
|
48
|
-
|
|
49
35
|
return data;
|
|
50
36
|
}
|
|
51
|
-
|
|
52
37
|
function _typeElementToSchema() {
|
|
53
38
|
const data = require("./utils/type-element-to-schema");
|
|
54
|
-
|
|
55
39
|
_typeElementToSchema = function () {
|
|
56
40
|
return data;
|
|
57
41
|
};
|
|
58
|
-
|
|
59
42
|
return data;
|
|
60
43
|
}
|
|
61
|
-
|
|
62
44
|
function _jsdocToDocSchema() {
|
|
63
45
|
const data = require("./utils/jsdoc-to-doc-schema");
|
|
64
|
-
|
|
65
46
|
_jsdocToDocSchema = function () {
|
|
66
47
|
return data;
|
|
67
48
|
};
|
|
68
|
-
|
|
69
49
|
return data;
|
|
70
50
|
}
|
|
71
|
-
|
|
72
51
|
class InterfaceDeclarationTransformer {
|
|
73
52
|
predicate(node) {
|
|
74
53
|
return node.kind === _typescript().SyntaxKind.InterfaceDeclaration;
|
|
75
54
|
}
|
|
76
|
-
|
|
77
55
|
async getIdentifiers(node) {
|
|
78
56
|
return [new (_exportIdentifier().ExportIdentifier)(node.name.getText(), node.getSourceFile().fileName)];
|
|
79
57
|
}
|
|
80
|
-
|
|
81
58
|
async transform(interfaceDec, context) {
|
|
82
59
|
const members = await (0, _pMapSeries().default)(interfaceDec.members, member => (0, _typeElementToSchema().typeElementToSchema)(member, context));
|
|
83
60
|
const doc = await (0, _jsdocToDocSchema().jsDocToDocSchema)(interfaceDec, context);
|
|
84
61
|
return new (_semanticsEntities().InterfaceSchema)(context.getLocation(interfaceDec), interfaceDec.name.getText(), members, doc);
|
|
85
62
|
}
|
|
86
|
-
|
|
87
63
|
}
|
|
88
|
-
|
|
89
64
|
exports.InterfaceDeclarationTransformer = InterfaceDeclarationTransformer;
|
|
90
65
|
|
|
91
66
|
//# sourceMappingURL=interface-declaration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["InterfaceDeclarationTransformer","predicate","node","kind","SyntaxKind","InterfaceDeclaration","getIdentifiers","ExportIdentifier","name","getText","getSourceFile","fileName","transform","interfaceDec","context","members","pMapSeries","member","typeElementToSchema","doc","jsDocToDocSchema","InterfaceSchema","getLocation"],"sources":["interface-declaration.ts"],"sourcesContent":["import { Node, InterfaceDeclaration, SyntaxKind } from 'typescript';\nimport pMapSeries from 'p-map-series';\nimport { InterfaceSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\nimport { typeElementToSchema } from './utils/type-element-to-schema';\nimport { jsDocToDocSchema } from './utils/jsdoc-to-doc-schema';\n\nexport class InterfaceDeclarationTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === SyntaxKind.InterfaceDeclaration;\n }\n\n async getIdentifiers(node: InterfaceDeclaration): Promise<ExportIdentifier[]> {\n return [new ExportIdentifier(node.name.getText(), node.getSourceFile().fileName)];\n }\n\n async transform(interfaceDec: InterfaceDeclaration, context: SchemaExtractorContext) {\n const members = await pMapSeries(interfaceDec.members, (member) => typeElementToSchema(member, context));\n const doc = await jsDocToDocSchema(interfaceDec, context);\n return new InterfaceSchema(context.getLocation(interfaceDec), interfaceDec.name.getText(), members, doc);\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["InterfaceDeclarationTransformer","predicate","node","kind","SyntaxKind","InterfaceDeclaration","getIdentifiers","ExportIdentifier","name","getText","getSourceFile","fileName","transform","interfaceDec","context","members","pMapSeries","member","typeElementToSchema","doc","jsDocToDocSchema","InterfaceSchema","getLocation"],"sources":["interface-declaration.ts"],"sourcesContent":["import { Node, InterfaceDeclaration, SyntaxKind } from 'typescript';\nimport pMapSeries from 'p-map-series';\nimport { InterfaceSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\nimport { typeElementToSchema } from './utils/type-element-to-schema';\nimport { jsDocToDocSchema } from './utils/jsdoc-to-doc-schema';\n\nexport class InterfaceDeclarationTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === SyntaxKind.InterfaceDeclaration;\n }\n\n async getIdentifiers(node: InterfaceDeclaration): Promise<ExportIdentifier[]> {\n return [new ExportIdentifier(node.name.getText(), node.getSourceFile().fileName)];\n }\n\n async transform(interfaceDec: InterfaceDeclaration, context: SchemaExtractorContext) {\n const members = await pMapSeries(interfaceDec.members, (member) => typeElementToSchema(member, context));\n const doc = await jsDocToDocSchema(interfaceDec, context);\n return new InterfaceSchema(context.getLocation(interfaceDec), interfaceDec.name.getText(), members, doc);\n }\n}\n"],"mappings":";;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,MAAMA,+BAA+B,CAA8B;EACxEC,SAAS,CAACC,IAAU,EAAE;IACpB,OAAOA,IAAI,CAACC,IAAI,KAAKC,wBAAU,CAACC,oBAAoB;EACtD;EAEA,MAAMC,cAAc,CAACJ,IAA0B,EAA+B;IAC5E,OAAO,CAAC,KAAIK,oCAAgB,EAACL,IAAI,CAACM,IAAI,CAACC,OAAO,EAAE,EAAEP,IAAI,CAACQ,aAAa,EAAE,CAACC,QAAQ,CAAC,CAAC;EACnF;EAEA,MAAMC,SAAS,CAACC,YAAkC,EAAEC,OAA+B,EAAE;IACnF,MAAMC,OAAO,GAAG,MAAM,IAAAC,qBAAU,EAACH,YAAY,CAACE,OAAO,EAAGE,MAAM,IAAK,IAAAC,0CAAmB,EAACD,MAAM,EAAEH,OAAO,CAAC,CAAC;IACxG,MAAMK,GAAG,GAAG,MAAM,IAAAC,oCAAgB,EAACP,YAAY,EAAEC,OAAO,CAAC;IACzD,OAAO,KAAIO,oCAAe,EAACP,OAAO,CAACQ,WAAW,CAACT,YAAY,CAAC,EAAEA,YAAY,CAACL,IAAI,CAACC,OAAO,EAAE,EAAEM,OAAO,EAAEI,GAAG,CAAC;EAC1G;AACF;AAAC"}
|
|
@@ -1,61 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
require("core-js/modules/es.array.iterator.js");
|
|
6
|
-
|
|
7
5
|
require("core-js/modules/es.promise.js");
|
|
8
|
-
|
|
9
6
|
Object.defineProperty(exports, "__esModule", {
|
|
10
7
|
value: true
|
|
11
8
|
});
|
|
12
9
|
exports.SourceFileTransformer = void 0;
|
|
13
|
-
|
|
14
10
|
function _typescript() {
|
|
15
11
|
const data = _interopRequireDefault(require("typescript"));
|
|
16
|
-
|
|
17
12
|
_typescript = function () {
|
|
18
13
|
return data;
|
|
19
14
|
};
|
|
20
|
-
|
|
21
15
|
return data;
|
|
22
16
|
}
|
|
23
|
-
|
|
24
17
|
function _lodash() {
|
|
25
18
|
const data = require("lodash");
|
|
26
|
-
|
|
27
19
|
_lodash = function () {
|
|
28
20
|
return data;
|
|
29
21
|
};
|
|
30
|
-
|
|
31
22
|
return data;
|
|
32
23
|
}
|
|
33
|
-
|
|
34
24
|
function _pMapSeries() {
|
|
35
25
|
const data = _interopRequireDefault(require("p-map-series"));
|
|
36
|
-
|
|
37
26
|
_pMapSeries = function () {
|
|
38
27
|
return data;
|
|
39
28
|
};
|
|
40
|
-
|
|
41
29
|
return data;
|
|
42
30
|
}
|
|
43
|
-
|
|
44
31
|
function _semanticsEntities() {
|
|
45
32
|
const data = require("@teambit/semantics.entities.semantic-schema");
|
|
46
|
-
|
|
47
33
|
_semanticsEntities = function () {
|
|
48
34
|
return data;
|
|
49
35
|
};
|
|
50
|
-
|
|
51
36
|
return data;
|
|
52
37
|
}
|
|
53
|
-
|
|
54
38
|
class SourceFileTransformer {
|
|
55
39
|
predicate(node) {
|
|
56
40
|
return node.kind === _typescript().default.SyntaxKind.SourceFile;
|
|
57
41
|
}
|
|
58
|
-
|
|
59
42
|
async getIdentifiers(sourceFile, context) {
|
|
60
43
|
const exports = this.listExports(sourceFile);
|
|
61
44
|
const exportNames = await Promise.all(exports.map(node => {
|
|
@@ -68,7 +51,6 @@ class SourceFileTransformer {
|
|
|
68
51
|
}, []);
|
|
69
52
|
return exportIds;
|
|
70
53
|
}
|
|
71
|
-
|
|
72
54
|
async transform(node, context) {
|
|
73
55
|
const exports = this.listExports(node);
|
|
74
56
|
const schemas = await (0, _pMapSeries().default)(exports, exportNode => {
|
|
@@ -76,27 +58,24 @@ class SourceFileTransformer {
|
|
|
76
58
|
});
|
|
77
59
|
return new (_semanticsEntities().Module)(context.getLocation(node), schemas);
|
|
78
60
|
}
|
|
61
|
+
|
|
79
62
|
/**
|
|
80
63
|
* list all exports of a source file.
|
|
81
64
|
*/
|
|
82
|
-
|
|
83
|
-
|
|
84
65
|
listExports(ast) {
|
|
85
66
|
return (0, _lodash().compact)(ast.statements.map(statement => {
|
|
86
67
|
var _statement$modifiers;
|
|
87
|
-
|
|
88
68
|
if (statement.kind === _typescript().default.SyntaxKind.ExportDeclaration) return statement;
|
|
89
69
|
const isExport = Boolean((_statement$modifiers = statement.modifiers) === null || _statement$modifiers === void 0 ? void 0 : _statement$modifiers.find(modifier => {
|
|
90
70
|
return modifier.kind === _typescript().default.SyntaxKind.ExportKeyword;
|
|
91
|
-
}));
|
|
71
|
+
}));
|
|
92
72
|
|
|
73
|
+
// eslint-disable-next-line consistent-return
|
|
93
74
|
if (!isExport) return;
|
|
94
75
|
return statement;
|
|
95
76
|
}));
|
|
96
77
|
}
|
|
97
|
-
|
|
98
78
|
}
|
|
99
|
-
|
|
100
79
|
exports.SourceFileTransformer = SourceFileTransformer;
|
|
101
80
|
|
|
102
81
|
//# sourceMappingURL=source-file-transformer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SourceFileTransformer","predicate","node","kind","ts","SyntaxKind","SourceFile","getIdentifiers","sourceFile","context","exports","listExports","exportNames","Promise","all","map","getExportedIdentifiers","exportIds","flatten","reduce","acc","current","item","find","exportName","id","push","transform","schemas","pMapSeries","exportNode","computeSchema","Module","getLocation","ast","compact","statements","statement","ExportDeclaration","isExport","Boolean","modifiers","modifier","ExportKeyword"],"sources":["source-file-transformer.ts"],"sourcesContent":["import ts, { Node, SourceFile } from 'typescript';\nimport { compact, flatten } from 'lodash';\nimport pMapSeries from 'p-map-series';\nimport { Module } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { ExportIdentifier } from '../export-identifier';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\n\nexport class SourceFileTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.SourceFile;\n }\n\n async getIdentifiers(sourceFile: SourceFile, context: SchemaExtractorContext) {\n const exports = this.listExports(sourceFile);\n\n const exportNames = await Promise.all(\n exports.map((node: Node) => {\n return context.getExportedIdentifiers(node);\n })\n );\n\n const exportIds = flatten(exportNames).reduce<ExportIdentifier[]>((acc, current) => {\n const item = acc.find((exportName) => exportName.id === current.id);\n if (!item) acc.push(current);\n return acc;\n }, []);\n\n return exportIds;\n }\n\n async transform(node: SourceFile, context: SchemaExtractorContext) {\n const exports = this.listExports(node);\n const schemas = await pMapSeries(exports, (exportNode) => {\n return context.computeSchema(exportNode);\n });\n\n return new Module(context.getLocation(node), schemas);\n }\n\n /**\n * list all exports of a source file.\n */\n private listExports(ast: SourceFile): Node[] {\n return compact(\n ast.statements.map((statement) => {\n if (statement.kind === ts.SyntaxKind.ExportDeclaration) return statement;\n const isExport = Boolean(\n statement.modifiers?.find((modifier) => {\n return modifier.kind === ts.SyntaxKind.ExportKeyword;\n })\n );\n\n // eslint-disable-next-line consistent-return\n if (!isExport) return;\n return statement;\n })\n );\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["SourceFileTransformer","predicate","node","kind","ts","SyntaxKind","SourceFile","getIdentifiers","sourceFile","context","exports","listExports","exportNames","Promise","all","map","getExportedIdentifiers","exportIds","flatten","reduce","acc","current","item","find","exportName","id","push","transform","schemas","pMapSeries","exportNode","computeSchema","Module","getLocation","ast","compact","statements","statement","ExportDeclaration","isExport","Boolean","modifiers","modifier","ExportKeyword"],"sources":["source-file-transformer.ts"],"sourcesContent":["import ts, { Node, SourceFile } from 'typescript';\nimport { compact, flatten } from 'lodash';\nimport pMapSeries from 'p-map-series';\nimport { Module } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { ExportIdentifier } from '../export-identifier';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\n\nexport class SourceFileTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.SourceFile;\n }\n\n async getIdentifiers(sourceFile: SourceFile, context: SchemaExtractorContext) {\n const exports = this.listExports(sourceFile);\n\n const exportNames = await Promise.all(\n exports.map((node: Node) => {\n return context.getExportedIdentifiers(node);\n })\n );\n\n const exportIds = flatten(exportNames).reduce<ExportIdentifier[]>((acc, current) => {\n const item = acc.find((exportName) => exportName.id === current.id);\n if (!item) acc.push(current);\n return acc;\n }, []);\n\n return exportIds;\n }\n\n async transform(node: SourceFile, context: SchemaExtractorContext) {\n const exports = this.listExports(node);\n const schemas = await pMapSeries(exports, (exportNode) => {\n return context.computeSchema(exportNode);\n });\n\n return new Module(context.getLocation(node), schemas);\n }\n\n /**\n * list all exports of a source file.\n */\n private listExports(ast: SourceFile): Node[] {\n return compact(\n ast.statements.map((statement) => {\n if (statement.kind === ts.SyntaxKind.ExportDeclaration) return statement;\n const isExport = Boolean(\n statement.modifiers?.find((modifier) => {\n return modifier.kind === ts.SyntaxKind.ExportKeyword;\n })\n );\n\n // eslint-disable-next-line consistent-return\n if (!isExport) return;\n return statement;\n })\n );\n }\n}\n"],"mappings":";;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAKO,MAAMA,qBAAqB,CAA8B;EAC9DC,SAAS,CAACC,IAAU,EAAE;IACpB,OAAOA,IAAI,CAACC,IAAI,KAAKC,qBAAE,CAACC,UAAU,CAACC,UAAU;EAC/C;EAEA,MAAMC,cAAc,CAACC,UAAsB,EAAEC,OAA+B,EAAE;IAC5E,MAAMC,OAAO,GAAG,IAAI,CAACC,WAAW,CAACH,UAAU,CAAC;IAE5C,MAAMI,WAAW,GAAG,MAAMC,OAAO,CAACC,GAAG,CACnCJ,OAAO,CAACK,GAAG,CAAEb,IAAU,IAAK;MAC1B,OAAOO,OAAO,CAACO,sBAAsB,CAACd,IAAI,CAAC;IAC7C,CAAC,CAAC,CACH;IAED,MAAMe,SAAS,GAAG,IAAAC,iBAAO,EAACN,WAAW,CAAC,CAACO,MAAM,CAAqB,CAACC,GAAG,EAAEC,OAAO,KAAK;MAClF,MAAMC,IAAI,GAAGF,GAAG,CAACG,IAAI,CAAEC,UAAU,IAAKA,UAAU,CAACC,EAAE,KAAKJ,OAAO,CAACI,EAAE,CAAC;MACnE,IAAI,CAACH,IAAI,EAAEF,GAAG,CAACM,IAAI,CAACL,OAAO,CAAC;MAC5B,OAAOD,GAAG;IACZ,CAAC,EAAE,EAAE,CAAC;IAEN,OAAOH,SAAS;EAClB;EAEA,MAAMU,SAAS,CAACzB,IAAgB,EAAEO,OAA+B,EAAE;IACjE,MAAMC,OAAO,GAAG,IAAI,CAACC,WAAW,CAACT,IAAI,CAAC;IACtC,MAAM0B,OAAO,GAAG,MAAM,IAAAC,qBAAU,EAACnB,OAAO,EAAGoB,UAAU,IAAK;MACxD,OAAOrB,OAAO,CAACsB,aAAa,CAACD,UAAU,CAAC;IAC1C,CAAC,CAAC;IAEF,OAAO,KAAIE,2BAAM,EAACvB,OAAO,CAACwB,WAAW,CAAC/B,IAAI,CAAC,EAAE0B,OAAO,CAAC;EACvD;;EAEA;AACF;AACA;EACUjB,WAAW,CAACuB,GAAe,EAAU;IAC3C,OAAO,IAAAC,iBAAO,EACZD,GAAG,CAACE,UAAU,CAACrB,GAAG,CAAEsB,SAAS,IAAK;MAAA;MAChC,IAAIA,SAAS,CAAClC,IAAI,KAAKC,qBAAE,CAACC,UAAU,CAACiC,iBAAiB,EAAE,OAAOD,SAAS;MACxE,MAAME,QAAQ,GAAGC,OAAO,yBACtBH,SAAS,CAACI,SAAS,yDAAnB,qBAAqBlB,IAAI,CAAEmB,QAAQ,IAAK;QACtC,OAAOA,QAAQ,CAACvC,IAAI,KAAKC,qBAAE,CAACC,UAAU,CAACsC,aAAa;MACtD,CAAC,CAAC,CACH;;MAED;MACA,IAAI,CAACJ,QAAQ,EAAE;MACf,OAAOF,SAAS;IAClB,CAAC,CAAC,CACH;EACH;AACF;AAAC"}
|
|
@@ -1,86 +1,63 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
require("core-js/modules/es.promise.js");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.TypeAliasTransformer = void 0;
|
|
11
|
-
|
|
12
9
|
function _typescript() {
|
|
13
10
|
const data = _interopRequireDefault(require("typescript"));
|
|
14
|
-
|
|
15
11
|
_typescript = function () {
|
|
16
12
|
return data;
|
|
17
13
|
};
|
|
18
|
-
|
|
19
14
|
return data;
|
|
20
15
|
}
|
|
21
|
-
|
|
22
16
|
function _semanticsEntities() {
|
|
23
17
|
const data = require("@teambit/semantics.entities.semantic-schema");
|
|
24
|
-
|
|
25
18
|
_semanticsEntities = function () {
|
|
26
19
|
return data;
|
|
27
20
|
};
|
|
28
|
-
|
|
29
21
|
return data;
|
|
30
22
|
}
|
|
31
|
-
|
|
32
23
|
function _exportIdentifier() {
|
|
33
24
|
const data = require("../export-identifier");
|
|
34
|
-
|
|
35
25
|
_exportIdentifier = function () {
|
|
36
26
|
return data;
|
|
37
27
|
};
|
|
38
|
-
|
|
39
28
|
return data;
|
|
40
29
|
}
|
|
41
|
-
|
|
42
30
|
function _typeNodeToSchema() {
|
|
43
31
|
const data = require("./utils/type-node-to-schema");
|
|
44
|
-
|
|
45
32
|
_typeNodeToSchema = function () {
|
|
46
33
|
return data;
|
|
47
34
|
};
|
|
48
|
-
|
|
49
35
|
return data;
|
|
50
36
|
}
|
|
51
|
-
|
|
52
37
|
function _jsdocToDocSchema() {
|
|
53
38
|
const data = require("./utils/jsdoc-to-doc-schema");
|
|
54
|
-
|
|
55
39
|
_jsdocToDocSchema = function () {
|
|
56
40
|
return data;
|
|
57
41
|
};
|
|
58
|
-
|
|
59
42
|
return data;
|
|
60
43
|
}
|
|
61
|
-
|
|
62
44
|
class TypeAliasTransformer {
|
|
63
45
|
predicate(node) {
|
|
64
46
|
return node.kind === _typescript().default.SyntaxKind.TypeAliasDeclaration;
|
|
65
47
|
}
|
|
66
|
-
|
|
67
48
|
async getIdentifiers(node) {
|
|
68
49
|
return [new (_exportIdentifier().ExportIdentifier)(node.name.getText(), node.getSourceFile().fileName)];
|
|
69
50
|
}
|
|
70
|
-
|
|
71
51
|
getName(node) {
|
|
72
52
|
return node.name.getText();
|
|
73
53
|
}
|
|
74
|
-
|
|
75
54
|
async transform(typeAlias, context) {
|
|
76
55
|
const type = await (0, _typeNodeToSchema().typeNodeToSchema)(typeAlias.type, context);
|
|
77
56
|
const displaySig = await context.getQuickInfoDisplayString(typeAlias.name);
|
|
78
57
|
const doc = await (0, _jsdocToDocSchema().jsDocToDocSchema)(typeAlias, context);
|
|
79
58
|
return new (_semanticsEntities().TypeSchema)(context.getLocation(typeAlias), this.getName(typeAlias), type, displaySig, doc);
|
|
80
59
|
}
|
|
81
|
-
|
|
82
60
|
}
|
|
83
|
-
|
|
84
61
|
exports.TypeAliasTransformer = TypeAliasTransformer;
|
|
85
62
|
|
|
86
63
|
//# sourceMappingURL=type-alias.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["TypeAliasTransformer","predicate","node","kind","ts","SyntaxKind","TypeAliasDeclaration","getIdentifiers","ExportIdentifier","name","getText","getSourceFile","fileName","getName","transform","typeAlias","context","type","typeNodeToSchema","displaySig","getQuickInfoDisplayString","doc","jsDocToDocSchema","TypeSchema","getLocation"],"sources":["type-alias.ts"],"sourcesContent":["import ts, { Node, TypeAliasDeclaration } from 'typescript';\nimport { TypeSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\nimport { typeNodeToSchema } from './utils/type-node-to-schema';\nimport { jsDocToDocSchema } from './utils/jsdoc-to-doc-schema';\n\nexport class TypeAliasTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.TypeAliasDeclaration;\n }\n\n async getIdentifiers(node: TypeAliasDeclaration) {\n return [new ExportIdentifier(node.name.getText(), node.getSourceFile().fileName)];\n }\n\n private getName(node: TypeAliasDeclaration): string {\n return node.name.getText();\n }\n\n async transform(typeAlias: TypeAliasDeclaration, context: SchemaExtractorContext) {\n const type = await typeNodeToSchema(typeAlias.type, context);\n const displaySig = await context.getQuickInfoDisplayString(typeAlias.name);\n const doc = await jsDocToDocSchema(typeAlias, context);\n return new TypeSchema(context.getLocation(typeAlias), this.getName(typeAlias), type, displaySig, doc);\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["TypeAliasTransformer","predicate","node","kind","ts","SyntaxKind","TypeAliasDeclaration","getIdentifiers","ExportIdentifier","name","getText","getSourceFile","fileName","getName","transform","typeAlias","context","type","typeNodeToSchema","displaySig","getQuickInfoDisplayString","doc","jsDocToDocSchema","TypeSchema","getLocation"],"sources":["type-alias.ts"],"sourcesContent":["import ts, { Node, TypeAliasDeclaration } from 'typescript';\nimport { TypeSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\nimport { typeNodeToSchema } from './utils/type-node-to-schema';\nimport { jsDocToDocSchema } from './utils/jsdoc-to-doc-schema';\n\nexport class TypeAliasTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.TypeAliasDeclaration;\n }\n\n async getIdentifiers(node: TypeAliasDeclaration) {\n return [new ExportIdentifier(node.name.getText(), node.getSourceFile().fileName)];\n }\n\n private getName(node: TypeAliasDeclaration): string {\n return node.name.getText();\n }\n\n async transform(typeAlias: TypeAliasDeclaration, context: SchemaExtractorContext) {\n const type = await typeNodeToSchema(typeAlias.type, context);\n const displaySig = await context.getQuickInfoDisplayString(typeAlias.name);\n const doc = await jsDocToDocSchema(typeAlias, context);\n return new TypeSchema(context.getLocation(typeAlias), this.getName(typeAlias), type, displaySig, doc);\n }\n}\n"],"mappings":";;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,MAAMA,oBAAoB,CAA8B;EAC7DC,SAAS,CAACC,IAAU,EAAE;IACpB,OAAOA,IAAI,CAACC,IAAI,KAAKC,qBAAE,CAACC,UAAU,CAACC,oBAAoB;EACzD;EAEA,MAAMC,cAAc,CAACL,IAA0B,EAAE;IAC/C,OAAO,CAAC,KAAIM,oCAAgB,EAACN,IAAI,CAACO,IAAI,CAACC,OAAO,EAAE,EAAER,IAAI,CAACS,aAAa,EAAE,CAACC,QAAQ,CAAC,CAAC;EACnF;EAEQC,OAAO,CAACX,IAA0B,EAAU;IAClD,OAAOA,IAAI,CAACO,IAAI,CAACC,OAAO,EAAE;EAC5B;EAEA,MAAMI,SAAS,CAACC,SAA+B,EAAEC,OAA+B,EAAE;IAChF,MAAMC,IAAI,GAAG,MAAM,IAAAC,oCAAgB,EAACH,SAAS,CAACE,IAAI,EAAED,OAAO,CAAC;IAC5D,MAAMG,UAAU,GAAG,MAAMH,OAAO,CAACI,yBAAyB,CAACL,SAAS,CAACN,IAAI,CAAC;IAC1E,MAAMY,GAAG,GAAG,MAAM,IAAAC,oCAAgB,EAACP,SAAS,EAAEC,OAAO,CAAC;IACtD,OAAO,KAAIO,+BAAU,EAACP,OAAO,CAACQ,WAAW,CAACT,SAAS,CAAC,EAAE,IAAI,CAACF,OAAO,CAACE,SAAS,CAAC,EAAEE,IAAI,EAAEE,UAAU,EAAEE,GAAG,CAAC;EACvG;AACF;AAAC"}
|
|
@@ -1,122 +1,88 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
require("core-js/modules/es.promise.js");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.classElementToSchema = classElementToSchema;
|
|
9
|
-
|
|
10
8
|
function _typescript() {
|
|
11
9
|
const data = require("typescript");
|
|
12
|
-
|
|
13
10
|
_typescript = function () {
|
|
14
11
|
return data;
|
|
15
12
|
};
|
|
16
|
-
|
|
17
13
|
return data;
|
|
18
14
|
}
|
|
19
|
-
|
|
20
15
|
function _semanticsEntities() {
|
|
21
16
|
const data = require("@teambit/semantics.entities.semantic-schema");
|
|
22
|
-
|
|
23
17
|
_semanticsEntities = function () {
|
|
24
18
|
return data;
|
|
25
19
|
};
|
|
26
|
-
|
|
27
20
|
return data;
|
|
28
21
|
}
|
|
29
|
-
|
|
30
22
|
function _getParams() {
|
|
31
23
|
const data = require("./get-params");
|
|
32
|
-
|
|
33
24
|
_getParams = function () {
|
|
34
25
|
return data;
|
|
35
26
|
};
|
|
36
|
-
|
|
37
27
|
return data;
|
|
38
28
|
}
|
|
39
|
-
|
|
40
29
|
function _typeElementToSchema() {
|
|
41
30
|
const data = require("./type-element-to-schema");
|
|
42
|
-
|
|
43
31
|
_typeElementToSchema = function () {
|
|
44
32
|
return data;
|
|
45
33
|
};
|
|
46
|
-
|
|
47
34
|
return data;
|
|
48
35
|
}
|
|
49
|
-
|
|
50
36
|
function _parseTypeFromQuickInfo() {
|
|
51
37
|
const data = require("./parse-type-from-quick-info");
|
|
52
|
-
|
|
53
38
|
_parseTypeFromQuickInfo = function () {
|
|
54
39
|
return data;
|
|
55
40
|
};
|
|
56
|
-
|
|
57
41
|
return data;
|
|
58
42
|
}
|
|
59
|
-
|
|
60
43
|
function _toFunctionLikeSchema() {
|
|
61
44
|
const data = require("./to-function-like-schema");
|
|
62
|
-
|
|
63
45
|
_toFunctionLikeSchema = function () {
|
|
64
46
|
return data;
|
|
65
47
|
};
|
|
66
|
-
|
|
67
48
|
return data;
|
|
68
49
|
}
|
|
69
|
-
|
|
70
50
|
function _jsdocToDocSchema() {
|
|
71
51
|
const data = require("./jsdoc-to-doc-schema");
|
|
72
|
-
|
|
73
52
|
_jsdocToDocSchema = function () {
|
|
74
53
|
return data;
|
|
75
54
|
};
|
|
76
|
-
|
|
77
55
|
return data;
|
|
78
56
|
}
|
|
79
|
-
|
|
80
57
|
async function classElementToSchema(node, context) {
|
|
81
58
|
switch (node.kind) {
|
|
82
59
|
case _typescript().SyntaxKind.Constructor:
|
|
83
60
|
return constructor(node, context);
|
|
84
|
-
|
|
85
61
|
case _typescript().SyntaxKind.PropertyDeclaration:
|
|
86
62
|
return propertyDeclaration(node, context);
|
|
87
|
-
|
|
88
63
|
case _typescript().SyntaxKind.MethodDeclaration:
|
|
89
64
|
return methodDeclaration(node, context);
|
|
90
|
-
|
|
91
65
|
case _typescript().SyntaxKind.GetAccessor:
|
|
92
66
|
return (0, _typeElementToSchema().getAccessor)(node, context);
|
|
93
|
-
|
|
94
67
|
case _typescript().SyntaxKind.SetAccessor:
|
|
95
68
|
return (0, _typeElementToSchema().setAccessor)(node, context);
|
|
96
|
-
|
|
97
69
|
case _typescript().SyntaxKind.IndexSignature:
|
|
98
70
|
return (0, _typeElementToSchema().indexSignature)(node, context);
|
|
99
|
-
|
|
100
71
|
case _typescript().SyntaxKind.ClassStaticBlockDeclaration: // not sure what is it, but the name sounds like not something we need
|
|
101
|
-
|
|
102
72
|
case _typescript().SyntaxKind.SemicolonClassElement:
|
|
103
73
|
// seems to be just a semicolon
|
|
104
74
|
return null;
|
|
105
|
-
|
|
106
75
|
default:
|
|
107
76
|
// should never be here unless typescript added new class elements
|
|
108
77
|
throw new Error(`unrecognized ClassElement type. got ${node.kind}`);
|
|
109
78
|
}
|
|
110
79
|
}
|
|
111
|
-
|
|
112
80
|
async function constructor(node, context) {
|
|
113
81
|
const args = await (0, _getParams().getParams)(node.parameters, context);
|
|
114
82
|
return new (_semanticsEntities().ConstructorSchema)(context.getLocation(node), args);
|
|
115
83
|
}
|
|
116
|
-
|
|
117
84
|
async function propertyDeclaration(node, context) {
|
|
118
85
|
var _info$body;
|
|
119
|
-
|
|
120
86
|
const name = node.name.getText();
|
|
121
87
|
const info = await context.getQuickInfo(node.name);
|
|
122
88
|
const displaySig = info === null || info === void 0 ? void 0 : (_info$body = info.body) === null || _info$body === void 0 ? void 0 : _info$body.displayString;
|
|
@@ -126,7 +92,6 @@ async function propertyDeclaration(node, context) {
|
|
|
126
92
|
const doc = await (0, _jsdocToDocSchema().jsDocToDocSchema)(node, context);
|
|
127
93
|
return new (_semanticsEntities().VariableLikeSchema)(context.getLocation(node), name, displaySig || '', type, isOptional, doc);
|
|
128
94
|
}
|
|
129
|
-
|
|
130
95
|
async function methodDeclaration(node, context) {
|
|
131
96
|
return (0, _toFunctionLikeSchema().toFunctionLikeSchema)(node, context);
|
|
132
97
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classElementToSchema","node","context","kind","SyntaxKind","Constructor","constructor","PropertyDeclaration","propertyDeclaration","MethodDeclaration","methodDeclaration","GetAccessor","getAccessor","SetAccessor","setAccessor","IndexSignature","indexSignature","ClassStaticBlockDeclaration","SemicolonClassElement","Error","args","getParams","parameters","ConstructorSchema","getLocation","name","getText","info","getQuickInfo","displaySig","body","displayString","typeStr","parseTypeFromQuickInfo","type","resolveType","isOptional","Boolean","questionToken","doc","jsDocToDocSchema","VariableLikeSchema","toFunctionLikeSchema"],"sources":["class-element-to-schema.ts"],"sourcesContent":["import {\n ClassElement,\n ConstructorDeclaration,\n GetAccessorDeclaration,\n IndexSignatureDeclaration,\n MethodDeclaration,\n PropertyDeclaration,\n SetAccessorDeclaration,\n SyntaxKind,\n} from 'typescript';\nimport { ConstructorSchema, SchemaNode, VariableLikeSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaExtractorContext } from '../../schema-extractor-context';\nimport { getParams } from './get-params';\nimport { getAccessor, indexSignature, setAccessor } from './type-element-to-schema';\nimport { parseTypeFromQuickInfo } from './parse-type-from-quick-info';\nimport { toFunctionLikeSchema } from './to-function-like-schema';\nimport { jsDocToDocSchema } from './jsdoc-to-doc-schema';\n\nexport async function classElementToSchema(\n node: ClassElement,\n context: SchemaExtractorContext\n): Promise<SchemaNode | null> {\n switch (node.kind) {\n case SyntaxKind.Constructor:\n return constructor(node as ConstructorDeclaration, context);\n case SyntaxKind.PropertyDeclaration:\n return propertyDeclaration(node as PropertyDeclaration, context);\n case SyntaxKind.MethodDeclaration:\n return methodDeclaration(node as MethodDeclaration, context);\n case SyntaxKind.GetAccessor:\n return getAccessor(node as GetAccessorDeclaration, context);\n case SyntaxKind.SetAccessor:\n return setAccessor(node as SetAccessorDeclaration, context);\n case SyntaxKind.IndexSignature:\n return indexSignature(node as IndexSignatureDeclaration, context);\n case SyntaxKind.ClassStaticBlockDeclaration: // not sure what is it, but the name sounds like not something we need\n case SyntaxKind.SemicolonClassElement: // seems to be just a semicolon\n return null;\n default:\n // should never be here unless typescript added new class elements\n throw new Error(`unrecognized ClassElement type. got ${node.kind}`);\n }\n}\n\nasync function constructor(node: ConstructorDeclaration, context: SchemaExtractorContext) {\n const args = await getParams(node.parameters, context);\n return new ConstructorSchema(context.getLocation(node), args);\n}\n\nasync function propertyDeclaration(node: PropertyDeclaration, context: SchemaExtractorContext) {\n const name = node.name.getText();\n const info = await context.getQuickInfo(node.name);\n const displaySig = info?.body?.displayString;\n const typeStr = parseTypeFromQuickInfo(info);\n const type = await context.resolveType(node, typeStr);\n const isOptional = Boolean(node.questionToken);\n const doc = await jsDocToDocSchema(node, context);\n return new VariableLikeSchema(context.getLocation(node), name, displaySig || '', type, isOptional, doc);\n}\n\nasync function methodDeclaration(node: MethodDeclaration, context: SchemaExtractorContext) {\n return toFunctionLikeSchema(node, context);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["classElementToSchema","node","context","kind","SyntaxKind","Constructor","constructor","PropertyDeclaration","propertyDeclaration","MethodDeclaration","methodDeclaration","GetAccessor","getAccessor","SetAccessor","setAccessor","IndexSignature","indexSignature","ClassStaticBlockDeclaration","SemicolonClassElement","Error","args","getParams","parameters","ConstructorSchema","getLocation","name","getText","info","getQuickInfo","displaySig","body","displayString","typeStr","parseTypeFromQuickInfo","type","resolveType","isOptional","Boolean","questionToken","doc","jsDocToDocSchema","VariableLikeSchema","toFunctionLikeSchema"],"sources":["class-element-to-schema.ts"],"sourcesContent":["import {\n ClassElement,\n ConstructorDeclaration,\n GetAccessorDeclaration,\n IndexSignatureDeclaration,\n MethodDeclaration,\n PropertyDeclaration,\n SetAccessorDeclaration,\n SyntaxKind,\n} from 'typescript';\nimport { ConstructorSchema, SchemaNode, VariableLikeSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaExtractorContext } from '../../schema-extractor-context';\nimport { getParams } from './get-params';\nimport { getAccessor, indexSignature, setAccessor } from './type-element-to-schema';\nimport { parseTypeFromQuickInfo } from './parse-type-from-quick-info';\nimport { toFunctionLikeSchema } from './to-function-like-schema';\nimport { jsDocToDocSchema } from './jsdoc-to-doc-schema';\n\nexport async function classElementToSchema(\n node: ClassElement,\n context: SchemaExtractorContext\n): Promise<SchemaNode | null> {\n switch (node.kind) {\n case SyntaxKind.Constructor:\n return constructor(node as ConstructorDeclaration, context);\n case SyntaxKind.PropertyDeclaration:\n return propertyDeclaration(node as PropertyDeclaration, context);\n case SyntaxKind.MethodDeclaration:\n return methodDeclaration(node as MethodDeclaration, context);\n case SyntaxKind.GetAccessor:\n return getAccessor(node as GetAccessorDeclaration, context);\n case SyntaxKind.SetAccessor:\n return setAccessor(node as SetAccessorDeclaration, context);\n case SyntaxKind.IndexSignature:\n return indexSignature(node as IndexSignatureDeclaration, context);\n case SyntaxKind.ClassStaticBlockDeclaration: // not sure what is it, but the name sounds like not something we need\n case SyntaxKind.SemicolonClassElement: // seems to be just a semicolon\n return null;\n default:\n // should never be here unless typescript added new class elements\n throw new Error(`unrecognized ClassElement type. got ${node.kind}`);\n }\n}\n\nasync function constructor(node: ConstructorDeclaration, context: SchemaExtractorContext) {\n const args = await getParams(node.parameters, context);\n return new ConstructorSchema(context.getLocation(node), args);\n}\n\nasync function propertyDeclaration(node: PropertyDeclaration, context: SchemaExtractorContext) {\n const name = node.name.getText();\n const info = await context.getQuickInfo(node.name);\n const displaySig = info?.body?.displayString;\n const typeStr = parseTypeFromQuickInfo(info);\n const type = await context.resolveType(node, typeStr);\n const isOptional = Boolean(node.questionToken);\n const doc = await jsDocToDocSchema(node, context);\n return new VariableLikeSchema(context.getLocation(node), name, displaySig || '', type, isOptional, doc);\n}\n\nasync function methodDeclaration(node: MethodDeclaration, context: SchemaExtractorContext) {\n return toFunctionLikeSchema(node, context);\n}\n"],"mappings":";;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAUA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,eAAeA,oBAAoB,CACxCC,IAAkB,EAClBC,OAA+B,EACH;EAC5B,QAAQD,IAAI,CAACE,IAAI;IACf,KAAKC,wBAAU,CAACC,WAAW;MACzB,OAAOC,WAAW,CAACL,IAAI,EAA4BC,OAAO,CAAC;IAC7D,KAAKE,wBAAU,CAACG,mBAAmB;MACjC,OAAOC,mBAAmB,CAACP,IAAI,EAAyBC,OAAO,CAAC;IAClE,KAAKE,wBAAU,CAACK,iBAAiB;MAC/B,OAAOC,iBAAiB,CAACT,IAAI,EAAuBC,OAAO,CAAC;IAC9D,KAAKE,wBAAU,CAACO,WAAW;MACzB,OAAO,IAAAC,kCAAW,EAACX,IAAI,EAA4BC,OAAO,CAAC;IAC7D,KAAKE,wBAAU,CAACS,WAAW;MACzB,OAAO,IAAAC,kCAAW,EAACb,IAAI,EAA4BC,OAAO,CAAC;IAC7D,KAAKE,wBAAU,CAACW,cAAc;MAC5B,OAAO,IAAAC,qCAAc,EAACf,IAAI,EAA+BC,OAAO,CAAC;IACnE,KAAKE,wBAAU,CAACa,2BAA2B,CAAC,CAAC;IAC7C,KAAKb,wBAAU,CAACc,qBAAqB;MAAE;MACrC,OAAO,IAAI;IACb;MACE;MACA,MAAM,IAAIC,KAAK,CAAE,uCAAsClB,IAAI,CAACE,IAAK,EAAC,CAAC;EAAC;AAE1E;AAEA,eAAeG,WAAW,CAACL,IAA4B,EAAEC,OAA+B,EAAE;EACxF,MAAMkB,IAAI,GAAG,MAAM,IAAAC,sBAAS,EAACpB,IAAI,CAACqB,UAAU,EAAEpB,OAAO,CAAC;EACtD,OAAO,KAAIqB,sCAAiB,EAACrB,OAAO,CAACsB,WAAW,CAACvB,IAAI,CAAC,EAAEmB,IAAI,CAAC;AAC/D;AAEA,eAAeZ,mBAAmB,CAACP,IAAyB,EAAEC,OAA+B,EAAE;EAAA;EAC7F,MAAMuB,IAAI,GAAGxB,IAAI,CAACwB,IAAI,CAACC,OAAO,EAAE;EAChC,MAAMC,IAAI,GAAG,MAAMzB,OAAO,CAAC0B,YAAY,CAAC3B,IAAI,CAACwB,IAAI,CAAC;EAClD,MAAMI,UAAU,GAAGF,IAAI,aAAJA,IAAI,qCAAJA,IAAI,CAAEG,IAAI,+CAAV,WAAYC,aAAa;EAC5C,MAAMC,OAAO,GAAG,IAAAC,gDAAsB,EAACN,IAAI,CAAC;EAC5C,MAAMO,IAAI,GAAG,MAAMhC,OAAO,CAACiC,WAAW,CAAClC,IAAI,EAAE+B,OAAO,CAAC;EACrD,MAAMI,UAAU,GAAGC,OAAO,CAACpC,IAAI,CAACqC,aAAa,CAAC;EAC9C,MAAMC,GAAG,GAAG,MAAM,IAAAC,oCAAgB,EAACvC,IAAI,EAAEC,OAAO,CAAC;EACjD,OAAO,KAAIuC,uCAAkB,EAACvC,OAAO,CAACsB,WAAW,CAACvB,IAAI,CAAC,EAAEwB,IAAI,EAAEI,UAAU,IAAI,EAAE,EAAEK,IAAI,EAAEE,UAAU,EAAEG,GAAG,CAAC;AACzG;AAEA,eAAe7B,iBAAiB,CAACT,IAAuB,EAAEC,OAA+B,EAAE;EACzF,OAAO,IAAAwC,4CAAoB,EAACzC,IAAI,EAAEC,OAAO,CAAC;AAC5C"}
|