@teambit/typescript 1.0.186 → 1.0.188
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/artifacts/__bit_junit.xml +15 -15
- package/artifacts/preview/teambit_typescript_typescript-preview.js +1 -1
- package/dist/{preview-1709781440634.js → preview-1710040632859.js} +2 -2
- package/dist/schema-extractor-context.d.ts +4 -4
- package/dist/sourceFileTransformers/class.js +4 -4
- package/dist/sourceFileTransformers/class.js.map +1 -1
- package/dist/sourceFileTransformers/export.js +2 -2
- package/dist/sourceFileTransformers/export.js.map +1 -1
- package/dist/sourceFileTransformers/expression-statement.js.map +1 -1
- package/dist/sourceFileTransformers/function.js +3 -3
- package/dist/sourceFileTransformers/function.js.map +1 -1
- package/dist/sourceFileTransformers/import.js +3 -3
- package/dist/sourceFileTransformers/import.js.map +1 -1
- package/dist/sourceFileTransformers/interface.js +1 -1
- package/dist/sourceFileTransformers/interface.js.map +1 -1
- package/dist/sourceFileTransformers/type-reference.js.map +1 -1
- package/dist/sourceFileTransformers/typeAlias.js +1 -1
- package/dist/sourceFileTransformers/typeAlias.js.map +1 -1
- package/dist/sourceFileTransformers/variable.js.map +1 -1
- package/dist/transformers/class-declaration.js +4 -2
- package/dist/transformers/class-declaration.js.map +1 -1
- package/dist/transformers/export-declaration.js +1 -1
- package/dist/transformers/export-declaration.js.map +1 -1
- package/dist/transformers/function-like.js +5 -3
- package/dist/transformers/function-like.js.map +1 -1
- package/dist/transformers/property-declaration.js +2 -2
- package/dist/transformers/property-declaration.js.map +1 -1
- package/dist/transformers/source-file-transformer.js +4 -2
- package/dist/transformers/source-file-transformer.js.map +1 -1
- package/dist/transformers/utils/parse-type-from-quick-info.d.ts +3 -3
- package/dist/transformers/utils/parse-type-from-quick-info.js +0 -2
- package/dist/transformers/utils/parse-type-from-quick-info.js.map +1 -1
- package/dist/transformers/variable-declaration.js +2 -1
- package/dist/transformers/variable-declaration.js.map +1 -1
- package/dist/typescript.parser.js +3 -2
- package/dist/typescript.parser.js.map +1 -1
- package/package.json +20 -20
- package/sourceFileTransformers/class.ts +2 -6
- package/sourceFileTransformers/export.ts +2 -3
- package/sourceFileTransformers/expression-statement.ts +7 -3
- package/sourceFileTransformers/function.ts +2 -5
- package/sourceFileTransformers/import.ts +1 -4
- package/sourceFileTransformers/interface.ts +1 -2
- package/sourceFileTransformers/type-reference.ts +1 -1
- package/sourceFileTransformers/typeAlias.ts +1 -2
- package/sourceFileTransformers/variable.ts +1 -1
- package/transformers/class-declaration.ts +5 -3
- package/transformers/export-declaration.ts +1 -1
- package/transformers/function-like.ts +6 -4
- package/transformers/property-declaration.ts +3 -3
- package/transformers/source-file-transformer.ts +4 -2
- package/transformers/utils/parse-type-from-quick-info.ts +3 -4
- package/transformers/variable-declaration.ts +2 -1
- package/artifacts/schema.json +0 -14426
|
@@ -2,7 +2,7 @@ import ts from 'typescript';
|
|
|
2
2
|
import { replaceName } from './replaceName';
|
|
3
3
|
|
|
4
4
|
export function classNamesTransformer(nameMapping: Record<string, string>): ts.TransformerFactory<ts.SourceFile> {
|
|
5
|
-
return (context) => {
|
|
5
|
+
return (context: ts.TransformationContext) => {
|
|
6
6
|
const { factory } = context;
|
|
7
7
|
|
|
8
8
|
const visit: ts.Visitor = (node) => {
|
|
@@ -17,7 +17,6 @@ export function classNamesTransformer(nameMapping: Record<string, string>): ts.T
|
|
|
17
17
|
const newMemberName = replaceName(oldMemberName, nameMapping);
|
|
18
18
|
return factory.updatePropertyDeclaration(
|
|
19
19
|
member,
|
|
20
|
-
member.decorators,
|
|
21
20
|
member.modifiers,
|
|
22
21
|
newMemberName ? ts.factory.createIdentifier(newMemberName) : member.name,
|
|
23
22
|
member.questionToken,
|
|
@@ -33,7 +32,6 @@ export function classNamesTransformer(nameMapping: Record<string, string>): ts.T
|
|
|
33
32
|
const updatedParameters = member.parameters.map((param) => {
|
|
34
33
|
return ts.factory.updateParameterDeclaration(
|
|
35
34
|
param,
|
|
36
|
-
param.decorators,
|
|
37
35
|
param.modifiers,
|
|
38
36
|
param.dotDotDotToken,
|
|
39
37
|
param.name,
|
|
@@ -45,7 +43,6 @@ export function classNamesTransformer(nameMapping: Record<string, string>): ts.T
|
|
|
45
43
|
|
|
46
44
|
return factory.updateMethodDeclaration(
|
|
47
45
|
member,
|
|
48
|
-
member.decorators,
|
|
49
46
|
member.modifiers,
|
|
50
47
|
member.asteriskToken,
|
|
51
48
|
newMemberName ? ts.factory.createIdentifier(newMemberName) : member.name,
|
|
@@ -61,7 +58,6 @@ export function classNamesTransformer(nameMapping: Record<string, string>): ts.T
|
|
|
61
58
|
|
|
62
59
|
return factory.updateClassDeclaration(
|
|
63
60
|
node,
|
|
64
|
-
node.decorators,
|
|
65
61
|
node.modifiers,
|
|
66
62
|
factory.createIdentifier(newName),
|
|
67
63
|
node.typeParameters,
|
|
@@ -72,6 +68,6 @@ export function classNamesTransformer(nameMapping: Record<string, string>): ts.T
|
|
|
72
68
|
}
|
|
73
69
|
return ts.visitEachChild(node, visit, context);
|
|
74
70
|
};
|
|
75
|
-
return (node) => ts.visitNode(node, visit);
|
|
71
|
+
return (node) => ts.visitNode(node, visit) as ts.SourceFile;
|
|
76
72
|
};
|
|
77
73
|
}
|
|
@@ -36,7 +36,6 @@ export const exportTransformer: SourceFileTransformer = (mapping: Record<string,
|
|
|
36
36
|
|
|
37
37
|
return ts.factory.updateExportDeclaration(
|
|
38
38
|
node,
|
|
39
|
-
node.decorators,
|
|
40
39
|
node.modifiers,
|
|
41
40
|
node.isTypeOnly,
|
|
42
41
|
updatedExportClause,
|
|
@@ -56,11 +55,11 @@ export const exportTransformer: SourceFileTransformer = (mapping: Record<string,
|
|
|
56
55
|
}
|
|
57
56
|
}
|
|
58
57
|
|
|
59
|
-
return ts.factory.updateExportAssignment(node, node.
|
|
58
|
+
return ts.factory.updateExportAssignment(node, node.modifiers, expression);
|
|
60
59
|
}
|
|
61
60
|
|
|
62
61
|
return ts.visitEachChild(node, visit, context);
|
|
63
62
|
};
|
|
64
|
-
return (node) => ts.visitNode(node, visit);
|
|
63
|
+
return (node) => ts.visitNode(node, visit) as ts.SourceFile;
|
|
65
64
|
};
|
|
66
65
|
};
|
|
@@ -21,7 +21,7 @@ export const expressionStatementTransformer: SourceFileTransformer = (mapping: R
|
|
|
21
21
|
|
|
22
22
|
const visit: ts.Visitor = (node) => {
|
|
23
23
|
if (ts.isExpressionStatement(node)) {
|
|
24
|
-
return ts.factory.updateExpressionStatement(node, ts.visitNode(node.expression, visit));
|
|
24
|
+
return ts.factory.updateExpressionStatement(node, ts.visitNode(node.expression, visit) as ts.Expression);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
if (ts.isPropertyAccessExpression(node)) {
|
|
@@ -29,7 +29,11 @@ export const expressionStatementTransformer: SourceFileTransformer = (mapping: R
|
|
|
29
29
|
if (ts.isIdentifier(node.name)) {
|
|
30
30
|
newName = replaceIdentifierText(node.name);
|
|
31
31
|
}
|
|
32
|
-
return ts.factory.updatePropertyAccessExpression(
|
|
32
|
+
return ts.factory.updatePropertyAccessExpression(
|
|
33
|
+
node,
|
|
34
|
+
ts.visitNode(node.expression, visit) as ts.Expression,
|
|
35
|
+
newName
|
|
36
|
+
);
|
|
33
37
|
}
|
|
34
38
|
|
|
35
39
|
if (ts.isIdentifier(node)) {
|
|
@@ -39,6 +43,6 @@ export const expressionStatementTransformer: SourceFileTransformer = (mapping: R
|
|
|
39
43
|
return ts.visitEachChild(node, visit, context);
|
|
40
44
|
};
|
|
41
45
|
|
|
42
|
-
return (node) => ts.visitNode(node, visit);
|
|
46
|
+
return (node) => ts.visitNode(node, visit) as ts.SourceFile;
|
|
43
47
|
};
|
|
44
48
|
};
|
|
@@ -28,14 +28,13 @@ export const functionNamesTransformer: SourceFileTransformer = (mapping: Record<
|
|
|
28
28
|
const functionName = node.name?.getText() ?? '';
|
|
29
29
|
const newName = Object.entries(mapping).find(([key]) => functionName.includes(key))?.[1] ?? functionName;
|
|
30
30
|
const parameters = node.parameters.map((param) => {
|
|
31
|
-
const newParamType = param.type ? ts.visitNode(param.type, updateTypeReference) : param.type;
|
|
31
|
+
const newParamType = param.type ? (ts.visitNode(param.type, updateTypeReference) as ts.TypeNode) : param.type;
|
|
32
32
|
if (ts.isIdentifier(param.name)) {
|
|
33
33
|
const oldName = param.name.getText();
|
|
34
34
|
const newParamName = Object.keys(mapping).find((key) => oldName.includes(key));
|
|
35
35
|
if (newParamName) {
|
|
36
36
|
return ts.factory.updateParameterDeclaration(
|
|
37
37
|
param,
|
|
38
|
-
param.decorators,
|
|
39
38
|
param.modifiers,
|
|
40
39
|
param.dotDotDotToken,
|
|
41
40
|
ts.factory.createIdentifier(newParamName),
|
|
@@ -61,7 +60,6 @@ export const functionNamesTransformer: SourceFileTransformer = (mapping: Record<
|
|
|
61
60
|
const newParamName = ts.factory.createObjectBindingPattern(elements);
|
|
62
61
|
return ts.factory.updateParameterDeclaration(
|
|
63
62
|
param,
|
|
64
|
-
param.decorators,
|
|
65
63
|
param.modifiers,
|
|
66
64
|
param.dotDotDotToken,
|
|
67
65
|
newParamName,
|
|
@@ -77,7 +75,6 @@ export const functionNamesTransformer: SourceFileTransformer = (mapping: Record<
|
|
|
77
75
|
const updatedBody = node.body && ts.isBlock(node.body) ? updateReturnStatement(node.body) : node.body;
|
|
78
76
|
return ts.factory.updateFunctionDeclaration(
|
|
79
77
|
node,
|
|
80
|
-
node.decorators,
|
|
81
78
|
node.modifiers,
|
|
82
79
|
node.asteriskToken,
|
|
83
80
|
newName ? ts.factory.createIdentifier(newName) : node.name,
|
|
@@ -168,6 +165,6 @@ export const functionNamesTransformer: SourceFileTransformer = (mapping: Record<
|
|
|
168
165
|
}
|
|
169
166
|
return ts.factory.createBlock([], true);
|
|
170
167
|
}
|
|
171
|
-
return (node) => ts.visitNode(node, visit);
|
|
168
|
+
return (node) => ts.visitNode(node, visit) as ts.SourceFile;
|
|
172
169
|
};
|
|
173
170
|
};
|
|
@@ -40,7 +40,6 @@ export const importTransformer: SourceFileTransformer = (mapping: Record<string,
|
|
|
40
40
|
|
|
41
41
|
return ts.factory.updateImportDeclaration(
|
|
42
42
|
node,
|
|
43
|
-
node.decorators,
|
|
44
43
|
node.modifiers,
|
|
45
44
|
updatedImportClause,
|
|
46
45
|
ts.factory.createStringLiteral(moduleSpecifier),
|
|
@@ -50,7 +49,6 @@ export const importTransformer: SourceFileTransformer = (mapping: Record<string,
|
|
|
50
49
|
|
|
51
50
|
return ts.factory.updateImportDeclaration(
|
|
52
51
|
node,
|
|
53
|
-
node.decorators,
|
|
54
52
|
node.modifiers,
|
|
55
53
|
node.importClause,
|
|
56
54
|
ts.factory.createStringLiteral(moduleSpecifier),
|
|
@@ -67,7 +65,6 @@ export const importTransformer: SourceFileTransformer = (mapping: Record<string,
|
|
|
67
65
|
|
|
68
66
|
const updatedImportEqualsDeclaration = ts.factory.updateImportEqualsDeclaration(
|
|
69
67
|
node,
|
|
70
|
-
node.decorators,
|
|
71
68
|
node.modifiers,
|
|
72
69
|
node.isTypeOnly,
|
|
73
70
|
node.name,
|
|
@@ -99,6 +96,6 @@ export const importTransformer: SourceFileTransformer = (mapping: Record<string,
|
|
|
99
96
|
|
|
100
97
|
return ts.visitEachChild(node, visit, context);
|
|
101
98
|
};
|
|
102
|
-
return (node) => ts.visitNode(node, visit);
|
|
99
|
+
return (node) => ts.visitNode(node, visit) as ts.SourceFile;
|
|
103
100
|
};
|
|
104
101
|
};
|
|
@@ -26,7 +26,6 @@ export function interfaceNamesTransformer(nameMapping: Record<string, string>):
|
|
|
26
26
|
});
|
|
27
27
|
return factory.updateInterfaceDeclaration(
|
|
28
28
|
node,
|
|
29
|
-
node.decorators,
|
|
30
29
|
node.modifiers,
|
|
31
30
|
factory.createIdentifier(newName),
|
|
32
31
|
node.typeParameters,
|
|
@@ -37,6 +36,6 @@ export function interfaceNamesTransformer(nameMapping: Record<string, string>):
|
|
|
37
36
|
}
|
|
38
37
|
return ts.visitEachChild(node, (child) => visit(child), context);
|
|
39
38
|
};
|
|
40
|
-
return (node) => ts.visitNode(node, visit);
|
|
39
|
+
return (node) => ts.visitNode(node, visit) as ts.SourceFile;
|
|
41
40
|
};
|
|
42
41
|
}
|
|
@@ -11,7 +11,6 @@ export function typeAliasNamesTransformer(nameMapping: Record<string, string>):
|
|
|
11
11
|
if (newName) {
|
|
12
12
|
return factory.updateTypeAliasDeclaration(
|
|
13
13
|
node,
|
|
14
|
-
node.decorators,
|
|
15
14
|
node.modifiers,
|
|
16
15
|
factory.createIdentifier(newName),
|
|
17
16
|
node.typeParameters,
|
|
@@ -21,6 +20,6 @@ export function typeAliasNamesTransformer(nameMapping: Record<string, string>):
|
|
|
21
20
|
}
|
|
22
21
|
return ts.visitEachChild(node, (child) => visit(child), context);
|
|
23
22
|
};
|
|
24
|
-
return (node) => ts.visitNode(node, visit);
|
|
23
|
+
return (node) => ts.visitNode(node, visit) as ts.SourceFile;
|
|
25
24
|
};
|
|
26
25
|
}
|
|
@@ -20,6 +20,6 @@ export function variableNamesTransformer(nameMapping: Record<string, string>): t
|
|
|
20
20
|
}
|
|
21
21
|
return ts.visitEachChild(node, (child) => visit(child), context);
|
|
22
22
|
};
|
|
23
|
-
return (node) => ts.visitNode(node, visit);
|
|
23
|
+
return (node) => ts.visitNode(node, visit) as ts.SourceFile;
|
|
24
24
|
};
|
|
25
25
|
}
|
|
@@ -51,8 +51,9 @@ export class ClassDeclarationTransformer implements SchemaTransformer {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
async transform(node: ClassDeclaration, context: SchemaExtractorContext) {
|
|
54
|
-
const
|
|
55
|
-
|
|
54
|
+
const nodeDecorators = ts.canHaveDecorators(node) ? ts.getDecorators(node) : undefined;
|
|
55
|
+
const decorators = nodeDecorators?.length
|
|
56
|
+
? await pMapSeries(nodeDecorators, (decorator) => context.computeSchema(decorator))
|
|
56
57
|
: undefined;
|
|
57
58
|
const className = this.getName(node);
|
|
58
59
|
const extendsExpressionsWithTypeArgs = await this.getExpressionWithTypeArgs(
|
|
@@ -72,7 +73,8 @@ export class ClassDeclarationTransformer implements SchemaTransformer {
|
|
|
72
73
|
});
|
|
73
74
|
const signature = node.name ? await context.getQuickInfoDisplayString(node.name) : undefined;
|
|
74
75
|
const members = await pMapSeries(node.members, async (member) => {
|
|
75
|
-
const
|
|
76
|
+
const memberModifiers = ts.canHaveModifiers(member) ? ts.getModifiers(member) : undefined;
|
|
77
|
+
const isPrivate = memberModifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.PrivateKeyword);
|
|
76
78
|
if (isPrivate) {
|
|
77
79
|
return null;
|
|
78
80
|
}
|
|
@@ -134,7 +134,7 @@ also, make sure the tsconfig.json in the root has the "jsx" setting defined.`);
|
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
if (definitionNode.parent.kind === SyntaxKind.ExportSpecifier)
|
|
137
|
-
return exportSpecifierToSchemaNode(definitionNode.parent as ExportSpecifier, context);
|
|
137
|
+
return await exportSpecifierToSchemaNode(definitionNode.parent as ExportSpecifier, context);
|
|
138
138
|
|
|
139
139
|
return await context.computeSchema(definitionNode.parent);
|
|
140
140
|
} catch (e) {
|
|
@@ -31,8 +31,9 @@ export class FunctionLikeTransformer implements SchemaTransformer {
|
|
|
31
31
|
|
|
32
32
|
async transform(node: SignatureDeclaration, context: SchemaExtractorContext): Promise<SchemaNode> {
|
|
33
33
|
const name = this.getName(node);
|
|
34
|
+
const nodeModifiers = ts.canHaveModifiers(node) ? ts.getModifiers(node) : undefined;
|
|
34
35
|
const getQuickInfoFromDefaultModifier = async () => {
|
|
35
|
-
const defaultModifier =
|
|
36
|
+
const defaultModifier = nodeModifiers?.find((modifier) => modifier.kind === ts.SyntaxKind.DefaultKeyword);
|
|
36
37
|
if (defaultModifier) return context.getQuickInfo(defaultModifier);
|
|
37
38
|
if (node.kind === ts.SyntaxKind.ArrowFunction) return context.getQuickInfo(node.equalsGreaterThanToken);
|
|
38
39
|
return null;
|
|
@@ -45,12 +46,13 @@ export class FunctionLikeTransformer implements SchemaTransformer {
|
|
|
45
46
|
)) as ParameterSchema[];
|
|
46
47
|
|
|
47
48
|
const returnType = await context.resolveType(node, returnTypeStr, Boolean(info));
|
|
48
|
-
const modifiers =
|
|
49
|
+
const modifiers = nodeModifiers?.map((modifier) => modifier.getText()) || [];
|
|
49
50
|
const typeParameters = node.typeParameters?.map((typeParam) => typeParam.name.getText());
|
|
50
51
|
const location = context.getLocation(node);
|
|
51
52
|
const doc = await context.jsDocToDocSchema(node);
|
|
52
|
-
const
|
|
53
|
-
|
|
53
|
+
const nodeDecorators = ts.canHaveDecorators(node) ? ts.getDecorators(node) : undefined;
|
|
54
|
+
const decorators = nodeDecorators?.length
|
|
55
|
+
? await pMapSeries(nodeDecorators, (decorator) => context.computeSchema(decorator))
|
|
54
56
|
: undefined;
|
|
55
57
|
|
|
56
58
|
return new FunctionLikeSchema(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Node, PropertyDeclaration, PropertySignature, SyntaxKind } from 'typescript';
|
|
1
|
+
import { Node, PropertyDeclaration, PropertySignature, SyntaxKind, isPropertyDeclaration } from 'typescript';
|
|
2
2
|
import { VariableLikeSchema } from '@teambit/semantics.entities.semantic-schema';
|
|
3
3
|
import { SchemaTransformer } from '../schema-transformer';
|
|
4
4
|
import { SchemaExtractorContext } from '../schema-extractor-context';
|
|
@@ -26,9 +26,9 @@ export class PropertyDeclarationTransformer implements SchemaTransformer {
|
|
|
26
26
|
const displaySig = info?.body?.displayString || node.getText();
|
|
27
27
|
const typeStr = parseTypeFromQuickInfo(info);
|
|
28
28
|
const type = await context.resolveType(node, typeStr);
|
|
29
|
-
const isOptional = Boolean(node.questionToken) || Boolean(node.initializer);
|
|
29
|
+
const isOptional = Boolean(node.questionToken) || (isPropertyDeclaration(node) && Boolean(node.initializer));
|
|
30
30
|
const doc = await context.jsDocToDocSchema(node);
|
|
31
|
-
const defaultValue = node
|
|
31
|
+
const defaultValue = isPropertyDeclaration(node) ? node.initializer?.getText() : undefined;
|
|
32
32
|
return new VariableLikeSchema(context.getLocation(node), name, displaySig, type, isOptional, doc, defaultValue);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -66,8 +66,9 @@ export class SourceFileTransformer implements SchemaTransformer {
|
|
|
66
66
|
return ast.statements.filter((statement) => {
|
|
67
67
|
if (statement.kind === ts.SyntaxKind.ExportDeclaration || statement.kind === ts.SyntaxKind.ExportAssignment)
|
|
68
68
|
return true;
|
|
69
|
+
const modifiers = ts.canHaveModifiers(statement) ? ts.getModifiers(statement) : undefined;
|
|
69
70
|
const isExport = Boolean(
|
|
70
|
-
|
|
71
|
+
modifiers?.find((modifier) => {
|
|
71
72
|
return modifier.kind === ts.SyntaxKind.ExportKeyword;
|
|
72
73
|
})
|
|
73
74
|
);
|
|
@@ -77,9 +78,10 @@ export class SourceFileTransformer implements SchemaTransformer {
|
|
|
77
78
|
|
|
78
79
|
private listInternalNodes(ast: SourceFile): Node[] {
|
|
79
80
|
return ast.statements.filter((statement) => {
|
|
81
|
+
const modifiers = ts.canHaveModifiers(statement) ? ts.getModifiers(statement) : undefined;
|
|
80
82
|
if (
|
|
81
83
|
!(statement.kind === ts.SyntaxKind.ExportDeclaration || statement.kind === ts.SyntaxKind.ExportAssignment) &&
|
|
82
|
-
!
|
|
84
|
+
!modifiers?.find((modifier) => {
|
|
83
85
|
return modifier.kind === ts.SyntaxKind.ExportKeyword;
|
|
84
86
|
})
|
|
85
87
|
) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import protocol from 'typescript/lib/protocol';
|
|
1
|
+
import type ts from 'typescript/lib/tsserverlibrary';
|
|
3
2
|
|
|
4
3
|
export const UNRESOLVED = '<<unresolved>>';
|
|
5
4
|
|
|
@@ -35,7 +34,7 @@ export const UNRESOLVED = '<<unresolved>>';
|
|
|
35
34
|
* b: number;
|
|
36
35
|
* }
|
|
37
36
|
*/
|
|
38
|
-
export function parseTypeFromQuickInfo(quickInfo: protocol.QuickInfoResponse | undefined): string {
|
|
37
|
+
export function parseTypeFromQuickInfo(quickInfo: ts.server.protocol.QuickInfoResponse | undefined): string {
|
|
39
38
|
if (!quickInfo?.body?.displayString) return '';
|
|
40
39
|
const displayString = quickInfo.body.displayString;
|
|
41
40
|
const splitByColon = displayString.split(':');
|
|
@@ -92,7 +91,7 @@ export function parseTypeFromQuickInfo(quickInfo: protocol.QuickInfoResponse | u
|
|
|
92
91
|
}
|
|
93
92
|
}
|
|
94
93
|
|
|
95
|
-
export function parseReturnTypeFromQuickInfo(quickInfo: protocol.QuickInfoResponse | undefined): string {
|
|
94
|
+
export function parseReturnTypeFromQuickInfo(quickInfo: ts.server.protocol.QuickInfoResponse | undefined): string {
|
|
96
95
|
if (!quickInfo) return '';
|
|
97
96
|
const typeStr = parseTypeFromQuickInfo(quickInfo);
|
|
98
97
|
const array = typeStr.split('=>');
|
|
@@ -33,7 +33,8 @@ export class VariableDeclaration implements SchemaTransformer {
|
|
|
33
33
|
const displaySig = info?.body?.displayString || '';
|
|
34
34
|
const location = context.getLocation(varDec);
|
|
35
35
|
const doc = await context.jsDocToDocSchema(varDec);
|
|
36
|
-
const
|
|
36
|
+
const nodeModifiers = ts.canHaveModifiers(varDec) ? ts.getModifiers(varDec) : undefined;
|
|
37
|
+
const modifiers = nodeModifiers?.map((modifier) => modifier.getText()) || [];
|
|
37
38
|
if (varDec.initializer?.kind === ts.SyntaxKind.ArrowFunction) {
|
|
38
39
|
const functionLikeInfo = await context.getQuickInfo((varDec.initializer as ArrowFunction).equalsGreaterThanToken);
|
|
39
40
|
const returnTypeStr = functionLikeInfo ? parseTypeFromQuickInfo(functionLikeInfo) : 'any';
|