@teambit/typescript 0.0.880 → 0.0.882
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.882.tgz +0 -0
- package/package.json +15 -15
- package/{preview-1666312873430.js → preview-1666496165706.js} +2 -2
- package/package-tar/teambit-typescript-0.0.880.tgz +0 -0
|
@@ -1,100 +1,75 @@
|
|
|
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.getParams = getParams;
|
|
11
|
-
|
|
12
9
|
function _semanticsEntities() {
|
|
13
10
|
const data = require("@teambit/semantics.entities.semantic-schema");
|
|
14
|
-
|
|
15
11
|
_semanticsEntities = 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 _typescript() {
|
|
33
24
|
const data = require("typescript");
|
|
34
|
-
|
|
35
25
|
_typescript = function () {
|
|
36
26
|
return data;
|
|
37
27
|
};
|
|
38
|
-
|
|
39
28
|
return data;
|
|
40
29
|
}
|
|
41
|
-
|
|
42
30
|
function _parseTypeFromQuickInfo() {
|
|
43
31
|
const data = require("./parse-type-from-quick-info");
|
|
44
|
-
|
|
45
32
|
_parseTypeFromQuickInfo = function () {
|
|
46
33
|
return data;
|
|
47
34
|
};
|
|
48
|
-
|
|
49
35
|
return data;
|
|
50
36
|
}
|
|
51
|
-
|
|
52
37
|
function _typeNodeToSchema() {
|
|
53
38
|
const data = require("./type-node-to-schema");
|
|
54
|
-
|
|
55
39
|
_typeNodeToSchema = function () {
|
|
56
40
|
return data;
|
|
57
41
|
};
|
|
58
|
-
|
|
59
42
|
return data;
|
|
60
43
|
}
|
|
61
|
-
|
|
62
44
|
async function getParams(parameterNodes, context) {
|
|
63
45
|
return (0, _pMapSeries().default)(parameterNodes, async param => {
|
|
64
46
|
return new (_semanticsEntities().ParameterSchema)(context.getLocation(param), getParamName(param), await getParamType(param, context), Boolean(param.questionToken), param.initializer ? param.initializer.getText() : undefined);
|
|
65
47
|
});
|
|
66
48
|
}
|
|
67
|
-
|
|
68
49
|
function getParamName(param) {
|
|
69
50
|
if ((0, _typescript().isIdentifier)(param.name)) {
|
|
70
51
|
return param.name.getText();
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
52
|
+
}
|
|
53
|
+
// it's binding pattern, either an array or an object
|
|
74
54
|
const elements = param.name.elements.map(elem => elem.getText());
|
|
75
55
|
const elementsStr = elements.join(', ');
|
|
76
|
-
|
|
77
56
|
if (param.name.kind === _typescript().SyntaxKind.ArrayBindingPattern) {
|
|
78
57
|
return `[ ${elementsStr} ]`;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
58
|
+
}
|
|
59
|
+
// it's an object binding
|
|
82
60
|
return `{ ${elementsStr} }`;
|
|
83
61
|
}
|
|
84
|
-
|
|
85
62
|
async function getParamType(param, context) {
|
|
86
63
|
if (param.type) {
|
|
87
64
|
const type = param.type;
|
|
88
65
|
return (0, _typeNodeToSchema().typeNodeToSchema)(type, context);
|
|
89
66
|
}
|
|
90
|
-
|
|
91
67
|
if ((0, _typescript().isIdentifier)(param.name)) {
|
|
92
68
|
const info = await context.getQuickInfo(param.name);
|
|
93
69
|
const parsed = (0, _parseTypeFromQuickInfo().parseTypeFromQuickInfo)(info);
|
|
94
70
|
return new (_semanticsEntities().InferenceTypeSchema)(context.getLocation(param), parsed);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
71
|
+
}
|
|
72
|
+
// it's binding pattern, either an array or an object
|
|
98
73
|
if (param.name.kind === _typescript().SyntaxKind.ArrayBindingPattern) {
|
|
99
74
|
const elements = await (0, _pMapSeries().default)(param.name.elements, async elem => {
|
|
100
75
|
const info = await context.getQuickInfo(elem);
|
|
@@ -103,7 +78,6 @@ async function getParamType(param, context) {
|
|
|
103
78
|
});
|
|
104
79
|
return new (_semanticsEntities().TupleTypeSchema)(context.getLocation(param), elements);
|
|
105
80
|
}
|
|
106
|
-
|
|
107
81
|
if (param.name.kind === _typescript().SyntaxKind.ObjectBindingPattern) {
|
|
108
82
|
const elements = await (0, _pMapSeries().default)(param.name.elements, async elem => {
|
|
109
83
|
const info = await context.getQuickInfo(elem.name);
|
|
@@ -112,7 +86,6 @@ async function getParamType(param, context) {
|
|
|
112
86
|
});
|
|
113
87
|
return new (_semanticsEntities().TypeLiteralSchema)(context.getLocation(param), elements);
|
|
114
88
|
}
|
|
115
|
-
|
|
116
89
|
throw new Error(`unknown param type`);
|
|
117
90
|
}
|
|
118
91
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getParams","parameterNodes","context","pMapSeries","param","ParameterSchema","getLocation","getParamName","getParamType","Boolean","questionToken","initializer","getText","undefined","isIdentifier","name","elements","map","elem","elementsStr","join","kind","SyntaxKind","ArrayBindingPattern","type","typeNodeToSchema","info","getQuickInfo","parsed","parseTypeFromQuickInfo","InferenceTypeSchema","TupleTypeSchema","ObjectBindingPattern","TypeLiteralSchema","Error"],"sources":["get-params.ts"],"sourcesContent":["import {\n InferenceTypeSchema,\n ParameterSchema,\n TupleTypeSchema,\n TypeLiteralSchema,\n SchemaNode,\n} from '@teambit/semantics.entities.semantic-schema';\nimport pMapSeries from 'p-map-series';\nimport {\n SyntaxKind,\n ParameterDeclaration,\n NodeArray,\n isIdentifier,\n BindingElement,\n ArrayBindingElement,\n} from 'typescript';\nimport { SchemaExtractorContext } from '../../schema-extractor-context';\nimport { parseTypeFromQuickInfo } from './parse-type-from-quick-info';\nimport { typeNodeToSchema } from './type-node-to-schema';\n\nexport async function getParams(\n parameterNodes: NodeArray<ParameterDeclaration>,\n context: SchemaExtractorContext\n): Promise<ParameterSchema[]> {\n return pMapSeries(parameterNodes, async (param) => {\n return new ParameterSchema(\n context.getLocation(param),\n getParamName(param),\n await getParamType(param, context),\n Boolean(param.questionToken),\n param.initializer ? param.initializer.getText() : undefined\n );\n });\n}\n\nfunction getParamName(param: ParameterDeclaration): string {\n if (isIdentifier(param.name)) {\n return param.name.getText();\n }\n // it's binding pattern, either an array or an object\n const elements = param.name.elements.map((elem) => elem.getText());\n const elementsStr = elements.join(', ');\n if (param.name.kind === SyntaxKind.ArrayBindingPattern) {\n return `[ ${elementsStr} ]`;\n }\n // it's an object binding\n return `{ ${elementsStr} }`;\n}\n\nasync function getParamType(param: ParameterDeclaration, context: SchemaExtractorContext): Promise<SchemaNode> {\n if (param.type) {\n const type = param.type;\n return typeNodeToSchema(type, context);\n }\n if (isIdentifier(param.name)) {\n const info = await context.getQuickInfo(param.name);\n const parsed = parseTypeFromQuickInfo(info);\n return new InferenceTypeSchema(context.getLocation(param), parsed);\n }\n // it's binding pattern, either an array or an object\n if (param.name.kind === SyntaxKind.ArrayBindingPattern) {\n const elements = await pMapSeries(param.name.elements, async (elem: ArrayBindingElement) => {\n const info = await context.getQuickInfo(elem);\n const parsed = parseTypeFromQuickInfo(info);\n return new InferenceTypeSchema(context.getLocation(param), parsed);\n });\n return new TupleTypeSchema(context.getLocation(param), elements);\n }\n if (param.name.kind === SyntaxKind.ObjectBindingPattern) {\n const elements = await pMapSeries(param.name.elements, async (elem: BindingElement) => {\n const info = await context.getQuickInfo(elem.name);\n const parsed = parseTypeFromQuickInfo(info);\n return new InferenceTypeSchema(context.getLocation(param), parsed, elem.name.getText());\n });\n return new TypeLiteralSchema(context.getLocation(param), elements);\n }\n throw new Error(`unknown param type`);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["getParams","parameterNodes","context","pMapSeries","param","ParameterSchema","getLocation","getParamName","getParamType","Boolean","questionToken","initializer","getText","undefined","isIdentifier","name","elements","map","elem","elementsStr","join","kind","SyntaxKind","ArrayBindingPattern","type","typeNodeToSchema","info","getQuickInfo","parsed","parseTypeFromQuickInfo","InferenceTypeSchema","TupleTypeSchema","ObjectBindingPattern","TypeLiteralSchema","Error"],"sources":["get-params.ts"],"sourcesContent":["import {\n InferenceTypeSchema,\n ParameterSchema,\n TupleTypeSchema,\n TypeLiteralSchema,\n SchemaNode,\n} from '@teambit/semantics.entities.semantic-schema';\nimport pMapSeries from 'p-map-series';\nimport {\n SyntaxKind,\n ParameterDeclaration,\n NodeArray,\n isIdentifier,\n BindingElement,\n ArrayBindingElement,\n} from 'typescript';\nimport { SchemaExtractorContext } from '../../schema-extractor-context';\nimport { parseTypeFromQuickInfo } from './parse-type-from-quick-info';\nimport { typeNodeToSchema } from './type-node-to-schema';\n\nexport async function getParams(\n parameterNodes: NodeArray<ParameterDeclaration>,\n context: SchemaExtractorContext\n): Promise<ParameterSchema[]> {\n return pMapSeries(parameterNodes, async (param) => {\n return new ParameterSchema(\n context.getLocation(param),\n getParamName(param),\n await getParamType(param, context),\n Boolean(param.questionToken),\n param.initializer ? param.initializer.getText() : undefined\n );\n });\n}\n\nfunction getParamName(param: ParameterDeclaration): string {\n if (isIdentifier(param.name)) {\n return param.name.getText();\n }\n // it's binding pattern, either an array or an object\n const elements = param.name.elements.map((elem) => elem.getText());\n const elementsStr = elements.join(', ');\n if (param.name.kind === SyntaxKind.ArrayBindingPattern) {\n return `[ ${elementsStr} ]`;\n }\n // it's an object binding\n return `{ ${elementsStr} }`;\n}\n\nasync function getParamType(param: ParameterDeclaration, context: SchemaExtractorContext): Promise<SchemaNode> {\n if (param.type) {\n const type = param.type;\n return typeNodeToSchema(type, context);\n }\n if (isIdentifier(param.name)) {\n const info = await context.getQuickInfo(param.name);\n const parsed = parseTypeFromQuickInfo(info);\n return new InferenceTypeSchema(context.getLocation(param), parsed);\n }\n // it's binding pattern, either an array or an object\n if (param.name.kind === SyntaxKind.ArrayBindingPattern) {\n const elements = await pMapSeries(param.name.elements, async (elem: ArrayBindingElement) => {\n const info = await context.getQuickInfo(elem);\n const parsed = parseTypeFromQuickInfo(info);\n return new InferenceTypeSchema(context.getLocation(param), parsed);\n });\n return new TupleTypeSchema(context.getLocation(param), elements);\n }\n if (param.name.kind === SyntaxKind.ObjectBindingPattern) {\n const elements = await pMapSeries(param.name.elements, async (elem: BindingElement) => {\n const info = await context.getQuickInfo(elem.name);\n const parsed = parseTypeFromQuickInfo(info);\n return new InferenceTypeSchema(context.getLocation(param), parsed, elem.name.getText());\n });\n return new TypeLiteralSchema(context.getLocation(param), elements);\n }\n throw new Error(`unknown param type`);\n}\n"],"mappings":";;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAOA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AASA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,eAAeA,SAAS,CAC7BC,cAA+C,EAC/CC,OAA+B,EACH;EAC5B,OAAO,IAAAC,qBAAU,EAACF,cAAc,EAAE,MAAOG,KAAK,IAAK;IACjD,OAAO,KAAIC,oCAAe,EACxBH,OAAO,CAACI,WAAW,CAACF,KAAK,CAAC,EAC1BG,YAAY,CAACH,KAAK,CAAC,EACnB,MAAMI,YAAY,CAACJ,KAAK,EAAEF,OAAO,CAAC,EAClCO,OAAO,CAACL,KAAK,CAACM,aAAa,CAAC,EAC5BN,KAAK,CAACO,WAAW,GAAGP,KAAK,CAACO,WAAW,CAACC,OAAO,EAAE,GAAGC,SAAS,CAC5D;EACH,CAAC,CAAC;AACJ;AAEA,SAASN,YAAY,CAACH,KAA2B,EAAU;EACzD,IAAI,IAAAU,0BAAY,EAACV,KAAK,CAACW,IAAI,CAAC,EAAE;IAC5B,OAAOX,KAAK,CAACW,IAAI,CAACH,OAAO,EAAE;EAC7B;EACA;EACA,MAAMI,QAAQ,GAAGZ,KAAK,CAACW,IAAI,CAACC,QAAQ,CAACC,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAACN,OAAO,EAAE,CAAC;EAClE,MA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CAAC,EAAEY,QAAQ,CAAC;EAClE;EACA,IAAIZ,KAAK,CAACW,IAAI,CAACM,IAAI,KAAKC,wBAAU,CAACU,oBAAoB,EAAE;IACvD,MAAMhB,QAAQ,GAAG,MAAM,IAAAb,qBAAU,EAACC,KAAK,CAACW,IAAI,CAACC,QAAQ,EAAE,MAAOE,IAAoB,IAAK;MACrF,MAAMQ,IAAI,GAAG,MAAMxB,OAAO,CAACyB,YAAY,CAACT,IAAI,CAACH,IAAI,CAAC;MAClD,MAAMa,MAAM,GAAG,IAAAC,gDAAsB,EAACH,IAAI,CAAC;MAC3C,OAAO,KAAII,wCAAmB,EAAC5B,OAAO,CAACI,WAAW,CAACF,KAAK,CAAC,EAAEwB,MAAM,EAAEV,IAAI,CAACH,IAAI,CAACH,OAAO,EAAE,CAAC;IACzF,CAAC,CAAC;IACF,OAAO,KAAIqB,sCAAiB,EAAC/B,OAAO,CAACI,WAAW,CAACF,KAAK,CAAC,EAAEY,QAAQ,CAAC;EACpE;EACA,MAAM,IAAIkB,KAAK,CAAE,oBAAmB,CAAC;AACvC"}
|
|
@@ -1,148 +1,108 @@
|
|
|
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.jsDocToDocSchema = jsDocToDocSchema;
|
|
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 _tsutils() {
|
|
23
17
|
const data = require("tsutils");
|
|
24
|
-
|
|
25
18
|
_tsutils = function () {
|
|
26
19
|
return data;
|
|
27
20
|
};
|
|
28
|
-
|
|
29
21
|
return data;
|
|
30
22
|
}
|
|
31
|
-
|
|
32
23
|
function _pMapSeries() {
|
|
33
24
|
const data = _interopRequireDefault(require("p-map-series"));
|
|
34
|
-
|
|
35
25
|
_pMapSeries = function () {
|
|
36
26
|
return data;
|
|
37
27
|
};
|
|
38
|
-
|
|
39
28
|
return data;
|
|
40
29
|
}
|
|
41
|
-
|
|
42
30
|
function _semanticsEntities() {
|
|
43
31
|
const data = require("@teambit/semantics.entities.semantic-schema");
|
|
44
|
-
|
|
45
32
|
_semanticsEntities = function () {
|
|
46
33
|
return data;
|
|
47
34
|
};
|
|
48
|
-
|
|
49
35
|
return data;
|
|
50
36
|
}
|
|
51
|
-
|
|
52
37
|
function _typeNodeToSchema() {
|
|
53
38
|
const data = require("./type-node-to-schema");
|
|
54
|
-
|
|
55
39
|
_typeNodeToSchema = function () {
|
|
56
40
|
return data;
|
|
57
41
|
};
|
|
58
|
-
|
|
59
42
|
return data;
|
|
60
43
|
}
|
|
61
|
-
|
|
62
44
|
/* eslint-disable no-fallthrough */
|
|
45
|
+
|
|
63
46
|
async function jsDocToDocSchema(node, context) {
|
|
64
47
|
if (!(0, _tsutils().canHaveJsDoc)(node)) {
|
|
65
48
|
return undefined;
|
|
66
49
|
}
|
|
67
|
-
|
|
68
50
|
const jsDocs = (0, _tsutils().getJsDoc)(node);
|
|
69
|
-
|
|
70
51
|
if (!jsDocs.length) {
|
|
71
52
|
return undefined;
|
|
72
|
-
}
|
|
53
|
+
}
|
|
54
|
+
// not sure how common it is to have multiple JSDocs. never seen it before.
|
|
73
55
|
// regardless, in typescript implementation of methods like `getJSDocDeprecatedTag()`, they use the first one. (`getFirstJSDocTag()`)
|
|
74
|
-
|
|
75
|
-
|
|
76
56
|
const jsDoc = jsDocs[0];
|
|
77
57
|
const location = context.getLocation(jsDoc);
|
|
78
58
|
const comment = (0, _typescript().getTextOfJSDocComment)(jsDoc.comment);
|
|
79
59
|
const tags = jsDoc.tags ? await (0, _pMapSeries().default)(jsDoc.tags, tag => tagParser(tag, context)) : undefined;
|
|
80
60
|
return new (_semanticsEntities().DocSchema)(location, jsDoc.getText(), comment, tags);
|
|
81
61
|
}
|
|
82
|
-
|
|
83
62
|
async function tagParser(tag, context) {
|
|
84
63
|
// for some reason, in some cases, if `tag.getSourceFile()` is not provided to the `getText()`, it throws "Cannot read property 'text' of undefined"
|
|
64
|
+
|
|
85
65
|
switch (tag.kind) {
|
|
86
66
|
case _typescript().SyntaxKind.JSDocReturnTag:
|
|
87
67
|
return returnTag(tag, context);
|
|
88
|
-
|
|
89
68
|
case _typescript().SyntaxKind.JSDocPropertyTag:
|
|
90
69
|
return propertyLikeTag(tag, context);
|
|
91
|
-
|
|
92
70
|
case _typescript().SyntaxKind.JSDocParameterTag:
|
|
93
71
|
return propertyLikeTag(tag, context);
|
|
94
|
-
|
|
95
72
|
case _typescript().SyntaxKind.JSDocAugmentsTag:
|
|
96
73
|
return simpleTag(tag, _semanticsEntities().TagName.augments, context);
|
|
97
|
-
|
|
98
74
|
case _typescript().SyntaxKind.JSDocAuthorTag:
|
|
99
75
|
return simpleTag(tag, _semanticsEntities().TagName.author, context);
|
|
100
|
-
|
|
101
76
|
case _typescript().SyntaxKind.JSDocClassTag:
|
|
102
77
|
return simpleTag(tag, _semanticsEntities().TagName.class, context);
|
|
103
|
-
|
|
104
78
|
case _typescript().SyntaxKind.JSDocCallbackTag:
|
|
105
79
|
return simpleTag(tag, _semanticsEntities().TagName.callback, context);
|
|
106
|
-
|
|
107
80
|
case _typescript().SyntaxKind.JSDocPublicTag:
|
|
108
81
|
return simpleTag(tag, _semanticsEntities().TagName.public, context);
|
|
109
|
-
|
|
110
82
|
case _typescript().SyntaxKind.JSDocPrivateTag:
|
|
111
83
|
return simpleTag(tag, _semanticsEntities().TagName.private, context);
|
|
112
|
-
|
|
113
84
|
case _typescript().SyntaxKind.JSDocProtectedTag:
|
|
114
85
|
return simpleTag(tag, _semanticsEntities().TagName.protected, context);
|
|
115
|
-
|
|
116
86
|
case _typescript().SyntaxKind.JSDocReadonlyTag:
|
|
117
87
|
return simpleTag(tag, _semanticsEntities().TagName.readonly, context);
|
|
118
|
-
|
|
119
88
|
case _typescript().SyntaxKind.JSDocOverrideTag:
|
|
120
89
|
return simpleTag(tag, _semanticsEntities().TagName.override, context);
|
|
121
|
-
|
|
122
90
|
case _typescript().SyntaxKind.JSDocDeprecatedTag:
|
|
123
91
|
return simpleTag(tag, _semanticsEntities().TagName.deprecated, context);
|
|
124
|
-
|
|
125
92
|
case _typescript().SyntaxKind.JSDocSeeTag:
|
|
126
93
|
return simpleTag(tag, _semanticsEntities().TagName.see, context);
|
|
127
|
-
|
|
128
94
|
case _typescript().SyntaxKind.JSDocEnumTag:
|
|
129
95
|
return simpleTag(tag, _semanticsEntities().TagName.enum, context);
|
|
130
|
-
|
|
131
96
|
case _typescript().SyntaxKind.JSDocThisTag:
|
|
132
97
|
return simpleTag(tag, _semanticsEntities().TagName.this, context);
|
|
133
|
-
|
|
134
98
|
case _typescript().SyntaxKind.JSDocTypeTag:
|
|
135
99
|
return simpleTag(tag, _semanticsEntities().TagName.type, context);
|
|
136
|
-
|
|
137
100
|
case _typescript().SyntaxKind.JSDocTemplateTag:
|
|
138
101
|
return simpleTag(tag, _semanticsEntities().TagName.template, context);
|
|
139
|
-
|
|
140
102
|
case _typescript().SyntaxKind.JSDocTypedefTag:
|
|
141
103
|
return simpleTag(tag, _semanticsEntities().TagName.typedef, context);
|
|
142
|
-
|
|
143
104
|
case _typescript().SyntaxKind.JSDocImplementsTag:
|
|
144
105
|
return simpleTag(tag, _semanticsEntities().TagName.implements, context);
|
|
145
|
-
|
|
146
106
|
default:
|
|
147
107
|
{
|
|
148
108
|
const tagName = tag.tagName.getText(tag.getSourceFile());
|
|
@@ -150,21 +110,16 @@ async function tagParser(tag, context) {
|
|
|
150
110
|
}
|
|
151
111
|
}
|
|
152
112
|
}
|
|
153
|
-
|
|
154
113
|
function simpleTag(tag, tagName, context) {
|
|
155
114
|
return new (_semanticsEntities().TagSchema)(context.getLocation(tag), tagName, (0, _typescript().getTextOfJSDocComment)(tag.comment));
|
|
156
115
|
}
|
|
157
|
-
|
|
158
116
|
async function returnTag(tag, context) {
|
|
159
117
|
var _tag$typeExpression, _tag$typeExpression2;
|
|
160
|
-
|
|
161
118
|
const type = (_tag$typeExpression = tag.typeExpression) !== null && _tag$typeExpression !== void 0 && _tag$typeExpression.type ? await (0, _typeNodeToSchema().typeNodeToSchema)((_tag$typeExpression2 = tag.typeExpression) === null || _tag$typeExpression2 === void 0 ? void 0 : _tag$typeExpression2.type, context) : undefined;
|
|
162
119
|
return new (_semanticsEntities().ReturnTagSchema)(context.getLocation(tag), (0, _typescript().getTextOfJSDocComment)(tag.comment), type);
|
|
163
120
|
}
|
|
164
|
-
|
|
165
121
|
async function propertyLikeTag(tag, context) {
|
|
166
122
|
var _tag$typeExpression3, _tag$typeExpression4;
|
|
167
|
-
|
|
168
123
|
const type = (_tag$typeExpression3 = tag.typeExpression) !== null && _tag$typeExpression3 !== void 0 && _tag$typeExpression3.type ? await (0, _typeNodeToSchema().typeNodeToSchema)((_tag$typeExpression4 = tag.typeExpression) === null || _tag$typeExpression4 === void 0 ? void 0 : _tag$typeExpression4.type, context) : undefined;
|
|
169
124
|
return new (_semanticsEntities().PropertyLikeTagSchema)(context.getLocation(tag), tag.name.getText(), (0, _typescript().getTextOfJSDocComment)(tag.comment), type);
|
|
170
125
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["jsDocToDocSchema","node","context","canHaveJsDoc","undefined","jsDocs","getJsDoc","length","jsDoc","location","getLocation","comment","getTextOfJSDocComment","tags","pMapSeries","tag","tagParser","DocSchema","getText","kind","SyntaxKind","JSDocReturnTag","returnTag","JSDocPropertyTag","propertyLikeTag","JSDocParameterTag","JSDocAugmentsTag","simpleTag","TagName","augments","JSDocAuthorTag","author","JSDocClassTag","class","JSDocCallbackTag","callback","JSDocPublicTag","public","JSDocPrivateTag","private","JSDocProtectedTag","protected","JSDocReadonlyTag","readonly","JSDocOverrideTag","override","JSDocDeprecatedTag","deprecated","JSDocSeeTag","see","JSDocEnumTag","enum","JSDocThisTag","this","JSDocTypeTag","type","JSDocTemplateTag","template","JSDocTypedefTag","typedef","JSDocImplementsTag","implements","tagName","getSourceFile","TagSchema","typeExpression","typeNodeToSchema","ReturnTagSchema","PropertyLikeTagSchema","name"],"sources":["jsdoc-to-doc-schema.ts"],"sourcesContent":["/* eslint-disable no-fallthrough */\nimport {\n getTextOfJSDocComment,\n JSDocParameterTag,\n JSDocPropertyLikeTag,\n JSDocPropertyTag,\n JSDocReturnTag,\n JSDocTag,\n Node,\n SyntaxKind,\n} from 'typescript';\nimport { getJsDoc, canHaveJsDoc } from 'tsutils';\nimport pMapSeries from 'p-map-series';\nimport {\n DocSchema,\n PropertyLikeTagSchema,\n ReturnTagSchema,\n TagName,\n TagSchema,\n} from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaExtractorContext } from '../../schema-extractor-context';\nimport { typeNodeToSchema } from './type-node-to-schema';\n\nexport async function jsDocToDocSchema(node: Node, context: SchemaExtractorContext): Promise<DocSchema | undefined> {\n if (!canHaveJsDoc(node)) {\n return undefined;\n }\n const jsDocs = getJsDoc(node);\n if (!jsDocs.length) {\n return undefined;\n }\n // not sure how common it is to have multiple JSDocs. never seen it before.\n // regardless, in typescript implementation of methods like `getJSDocDeprecatedTag()`, they use the first one. (`getFirstJSDocTag()`)\n const jsDoc = jsDocs[0];\n const location = context.getLocation(jsDoc);\n const comment = getTextOfJSDocComment(jsDoc.comment);\n const tags = jsDoc.tags ? await pMapSeries(jsDoc.tags, (tag) => tagParser(tag, context)) : undefined;\n return new DocSchema(location, jsDoc.getText(), comment, tags);\n}\n\nasync function tagParser(tag: JSDocTag, context: SchemaExtractorContext): Promise<TagSchema> {\n // for some reason, in some cases, if `tag.getSourceFile()` is not provided to the `getText()`, it throws \"Cannot read property 'text' of undefined\"\n\n switch (tag.kind) {\n case SyntaxKind.JSDocReturnTag:\n return returnTag(tag as JSDocReturnTag, context);\n case SyntaxKind.JSDocPropertyTag:\n return propertyLikeTag(tag as JSDocPropertyTag, context);\n case SyntaxKind.JSDocParameterTag:\n return propertyLikeTag(tag as JSDocParameterTag, context);\n case SyntaxKind.JSDocAugmentsTag:\n return simpleTag(tag, TagName.augments, context);\n case SyntaxKind.JSDocAuthorTag:\n return simpleTag(tag, TagName.author, context);\n case SyntaxKind.JSDocClassTag:\n return simpleTag(tag, TagName.class, context);\n case SyntaxKind.JSDocCallbackTag:\n return simpleTag(tag, TagName.callback, context);\n case SyntaxKind.JSDocPublicTag:\n return simpleTag(tag, TagName.public, context);\n case SyntaxKind.JSDocPrivateTag:\n return simpleTag(tag, TagName.private, context);\n case SyntaxKind.JSDocProtectedTag:\n return simpleTag(tag, TagName.protected, context);\n case SyntaxKind.JSDocReadonlyTag:\n return simpleTag(tag, TagName.readonly, context);\n case SyntaxKind.JSDocOverrideTag:\n return simpleTag(tag, TagName.override, context);\n case SyntaxKind.JSDocDeprecatedTag:\n return simpleTag(tag, TagName.deprecated, context);\n case SyntaxKind.JSDocSeeTag:\n return simpleTag(tag, TagName.see, context);\n case SyntaxKind.JSDocEnumTag:\n return simpleTag(tag, TagName.enum, context);\n case SyntaxKind.JSDocThisTag:\n return simpleTag(tag, TagName.this, context);\n case SyntaxKind.JSDocTypeTag:\n return simpleTag(tag, TagName.type, context);\n case SyntaxKind.JSDocTemplateTag:\n return simpleTag(tag, TagName.template, context);\n case SyntaxKind.JSDocTypedefTag:\n return simpleTag(tag, TagName.typedef, context);\n case SyntaxKind.JSDocImplementsTag:\n return simpleTag(tag, TagName.implements, context);\n default: {\n const tagName: TagName | string = tag.tagName.getText(tag.getSourceFile());\n return simpleTag(tag, tagName, context);\n }\n }\n}\n\nfunction simpleTag(tag: JSDocTag, tagName: TagName | string, context: SchemaExtractorContext): TagSchema {\n return new TagSchema(context.getLocation(tag), tagName, getTextOfJSDocComment(tag.comment));\n}\n\nasync function returnTag(tag: JSDocReturnTag, context: SchemaExtractorContext) {\n const type = tag.typeExpression?.type ? await typeNodeToSchema(tag.typeExpression?.type, context) : undefined;\n return new ReturnTagSchema(context.getLocation(tag), getTextOfJSDocComment(tag.comment), type);\n}\n\nasync function propertyLikeTag(tag: JSDocPropertyLikeTag, context: SchemaExtractorContext) {\n const type = tag.typeExpression?.type ? await typeNodeToSchema(tag.typeExpression?.type, context) : undefined;\n return new PropertyLikeTagSchema(\n context.getLocation(tag),\n tag.name.getText(),\n getTextOfJSDocComment(tag.comment),\n type\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["jsDocToDocSchema","node","context","canHaveJsDoc","undefined","jsDocs","getJsDoc","length","jsDoc","location","getLocation","comment","getTextOfJSDocComment","tags","pMapSeries","tag","tagParser","DocSchema","getText","kind","SyntaxKind","JSDocReturnTag","returnTag","JSDocPropertyTag","propertyLikeTag","JSDocParameterTag","JSDocAugmentsTag","simpleTag","TagName","augments","JSDocAuthorTag","author","JSDocClassTag","class","JSDocCallbackTag","callback","JSDocPublicTag","public","JSDocPrivateTag","private","JSDocProtectedTag","protected","JSDocReadonlyTag","readonly","JSDocOverrideTag","override","JSDocDeprecatedTag","deprecated","JSDocSeeTag","see","JSDocEnumTag","enum","JSDocThisTag","this","JSDocTypeTag","type","JSDocTemplateTag","template","JSDocTypedefTag","typedef","JSDocImplementsTag","implements","tagName","getSourceFile","TagSchema","typeExpression","typeNodeToSchema","ReturnTagSchema","PropertyLikeTagSchema","name"],"sources":["jsdoc-to-doc-schema.ts"],"sourcesContent":["/* eslint-disable no-fallthrough */\nimport {\n getTextOfJSDocComment,\n JSDocParameterTag,\n JSDocPropertyLikeTag,\n JSDocPropertyTag,\n JSDocReturnTag,\n JSDocTag,\n Node,\n SyntaxKind,\n} from 'typescript';\nimport { getJsDoc, canHaveJsDoc } from 'tsutils';\nimport pMapSeries from 'p-map-series';\nimport {\n DocSchema,\n PropertyLikeTagSchema,\n ReturnTagSchema,\n TagName,\n TagSchema,\n} from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaExtractorContext } from '../../schema-extractor-context';\nimport { typeNodeToSchema } from './type-node-to-schema';\n\nexport async function jsDocToDocSchema(node: Node, context: SchemaExtractorContext): Promise<DocSchema | undefined> {\n if (!canHaveJsDoc(node)) {\n return undefined;\n }\n const jsDocs = getJsDoc(node);\n if (!jsDocs.length) {\n return undefined;\n }\n // not sure how common it is to have multiple JSDocs. never seen it before.\n // regardless, in typescript implementation of methods like `getJSDocDeprecatedTag()`, they use the first one. (`getFirstJSDocTag()`)\n const jsDoc = jsDocs[0];\n const location = context.getLocation(jsDoc);\n const comment = getTextOfJSDocComment(jsDoc.comment);\n const tags = jsDoc.tags ? await pMapSeries(jsDoc.tags, (tag) => tagParser(tag, context)) : undefined;\n return new DocSchema(location, jsDoc.getText(), comment, tags);\n}\n\nasync function tagParser(tag: JSDocTag, context: SchemaExtractorContext): Promise<TagSchema> {\n // for some reason, in some cases, if `tag.getSourceFile()` is not provided to the `getText()`, it throws \"Cannot read property 'text' of undefined\"\n\n switch (tag.kind) {\n case SyntaxKind.JSDocReturnTag:\n return returnTag(tag as JSDocReturnTag, context);\n case SyntaxKind.JSDocPropertyTag:\n return propertyLikeTag(tag as JSDocPropertyTag, context);\n case SyntaxKind.JSDocParameterTag:\n return propertyLikeTag(tag as JSDocParameterTag, context);\n case SyntaxKind.JSDocAugmentsTag:\n return simpleTag(tag, TagName.augments, context);\n case SyntaxKind.JSDocAuthorTag:\n return simpleTag(tag, TagName.author, context);\n case SyntaxKind.JSDocClassTag:\n return simpleTag(tag, TagName.class, context);\n case SyntaxKind.JSDocCallbackTag:\n return simpleTag(tag, TagName.callback, context);\n case SyntaxKind.JSDocPublicTag:\n return simpleTag(tag, TagName.public, context);\n case SyntaxKind.JSDocPrivateTag:\n return simpleTag(tag, TagName.private, context);\n case SyntaxKind.JSDocProtectedTag:\n return simpleTag(tag, TagName.protected, context);\n case SyntaxKind.JSDocReadonlyTag:\n return simpleTag(tag, TagName.readonly, context);\n case SyntaxKind.JSDocOverrideTag:\n return simpleTag(tag, TagName.override, context);\n case SyntaxKind.JSDocDeprecatedTag:\n return simpleTag(tag, TagName.deprecated, context);\n case SyntaxKind.JSDocSeeTag:\n return simpleTag(tag, TagName.see, context);\n case SyntaxKind.JSDocEnumTag:\n return simpleTag(tag, TagName.enum, context);\n case SyntaxKind.JSDocThisTag:\n return simpleTag(tag, TagName.this, context);\n case SyntaxKind.JSDocTypeTag:\n return simpleTag(tag, TagName.type, context);\n case SyntaxKind.JSDocTemplateTag:\n return simpleTag(tag, TagName.template, context);\n case SyntaxKind.JSDocTypedefTag:\n return simpleTag(tag, TagName.typedef, context);\n case SyntaxKind.JSDocImplementsTag:\n return simpleTag(tag, TagName.implements, context);\n default: {\n const tagName: TagName | string = tag.tagName.getText(tag.getSourceFile());\n return simpleTag(tag, tagName, context);\n }\n }\n}\n\nfunction simpleTag(tag: JSDocTag, tagName: TagName | string, context: SchemaExtractorContext): TagSchema {\n return new TagSchema(context.getLocation(tag), tagName, getTextOfJSDocComment(tag.comment));\n}\n\nasync function returnTag(tag: JSDocReturnTag, context: SchemaExtractorContext) {\n const type = tag.typeExpression?.type ? await typeNodeToSchema(tag.typeExpression?.type, context) : undefined;\n return new ReturnTagSchema(context.getLocation(tag), getTextOfJSDocComment(tag.comment), type);\n}\n\nasync function propertyLikeTag(tag: JSDocPropertyLikeTag, context: SchemaExtractorContext) {\n const type = tag.typeExpression?.type ? await typeNodeToSchema(tag.typeExpression?.type, context) : undefined;\n return new PropertyLikeTagSchema(\n context.getLocation(tag),\n tag.name.getText(),\n getTextOfJSDocComment(tag.comment),\n type\n );\n}\n"],"mappings":";;;;;;;;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAUA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EA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G,CAACkD,cAAc,gDAAlB,oBAAoBV,IAAI,GAAG,MAAM,IAAAW,oCAAgB,0BAACnD,GAAG,CAACkD,cAAc,yDAAlB,qBAAoBV,IAAI,EAAErD,OAAO,CAAC,GAAGE,SAAS;EAC7G,OAAO,KAAI+D,oCAAe,EAACjE,OAAO,CAACQ,WAAW,CAACK,GAAG,CAAC,EAAE,IAAAH,mCAAqB,EAACG,GAAG,CAACJ,OAAO,CAAC,EAAE4C,IAAI,CAAC;AAChG;AAEA,eAAe/B,eAAe,CAACT,GAAyB,EAAEb,OAA+B,EAAE;EAAA;EACzF,MAAMqD,IAAI,GAAG,wBAAAxC,GAAG,CAACkD,cAAc,iDAAlB,qBAAoBV,IAAI,GAAG,MAAM,IAAAW,oCAAgB,0BAACnD,GAAG,CAACkD,cAAc,yDAAlB,qBAAoBV,IAAI,EAAErD,OAAO,CAAC,GAAGE,SAAS;EAC7G,OAAO,KAAIgE,0CAAqB,EAC9BlE,OAAO,CAACQ,WAAW,CAACK,GAAG,CAAC,EACxBA,GAAG,CAACsD,IAAI,CAACnD,OAAO,EAAE,EAClB,IAAAN,mCAAqB,EAACG,GAAG,CAACJ,OAAO,CAAC,EAClC4C,IAAI,CACL;AACH"}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
require("core-js/modules/es.array.iterator.js");
|
|
4
|
-
|
|
5
4
|
require("core-js/modules/es.regexp.exec.js");
|
|
6
|
-
|
|
7
5
|
require("core-js/modules/es.string.trim.js");
|
|
8
|
-
|
|
9
6
|
Object.defineProperty(exports, "__esModule", {
|
|
10
7
|
value: true
|
|
11
8
|
});
|
|
@@ -13,7 +10,9 @@ exports.UNRESOLVED = void 0;
|
|
|
13
10
|
exports.parseReturnTypeFromQuickInfo = parseReturnTypeFromQuickInfo;
|
|
14
11
|
exports.parseTypeFromQuickInfo = parseTypeFromQuickInfo;
|
|
15
12
|
// eslint-disable-next-line import/no-unresolved
|
|
13
|
+
|
|
16
14
|
const UNRESOLVED = '<<unresolved>>';
|
|
15
|
+
|
|
17
16
|
/**
|
|
18
17
|
* try to parse the type from the quickinfo.
|
|
19
18
|
* this is an error-prone process, we do our best here.
|
|
@@ -46,16 +45,12 @@ const UNRESOLVED = '<<unresolved>>';
|
|
|
46
45
|
* b: number;
|
|
47
46
|
* }
|
|
48
47
|
*/
|
|
49
|
-
|
|
50
48
|
exports.UNRESOLVED = UNRESOLVED;
|
|
51
|
-
|
|
52
49
|
function parseTypeFromQuickInfo(quickInfo) {
|
|
53
50
|
var _quickInfo$body;
|
|
54
|
-
|
|
55
51
|
if (!(quickInfo !== null && quickInfo !== void 0 && (_quickInfo$body = quickInfo.body) !== null && _quickInfo$body !== void 0 && _quickInfo$body.displayString)) return '';
|
|
56
52
|
const displayString = quickInfo.body.displayString;
|
|
57
53
|
const splitByColon = displayString.split(':');
|
|
58
|
-
|
|
59
54
|
switch (quickInfo.body.kind) {
|
|
60
55
|
case 'const':
|
|
61
56
|
case 'property':
|
|
@@ -65,12 +60,10 @@ function parseTypeFromQuickInfo(quickInfo) {
|
|
|
65
60
|
const [, ...tail] = splitByColon;
|
|
66
61
|
return tail.join(':').trim();
|
|
67
62
|
}
|
|
68
|
-
|
|
69
63
|
case 'method':
|
|
70
64
|
case 'function':
|
|
71
65
|
{
|
|
72
66
|
const split = displayString.split('): ');
|
|
73
|
-
|
|
74
67
|
if (split.length !== 2) {
|
|
75
68
|
// it's hard to determine where the return-type is. so it's better to show unresolved.
|
|
76
69
|
// maybe, in the UI, in this case, it's best to show the signature.
|
|
@@ -80,10 +73,8 @@ function parseTypeFromQuickInfo(quickInfo) {
|
|
|
80
73
|
// }): T | undefined
|
|
81
74
|
return UNRESOLVED;
|
|
82
75
|
}
|
|
83
|
-
|
|
84
76
|
return split[1].trim();
|
|
85
77
|
}
|
|
86
|
-
|
|
87
78
|
case 'alias':
|
|
88
79
|
{
|
|
89
80
|
// e.g. (alias) class BuilderService\nimport BuilderService
|
|
@@ -92,12 +83,11 @@ function parseTypeFromQuickInfo(quickInfo) {
|
|
|
92
83
|
// '}\n' +
|
|
93
84
|
// 'import Serializable'
|
|
94
85
|
const firstLine = displayString.split('\n')[0];
|
|
95
|
-
const splitBySpace = firstLine.trim().split(' ');
|
|
96
|
-
|
|
86
|
+
const splitBySpace = firstLine.trim().split(' ');
|
|
87
|
+
// first two are alias keyword and alias type
|
|
97
88
|
const [,, typeName] = splitBySpace;
|
|
98
89
|
return typeName;
|
|
99
90
|
}
|
|
100
|
-
|
|
101
91
|
case 'type':
|
|
102
92
|
{
|
|
103
93
|
// e.g. `type TaskSlot = SlotRegistry<BuildTask[]>`
|
|
@@ -105,12 +95,10 @@ function parseTypeFromQuickInfo(quickInfo) {
|
|
|
105
95
|
const [, ...tail] = splitByEqual;
|
|
106
96
|
return tail.join('=').trim();
|
|
107
97
|
}
|
|
108
|
-
|
|
109
98
|
default:
|
|
110
99
|
return splitByColon[splitByColon.length - 1].trim();
|
|
111
100
|
}
|
|
112
101
|
}
|
|
113
|
-
|
|
114
102
|
function parseReturnTypeFromQuickInfo(quickInfo) {
|
|
115
103
|
if (!quickInfo) return '';
|
|
116
104
|
const typeStr = parseTypeFromQuickInfo(quickInfo);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["UNRESOLVED","parseTypeFromQuickInfo","quickInfo","body","displayString","splitByColon","split","kind","tail","join","trim","length","firstLine","splitBySpace","typeName","splitByEqual","parseReturnTypeFromQuickInfo","typeStr","array"],"sources":["parse-type-from-quick-info.ts"],"sourcesContent":["// eslint-disable-next-line import/no-unresolved\nimport protocol from 'typescript/lib/protocol';\n\nexport const UNRESOLVED = '<<unresolved>>';\n\n/**\n * try to parse the type from the quickinfo.\n * this is an error-prone process, we do our best here.\n *\n * an example of a function with many \":\"\n * `export function getObj(a: string, func: (b: number) => {}) { return { a: 1, b: 2 } };`\n * which produce the following quickinfo:\n * ```ts\n * function getObj(a: string, func: (b: number) => {}): {\n * a: number;\n * b: number;\n * }\n * ```\n *\n * some examples of quickinfo:\n *\n * function ts.signatureToDisplayParts(typechecker: TypeChecker, signature: Signature, enclosingDeclaration?: Node | undefined, flags?: TypeFormatFlags): SymbolDisplayPart[]\n *\n * const enum ts.TypeFormatFlags\n *\n * (method) ts.TypeChecker.writeSignature(signature: Signature, enclosingDeclaration?: Node | undefined, flags?: TypeFormatFlags | undefined, kind?: SignatureKind | undefined, writer?: EmitTextWriter | undefined): string\n *\n * const obj: {\n * a: number;\n * b: number;\n * }\n *\n * function getObj(a: string): {\n * a: number;\n * b: number;\n * }\n */\nexport function parseTypeFromQuickInfo(quickInfo: protocol.QuickInfoResponse | undefined): string {\n if (!quickInfo?.body?.displayString) return '';\n const displayString = quickInfo.body.displayString;\n const splitByColon = displayString.split(':');\n switch (quickInfo.body.kind) {\n case 'const':\n case 'property':\n case 'let':\n case 'var': {\n const [, ...tail] = splitByColon;\n return tail.join(':').trim();\n }\n case 'method':\n case 'function': {\n const split = displayString.split('): ');\n if (split.length !== 2) {\n // it's hard to determine where the return-type is. so it's better to show unresolved.\n // maybe, in the UI, in this case, it's best to show the signature.\n // e.g.\n // (method) IssuesList.getIssue<T extends ComponentIssue>(IssueClass: {\n // new (): T;\n // }): T | undefined\n return UNRESOLVED;\n }\n return split[1].trim();\n }\n case 'alias': {\n // e.g. (alias) class BuilderService\\nimport BuilderService\n // e.g. '(alias) type Serializable = {\\n' +\n // ' toString(): string;\\n' +\n // '}\\n' +\n // 'import Serializable'\n const firstLine = displayString.split('\\n')[0];\n const splitBySpace = firstLine.trim().split(' ');\n // first two are alias keyword and alias type\n const [, , typeName] = splitBySpace;\n return typeName;\n }\n case 'type': {\n // e.g. `type TaskSlot = SlotRegistry<BuildTask[]>`\n const splitByEqual = displayString.split('=');\n const [, ...tail] = splitByEqual;\n return tail.join('=').trim();\n }\n default:\n return splitByColon[splitByColon.length - 1].trim();\n }\n}\n\nexport function parseReturnTypeFromQuickInfo(quickInfo: protocol.QuickInfoResponse | undefined): string {\n if (!quickInfo) return '';\n const typeStr = parseTypeFromQuickInfo(quickInfo);\n const array = typeStr.split('=>');\n return array[array.length - 1].trim();\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["UNRESOLVED","parseTypeFromQuickInfo","quickInfo","body","displayString","splitByColon","split","kind","tail","join","trim","length","firstLine","splitBySpace","typeName","splitByEqual","parseReturnTypeFromQuickInfo","typeStr","array"],"sources":["parse-type-from-quick-info.ts"],"sourcesContent":["// eslint-disable-next-line import/no-unresolved\nimport protocol from 'typescript/lib/protocol';\n\nexport const UNRESOLVED = '<<unresolved>>';\n\n/**\n * try to parse the type from the quickinfo.\n * this is an error-prone process, we do our best here.\n *\n * an example of a function with many \":\"\n * `export function getObj(a: string, func: (b: number) => {}) { return { a: 1, b: 2 } };`\n * which produce the following quickinfo:\n * ```ts\n * function getObj(a: string, func: (b: number) => {}): {\n * a: number;\n * b: number;\n * }\n * ```\n *\n * some examples of quickinfo:\n *\n * function ts.signatureToDisplayParts(typechecker: TypeChecker, signature: Signature, enclosingDeclaration?: Node | undefined, flags?: TypeFormatFlags): SymbolDisplayPart[]\n *\n * const enum ts.TypeFormatFlags\n *\n * (method) ts.TypeChecker.writeSignature(signature: Signature, enclosingDeclaration?: Node | undefined, flags?: TypeFormatFlags | undefined, kind?: SignatureKind | undefined, writer?: EmitTextWriter | undefined): string\n *\n * const obj: {\n * a: number;\n * b: number;\n * }\n *\n * function getObj(a: string): {\n * a: number;\n * b: number;\n * }\n */\nexport function parseTypeFromQuickInfo(quickInfo: protocol.QuickInfoResponse | undefined): string {\n if (!quickInfo?.body?.displayString) return '';\n const displayString = quickInfo.body.displayString;\n const splitByColon = displayString.split(':');\n switch (quickInfo.body.kind) {\n case 'const':\n case 'property':\n case 'let':\n case 'var': {\n const [, ...tail] = splitByColon;\n return tail.join(':').trim();\n }\n case 'method':\n case 'function': {\n const split = displayString.split('): ');\n if (split.length !== 2) {\n // it's hard to determine where the return-type is. so it's better to show unresolved.\n // maybe, in the UI, in this case, it's best to show the signature.\n // e.g.\n // (method) IssuesList.getIssue<T extends ComponentIssue>(IssueClass: {\n // new (): T;\n // }): T | undefined\n return UNRESOLVED;\n }\n return split[1].trim();\n }\n case 'alias': {\n // e.g. (alias) class BuilderService\\nimport BuilderService\n // e.g. '(alias) type Serializable = {\\n' +\n // ' toString(): string;\\n' +\n // '}\\n' +\n // 'import Serializable'\n const firstLine = displayString.split('\\n')[0];\n const splitBySpace = firstLine.trim().split(' ');\n // first two are alias keyword and alias type\n const [, , typeName] = splitBySpace;\n return typeName;\n }\n case 'type': {\n // e.g. `type TaskSlot = SlotRegistry<BuildTask[]>`\n const splitByEqual = displayString.split('=');\n const [, ...tail] = splitByEqual;\n return tail.join('=').trim();\n }\n default:\n return splitByColon[splitByColon.length - 1].trim();\n }\n}\n\nexport function parseReturnTypeFromQuickInfo(quickInfo: protocol.QuickInfoResponse | undefined): string {\n if (!quickInfo) return '';\n const typeStr = parseTypeFromQuickInfo(quickInfo);\n const array = typeStr.split('=>');\n return array[array.length - 1].trim();\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAGO,MAAMA,UAAU,GAAG,gBAAgB;;AAE1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA/BA;AAgCO,SAASC,sBAAsB,CAACC,SAAiD,EAAU;EAAA;EAChG,IAAI,EAACA,SAAS,aAATA,SAAS,kCAATA,SAAS,CAAEC,IAAI,4CAAf,gBAAiBC,aAAa,GAAE,OAAO,EAAE;EAC9C,MAAMA,aAAa,GAAGF,SAAS,CAACC,IAAI,CAACC,aAAa;EAClD,MAAMC,YAAY,GAAGD,aAAa,CAACE,KAAK,CAAC,GAAG,CAAC;EAC7C,QAAQJ,SAAS,CAACC,IAAI,CAACI,IAAI;IACzB,KAAK,OAAO;IACZ,KAAK,UAAU;IACf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OAAOY,KAAK,CAACA,KAAK,CAACP,MAAM,GAAG,CAAC,CAAC,CAACD,IAAI,EAAE;AACvC"}
|
|
@@ -1,55 +1,40 @@
|
|
|
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.toFunctionLikeSchema = toFunctionLikeSchema;
|
|
9
|
-
|
|
10
8
|
function _semanticsEntities() {
|
|
11
9
|
const data = require("@teambit/semantics.entities.semantic-schema");
|
|
12
|
-
|
|
13
10
|
_semanticsEntities = function () {
|
|
14
11
|
return data;
|
|
15
12
|
};
|
|
16
|
-
|
|
17
13
|
return data;
|
|
18
14
|
}
|
|
19
|
-
|
|
20
15
|
function _getParams() {
|
|
21
16
|
const data = require("./get-params");
|
|
22
|
-
|
|
23
17
|
_getParams = function () {
|
|
24
18
|
return data;
|
|
25
19
|
};
|
|
26
|
-
|
|
27
20
|
return data;
|
|
28
21
|
}
|
|
29
|
-
|
|
30
22
|
function _parseTypeFromQuickInfo() {
|
|
31
23
|
const data = require("./parse-type-from-quick-info");
|
|
32
|
-
|
|
33
24
|
_parseTypeFromQuickInfo = function () {
|
|
34
25
|
return data;
|
|
35
26
|
};
|
|
36
|
-
|
|
37
27
|
return data;
|
|
38
28
|
}
|
|
39
|
-
|
|
40
29
|
function _jsdocToDocSchema() {
|
|
41
30
|
const data = require("./jsdoc-to-doc-schema");
|
|
42
|
-
|
|
43
31
|
_jsdocToDocSchema = function () {
|
|
44
32
|
return data;
|
|
45
33
|
};
|
|
46
|
-
|
|
47
34
|
return data;
|
|
48
35
|
}
|
|
49
|
-
|
|
50
36
|
async function toFunctionLikeSchema(node, context, funcName) {
|
|
51
37
|
var _node$name, _info$body, _node$modifiers, _node$typeParameters;
|
|
52
|
-
|
|
53
38
|
const name = funcName || ((_node$name = node.name) === null || _node$name === void 0 ? void 0 : _node$name.getText()) || '';
|
|
54
39
|
const info = node.name ? await context.getQuickInfo(node.name) : null;
|
|
55
40
|
const returnTypeStr = info ? (0, _parseTypeFromQuickInfo().parseTypeFromQuickInfo)(info) : 'any';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["toFunctionLikeSchema","node","context","funcName","name","getText","info","getQuickInfo","returnTypeStr","parseTypeFromQuickInfo","displaySig","body","displayString","args","getParams","parameters","returnType","resolveType","Boolean","modifiers","map","modifier","typeParameters","typeParam","location","getLocation","doc","jsDocToDocSchema","FunctionLikeSchema"],"sources":["to-function-like-schema.ts"],"sourcesContent":["import { SignatureDeclaration } from 'typescript';\nimport { FunctionLikeSchema, Modifier } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaExtractorContext } from '../../schema-extractor-context';\nimport { getParams } from './get-params';\nimport { parseTypeFromQuickInfo } from './parse-type-from-quick-info';\nimport { jsDocToDocSchema } from './jsdoc-to-doc-schema';\n\nexport async function toFunctionLikeSchema(\n node: SignatureDeclaration,\n context: SchemaExtractorContext,\n funcName?: string\n) {\n const name = funcName || node.name?.getText() || '';\n const info = node.name ? await context.getQuickInfo(node.name) : null;\n const returnTypeStr = info ? parseTypeFromQuickInfo(info) : 'any';\n const displaySig = info?.body?.displayString || '';\n const args = await getParams(node.parameters, context);\n const returnType = await context.resolveType(node, returnTypeStr, Boolean(info));\n const modifiers = node.modifiers?.map((modifier) => modifier.getText()) || [];\n const typeParameters = node.typeParameters?.map((typeParam) => typeParam.name.getText());\n const location = context.getLocation(node);\n const doc = await jsDocToDocSchema(node, context);\n return new FunctionLikeSchema(\n location,\n name,\n args,\n returnType,\n displaySig,\n modifiers as Modifier[],\n doc,\n typeParameters\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["toFunctionLikeSchema","node","context","funcName","name","getText","info","getQuickInfo","returnTypeStr","parseTypeFromQuickInfo","displaySig","body","displayString","args","getParams","parameters","returnType","resolveType","Boolean","modifiers","map","modifier","typeParameters","typeParam","location","getLocation","doc","jsDocToDocSchema","FunctionLikeSchema"],"sources":["to-function-like-schema.ts"],"sourcesContent":["import { SignatureDeclaration } from 'typescript';\nimport { FunctionLikeSchema, Modifier } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaExtractorContext } from '../../schema-extractor-context';\nimport { getParams } from './get-params';\nimport { parseTypeFromQuickInfo } from './parse-type-from-quick-info';\nimport { jsDocToDocSchema } from './jsdoc-to-doc-schema';\n\nexport async function toFunctionLikeSchema(\n node: SignatureDeclaration,\n context: SchemaExtractorContext,\n funcName?: string\n) {\n const name = funcName || node.name?.getText() || '';\n const info = node.name ? await context.getQuickInfo(node.name) : null;\n const returnTypeStr = info ? parseTypeFromQuickInfo(info) : 'any';\n const displaySig = info?.body?.displayString || '';\n const args = await getParams(node.parameters, context);\n const returnType = await context.resolveType(node, returnTypeStr, Boolean(info));\n const modifiers = node.modifiers?.map((modifier) => modifier.getText()) || [];\n const typeParameters = node.typeParameters?.map((typeParam) => typeParam.name.getText());\n const location = context.getLocation(node);\n const doc = await jsDocToDocSchema(node, context);\n return new FunctionLikeSchema(\n location,\n name,\n args,\n returnType,\n displaySig,\n modifiers as Modifier[],\n doc,\n typeParameters\n );\n}\n"],"mappings":";;;;;;;AACA;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;AAEO,eAAeA,oBAAoB,CACxCC,IAA0B,EAC1BC,OAA+B,EAC/BC,QAAiB,EACjB;EAAA;EACA,MAAMC,IAAI,GAAGD,QAAQ,mBAAIF,IAAI,CAACG,IAAI,+CAAT,WAAWC,OAAO,EAAE,KAAI,EAAE;EACnD,MAAMC,IAAI,GAAGL,IAAI,CAACG,IAAI,GAAG,MAAMF,OAAO,CAACK,YAAY,CAACN,IAAI,CAACG,IAAI,CAAC,GAAG,IAAI;E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