@teambit/typescript 0.0.726 → 0.0.729
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/exceptions/transformer-not-found.js +14 -1
- package/dist/exceptions/transformer-not-found.js.map +1 -1
- package/dist/schema-extractor-context.d.ts +33 -4
- package/dist/schema-extractor-context.js +163 -24
- package/dist/schema-extractor-context.js.map +1 -1
- package/dist/transformers/class-deceleration.d.ts +11 -0
- package/dist/transformers/class-deceleration.js +126 -0
- package/dist/transformers/class-deceleration.js.map +1 -0
- package/dist/transformers/constructor.d.ts +10 -0
- package/dist/transformers/constructor.js +70 -0
- package/dist/transformers/constructor.js.map +1 -0
- package/dist/transformers/export-declaration.d.ts +2 -1
- package/dist/transformers/export-declaration.js +64 -13
- package/dist/transformers/export-declaration.js.map +1 -1
- package/dist/transformers/function-declaration.d.ts +1 -3
- package/dist/transformers/function-declaration.js +25 -31
- package/dist/transformers/function-declaration.js.map +1 -1
- package/dist/transformers/index-signature.d.ts +9 -0
- package/dist/transformers/index-signature.js +61 -0
- package/dist/transformers/index-signature.js.map +1 -0
- package/dist/transformers/index.d.ts +14 -0
- package/dist/transformers/index.js +224 -0
- package/dist/transformers/index.js.map +1 -1
- package/dist/transformers/interface-declaration.d.ts +10 -0
- package/dist/transformers/interface-declaration.js +73 -0
- package/dist/transformers/interface-declaration.js.map +1 -0
- package/dist/transformers/literal-type.d.ts +8 -0
- package/dist/transformers/literal-type.js +50 -0
- package/dist/transformers/literal-type.js.map +1 -0
- package/dist/transformers/method-declaration.d.ts +11 -0
- package/dist/transformers/method-declaration.js +94 -0
- package/dist/transformers/method-declaration.js.map +1 -0
- package/dist/transformers/method-signature.d.ts +10 -0
- package/dist/transformers/method-signature.js +81 -0
- package/dist/transformers/method-signature.js.map +1 -0
- package/dist/transformers/property-declaration.d.ts +11 -0
- package/dist/transformers/property-declaration.js +81 -0
- package/dist/transformers/property-declaration.js.map +1 -0
- package/dist/transformers/property-signature.d.ts +10 -0
- package/dist/transformers/property-signature.js +91 -0
- package/dist/transformers/property-signature.js.map +1 -0
- package/dist/transformers/source-file-transformer.d.ts +2 -1
- package/dist/transformers/source-file-transformer.js +23 -3
- package/dist/transformers/source-file-transformer.js.map +1 -1
- package/dist/transformers/type-alias.d.ts +4 -1
- package/dist/transformers/type-alias.js +22 -2
- package/dist/transformers/type-alias.js.map +1 -1
- package/dist/transformers/type-intersection.d.ts +9 -0
- package/dist/transformers/type-intersection.js +63 -0
- package/dist/transformers/type-intersection.js.map +1 -0
- package/dist/transformers/type-literal.d.ts +14 -0
- package/dist/transformers/type-literal.js +67 -0
- package/dist/transformers/type-literal.js.map +1 -0
- package/dist/transformers/type-reference.d.ts +8 -0
- package/dist/transformers/type-reference.js +41 -0
- package/dist/transformers/type-reference.js.map +1 -0
- package/dist/transformers/type-union.d.ts +9 -0
- package/dist/transformers/type-union.js +63 -0
- package/dist/transformers/type-union.js.map +1 -0
- package/dist/transformers/utils/get-params.d.ts +4 -0
- package/dist/transformers/utils/get-params.js +67 -0
- package/dist/transformers/utils/get-params.js.map +1 -0
- package/dist/transformers/utils/parse-type-from-quick-info.d.ts +2 -0
- package/dist/transformers/utils/parse-type-from-quick-info.js +26 -0
- package/dist/transformers/utils/parse-type-from-quick-info.js.map +1 -0
- package/dist/transformers/variable-declaration.d.ts +11 -0
- package/dist/transformers/variable-declaration.js +98 -0
- package/dist/transformers/variable-declaration.js.map +1 -0
- package/dist/transformers/variable-statement.d.ts +7 -1
- package/dist/transformers/variable-statement.js +42 -2
- package/dist/transformers/variable-statement.js.map +1 -1
- package/dist/typescript.extractor.d.ts +3 -3
- package/dist/typescript.extractor.js +7 -4
- package/dist/typescript.extractor.js.map +1 -1
- package/dist/typescript.main.runtime.js +1 -1
- package/dist/typescript.main.runtime.js.map +1 -1
- package/exceptions/transformer-not-found.ts +5 -4
- package/package-tar/teambit-typescript-0.0.729.tgz +0 -0
- package/package.json +15 -15
- package/{preview-1651721125153.js → preview-1652239597845.js} +2 -2
- package/transformers/class-deceleration.ts +49 -0
- package/transformers/constructor.ts +22 -0
- package/transformers/export-declaration.ts +42 -13
- package/transformers/function-declaration.ts +7 -27
- package/transformers/index-signature.ts +21 -0
- package/transformers/index.ts +14 -0
- package/transformers/interface-declaration.ts +24 -0
- package/transformers/literal-type.ts +18 -0
- package/transformers/method-declaration.ts +32 -0
- package/transformers/method-signature.ts +30 -0
- package/transformers/property-declaration.ts +31 -0
- package/transformers/property-signature.ts +38 -0
- package/transformers/source-file-transformer.ts +6 -6
- package/transformers/type-alias.ts +12 -2
- package/transformers/type-intersection.ts +23 -0
- package/transformers/type-literal.ts +28 -0
- package/transformers/type-reference.ts +19 -0
- package/transformers/type-union.ts +23 -0
- package/transformers/utils/get-params.ts +30 -0
- package/transformers/utils/parse-type-from-quick-info.ts +12 -0
- package/transformers/variable-declaration.ts +36 -0
- package/transformers/variable-statement.ts +16 -2
- package/package-tar/teambit-typescript-0.0.726.tgz +0 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
require("core-js/modules/es.promise.js");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.PropertyDeclaration = void 0;
|
|
11
|
+
|
|
12
|
+
function _semanticsEntities() {
|
|
13
|
+
const data = require("@teambit/semantics.entities.semantic-schema");
|
|
14
|
+
|
|
15
|
+
_semanticsEntities = function () {
|
|
16
|
+
return data;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function _typescript() {
|
|
23
|
+
const data = _interopRequireDefault(require("typescript"));
|
|
24
|
+
|
|
25
|
+
_typescript = function () {
|
|
26
|
+
return data;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return data;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function _exportIdentifier() {
|
|
33
|
+
const data = require("../export-identifier");
|
|
34
|
+
|
|
35
|
+
_exportIdentifier = function () {
|
|
36
|
+
return data;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return data;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function _parseTypeFromQuickInfo() {
|
|
43
|
+
const data = require("./utils/parse-type-from-quick-info");
|
|
44
|
+
|
|
45
|
+
_parseTypeFromQuickInfo = function () {
|
|
46
|
+
return data;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return data;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
class PropertyDeclaration {
|
|
53
|
+
predicate(node) {
|
|
54
|
+
return node.kind === _typescript().default.SyntaxKind.PropertyDeclaration;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
getName(node) {
|
|
58
|
+
return node.name.getText();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async getIdentifiers(node) {
|
|
62
|
+
return [new (_exportIdentifier().ExportIdentifier)(node.name.getText(), node.getSourceFile().fileName)];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async transform(propertyDec, context) {
|
|
66
|
+
var _info$body;
|
|
67
|
+
|
|
68
|
+
const name = this.getName(propertyDec); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
69
|
+
|
|
70
|
+
const info = await context.getQuickInfo(propertyDec.name);
|
|
71
|
+
const displaySig = info === null || info === void 0 ? void 0 : (_info$body = info.body) === null || _info$body === void 0 ? void 0 : _info$body.displayString;
|
|
72
|
+
const typeStr = (0, _parseTypeFromQuickInfo().parseTypeFromQuickInfo)(displaySig);
|
|
73
|
+
const type = await context.resolveType(propertyDec, typeStr);
|
|
74
|
+
return new (_semanticsEntities().VariableSchema)(name || '', displaySig || '', type);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
exports.PropertyDeclaration = PropertyDeclaration;
|
|
80
|
+
|
|
81
|
+
//# sourceMappingURL=property-declaration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["property-declaration.ts"],"names":["PropertyDeclaration","predicate","node","kind","ts","SyntaxKind","getName","name","getText","getIdentifiers","ExportIdentifier","getSourceFile","fileName","transform","propertyDec","context","info","getQuickInfo","displaySig","body","displayString","typeStr","type","resolveType","VariableSchema"],"mappings":";;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,mBAAN,CAAuD;AAC5DC,EAAAA,SAAS,CAACC,IAAD,EAAa;AACpB,WAAOA,IAAI,CAACC,IAAL,KAAcC,sBAAGC,UAAH,CAAcL,mBAAnC;AACD;;AAEDM,EAAAA,OAAO,CAACJ,IAAD,EAAgC;AACrC,WAAOA,IAAI,CAACK,IAAL,CAAUC,OAAV,EAAP;AACD;;AAEmB,QAAdC,cAAc,CAACP,IAAD,EAAgC;AAClD,WAAO,CAAC,KAAIQ,oCAAJ,EAAqBR,IAAI,CAACK,IAAL,CAAUC,OAAV,EAArB,EAA0CN,IAAI,CAACS,aAAL,GAAqBC,QAA/D,CAAD,CAAP;AACD;;AAEc,QAATC,SAAS,CAACC,WAAD,EAAuCC,OAAvC,EAA6F;AAAA;;AAC1G,UAAMR,IAAI,GAAG,KAAKD,OAAL,CAAaQ,WAAb,CAAb,CAD0G,CAE1G;;AACA,UAAME,IAAI,GAAG,MAAMD,OAAO,CAACE,YAAR,CAAqBH,WAAW,CAACP,IAAjC,CAAnB;AACA,UAAMW,UAAU,GAAGF,IAAH,aAAGA,IAAH,qCAAGA,IAAI,CAAEG,IAAT,+CAAG,WAAYC,aAA/B;AACA,UAAMC,OAAO,GAAG,sDAAuBH,UAAvB,CAAhB;AACA,UAAMI,IAAI,GAAG,MAAMP,OAAO,CAACQ,WAAR,CAAoBT,WAApB,EAAiCO,OAAjC,CAAnB;AAEA,WAAO,KAAIG,mCAAJ,EAAmBjB,IAAI,IAAI,EAA3B,EAA+BW,UAAU,IAAI,EAA7C,EAAiDI,IAAjD,CAAP;AACD;;AAtB2D","sourcesContent":["import { SchemaNode, VariableSchema } from '@teambit/semantics.entities.semantic-schema';\nimport ts, { Node, PropertyDeclaration as PropertyDeclarationNode } from 'typescript';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\nimport { parseTypeFromQuickInfo } from './utils/parse-type-from-quick-info';\n\nexport class PropertyDeclaration implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.PropertyDeclaration;\n }\n\n getName(node: PropertyDeclarationNode) {\n return node.name.getText();\n }\n\n async getIdentifiers(node: PropertyDeclarationNode) {\n return [new ExportIdentifier(node.name.getText(), node.getSourceFile().fileName)];\n }\n\n async transform(propertyDec: PropertyDeclarationNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n const name = this.getName(propertyDec);\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const info = await context.getQuickInfo(propertyDec.name!);\n const displaySig = info?.body?.displayString;\n const typeStr = parseTypeFromQuickInfo(displaySig);\n const type = await context.resolveType(propertyDec, typeStr);\n\n return new VariableSchema(name || '', displaySig || '', type);\n }\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SchemaNode } from '@teambit/semantics.entities.semantic-schema';
|
|
2
|
+
import { Node, PropertySignature as PropertySignatureNode } from 'typescript';
|
|
3
|
+
import { SchemaTransformer } from '../schema-transformer';
|
|
4
|
+
import { SchemaExtractorContext } from '../schema-extractor-context';
|
|
5
|
+
export declare class PropertySignature implements SchemaTransformer {
|
|
6
|
+
predicate(node: Node): boolean;
|
|
7
|
+
getName(node: PropertySignatureNode): string;
|
|
8
|
+
getIdentifiers(): Promise<never[]>;
|
|
9
|
+
transform(prop: PropertySignatureNode, context: SchemaExtractorContext): Promise<SchemaNode>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
require("core-js/modules/es.promise.js");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.PropertySignature = void 0;
|
|
11
|
+
|
|
12
|
+
function _semanticsEntities() {
|
|
13
|
+
const data = require("@teambit/semantics.entities.semantic-schema");
|
|
14
|
+
|
|
15
|
+
_semanticsEntities = function () {
|
|
16
|
+
return data;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function _typescript() {
|
|
23
|
+
const data = _interopRequireDefault(require("typescript"));
|
|
24
|
+
|
|
25
|
+
_typescript = function () {
|
|
26
|
+
return data;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return data;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function _getParams() {
|
|
33
|
+
const data = require("./utils/get-params");
|
|
34
|
+
|
|
35
|
+
_getParams = function () {
|
|
36
|
+
return data;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return data;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function _parseTypeFromQuickInfo() {
|
|
43
|
+
const data = require("./utils/parse-type-from-quick-info");
|
|
44
|
+
|
|
45
|
+
_parseTypeFromQuickInfo = function () {
|
|
46
|
+
return data;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return data;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
class PropertySignature {
|
|
53
|
+
predicate(node) {
|
|
54
|
+
return node.kind === _typescript().default.SyntaxKind.PropertySignature;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
getName(node) {
|
|
58
|
+
return node.name.getText();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async getIdentifiers() {
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async transform(prop, context) {
|
|
66
|
+
var _info$body, _prop$type;
|
|
67
|
+
|
|
68
|
+
const name = this.getName(prop); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
69
|
+
|
|
70
|
+
const info = await context.getQuickInfo(prop.name);
|
|
71
|
+
const displaySig = (info === null || info === void 0 ? void 0 : (_info$body = info.body) === null || _info$body === void 0 ? void 0 : _info$body.displayString) || '';
|
|
72
|
+
|
|
73
|
+
if (((_prop$type = prop.type) === null || _prop$type === void 0 ? void 0 : _prop$type.kind) === _typescript().default.SyntaxKind.FunctionType) {
|
|
74
|
+
// e.g. `propertySig: () => void;` inside interface
|
|
75
|
+
const propType = prop.type;
|
|
76
|
+
const args = await (0, _getParams().getParams)(propType.parameters, context);
|
|
77
|
+
const typeStr = (0, _parseTypeFromQuickInfo().parseReturnTypeFromQuickInfo)(displaySig);
|
|
78
|
+
const returnType = await context.resolveType(propType, typeStr);
|
|
79
|
+
return new (_semanticsEntities().FunctionSchema)(name, args, returnType, displaySig);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const typeStr = (0, _parseTypeFromQuickInfo().parseTypeFromQuickInfo)(displaySig);
|
|
83
|
+
const type = await context.resolveType(prop, typeStr);
|
|
84
|
+
return new (_semanticsEntities().VariableSchema)(name, displaySig, type);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
exports.PropertySignature = PropertySignature;
|
|
90
|
+
|
|
91
|
+
//# sourceMappingURL=property-signature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["property-signature.ts"],"names":["PropertySignature","predicate","node","kind","ts","SyntaxKind","getName","name","getText","getIdentifiers","transform","prop","context","info","getQuickInfo","displaySig","body","displayString","type","FunctionType","propType","args","parameters","typeStr","returnType","resolveType","FunctionSchema","VariableSchema"],"mappings":";;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,iBAAN,CAAqD;AAC1DC,EAAAA,SAAS,CAACC,IAAD,EAAa;AACpB,WAAOA,IAAI,CAACC,IAAL,KAAcC,sBAAGC,UAAH,CAAcL,iBAAnC;AACD;;AAEDM,EAAAA,OAAO,CAACJ,IAAD,EAA8B;AACnC,WAAOA,IAAI,CAACK,IAAL,CAAUC,OAAV,EAAP;AACD;;AAEmB,QAAdC,cAAc,GAAG;AACrB,WAAO,EAAP;AACD;;AAEc,QAATC,SAAS,CAACC,IAAD,EAA8BC,OAA9B,EAAoF;AAAA;;AACjG,UAAML,IAAI,GAAG,KAAKD,OAAL,CAAaK,IAAb,CAAb,CADiG,CAEjG;;AACA,UAAME,IAAI,GAAG,MAAMD,OAAO,CAACE,YAAR,CAAqBH,IAAI,CAACJ,IAA1B,CAAnB;AACA,UAAMQ,UAAU,GAAG,CAAAF,IAAI,SAAJ,IAAAA,IAAI,WAAJ,0BAAAA,IAAI,CAAEG,IAAN,0DAAYC,aAAZ,KAA6B,EAAhD;;AACA,QAAI,eAAAN,IAAI,CAACO,IAAL,0DAAWf,IAAX,MAAoBC,sBAAGC,UAAH,CAAcc,YAAtC,EAAoD;AAClD;AACA,YAAMC,QAAQ,GAAGT,IAAI,CAACO,IAAtB;AACA,YAAMG,IAAI,GAAG,MAAM,4BAAUD,QAAQ,CAACE,UAAnB,EAA+BV,OAA/B,CAAnB;AACA,YAAMW,OAAO,GAAG,4DAA6BR,UAA7B,CAAhB;AACA,YAAMS,UAAU,GAAG,MAAMZ,OAAO,CAACa,WAAR,CAAoBL,QAApB,EAA8BG,OAA9B,CAAzB;AACA,aAAO,KAAIG,mCAAJ,EAAmBnB,IAAnB,EAAyBc,IAAzB,EAA+BG,UAA/B,EAA2CT,UAA3C,CAAP;AACD;;AACD,UAAMQ,OAAO,GAAG,sDAAuBR,UAAvB,CAAhB;AACA,UAAMG,IAAI,GAAG,MAAMN,OAAO,CAACa,WAAR,CAAoBd,IAApB,EAA0BY,OAA1B,CAAnB;AACA,WAAO,KAAII,mCAAJ,EAAmBpB,IAAnB,EAAyBQ,UAAzB,EAAqCG,IAArC,CAAP;AACD;;AA7ByD","sourcesContent":["import { FunctionSchema, SchemaNode, VariableSchema } from '@teambit/semantics.entities.semantic-schema';\nimport ts, { FunctionTypeNode, Node, PropertySignature as PropertySignatureNode } from 'typescript';\nimport { getParams } from './utils/get-params';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { parseReturnTypeFromQuickInfo, parseTypeFromQuickInfo } from './utils/parse-type-from-quick-info';\n\nexport class PropertySignature implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.PropertySignature;\n }\n\n getName(node: PropertySignatureNode) {\n return node.name.getText();\n }\n\n async getIdentifiers() {\n return [];\n }\n\n async transform(prop: PropertySignatureNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n const name = this.getName(prop);\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const info = await context.getQuickInfo(prop.name!);\n const displaySig = info?.body?.displayString || '';\n if (prop.type?.kind === ts.SyntaxKind.FunctionType) {\n // e.g. `propertySig: () => void;` inside interface\n const propType = prop.type as FunctionTypeNode;\n const args = await getParams(propType.parameters, context);\n const typeStr = parseReturnTypeFromQuickInfo(displaySig);\n const returnType = await context.resolveType(propType, typeStr);\n return new FunctionSchema(name, args, returnType, displaySig);\n }\n const typeStr = parseTypeFromQuickInfo(displaySig);\n const type = await context.resolveType(prop, typeStr);\n return new VariableSchema(name, displaySig, type);\n }\n}\n"]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Node, SourceFile } from 'typescript';
|
|
2
|
+
import { Module } from '@teambit/semantics.entities.semantic-schema';
|
|
2
3
|
import { SchemaTransformer } from '../schema-transformer';
|
|
3
4
|
import { ExportIdentifier } from '../export-identifier';
|
|
4
5
|
import { SchemaExtractorContext } from '../schema-extractor-context';
|
|
5
6
|
export declare class SourceFileTransformer implements SchemaTransformer {
|
|
6
7
|
predicate(node: Node): boolean;
|
|
7
8
|
getIdentifiers(sourceFile: SourceFile, context: SchemaExtractorContext): Promise<ExportIdentifier[]>;
|
|
8
|
-
transform(node: SourceFile, context: SchemaExtractorContext): Promise<
|
|
9
|
+
transform(node: SourceFile, context: SchemaExtractorContext): Promise<Module>;
|
|
9
10
|
/**
|
|
10
11
|
* list all exports of a source file.
|
|
11
12
|
*/
|
|
@@ -31,6 +31,26 @@ function _lodash() {
|
|
|
31
31
|
return data;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
function _pMapSeries() {
|
|
35
|
+
const data = _interopRequireDefault(require("p-map-series"));
|
|
36
|
+
|
|
37
|
+
_pMapSeries = function () {
|
|
38
|
+
return data;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
return data;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function _semanticsEntities() {
|
|
45
|
+
const data = require("@teambit/semantics.entities.semantic-schema");
|
|
46
|
+
|
|
47
|
+
_semanticsEntities = function () {
|
|
48
|
+
return data;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return data;
|
|
52
|
+
}
|
|
53
|
+
|
|
34
54
|
class SourceFileTransformer {
|
|
35
55
|
predicate(node) {
|
|
36
56
|
return node.kind === _typescript().default.SyntaxKind.SourceFile;
|
|
@@ -51,10 +71,10 @@ class SourceFileTransformer {
|
|
|
51
71
|
|
|
52
72
|
async transform(node, context) {
|
|
53
73
|
const exports = this.listExports(node);
|
|
54
|
-
const schemas = await
|
|
74
|
+
const schemas = await (0, _pMapSeries().default)(exports, exportNode => {
|
|
55
75
|
return context.computeSchema(exportNode);
|
|
56
|
-
})
|
|
57
|
-
return schemas;
|
|
76
|
+
});
|
|
77
|
+
return new (_semanticsEntities().Module)(schemas);
|
|
58
78
|
}
|
|
59
79
|
/**
|
|
60
80
|
* list all exports of a source file.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["source-file-transformer.ts"],"names":["SourceFileTransformer","predicate","node","kind","ts","SyntaxKind","SourceFile","getIdentifiers","sourceFile","context","exports","listExports","exportNames","Promise","all","map","getExportedIdentifiers","exportIds","reduce","acc","current","item","find","exportName","id","push","transform","schemas","exportNode","computeSchema","ast","statements","statement","ExportDeclaration","isExport","Boolean","modifiers","modifier","ExportKeyword"],"mappings":";;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAKO,MAAMA,qBAAN,CAAyD;AAC9DC,EAAAA,SAAS,CAACC,IAAD,EAAa;AACpB,WAAOA,IAAI,CAACC,IAAL,KAAcC,sBAAGC,UAAH,CAAcC,UAAnC;AACD;;AAEmB,QAAdC,cAAc,CAACC,UAAD,EAAyBC,OAAzB,EAA0D;AAC5E,UAAMC,OAAO,GAAG,KAAKC,WAAL,CAAiBH,UAAjB,CAAhB;AAEA,UAAMI,WAAW,GAAG,MAAMC,OAAO,CAACC,GAAR,CACxBJ,OAAO,CAACK,GAAR,CAAab,IAAD,IAAgB;AAC1B,aAAOO,OAAO,CAACO,sBAAR,CAA+Bd,IAA/B,CAAP;AACD,KAFD,CADwB,CAA1B;AAMA,UAAMe,SAAS,GAAG,uBAAQL,WAAR,EAAqBM,MAArB,CAAgD,CAACC,GAAD,EAAMC,OAAN,KAAkB;AAClF,YAAMC,IAAI,GAAGF,GAAG,CAACG,IAAJ,CAAUC,UAAD,IAAgBA,UAAU,CAACC,EAAX,KAAkBJ,OAAO,CAACI,EAAnD,CAAb;AACA,UAAI,CAACH,IAAL,EAAWF,GAAG,CAACM,IAAJ,CAASL,OAAT;AACX,aAAOD,GAAP;AACD,KAJiB,EAIf,EAJe,CAAlB;AAMA,WAAOF,SAAP;AACD;;AAEc,QAATS,SAAS,CAACxB,IAAD,EAAmBO,OAAnB,EAAoD;AACjE,UAAMC,OAAO,GAAG,KAAKC,WAAL,CAAiBT,IAAjB,CAAhB;AACA,UAAMyB,OAAO,GAAG,
|
|
1
|
+
{"version":3,"sources":["source-file-transformer.ts"],"names":["SourceFileTransformer","predicate","node","kind","ts","SyntaxKind","SourceFile","getIdentifiers","sourceFile","context","exports","listExports","exportNames","Promise","all","map","getExportedIdentifiers","exportIds","reduce","acc","current","item","find","exportName","id","push","transform","schemas","exportNode","computeSchema","Module","ast","statements","statement","ExportDeclaration","isExport","Boolean","modifiers","modifier","ExportKeyword"],"mappings":";;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAKO,MAAMA,qBAAN,CAAyD;AAC9DC,EAAAA,SAAS,CAACC,IAAD,EAAa;AACpB,WAAOA,IAAI,CAACC,IAAL,KAAcC,sBAAGC,UAAH,CAAcC,UAAnC;AACD;;AAEmB,QAAdC,cAAc,CAACC,UAAD,EAAyBC,OAAzB,EAA0D;AAC5E,UAAMC,OAAO,GAAG,KAAKC,WAAL,CAAiBH,UAAjB,CAAhB;AAEA,UAAMI,WAAW,GAAG,MAAMC,OAAO,CAACC,GAAR,CACxBJ,OAAO,CAACK,GAAR,CAAab,IAAD,IAAgB;AAC1B,aAAOO,OAAO,CAACO,sBAAR,CAA+Bd,IAA/B,CAAP;AACD,KAFD,CADwB,CAA1B;AAMA,UAAMe,SAAS,GAAG,uBAAQL,WAAR,EAAqBM,MAArB,CAAgD,CAACC,GAAD,EAAMC,OAAN,KAAkB;AAClF,YAAMC,IAAI,GAAGF,GAAG,CAACG,IAAJ,CAAUC,UAAD,IAAgBA,UAAU,CAACC,EAAX,KAAkBJ,OAAO,CAACI,EAAnD,CAAb;AACA,UAAI,CAACH,IAAL,EAAWF,GAAG,CAACM,IAAJ,CAASL,OAAT;AACX,aAAOD,GAAP;AACD,KAJiB,EAIf,EAJe,CAAlB;AAMA,WAAOF,SAAP;AACD;;AAEc,QAATS,SAAS,CAACxB,IAAD,EAAmBO,OAAnB,EAAoD;AACjE,UAAMC,OAAO,GAAG,KAAKC,WAAL,CAAiBT,IAAjB,CAAhB;AACA,UAAMyB,OAAO,GAAG,MAAM,2BAAWjB,OAAX,EAAqBkB,UAAD,IAAgB;AACxD,aAAOnB,OAAO,CAACoB,aAAR,CAAsBD,UAAtB,CAAP;AACD,KAFqB,CAAtB;AAIA,WAAO,KAAIE,2BAAJ,EAAWH,OAAX,CAAP;AACD;AAED;AACF;AACA;;;AACUhB,EAAAA,WAAW,CAACoB,GAAD,EAA0B;AAC3C,WAAO,uBACLA,GAAG,CAACC,UAAJ,CAAejB,GAAf,CAAoBkB,SAAD,IAAe;AAAA;;AAChC,UAAIA,SAAS,CAAC9B,IAAV,KAAmBC,sBAAGC,UAAH,CAAc6B,iBAArC,EAAwD,OAAOD,SAAP;AACxD,YAAME,QAAQ,GAAGC,OAAO,yBACtBH,SAAS,CAACI,SADY,yDACtB,qBAAqBf,IAArB,CAA2BgB,QAAD,IAAc;AACtC,eAAOA,QAAQ,CAACnC,IAAT,KAAkBC,sBAAGC,UAAH,CAAckC,aAAvC;AACD,OAFD,CADsB,CAAxB,CAFgC,CAQhC;;AACA,UAAI,CAACJ,QAAL,EAAe;AACf,aAAOF,SAAP;AACD,KAXD,CADK,CAAP;AAcD;;AAlD6D","sourcesContent":["import ts, { Node, SourceFile } from 'typescript';\nimport { compact, flatten } from 'lodash';\nimport pMapSeries from 'p-map-series';\nimport { Module } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { ExportIdentifier } from '../export-identifier';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\n\nexport class SourceFileTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.SourceFile;\n }\n\n async getIdentifiers(sourceFile: SourceFile, context: SchemaExtractorContext) {\n const exports = this.listExports(sourceFile);\n\n const exportNames = await Promise.all(\n exports.map((node: Node) => {\n return context.getExportedIdentifiers(node);\n })\n );\n\n const exportIds = flatten(exportNames).reduce<ExportIdentifier[]>((acc, current) => {\n const item = acc.find((exportName) => exportName.id === current.id);\n if (!item) acc.push(current);\n return acc;\n }, []);\n\n return exportIds;\n }\n\n async transform(node: SourceFile, context: SchemaExtractorContext) {\n const exports = this.listExports(node);\n const schemas = await pMapSeries(exports, (exportNode) => {\n return context.computeSchema(exportNode);\n });\n\n return new Module(schemas);\n }\n\n /**\n * list all exports of a source file.\n */\n private listExports(ast: SourceFile): Node[] {\n return compact(\n ast.statements.map((statement) => {\n if (statement.kind === ts.SyntaxKind.ExportDeclaration) return statement;\n const isExport = Boolean(\n statement.modifiers?.find((modifier) => {\n return modifier.kind === ts.SyntaxKind.ExportKeyword;\n })\n );\n\n // eslint-disable-next-line consistent-return\n if (!isExport) return;\n return statement;\n })\n );\n }\n}\n"]}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { Node, TypeAliasDeclaration } from 'typescript';
|
|
2
|
+
import { TypeSchema } from '@teambit/semantics.entities.semantic-schema';
|
|
2
3
|
import { SchemaTransformer } from '../schema-transformer';
|
|
4
|
+
import { SchemaExtractorContext } from '../schema-extractor-context';
|
|
3
5
|
import { ExportIdentifier } from '../export-identifier';
|
|
4
6
|
export declare class TypeAliasTransformer implements SchemaTransformer {
|
|
5
7
|
predicate(node: Node): boolean;
|
|
6
8
|
getIdentifiers(node: TypeAliasDeclaration): Promise<ExportIdentifier[]>;
|
|
7
|
-
|
|
9
|
+
private getName;
|
|
10
|
+
transform(typeAlias: TypeAliasDeclaration, context: SchemaExtractorContext): Promise<TypeSchema>;
|
|
8
11
|
}
|
|
@@ -19,6 +19,16 @@ function _typescript() {
|
|
|
19
19
|
return data;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
function _semanticsEntities() {
|
|
23
|
+
const data = require("@teambit/semantics.entities.semantic-schema");
|
|
24
|
+
|
|
25
|
+
_semanticsEntities = function () {
|
|
26
|
+
return data;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return data;
|
|
30
|
+
}
|
|
31
|
+
|
|
22
32
|
function _exportIdentifier() {
|
|
23
33
|
const data = require("../export-identifier");
|
|
24
34
|
|
|
@@ -38,8 +48,18 @@ class TypeAliasTransformer {
|
|
|
38
48
|
return [new (_exportIdentifier().ExportIdentifier)(node.name.getText(), node.getSourceFile().fileName)];
|
|
39
49
|
}
|
|
40
50
|
|
|
41
|
-
|
|
42
|
-
return
|
|
51
|
+
getName(node) {
|
|
52
|
+
return node.name.getText();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async transform(typeAlias, context) {
|
|
56
|
+
var _info$body;
|
|
57
|
+
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
59
|
+
const info = await context.getQuickInfo(typeAlias.name);
|
|
60
|
+
const displaySig = info === null || info === void 0 ? void 0 : (_info$body = info.body) === null || _info$body === void 0 ? void 0 : _info$body.displayString;
|
|
61
|
+
const type = await context.computeSchema(typeAlias.type);
|
|
62
|
+
return new (_semanticsEntities().TypeSchema)(this.getName(typeAlias), type, displaySig);
|
|
43
63
|
}
|
|
44
64
|
|
|
45
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["type-alias.ts"],"names":["TypeAliasTransformer","predicate","node","kind","ts","SyntaxKind","TypeAliasDeclaration","getIdentifiers","ExportIdentifier","name","getText","getSourceFile","fileName","transform"],"mappings":";;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;
|
|
1
|
+
{"version":3,"sources":["type-alias.ts"],"names":["TypeAliasTransformer","predicate","node","kind","ts","SyntaxKind","TypeAliasDeclaration","getIdentifiers","ExportIdentifier","name","getText","getSourceFile","fileName","getName","transform","typeAlias","context","info","getQuickInfo","displaySig","body","displayString","type","computeSchema","TypeSchema"],"mappings":";;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,oBAAN,CAAwD;AAC7DC,EAAAA,SAAS,CAACC,IAAD,EAAa;AACpB,WAAOA,IAAI,CAACC,IAAL,KAAcC,sBAAGC,UAAH,CAAcC,oBAAnC;AACD;;AAEmB,QAAdC,cAAc,CAACL,IAAD,EAA6B;AAC/C,WAAO,CAAC,KAAIM,oCAAJ,EAAqBN,IAAI,CAACO,IAAL,CAAUC,OAAV,EAArB,EAA0CR,IAAI,CAACS,aAAL,GAAqBC,QAA/D,CAAD,CAAP;AACD;;AAEOC,EAAAA,OAAO,CAACX,IAAD,EAAqC;AAClD,WAAOA,IAAI,CAACO,IAAL,CAAUC,OAAV,EAAP;AACD;;AAEc,QAATI,SAAS,CAACC,SAAD,EAAkCC,OAAlC,EAAmE;AAAA;;AAChF;AACA,UAAMC,IAAI,GAAG,MAAMD,OAAO,CAACE,YAAR,CAAqBH,SAAS,CAACN,IAA/B,CAAnB;AACA,UAAMU,UAAU,GAAGF,IAAH,aAAGA,IAAH,qCAAGA,IAAI,CAAEG,IAAT,+CAAG,WAAYC,aAA/B;AACA,UAAMC,IAAI,GAAG,MAAMN,OAAO,CAACO,aAAR,CAAsBR,SAAS,CAACO,IAAhC,CAAnB;AACA,WAAO,KAAIE,+BAAJ,EAAe,KAAKX,OAAL,CAAaE,SAAb,CAAf,EAAwCO,IAAxC,EAA8CH,UAA9C,CAAP;AACD;;AAnB4D","sourcesContent":["import ts, { Node, TypeAliasDeclaration } from 'typescript';\nimport { TypeSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\n\nexport class TypeAliasTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.TypeAliasDeclaration;\n }\n\n async getIdentifiers(node: TypeAliasDeclaration) {\n return [new ExportIdentifier(node.name.getText(), node.getSourceFile().fileName)];\n }\n\n private getName(node: TypeAliasDeclaration): string {\n return node.name.getText();\n }\n\n async transform(typeAlias: TypeAliasDeclaration, context: SchemaExtractorContext) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const info = await context.getQuickInfo(typeAlias.name!);\n const displaySig = info?.body?.displayString;\n const type = await context.computeSchema(typeAlias.type);\n return new TypeSchema(this.getName(typeAlias), type, displaySig as string);\n }\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Node, IntersectionTypeNode } from 'typescript';
|
|
2
|
+
import { TypeIntersectionSchema } from '@teambit/semantics.entities.semantic-schema';
|
|
3
|
+
import { SchemaTransformer } from '../schema-transformer';
|
|
4
|
+
import { SchemaExtractorContext } from '../schema-extractor-context';
|
|
5
|
+
export declare class TypeIntersectionTransformer implements SchemaTransformer {
|
|
6
|
+
predicate(node: Node): boolean;
|
|
7
|
+
getIdentifiers(): Promise<never[]>;
|
|
8
|
+
transform(intersectionType: IntersectionTypeNode, context: SchemaExtractorContext): Promise<TypeIntersectionSchema>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
require("core-js/modules/es.promise.js");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.TypeIntersectionTransformer = void 0;
|
|
11
|
+
|
|
12
|
+
function _typescript() {
|
|
13
|
+
const data = _interopRequireDefault(require("typescript"));
|
|
14
|
+
|
|
15
|
+
_typescript = function () {
|
|
16
|
+
return data;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function _pMapSeries() {
|
|
23
|
+
const data = _interopRequireDefault(require("p-map-series"));
|
|
24
|
+
|
|
25
|
+
_pMapSeries = function () {
|
|
26
|
+
return data;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return data;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function _semanticsEntities() {
|
|
33
|
+
const data = require("@teambit/semantics.entities.semantic-schema");
|
|
34
|
+
|
|
35
|
+
_semanticsEntities = function () {
|
|
36
|
+
return data;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return data;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
class TypeIntersectionTransformer {
|
|
43
|
+
predicate(node) {
|
|
44
|
+
return node.kind === _typescript().default.SyntaxKind.IntersectionType;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async getIdentifiers() {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async transform(intersectionType, context) {
|
|
52
|
+
const types = await (0, _pMapSeries().default)(intersectionType.types, async type => {
|
|
53
|
+
const typeSchema = await context.computeSchema(type);
|
|
54
|
+
return typeSchema;
|
|
55
|
+
});
|
|
56
|
+
return new (_semanticsEntities().TypeIntersectionSchema)(types);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
exports.TypeIntersectionTransformer = TypeIntersectionTransformer;
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=type-intersection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["type-intersection.ts"],"names":["TypeIntersectionTransformer","predicate","node","kind","ts","SyntaxKind","IntersectionType","getIdentifiers","transform","intersectionType","context","types","type","typeSchema","computeSchema","TypeIntersectionSchema"],"mappings":";;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAIO,MAAMA,2BAAN,CAA+D;AACpEC,EAAAA,SAAS,CAACC,IAAD,EAAa;AACpB,WAAOA,IAAI,CAACC,IAAL,KAAcC,sBAAGC,UAAH,CAAcC,gBAAnC;AACD;;AAEmB,QAAdC,cAAc,GAAG;AACrB,WAAO,EAAP;AACD;;AAEc,QAATC,SAAS,CAACC,gBAAD,EAAyCC,OAAzC,EAA0E;AACvF,UAAMC,KAAK,GAAG,MAAM,2BAAWF,gBAAgB,CAACE,KAA5B,EAAmC,MAAOC,IAAP,IAAgB;AACrE,YAAMC,UAAU,GAAG,MAAMH,OAAO,CAACI,aAAR,CAAsBF,IAAtB,CAAzB;AACA,aAAOC,UAAP;AACD,KAHmB,CAApB;AAIA,WAAO,KAAIE,2CAAJ,EAA2BJ,KAA3B,CAAP;AACD;;AAfmE","sourcesContent":["import ts, { Node, IntersectionTypeNode } from 'typescript';\nimport pMapSeries from 'p-map-series';\nimport { TypeIntersectionSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\n\nexport class TypeIntersectionTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.IntersectionType;\n }\n\n async getIdentifiers() {\n return [];\n }\n\n async transform(intersectionType: IntersectionTypeNode, context: SchemaExtractorContext) {\n const types = await pMapSeries(intersectionType.types, async (type) => {\n const typeSchema = await context.computeSchema(type);\n return typeSchema;\n });\n return new TypeIntersectionSchema(types);\n }\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Node, TypeLiteralNode } from 'typescript';
|
|
2
|
+
import { TypeLiteralSchema } from '@teambit/semantics.entities.semantic-schema';
|
|
3
|
+
import { SchemaTransformer } from '../schema-transformer';
|
|
4
|
+
import { SchemaExtractorContext } from '../schema-extractor-context';
|
|
5
|
+
import { ExportIdentifier } from '../export-identifier';
|
|
6
|
+
/**
|
|
7
|
+
* not to be confused with "LiteralType", which is string/boolean/null.
|
|
8
|
+
* this "TypeLiteral" is an object with properties, such as: `{ a: string; b: number }`, similar to Interface.
|
|
9
|
+
*/
|
|
10
|
+
export declare class TypeLiteralTransformer implements SchemaTransformer {
|
|
11
|
+
predicate(node: Node): boolean;
|
|
12
|
+
getIdentifiers(): Promise<ExportIdentifier[]>;
|
|
13
|
+
transform(typeLiteral: TypeLiteralNode, context: SchemaExtractorContext): Promise<TypeLiteralSchema>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
require("core-js/modules/es.promise.js");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.TypeLiteralTransformer = void 0;
|
|
11
|
+
|
|
12
|
+
function _typescript() {
|
|
13
|
+
const data = _interopRequireDefault(require("typescript"));
|
|
14
|
+
|
|
15
|
+
_typescript = function () {
|
|
16
|
+
return data;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function _pMapSeries() {
|
|
23
|
+
const data = _interopRequireDefault(require("p-map-series"));
|
|
24
|
+
|
|
25
|
+
_pMapSeries = function () {
|
|
26
|
+
return data;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return data;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function _semanticsEntities() {
|
|
33
|
+
const data = require("@teambit/semantics.entities.semantic-schema");
|
|
34
|
+
|
|
35
|
+
_semanticsEntities = function () {
|
|
36
|
+
return data;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return data;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* not to be confused with "LiteralType", which is string/boolean/null.
|
|
44
|
+
* this "TypeLiteral" is an object with properties, such as: `{ a: string; b: number }`, similar to Interface.
|
|
45
|
+
*/
|
|
46
|
+
class TypeLiteralTransformer {
|
|
47
|
+
predicate(node) {
|
|
48
|
+
return node.kind === _typescript().default.SyntaxKind.TypeLiteral;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async getIdentifiers() {
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async transform(typeLiteral, context) {
|
|
56
|
+
const members = await (0, _pMapSeries().default)(typeLiteral.members, async member => {
|
|
57
|
+
const typeSchema = await context.computeSchema(member);
|
|
58
|
+
return typeSchema;
|
|
59
|
+
});
|
|
60
|
+
return new (_semanticsEntities().TypeLiteralSchema)(members);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
exports.TypeLiteralTransformer = TypeLiteralTransformer;
|
|
66
|
+
|
|
67
|
+
//# sourceMappingURL=type-literal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["type-literal.ts"],"names":["TypeLiteralTransformer","predicate","node","kind","ts","SyntaxKind","TypeLiteral","getIdentifiers","transform","typeLiteral","context","members","member","typeSchema","computeSchema","TypeLiteralSchema"],"mappings":";;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAKA;AACA;AACA;AACA;AACO,MAAMA,sBAAN,CAA0D;AAC/DC,EAAAA,SAAS,CAACC,IAAD,EAAa;AACpB,WAAOA,IAAI,CAACC,IAAL,KAAcC,sBAAGC,UAAH,CAAcC,WAAnC;AACD;;AAEmB,QAAdC,cAAc,GAAgC;AAClD,WAAO,EAAP;AACD;;AAEc,QAATC,SAAS,CAACC,WAAD,EAA+BC,OAA/B,EAAgE;AAC7E,UAAMC,OAAO,GAAG,MAAM,2BAAWF,WAAW,CAACE,OAAvB,EAAgC,MAAOC,MAAP,IAAkB;AACtE,YAAMC,UAAU,GAAG,MAAMH,OAAO,CAACI,aAAR,CAAsBF,MAAtB,CAAzB;AACA,aAAOC,UAAP;AACD,KAHqB,CAAtB;AAIA,WAAO,KAAIE,sCAAJ,EAAsBJ,OAAtB,CAAP;AACD;;AAf8D","sourcesContent":["import ts, { Node, TypeLiteralNode } from 'typescript';\nimport pMapSeries from 'p-map-series';\nimport { TypeLiteralSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\n\n/**\n * not to be confused with \"LiteralType\", which is string/boolean/null.\n * this \"TypeLiteral\" is an object with properties, such as: `{ a: string; b: number }`, similar to Interface.\n */\nexport class TypeLiteralTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.TypeLiteral;\n }\n\n async getIdentifiers(): Promise<ExportIdentifier[]> {\n return [];\n }\n\n async transform(typeLiteral: TypeLiteralNode, context: SchemaExtractorContext) {\n const members = await pMapSeries(typeLiteral.members, async (member) => {\n const typeSchema = await context.computeSchema(member);\n return typeSchema;\n });\n return new TypeLiteralSchema(members);\n }\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Node, TypeReferenceNode } from 'typescript';
|
|
2
|
+
import { SchemaTransformer } from '../schema-transformer';
|
|
3
|
+
import { SchemaExtractorContext } from '../schema-extractor-context';
|
|
4
|
+
export declare class TypeReferenceTransformer implements SchemaTransformer {
|
|
5
|
+
predicate(node: Node): boolean;
|
|
6
|
+
getIdentifiers(): Promise<never[]>;
|
|
7
|
+
transform(typeReference: TypeReferenceNode, context: SchemaExtractorContext): Promise<import("@teambit/semantics.entities.semantic-schema").TypeRefSchema>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
require("core-js/modules/es.promise.js");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.TypeReferenceTransformer = void 0;
|
|
11
|
+
|
|
12
|
+
function _typescript() {
|
|
13
|
+
const data = _interopRequireDefault(require("typescript"));
|
|
14
|
+
|
|
15
|
+
_typescript = function () {
|
|
16
|
+
return data;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
class TypeReferenceTransformer {
|
|
23
|
+
predicate(node) {
|
|
24
|
+
return node.kind === _typescript().default.SyntaxKind.TypeReference;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async getIdentifiers() {
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async transform(typeReference, context) {
|
|
32
|
+
const name = typeReference.typeName.getText();
|
|
33
|
+
const type = await context.resolveType(typeReference, name);
|
|
34
|
+
return type;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
exports.TypeReferenceTransformer = TypeReferenceTransformer;
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=type-reference.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["type-reference.ts"],"names":["TypeReferenceTransformer","predicate","node","kind","ts","SyntaxKind","TypeReference","getIdentifiers","transform","typeReference","context","name","typeName","getText","type","resolveType"],"mappings":";;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAIO,MAAMA,wBAAN,CAA4D;AACjEC,EAAAA,SAAS,CAACC,IAAD,EAAa;AACpB,WAAOA,IAAI,CAACC,IAAL,KAAcC,sBAAGC,UAAH,CAAcC,aAAnC;AACD;;AAEmB,QAAdC,cAAc,GAAG;AACrB,WAAO,EAAP;AACD;;AAEc,QAATC,SAAS,CAACC,aAAD,EAAmCC,OAAnC,EAAoE;AACjF,UAAMC,IAAI,GAAGF,aAAa,CAACG,QAAd,CAAuBC,OAAvB,EAAb;AACA,UAAMC,IAAI,GAAG,MAAMJ,OAAO,CAACK,WAAR,CAAoBN,aAApB,EAAmCE,IAAnC,CAAnB;AACA,WAAOG,IAAP;AACD;;AAbgE","sourcesContent":["import ts, { Node, TypeReferenceNode } from 'typescript';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\n\nexport class TypeReferenceTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.TypeReference;\n }\n\n async getIdentifiers() {\n return [];\n }\n\n async transform(typeReference: TypeReferenceNode, context: SchemaExtractorContext) {\n const name = typeReference.typeName.getText();\n const type = await context.resolveType(typeReference, name);\n return type;\n }\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Node, UnionTypeNode } from 'typescript';
|
|
2
|
+
import { TypeUnionSchema } from '@teambit/semantics.entities.semantic-schema';
|
|
3
|
+
import { SchemaTransformer } from '../schema-transformer';
|
|
4
|
+
import { SchemaExtractorContext } from '../schema-extractor-context';
|
|
5
|
+
export declare class TypeUnionTransformer implements SchemaTransformer {
|
|
6
|
+
predicate(node: Node): boolean;
|
|
7
|
+
getIdentifiers(): Promise<never[]>;
|
|
8
|
+
transform(unionType: UnionTypeNode, context: SchemaExtractorContext): Promise<TypeUnionSchema>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
require("core-js/modules/es.promise.js");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.TypeUnionTransformer = void 0;
|
|
11
|
+
|
|
12
|
+
function _typescript() {
|
|
13
|
+
const data = _interopRequireDefault(require("typescript"));
|
|
14
|
+
|
|
15
|
+
_typescript = function () {
|
|
16
|
+
return data;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function _pMapSeries() {
|
|
23
|
+
const data = _interopRequireDefault(require("p-map-series"));
|
|
24
|
+
|
|
25
|
+
_pMapSeries = function () {
|
|
26
|
+
return data;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return data;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function _semanticsEntities() {
|
|
33
|
+
const data = require("@teambit/semantics.entities.semantic-schema");
|
|
34
|
+
|
|
35
|
+
_semanticsEntities = function () {
|
|
36
|
+
return data;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return data;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
class TypeUnionTransformer {
|
|
43
|
+
predicate(node) {
|
|
44
|
+
return node.kind === _typescript().default.SyntaxKind.UnionType;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async getIdentifiers() {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async transform(unionType, context) {
|
|
52
|
+
const types = await (0, _pMapSeries().default)(unionType.types, async type => {
|
|
53
|
+
const typeSchema = await context.computeSchema(type);
|
|
54
|
+
return typeSchema;
|
|
55
|
+
});
|
|
56
|
+
return new (_semanticsEntities().TypeUnionSchema)(types);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
exports.TypeUnionTransformer = TypeUnionTransformer;
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=type-union.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["type-union.ts"],"names":["TypeUnionTransformer","predicate","node","kind","ts","SyntaxKind","UnionType","getIdentifiers","transform","unionType","context","types","type","typeSchema","computeSchema","TypeUnionSchema"],"mappings":";;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAIO,MAAMA,oBAAN,CAAwD;AAC7DC,EAAAA,SAAS,CAACC,IAAD,EAAa;AACpB,WAAOA,IAAI,CAACC,IAAL,KAAcC,sBAAGC,UAAH,CAAcC,SAAnC;AACD;;AAEmB,QAAdC,cAAc,GAAG;AACrB,WAAO,EAAP;AACD;;AAEc,QAATC,SAAS,CAACC,SAAD,EAA2BC,OAA3B,EAA4D;AACzE,UAAMC,KAAK,GAAG,MAAM,2BAAWF,SAAS,CAACE,KAArB,EAA4B,MAAOC,IAAP,IAAgB;AAC9D,YAAMC,UAAU,GAAG,MAAMH,OAAO,CAACI,aAAR,CAAsBF,IAAtB,CAAzB;AACA,aAAOC,UAAP;AACD,KAHmB,CAApB;AAIA,WAAO,KAAIE,oCAAJ,EAAoBJ,KAApB,CAAP;AACD;;AAf4D","sourcesContent":["import ts, { Node, UnionTypeNode } from 'typescript';\nimport pMapSeries from 'p-map-series';\nimport { TypeUnionSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\n\nexport class TypeUnionTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.UnionType;\n }\n\n async getIdentifiers() {\n return [];\n }\n\n async transform(unionType: UnionTypeNode, context: SchemaExtractorContext) {\n const types = await pMapSeries(unionType.types, async (type) => {\n const typeSchema = await context.computeSchema(type);\n return typeSchema;\n });\n return new TypeUnionSchema(types);\n }\n}\n"]}
|