@teambit/typescript 0.0.736 → 0.0.737
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/schema-extractor-context.d.ts +2 -1
- package/dist/schema-extractor-context.js +15 -6
- package/dist/schema-extractor-context.js.map +1 -1
- package/dist/transformers/class-deceleration.js +2 -2
- package/dist/transformers/class-deceleration.js.map +1 -1
- package/dist/transformers/constructor.js +1 -1
- package/dist/transformers/constructor.js.map +1 -1
- package/dist/transformers/export-declaration.js +1 -1
- package/dist/transformers/export-declaration.js.map +1 -1
- package/dist/transformers/index-signature.js +1 -1
- package/dist/transformers/index-signature.js.map +1 -1
- package/dist/transformers/interface-declaration.js +1 -1
- package/dist/transformers/interface-declaration.js.map +1 -1
- package/dist/transformers/literal-type.d.ts +2 -1
- package/dist/transformers/literal-type.js +2 -2
- package/dist/transformers/literal-type.js.map +1 -1
- package/dist/transformers/property-declaration.js +1 -1
- package/dist/transformers/property-declaration.js.map +1 -1
- package/dist/transformers/property-signature.js +1 -1
- package/dist/transformers/property-signature.js.map +1 -1
- package/dist/transformers/source-file-transformer.js +1 -1
- package/dist/transformers/source-file-transformer.js.map +1 -1
- package/dist/transformers/type-alias.js +1 -1
- package/dist/transformers/type-alias.js.map +1 -1
- package/dist/transformers/utils/get-params.js +6 -2
- package/dist/transformers/utils/get-params.js.map +1 -1
- package/dist/transformers/utils/to-function-schema.js +2 -2
- package/dist/transformers/utils/to-function-schema.js.map +1 -1
- package/dist/transformers/utils/type-node-to-schema.js +17 -10
- package/dist/transformers/utils/type-node-to-schema.js.map +1 -1
- package/dist/transformers/variable-declaration.js +3 -3
- package/dist/transformers/variable-declaration.js.map +1 -1
- package/dist/transformers/variable-statement.js +2 -3
- package/dist/transformers/variable-statement.js.map +1 -1
- package/dist/typescript.extractor.js +3 -3
- package/dist/typescript.extractor.js.map +1 -1
- package/dist/typescript.parser.d.ts +2 -2
- package/dist/typescript.parser.js +4 -4
- package/dist/typescript.parser.js.map +1 -1
- package/package-tar/teambit-typescript-0.0.737.tgz +0 -0
- package/package.json +11 -11
- package/{preview-1652844422371.js → preview-1652930732694.js} +2 -2
- package/transformers/class-deceleration.ts +2 -2
- package/transformers/constructor.ts +1 -1
- package/transformers/export-declaration.ts +1 -1
- package/transformers/index-signature.ts +1 -1
- package/transformers/interface-declaration.ts +1 -1
- package/transformers/literal-type.ts +3 -2
- package/transformers/property-declaration.ts +1 -1
- package/transformers/property-signature.ts +1 -1
- package/transformers/source-file-transformer.ts +1 -1
- package/transformers/type-alias.ts +1 -1
- package/transformers/utils/get-params.ts +5 -1
- package/transformers/utils/to-function-schema.ts +2 -2
- package/transformers/utils/type-node-to-schema.ts +16 -10
- package/transformers/variable-declaration.ts +3 -3
- package/transformers/variable-statement.ts +1 -2
- package/tsconfig.json +1 -1
- package/dist/transformers/export-declaration-type.d.ts +0 -0
- package/dist/transformers/export-declaration-type.js +0 -3
- package/dist/transformers/export-declaration-type.js.map +0 -1
- package/package-tar/teambit-typescript-0.0.736.tgz +0 -0
- package/transformers/export-declaration-type.ts +0 -0
|
@@ -31,8 +31,9 @@ import { getParams } from './get-params';
|
|
|
31
31
|
|
|
32
32
|
// eslint-disable-next-line complexity
|
|
33
33
|
export async function typeNodeToSchema(node: TypeNode, context: SchemaExtractorContext): Promise<SchemaNode> {
|
|
34
|
+
const location = context.getLocation(node);
|
|
34
35
|
if (isKeywordType(node)) {
|
|
35
|
-
return new KeywordTypeSchema(node.getText());
|
|
36
|
+
return new KeywordTypeSchema(location, node.getText());
|
|
36
37
|
}
|
|
37
38
|
switch (node.kind) {
|
|
38
39
|
case SyntaxKind.IntersectionType:
|
|
@@ -44,7 +45,7 @@ export async function typeNodeToSchema(node: TypeNode, context: SchemaExtractorC
|
|
|
44
45
|
case SyntaxKind.TypeLiteral:
|
|
45
46
|
return typeLiteral(node as TypeLiteralNode, context);
|
|
46
47
|
case SyntaxKind.LiteralType: // e.g. string/boolean
|
|
47
|
-
return new LiteralTypeSchema(node.getText());
|
|
48
|
+
return new LiteralTypeSchema(location, node.getText());
|
|
48
49
|
case SyntaxKind.FunctionType:
|
|
49
50
|
return functionType(node as FunctionTypeNode, context);
|
|
50
51
|
case SyntaxKind.TypeQuery:
|
|
@@ -117,7 +118,8 @@ async function intersectionType(node: IntersectionTypeNode, context: SchemaExtra
|
|
|
117
118
|
const typeSchema = await typeNodeToSchema(type, context);
|
|
118
119
|
return typeSchema;
|
|
119
120
|
});
|
|
120
|
-
|
|
121
|
+
const location = context.getLocation(node);
|
|
122
|
+
return new TypeIntersectionSchema(location, types);
|
|
121
123
|
}
|
|
122
124
|
|
|
123
125
|
async function unionType(node: UnionTypeNode, context: SchemaExtractorContext) {
|
|
@@ -125,7 +127,8 @@ async function unionType(node: UnionTypeNode, context: SchemaExtractorContext) {
|
|
|
125
127
|
const typeSchema = await typeNodeToSchema(type, context);
|
|
126
128
|
return typeSchema;
|
|
127
129
|
});
|
|
128
|
-
|
|
130
|
+
const location = context.getLocation(node);
|
|
131
|
+
return new TypeUnionSchema(location, types);
|
|
129
132
|
}
|
|
130
133
|
|
|
131
134
|
/**
|
|
@@ -137,7 +140,8 @@ async function typeLiteral(node: TypeLiteralNode, context: SchemaExtractorContex
|
|
|
137
140
|
const typeSchema = await context.computeSchema(member);
|
|
138
141
|
return typeSchema;
|
|
139
142
|
});
|
|
140
|
-
|
|
143
|
+
const location = context.getLocation(node);
|
|
144
|
+
return new TypeLiteralSchema(location, members);
|
|
141
145
|
}
|
|
142
146
|
|
|
143
147
|
/**
|
|
@@ -158,7 +162,7 @@ async function functionType(node: FunctionTypeNode, context: SchemaExtractorCont
|
|
|
158
162
|
const params = await getParams(node.parameters, context);
|
|
159
163
|
const returnType = await typeNodeToSchema(node.type, context);
|
|
160
164
|
const location = context.getLocation(node);
|
|
161
|
-
return new FunctionLikeSchema(name, params, returnType, ''
|
|
165
|
+
return new FunctionLikeSchema(location, name, params, returnType, '');
|
|
162
166
|
}
|
|
163
167
|
|
|
164
168
|
/**
|
|
@@ -167,12 +171,14 @@ async function functionType(node: FunctionTypeNode, context: SchemaExtractorCont
|
|
|
167
171
|
async function typeQuery(node: TypeQueryNode, context: SchemaExtractorContext) {
|
|
168
172
|
const displaySig = await context.getQuickInfoDisplayString(node.exprName);
|
|
169
173
|
const type = await context.resolveType(node.exprName, node.exprName.getText(), false);
|
|
170
|
-
|
|
174
|
+
const location = context.getLocation(node);
|
|
175
|
+
return new TypeQuerySchema(location, type, displaySig);
|
|
171
176
|
}
|
|
172
177
|
|
|
173
178
|
async function arrayType(node: ArrayTypeNode, context: SchemaExtractorContext) {
|
|
174
179
|
const type = await typeNodeToSchema(node.elementType, context);
|
|
175
|
-
|
|
180
|
+
const location = context.getLocation(node);
|
|
181
|
+
return new TypeArraySchema(location, type);
|
|
176
182
|
}
|
|
177
183
|
|
|
178
184
|
/**
|
|
@@ -181,7 +187,7 @@ async function arrayType(node: ArrayTypeNode, context: SchemaExtractorContext) {
|
|
|
181
187
|
async function typeOperator(node: TypeOperatorNode, context: SchemaExtractorContext) {
|
|
182
188
|
const operatorName = getOperatorName(node.operator);
|
|
183
189
|
const type = await typeNodeToSchema(node.type, context);
|
|
184
|
-
return new TypeOperatorSchema(operatorName, type);
|
|
190
|
+
return new TypeOperatorSchema(context.getLocation(node), operatorName, type);
|
|
185
191
|
}
|
|
186
192
|
|
|
187
193
|
function getOperatorName(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword) {
|
|
@@ -202,5 +208,5 @@ async function tupleType(node: TupleTypeNode, context: SchemaExtractorContext) {
|
|
|
202
208
|
const typeSchema = await typeNodeToSchema(elem, context);
|
|
203
209
|
return typeSchema;
|
|
204
210
|
});
|
|
205
|
-
return new TupleTypeSchema(elements);
|
|
211
|
+
return new TupleTypeSchema(context.getLocation(node), elements);
|
|
206
212
|
}
|
|
@@ -23,15 +23,15 @@ export class VariableDeclaration implements SchemaTransformer {
|
|
|
23
23
|
const name = this.getName(varDec);
|
|
24
24
|
const info = await context.getQuickInfo(varDec.name);
|
|
25
25
|
const displaySig = info?.body?.displayString || '';
|
|
26
|
+
const location = context.getLocation(varDec);
|
|
26
27
|
if (varDec.initializer?.kind === ts.SyntaxKind.ArrowFunction) {
|
|
27
28
|
const args = await getParams((varDec.initializer as ArrowFunction).parameters, context);
|
|
28
29
|
const typeStr = parseReturnTypeFromQuickInfo(info);
|
|
29
30
|
const returnType = await context.resolveType(varDec, typeStr);
|
|
30
|
-
|
|
31
|
-
return new FunctionLikeSchema(name, args, returnType, displaySig, location);
|
|
31
|
+
return new FunctionLikeSchema(location, name, args, returnType, displaySig);
|
|
32
32
|
}
|
|
33
33
|
const typeStr = parseTypeFromQuickInfo(info);
|
|
34
34
|
const type = await context.resolveType(varDec, typeStr);
|
|
35
|
-
return new VariableSchema(name, displaySig, type);
|
|
35
|
+
return new VariableSchema(location, name, displaySig, type);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -27,7 +27,6 @@ export class VariableStatementTransformer implements SchemaTransformer {
|
|
|
27
27
|
const schema = await context.visitDefinition(dec.name);
|
|
28
28
|
return schema;
|
|
29
29
|
});
|
|
30
|
-
|
|
31
|
-
return new Module(compact(schemas));
|
|
30
|
+
return new Module(context.getLocation(node), compact(schemas));
|
|
32
31
|
}
|
|
33
32
|
}
|
package/tsconfig.json
CHANGED
|
@@ -15,13 +15,13 @@
|
|
|
15
15
|
"declaration": true,
|
|
16
16
|
"sourceMap": true,
|
|
17
17
|
"skipLibCheck": true,
|
|
18
|
+
"experimentalDecorators": true,
|
|
18
19
|
"outDir": "dist",
|
|
19
20
|
"moduleResolution": "node",
|
|
20
21
|
"esModuleInterop": true,
|
|
21
22
|
"rootDir": ".",
|
|
22
23
|
"resolveJsonModule": true,
|
|
23
24
|
"emitDeclarationOnly": true,
|
|
24
|
-
"experimentalDecorators": true,
|
|
25
25
|
"emitDecoratorMetadata": true,
|
|
26
26
|
"allowSyntheticDefaultImports": true,
|
|
27
27
|
"strictPropertyInitialization": false,
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
Binary file
|
|
File without changes
|