@teambit/typescript 1.0.805 → 1.0.807
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/extractor-options.d.ts +5 -0
- package/dist/extractor-options.js.map +1 -1
- package/dist/identifier.js +11 -2
- package/dist/identifier.js.map +1 -1
- package/dist/{preview-1762811525854.js → preview-1763140835034.js} +2 -2
- package/dist/schema-extractor-context.d.ts +14 -0
- package/dist/schema-extractor-context.js +54 -6
- package/dist/schema-extractor-context.js.map +1 -1
- package/dist/transformers/index-signature.d.ts +1 -1
- package/dist/transformers/object-literal-expression.js +25 -3
- package/dist/transformers/object-literal-expression.js.map +1 -1
- package/dist/transformers/variable-declaration.js +5 -0
- package/dist/transformers/variable-declaration.js.map +1 -1
- package/dist/typescript.extractor.d.ts +9 -4
- package/dist/typescript.extractor.js +77 -14
- package/dist/typescript.extractor.js.map +1 -1
- package/dist/typescript.main.runtime.d.ts +1 -1
- package/dist/typescript.main.runtime.js +2 -2
- package/dist/typescript.main.runtime.js.map +1 -1
- package/package.json +18 -16
- package/transformers/object-literal-expression.ts +39 -4
- package/transformers/variable-declaration.ts +5 -0
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/typescript",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.807",
|
|
4
4
|
"homepage": "https://bit.cloud/teambit/typescript/typescript",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.typescript",
|
|
8
8
|
"name": "typescript",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.807"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"lodash": "4.17.21",
|
|
@@ -14,33 +14,35 @@
|
|
|
14
14
|
"tsutils": "3.21.0",
|
|
15
15
|
"typescript": "5.9.2",
|
|
16
16
|
"get-tsconfig": "4.2.0",
|
|
17
|
+
"minimatch": "3.0.5",
|
|
17
18
|
"fs-extra": "10.0.0",
|
|
18
19
|
"chalk": "4.1.2",
|
|
20
|
+
"@teambit/legacy.utils": "0.0.28",
|
|
19
21
|
"@teambit/typescript.modules.ts-config-mutator": "0.0.87",
|
|
20
22
|
"@teambit/typescript.typescript-compiler": "2.0.63",
|
|
21
23
|
"@teambit/component.sources": "0.0.138",
|
|
22
|
-
"@teambit/legacy.utils": "0.0.28",
|
|
23
|
-
"@teambit/semantics.entities.semantic-schema": "0.0.94",
|
|
24
24
|
"@teambit/ts-server": "0.0.71",
|
|
25
25
|
"@teambit/harmony": "0.4.7",
|
|
26
26
|
"@teambit/logger": "0.0.1378",
|
|
27
27
|
"@teambit/cli": "0.0.1285",
|
|
28
28
|
"@teambit/legacy.constants": "0.0.19",
|
|
29
|
-
"@teambit/compiler": "1.0.
|
|
30
|
-
"@teambit/builder": "1.0.
|
|
31
|
-
"@teambit/component": "1.0.
|
|
32
|
-
"@teambit/dependency-resolver": "1.0.
|
|
33
|
-
"@teambit/formatter": "1.0.
|
|
34
|
-
"@teambit/
|
|
35
|
-
"@teambit/
|
|
36
|
-
"@teambit/
|
|
37
|
-
"@teambit/
|
|
38
|
-
"@teambit/
|
|
39
|
-
"@teambit/
|
|
40
|
-
"@teambit/
|
|
29
|
+
"@teambit/compiler": "1.0.807",
|
|
30
|
+
"@teambit/builder": "1.0.807",
|
|
31
|
+
"@teambit/component": "1.0.807",
|
|
32
|
+
"@teambit/dependency-resolver": "1.0.807",
|
|
33
|
+
"@teambit/formatter": "1.0.807",
|
|
34
|
+
"@teambit/semantics.entities.semantic-schema": "0.0.95",
|
|
35
|
+
"@teambit/aspect-loader": "1.0.807",
|
|
36
|
+
"@teambit/envs": "1.0.807",
|
|
37
|
+
"@teambit/schema": "1.0.807",
|
|
38
|
+
"@teambit/scope": "1.0.807",
|
|
39
|
+
"@teambit/workspace": "1.0.807",
|
|
40
|
+
"@teambit/pkg": "1.0.807",
|
|
41
|
+
"@teambit/watcher": "1.0.807"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
44
|
"@types/lodash": "4.14.165",
|
|
45
|
+
"@types/minimatch": "3.0.4",
|
|
44
46
|
"@types/fs-extra": "9.0.7",
|
|
45
47
|
"@types/mocha": "9.1.0",
|
|
46
48
|
"@teambit/typescript.aspect-docs.typescript": "0.0.172",
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import type { Node, ObjectLiteralExpression } from 'typescript';
|
|
2
2
|
import ts from 'typescript';
|
|
3
3
|
import pMapSeries from 'p-map-series';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
ObjectLiteralExpressionSchema,
|
|
6
|
+
UnImplementedSchema,
|
|
7
|
+
PropertyAssignmentSchema,
|
|
8
|
+
} from '@teambit/semantics.entities.semantic-schema';
|
|
5
9
|
import type { SchemaExtractorContext } from '../schema-extractor-context';
|
|
6
10
|
import type { SchemaTransformer } from '../schema-transformer';
|
|
11
|
+
import { parseTypeFromQuickInfo } from './utils/parse-type-from-quick-info';
|
|
7
12
|
|
|
8
13
|
export class ObjectLiteralExpressionTransformer implements SchemaTransformer {
|
|
9
14
|
predicate(node: Node) {
|
|
@@ -17,9 +22,39 @@ export class ObjectLiteralExpressionTransformer implements SchemaTransformer {
|
|
|
17
22
|
async transform(node: ObjectLiteralExpression, context: SchemaExtractorContext) {
|
|
18
23
|
const properties = await pMapSeries(node.properties, async (prop) => {
|
|
19
24
|
const schema = await context.computeSchema(prop);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
|
|
26
|
+
if (schema instanceof UnImplementedSchema && ts.isPropertyAssignment(prop)) {
|
|
27
|
+
const init = prop.initializer;
|
|
28
|
+
|
|
29
|
+
if (ts.isIdentifier(init)) {
|
|
30
|
+
const internalRef = await context.getTypeRef(
|
|
31
|
+
init.getText(),
|
|
32
|
+
context.getIdentifierKeyForNode(init),
|
|
33
|
+
context.getLocation(init)
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
if (internalRef) return internalRef;
|
|
37
|
+
|
|
38
|
+
return context.getTypeRefForExternalNode(init);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const qi = await context.getQuickInfo(init);
|
|
42
|
+
const typeStr = (qi?.body?.displayString && parseTypeFromQuickInfo(qi)) || '';
|
|
43
|
+
return context.resolveType(init as ts.Node & { type?: ts.TypeNode }, typeStr);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (schema instanceof PropertyAssignmentSchema && ts.isPropertyAssignment(prop)) {
|
|
47
|
+
const init = prop.initializer;
|
|
48
|
+
if (schema.value instanceof UnImplementedSchema && ts.isIdentifier(init)) {
|
|
49
|
+
const internalRef = await context.getTypeRef(
|
|
50
|
+
init.getText(),
|
|
51
|
+
context.getIdentifierKeyForNode(init),
|
|
52
|
+
context.getLocation(init)
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
const valueSchema = internalRef ?? (await context.getTypeRefForExternalNode(init));
|
|
56
|
+
return new PropertyAssignmentSchema(schema.name, valueSchema, schema.location, schema.doc);
|
|
57
|
+
}
|
|
23
58
|
}
|
|
24
59
|
return schema;
|
|
25
60
|
});
|
|
@@ -35,6 +35,11 @@ export class VariableDeclaration implements SchemaTransformer {
|
|
|
35
35
|
const doc = await context.jsDocToDocSchema(varDec);
|
|
36
36
|
const nodeModifiers = ts.canHaveModifiers(varDec) ? ts.getModifiers(varDec) : undefined;
|
|
37
37
|
const modifiers = nodeModifiers?.map((modifier) => modifier.getText()) || [];
|
|
38
|
+
if (varDec.initializer && ts.isObjectLiteralExpression(varDec.initializer)) {
|
|
39
|
+
const typeFromInit = await context.computeSchema(varDec.initializer);
|
|
40
|
+
const defaultValue = varDec.initializer.getText();
|
|
41
|
+
return new VariableLikeSchema(location, name, displaySig, typeFromInit, false, doc, defaultValue);
|
|
42
|
+
}
|
|
38
43
|
if (varDec.initializer?.kind === ts.SyntaxKind.ArrowFunction) {
|
|
39
44
|
const functionLikeInfo = await context.getQuickInfo((varDec.initializer as ArrowFunction).equalsGreaterThanToken);
|
|
40
45
|
const returnTypeStr = functionLikeInfo ? parseTypeFromQuickInfo(functionLikeInfo) : 'any';
|