@teambit/typescript 0.0.965 → 0.0.967
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/export-identifier.d.ts +5 -4
- package/dist/export-identifier.js +23 -4
- package/dist/export-identifier.js.map +1 -1
- package/dist/identifier-list.d.ts +7 -0
- package/dist/identifier-list.js +21 -0
- package/dist/identifier-list.js.map +1 -0
- package/dist/identifier.d.ts +9 -0
- package/dist/identifier.js +30 -0
- package/dist/identifier.js.map +1 -0
- package/dist/{preview-1674271762484.js → preview-1674617375675.js} +2 -2
- package/dist/schema-extractor-context.d.ts +40 -8
- package/dist/schema-extractor-context.js +243 -101
- package/dist/schema-extractor-context.js.map +1 -1
- package/dist/schema-transformer.d.ts +2 -2
- package/dist/schema-transformer.js.map +1 -1
- package/dist/transformers/array-type.d.ts +10 -0
- package/dist/transformers/array-type.js +38 -0
- package/dist/transformers/array-type.js.map +1 -0
- package/dist/transformers/binding-element.d.ts +2 -2
- package/dist/transformers/binding-element.js +7 -7
- package/dist/transformers/binding-element.js.map +1 -1
- package/dist/transformers/class-declaration.d.ts +2 -2
- package/dist/transformers/class-declaration.js +6 -20
- package/dist/transformers/class-declaration.js.map +1 -1
- package/dist/transformers/conditional-type.d.ts +10 -0
- package/dist/transformers/conditional-type.js +39 -0
- package/dist/transformers/conditional-type.js.map +1 -0
- package/dist/transformers/constructor.d.ts +10 -0
- package/dist/transformers/constructor.js +50 -0
- package/dist/transformers/constructor.js.map +1 -0
- package/dist/transformers/enum-declaration.d.ts +2 -2
- package/dist/transformers/enum-declaration.js +4 -4
- package/dist/transformers/enum-declaration.js.map +1 -1
- package/dist/transformers/{export-assignment-declaration.d.ts → export-assignment.d.ts} +7 -2
- package/dist/transformers/export-assignment.js +41 -0
- package/dist/transformers/export-assignment.js.map +1 -0
- package/dist/transformers/export-declaration.d.ts +2 -3
- package/dist/transformers/export-declaration.js +21 -10
- package/dist/transformers/export-declaration.js.map +1 -1
- package/dist/transformers/function-like.d.ts +11 -0
- package/dist/transformers/function-like.js +82 -0
- package/dist/transformers/function-like.js.map +1 -0
- package/dist/transformers/get-accessor.d.ts +10 -0
- package/dist/transformers/get-accessor.js +48 -0
- package/dist/transformers/get-accessor.js.map +1 -0
- package/dist/transformers/import-declaration.d.ts +10 -0
- package/dist/transformers/import-declaration.js +74 -0
- package/dist/transformers/import-declaration.js.map +1 -0
- package/dist/transformers/index-signature.d.ts +10 -0
- package/dist/transformers/index-signature.js +45 -0
- package/dist/transformers/index-signature.js.map +1 -0
- package/dist/transformers/index.d.ts +28 -3
- package/dist/transformers/index.js +337 -12
- package/dist/transformers/index.js.map +1 -1
- package/dist/transformers/indexed-access-type.d.ts +10 -0
- package/dist/transformers/indexed-access-type.js +37 -0
- package/dist/transformers/indexed-access-type.js.map +1 -0
- package/dist/transformers/interface-declaration.d.ts +2 -2
- package/dist/transformers/interface-declaration.js +6 -20
- package/dist/transformers/interface-declaration.js.map +1 -1
- package/dist/transformers/intersection-type.d.ts +10 -0
- package/dist/transformers/intersection-type.js +48 -0
- package/dist/transformers/intersection-type.js.map +1 -0
- package/dist/transformers/keyword-type.d.ts +13 -0
- package/dist/transformers/keyword-type.js +55 -0
- package/dist/transformers/keyword-type.js.map +1 -0
- package/dist/transformers/literal-type.d.ts +13 -0
- package/dist/transformers/literal-type.js +40 -0
- package/dist/transformers/literal-type.js.map +1 -0
- package/dist/transformers/named-tuple.d.ts +10 -0
- package/dist/transformers/named-tuple.js +38 -0
- package/dist/transformers/named-tuple.js.map +1 -0
- package/dist/transformers/parameter.d.ts +13 -0
- package/dist/transformers/parameter.js +112 -0
- package/dist/transformers/parameter.js.map +1 -0
- package/dist/transformers/parenthesized-type.d.ts +10 -0
- package/dist/transformers/parenthesized-type.js +36 -0
- package/dist/transformers/parenthesized-type.js.map +1 -0
- package/dist/transformers/property-declaration.d.ts +11 -0
- package/dist/transformers/property-declaration.js +57 -0
- package/dist/transformers/property-declaration.js.map +1 -0
- package/dist/transformers/set-accessor.d.ts +10 -0
- package/dist/transformers/set-accessor.js +45 -0
- package/dist/transformers/set-accessor.js.map +1 -0
- package/dist/transformers/source-file-transformer.d.ts +3 -2
- package/dist/transformers/source-file-transformer.js +44 -15
- package/dist/transformers/source-file-transformer.js.map +1 -1
- package/dist/transformers/template-literal-type-span.d.ts +10 -0
- package/dist/transformers/template-literal-type-span.js +37 -0
- package/dist/transformers/template-literal-type-span.js.map +1 -0
- package/dist/transformers/template-literal-type.d.ts +10 -0
- package/dist/transformers/template-literal-type.js +45 -0
- package/dist/transformers/template-literal-type.js.map +1 -0
- package/dist/transformers/this-type.d.ts +10 -0
- package/dist/transformers/this-type.js +35 -0
- package/dist/transformers/this-type.js.map +1 -0
- package/dist/transformers/tuple-type.d.ts +10 -0
- package/dist/transformers/tuple-type.js +47 -0
- package/dist/transformers/tuple-type.js.map +1 -0
- package/dist/transformers/type-alias.d.ts +2 -2
- package/dist/transformers/type-alias.js +5 -12
- package/dist/transformers/type-alias.js.map +1 -1
- package/dist/transformers/type-literal.d.ts +14 -0
- package/dist/transformers/type-literal.js +49 -0
- package/dist/transformers/type-literal.js.map +1 -0
- package/dist/transformers/type-operator.d.ts +14 -0
- package/dist/transformers/type-operator.js +52 -0
- package/dist/transformers/type-operator.js.map +1 -0
- package/dist/transformers/type-predicate.d.ts +10 -0
- package/dist/transformers/type-predicate.js +38 -0
- package/dist/transformers/type-predicate.js.map +1 -0
- package/dist/transformers/type-query.d.ts +13 -0
- package/dist/transformers/type-query.js +42 -0
- package/dist/transformers/type-query.js.map +1 -0
- package/dist/transformers/type-reference.d.ts +16 -0
- package/dist/transformers/type-reference.js +56 -0
- package/dist/transformers/type-reference.js.map +1 -0
- package/dist/transformers/union-type.d.ts +10 -0
- package/dist/transformers/union-type.js +48 -0
- package/dist/transformers/union-type.js.map +1 -0
- package/dist/transformers/utils/jsdoc-to-doc-schema.js +2 -10
- package/dist/transformers/utils/jsdoc-to-doc-schema.js.map +1 -1
- package/dist/transformers/variable-declaration.d.ts +2 -2
- package/dist/transformers/variable-declaration.js +11 -11
- package/dist/transformers/variable-declaration.js.map +1 -1
- package/dist/transformers/variable-statement.d.ts +2 -2
- package/dist/transformers/variable-statement.js +5 -5
- package/dist/transformers/variable-statement.js.map +1 -1
- package/dist/typescript.extractor.d.ts +10 -4
- package/dist/typescript.extractor.js +70 -17
- package/dist/typescript.extractor.js.map +1 -1
- package/dist/typescript.main.runtime.d.ts +4 -2
- package/dist/typescript.main.runtime.js +5 -11
- package/dist/typescript.main.runtime.js.map +1 -1
- package/package-tar/teambit-typescript-0.0.967.tgz +0 -0
- package/package.json +17 -17
- package/transformers/array-type.ts +21 -0
- package/transformers/binding-element.ts +2 -2
- package/transformers/class-declaration.ts +4 -6
- package/transformers/conditional-type.ts +23 -0
- package/transformers/constructor.ts +40 -0
- package/transformers/enum-declaration.ts +3 -3
- package/transformers/{export-assignment-declaration.ts → export-assignment.ts} +9 -3
- package/transformers/export-declaration.ts +35 -8
- package/transformers/function-like.ts +65 -0
- package/transformers/get-accessor.ts +24 -0
- package/transformers/import-declaration.ts +56 -0
- package/transformers/index-signature.ts +24 -0
- package/transformers/index.ts +28 -3
- package/transformers/indexed-access-type.ts +21 -0
- package/transformers/interface-declaration.ts +5 -7
- package/transformers/intersection-type.ts +25 -0
- package/transformers/keyword-type.ts +39 -0
- package/transformers/literal-type.ts +23 -0
- package/transformers/named-tuple.ts +22 -0
- package/transformers/parameter.ts +110 -0
- package/transformers/parenthesized-type.ts +20 -0
- package/transformers/property-declaration.ts +33 -0
- package/transformers/set-accessor.ts +25 -0
- package/transformers/source-file-transformer.ts +56 -24
- package/transformers/template-literal-type-span.ts +21 -0
- package/transformers/template-literal-type.ts +24 -0
- package/transformers/this-type.ts +19 -0
- package/transformers/tuple-type.ts +24 -0
- package/transformers/type-alias.ts +3 -4
- package/transformers/type-literal.ts +26 -0
- package/transformers/type-operator.ts +37 -0
- package/transformers/type-predicate.ts +22 -0
- package/transformers/type-query.ts +25 -0
- package/transformers/type-reference.ts +33 -0
- package/transformers/union-type.ts +25 -0
- package/transformers/utils/jsdoc-to-doc-schema.ts +2 -4
- package/transformers/variable-declaration.ts +7 -4
- package/transformers/variable-statement.ts +3 -3
- package/dist/export-list.d.ts +0 -6
- package/dist/export-list.js +0 -17
- package/dist/export-list.js.map +0 -1
- package/dist/transformers/export-assignment-declaration.js +0 -29
- package/dist/transformers/export-assignment-declaration.js.map +0 -1
- package/dist/transformers/function-declaration.d.ts +0 -11
- package/dist/transformers/function-declaration.js +0 -49
- package/dist/transformers/function-declaration.js.map +0 -1
- package/dist/transformers/utils/class-element-to-schema.d.ts +0 -4
- package/dist/transformers/utils/class-element-to-schema.js +0 -95
- package/dist/transformers/utils/class-element-to-schema.js.map +0 -1
- package/dist/transformers/utils/get-params.d.ts +0 -4
- package/dist/transformers/utils/get-params.js +0 -100
- package/dist/transformers/utils/get-params.js.map +0 -1
- package/dist/transformers/utils/to-function-like-schema.d.ts +0 -4
- package/dist/transformers/utils/to-function-like-schema.js +0 -58
- package/dist/transformers/utils/to-function-like-schema.js.map +0 -1
- package/dist/transformers/utils/type-element-to-schema.d.ts +0 -7
- package/dist/transformers/utils/type-element-to-schema.js +0 -106
- package/dist/transformers/utils/type-element-to-schema.js.map +0 -1
- package/dist/transformers/utils/type-node-to-schema.d.ts +0 -4
- package/dist/transformers/utils/type-node-to-schema.js +0 -274
- package/dist/transformers/utils/type-node-to-schema.js.map +0 -1
- package/package-tar/teambit-typescript-0.0.965.tgz +0 -0
- package/transformers/function-declaration.ts +0 -25
- package/transformers/utils/class-element-to-schema.ts +0 -64
- package/transformers/utils/get-params.ts +0 -92
- package/transformers/utils/to-function-like-schema.ts +0 -39
- package/transformers/utils/type-element-to-schema.ts +0 -79
- package/transformers/utils/type-node-to-schema.ts +0 -294
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.promise.js");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.KeywordTypeTransformer = void 0;
|
|
8
|
+
function _typescript() {
|
|
9
|
+
const data = require("typescript");
|
|
10
|
+
_typescript = function () {
|
|
11
|
+
return data;
|
|
12
|
+
};
|
|
13
|
+
return data;
|
|
14
|
+
}
|
|
15
|
+
function _semanticsEntities() {
|
|
16
|
+
const data = require("@teambit/semantics.entities.semantic-schema");
|
|
17
|
+
_semanticsEntities = function () {
|
|
18
|
+
return data;
|
|
19
|
+
};
|
|
20
|
+
return data;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* whether it's kind of `ts.KeywordTypeSyntaxKind`
|
|
24
|
+
*/
|
|
25
|
+
class KeywordTypeTransformer {
|
|
26
|
+
predicate(node) {
|
|
27
|
+
switch (node.kind) {
|
|
28
|
+
case _typescript().SyntaxKind.AnyKeyword:
|
|
29
|
+
case _typescript().SyntaxKind.BigIntKeyword:
|
|
30
|
+
case _typescript().SyntaxKind.BooleanKeyword:
|
|
31
|
+
case _typescript().SyntaxKind.IntrinsicKeyword:
|
|
32
|
+
case _typescript().SyntaxKind.NeverKeyword:
|
|
33
|
+
case _typescript().SyntaxKind.NumberKeyword:
|
|
34
|
+
case _typescript().SyntaxKind.ObjectKeyword:
|
|
35
|
+
case _typescript().SyntaxKind.StringKeyword:
|
|
36
|
+
case _typescript().SyntaxKind.SymbolKeyword:
|
|
37
|
+
case _typescript().SyntaxKind.UndefinedKeyword:
|
|
38
|
+
case _typescript().SyntaxKind.UnknownKeyword:
|
|
39
|
+
case _typescript().SyntaxKind.VoidKeyword:
|
|
40
|
+
return true;
|
|
41
|
+
default:
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
async getIdentifiers() {
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
async transform(node, context) {
|
|
49
|
+
const location = context.getLocation(node);
|
|
50
|
+
return new (_semanticsEntities().KeywordTypeSchema)(location, node.getText());
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.KeywordTypeTransformer = KeywordTypeTransformer;
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=keyword-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["KeywordTypeTransformer","predicate","node","kind","SyntaxKind","AnyKeyword","BigIntKeyword","BooleanKeyword","IntrinsicKeyword","NeverKeyword","NumberKeyword","ObjectKeyword","StringKeyword","SymbolKeyword","UndefinedKeyword","UnknownKeyword","VoidKeyword","getIdentifiers","transform","context","location","getLocation","KeywordTypeSchema","getText"],"sources":["keyword-type.ts"],"sourcesContent":["import { Node, SyntaxKind } from 'typescript';\nimport { KeywordTypeSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { Identifier } from '../identifier';\n\n/**\n * whether it's kind of `ts.KeywordTypeSyntaxKind`\n */\nexport class KeywordTypeTransformer implements SchemaTransformer {\n predicate(node: Node) {\n switch (node.kind) {\n case SyntaxKind.AnyKeyword:\n case SyntaxKind.BigIntKeyword:\n case SyntaxKind.BooleanKeyword:\n case SyntaxKind.IntrinsicKeyword:\n case SyntaxKind.NeverKeyword:\n case SyntaxKind.NumberKeyword:\n case SyntaxKind.ObjectKeyword:\n case SyntaxKind.StringKeyword:\n case SyntaxKind.SymbolKeyword:\n case SyntaxKind.UndefinedKeyword:\n case SyntaxKind.UnknownKeyword:\n case SyntaxKind.VoidKeyword:\n return true;\n default:\n return false;\n }\n }\n\n async getIdentifiers(): Promise<Identifier[]> {\n return [];\n }\n\n async transform(node: Node, context: SchemaExtractorContext) {\n const location = context.getLocation(node);\n return new KeywordTypeSchema(location, node.getText());\n }\n}\n"],"mappings":";;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAKA;AACA;AACA;AACO,MAAMA,sBAAsB,CAA8B;EAC/DC,SAAS,CAACC,IAAU,EAAE;IACpB,QAAQA,IAAI,CAACC,IAAI;MACf,KAAKC,wBAAU,CAACC,UAAU;MAC1B,KAAKD,wBAAU,CAACE,aAAa;MAC7B,KAAKF,wBAAU,CAACG,cAAc;MAC9B,KAAKH,wBAAU,CAACI,gBAAgB;MAChC,KAAKJ,wBAAU,CAACK,YAAY;MAC5B,KAAKL,wBAAU,CAACM,aAAa;MAC7B,KAAKN,wBAAU,CAACO,aAAa;MAC7B,KAAKP,wBAAU,CAACQ,aAAa;MAC7B,KAAKR,wBAAU,CAACS,aAAa;MAC7B,KAAKT,wBAAU,CAACU,gBAAgB;MAChC,KAAKV,wBAAU,CAACW,cAAc;MAC9B,KAAKX,wBAAU,CAACY,WAAW;QACzB,OAAO,IAAI;MACb;QACE,OAAO,KAAK;IAAC;EAEnB;EAEA,MAAMC,cAAc,GAA0B;IAC5C,OAAO,EAAE;EACX;EAEA,MAAMC,SAAS,CAAChB,IAAU,EAAEiB,OAA+B,EAAE;IAC3D,MAAMC,QAAQ,GAAGD,OAAO,CAACE,WAAW,CAACnB,IAAI,CAAC;IAC1C,OAAO,KAAIoB,sCAAiB,EAACF,QAAQ,EAAElB,IAAI,CAACqB,OAAO,EAAE,CAAC;EACxD;AACF;AAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { LiteralTypeNode, Node } from 'typescript';
|
|
2
|
+
import { LiteralTypeSchema } from '@teambit/semantics.entities.semantic-schema';
|
|
3
|
+
import { SchemaTransformer } from '../schema-transformer';
|
|
4
|
+
import { SchemaExtractorContext } from '../schema-extractor-context';
|
|
5
|
+
import { Identifier } from '../identifier';
|
|
6
|
+
/**
|
|
7
|
+
* e.g. string/boolean
|
|
8
|
+
*/
|
|
9
|
+
export declare class LiteralTypeTransformer implements SchemaTransformer {
|
|
10
|
+
predicate(node: Node): boolean;
|
|
11
|
+
getIdentifiers(): Promise<Identifier[]>;
|
|
12
|
+
transform(node: LiteralTypeNode, context: SchemaExtractorContext): Promise<LiteralTypeSchema>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
require("core-js/modules/es.promise.js");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.LiteralTypeTransformer = void 0;
|
|
9
|
+
function _typescript() {
|
|
10
|
+
const data = _interopRequireDefault(require("typescript"));
|
|
11
|
+
_typescript = function () {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
return data;
|
|
15
|
+
}
|
|
16
|
+
function _semanticsEntities() {
|
|
17
|
+
const data = require("@teambit/semantics.entities.semantic-schema");
|
|
18
|
+
_semanticsEntities = function () {
|
|
19
|
+
return data;
|
|
20
|
+
};
|
|
21
|
+
return data;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* e.g. string/boolean
|
|
25
|
+
*/
|
|
26
|
+
class LiteralTypeTransformer {
|
|
27
|
+
predicate(node) {
|
|
28
|
+
return node.kind === _typescript().default.SyntaxKind.LiteralType;
|
|
29
|
+
}
|
|
30
|
+
async getIdentifiers() {
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
async transform(node, context) {
|
|
34
|
+
const location = context.getLocation(node);
|
|
35
|
+
return new (_semanticsEntities().LiteralTypeSchema)(location, node.getText());
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.LiteralTypeTransformer = LiteralTypeTransformer;
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=literal-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["LiteralTypeTransformer","predicate","node","kind","ts","SyntaxKind","LiteralType","getIdentifiers","transform","context","location","getLocation","LiteralTypeSchema","getText"],"sources":["literal-type.ts"],"sourcesContent":["import ts, { LiteralTypeNode, Node } from 'typescript';\nimport { LiteralTypeSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { Identifier } from '../identifier';\n\n/**\n * e.g. string/boolean\n */\nexport class LiteralTypeTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.LiteralType;\n }\n\n async getIdentifiers(): Promise<Identifier[]> {\n return [];\n }\n\n async transform(node: LiteralTypeNode, context: SchemaExtractorContext) {\n const location = context.getLocation(node);\n return new LiteralTypeSchema(location, node.getText());\n }\n}\n"],"mappings":";;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAKA;AACA;AACA;AACO,MAAMA,sBAAsB,CAA8B;EAC/DC,SAAS,CAACC,IAAU,EAAE;IACpB,OAAOA,IAAI,CAACC,IAAI,KAAKC,qBAAE,CAACC,UAAU,CAACC,WAAW;EAChD;EAEA,MAAMC,cAAc,GAA0B;IAC5C,OAAO,EAAE;EACX;EAEA,MAAMC,SAAS,CAACN,IAAqB,EAAEO,OAA+B,EAAE;IACtE,MAAMC,QAAQ,GAAGD,OAAO,CAACE,WAAW,CAACT,IAAI,CAAC;IAC1C,OAAO,KAAIU,sCAAiB,EAACF,QAAQ,EAAER,IAAI,CAACW,OAAO,EAAE,CAAC;EACxD;AACF;AAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Node, NamedTupleMember } from 'typescript';
|
|
2
|
+
import { NamedTupleSchema } from '@teambit/semantics.entities.semantic-schema';
|
|
3
|
+
import { SchemaTransformer } from '../schema-transformer';
|
|
4
|
+
import { SchemaExtractorContext } from '../schema-extractor-context';
|
|
5
|
+
import { Identifier } from '../identifier';
|
|
6
|
+
export declare class NamedTupleTransformer implements SchemaTransformer {
|
|
7
|
+
predicate(node: Node): boolean;
|
|
8
|
+
getIdentifiers(): Promise<Identifier[]>;
|
|
9
|
+
transform(node: NamedTupleMember, context: SchemaExtractorContext): Promise<NamedTupleSchema>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.promise.js");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.NamedTupleTransformer = void 0;
|
|
8
|
+
function _typescript() {
|
|
9
|
+
const data = require("typescript");
|
|
10
|
+
_typescript = function () {
|
|
11
|
+
return data;
|
|
12
|
+
};
|
|
13
|
+
return data;
|
|
14
|
+
}
|
|
15
|
+
function _semanticsEntities() {
|
|
16
|
+
const data = require("@teambit/semantics.entities.semantic-schema");
|
|
17
|
+
_semanticsEntities = function () {
|
|
18
|
+
return data;
|
|
19
|
+
};
|
|
20
|
+
return data;
|
|
21
|
+
}
|
|
22
|
+
class NamedTupleTransformer {
|
|
23
|
+
predicate(node) {
|
|
24
|
+
return node.kind === _typescript().SyntaxKind.NamedTupleMember;
|
|
25
|
+
}
|
|
26
|
+
async getIdentifiers() {
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
async transform(node, context) {
|
|
30
|
+
const name = node.name.getText();
|
|
31
|
+
const location = context.getLocation(node);
|
|
32
|
+
const type = await context.computeSchema(node.type);
|
|
33
|
+
return new (_semanticsEntities().NamedTupleSchema)(location, type, name);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.NamedTupleTransformer = NamedTupleTransformer;
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=named-tuple.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["NamedTupleTransformer","predicate","node","kind","SyntaxKind","NamedTupleMember","getIdentifiers","transform","context","name","getText","location","getLocation","type","computeSchema","NamedTupleSchema"],"sources":["named-tuple.ts"],"sourcesContent":["import { Node, SyntaxKind, NamedTupleMember } from 'typescript';\nimport { NamedTupleSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { Identifier } from '../identifier';\n\nexport class NamedTupleTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === SyntaxKind.NamedTupleMember;\n }\n\n async getIdentifiers(): Promise<Identifier[]> {\n return [];\n }\n\n async transform(node: NamedTupleMember, context: SchemaExtractorContext) {\n const name = node.name.getText();\n const location = context.getLocation(node);\n const type = await context.computeSchema(node.type);\n return new NamedTupleSchema(location, type, name);\n }\n}\n"],"mappings":";;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAKO,MAAMA,qBAAqB,CAA8B;EAC9DC,SAAS,CAACC,IAAU,EAAE;IACpB,OAAOA,IAAI,CAACC,IAAI,KAAKC,wBAAU,CAACC,gBAAgB;EAClD;EAEA,MAAMC,cAAc,GAA0B;IAC5C,OAAO,EAAE;EACX;EAEA,MAAMC,SAAS,CAACL,IAAsB,EAAEM,OAA+B,EAAE;IACvE,MAAMC,IAAI,GAAGP,IAAI,CAACO,IAAI,CAACC,OAAO,EAAE;IAChC,MAAMC,QAAQ,GAAGH,OAAO,CAACI,WAAW,CAACV,IAAI,CAAC;IAC1C,MAAMW,IAAI,GAAG,MAAML,OAAO,CAACM,aAAa,CAACZ,IAAI,CAACW,IAAI,CAAC;IACnD,OAAO,KAAIE,qCAAgB,EAACJ,QAAQ,EAAEE,IAAI,EAAEJ,IAAI,CAAC;EACnD;AACF;AAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Node, ParameterDeclaration } from 'typescript';
|
|
2
|
+
import { ParameterSchema, SchemaNode } from '@teambit/semantics.entities.semantic-schema';
|
|
3
|
+
import { SchemaTransformer } from '../schema-transformer';
|
|
4
|
+
import { SchemaExtractorContext } from '../schema-extractor-context';
|
|
5
|
+
import { Identifier } from '../identifier';
|
|
6
|
+
export declare class ParameterTransformer implements SchemaTransformer {
|
|
7
|
+
predicate(node: Node): boolean;
|
|
8
|
+
getIdentifiers(): Promise<Identifier[]>;
|
|
9
|
+
transform(node: ParameterDeclaration, context: SchemaExtractorContext): Promise<ParameterSchema>;
|
|
10
|
+
getName(param: ParameterDeclaration): string;
|
|
11
|
+
getType(param: ParameterDeclaration, context: SchemaExtractorContext): Promise<SchemaNode>;
|
|
12
|
+
getObjectBindingNodes(param: ParameterDeclaration, context: SchemaExtractorContext): Promise<SchemaNode[] | undefined>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
require("core-js/modules/es.promise.js");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.ParameterTransformer = void 0;
|
|
9
|
+
function _typescript() {
|
|
10
|
+
const data = _interopRequireWildcard(require("typescript"));
|
|
11
|
+
_typescript = function () {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
return data;
|
|
15
|
+
}
|
|
16
|
+
function _semanticsEntities() {
|
|
17
|
+
const data = require("@teambit/semantics.entities.semantic-schema");
|
|
18
|
+
_semanticsEntities = function () {
|
|
19
|
+
return data;
|
|
20
|
+
};
|
|
21
|
+
return data;
|
|
22
|
+
}
|
|
23
|
+
function _pMapSeries() {
|
|
24
|
+
const data = _interopRequireDefault(require("p-map-series"));
|
|
25
|
+
_pMapSeries = function () {
|
|
26
|
+
return data;
|
|
27
|
+
};
|
|
28
|
+
return data;
|
|
29
|
+
}
|
|
30
|
+
function _parseTypeFromQuickInfo() {
|
|
31
|
+
const data = require("./utils/parse-type-from-quick-info");
|
|
32
|
+
_parseTypeFromQuickInfo = function () {
|
|
33
|
+
return data;
|
|
34
|
+
};
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
37
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
38
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
39
|
+
class ParameterTransformer {
|
|
40
|
+
predicate(node) {
|
|
41
|
+
return node.kind === _typescript().default.SyntaxKind.Parameter;
|
|
42
|
+
}
|
|
43
|
+
async getIdentifiers() {
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
async transform(node, context) {
|
|
47
|
+
return new (_semanticsEntities().ParameterSchema)(context.getLocation(node), this.getName(node), await this.getType(node, context), Boolean(node.questionToken), node.initializer ? node.initializer.getText() : undefined, undefined, await this.getObjectBindingNodes(node, context));
|
|
48
|
+
}
|
|
49
|
+
getName(param) {
|
|
50
|
+
if ((0, _typescript().isIdentifier)(param.name)) {
|
|
51
|
+
return param.name.getText();
|
|
52
|
+
}
|
|
53
|
+
// it's binding pattern, either an array or an object
|
|
54
|
+
const elements = param.name.elements.map(elem => elem.getText());
|
|
55
|
+
const elementsStr = elements.join(', ');
|
|
56
|
+
if (param.name.kind === _typescript().SyntaxKind.ArrayBindingPattern) {
|
|
57
|
+
return `[ ${elementsStr} ]`;
|
|
58
|
+
}
|
|
59
|
+
// it's an object binding
|
|
60
|
+
return `{ ${elementsStr} }`;
|
|
61
|
+
}
|
|
62
|
+
async getType(param, context) {
|
|
63
|
+
if (param.type) {
|
|
64
|
+
return context.computeSchema(param.type);
|
|
65
|
+
}
|
|
66
|
+
if ((0, _typescript().isIdentifier)(param.name)) {
|
|
67
|
+
const info = await context.getQuickInfo(param.name);
|
|
68
|
+
const parsed = (0, _parseTypeFromQuickInfo().parseTypeFromQuickInfo)(info);
|
|
69
|
+
return new (_semanticsEntities().InferenceTypeSchema)(context.getLocation(param), parsed);
|
|
70
|
+
}
|
|
71
|
+
// it's binding pattern, either an array or an object
|
|
72
|
+
if (param.name.kind === _typescript().SyntaxKind.ArrayBindingPattern) {
|
|
73
|
+
const elements = await (0, _pMapSeries().default)(param.name.elements, async elem => {
|
|
74
|
+
const info = await context.getQuickInfo(elem);
|
|
75
|
+
const parsed = (0, _parseTypeFromQuickInfo().parseTypeFromQuickInfo)(info);
|
|
76
|
+
return new (_semanticsEntities().InferenceTypeSchema)(context.getLocation(param), parsed);
|
|
77
|
+
});
|
|
78
|
+
return new (_semanticsEntities().TupleTypeSchema)(context.getLocation(param), elements);
|
|
79
|
+
}
|
|
80
|
+
if (param.name.kind === _typescript().SyntaxKind.ObjectBindingPattern) {
|
|
81
|
+
const elements = await (0, _pMapSeries().default)(param.name.elements, async elem => {
|
|
82
|
+
const info = await context.getQuickInfo(elem.name);
|
|
83
|
+
const parsed = (0, _parseTypeFromQuickInfo().parseTypeFromQuickInfo)(info);
|
|
84
|
+
return new (_semanticsEntities().InferenceTypeSchema)(context.getLocation(param), parsed, elem.name.getText());
|
|
85
|
+
});
|
|
86
|
+
return new (_semanticsEntities().TypeLiteralSchema)(context.getLocation(param), elements);
|
|
87
|
+
}
|
|
88
|
+
throw new Error(`unknown param type`);
|
|
89
|
+
}
|
|
90
|
+
async getObjectBindingNodes(param, context) {
|
|
91
|
+
if (param.name.kind !== _typescript().SyntaxKind.ObjectBindingPattern) return undefined;
|
|
92
|
+
return (0, _pMapSeries().default)(param.name.elements, async elem => {
|
|
93
|
+
const info = elem.name.kind === _typescript().SyntaxKind.ObjectBindingPattern ? undefined : await context.getQuickInfo(elem.name);
|
|
94
|
+
// @todo look into extracting nested objected binding patters
|
|
95
|
+
/**
|
|
96
|
+
* apiNode: {
|
|
97
|
+
api: {
|
|
98
|
+
name,
|
|
99
|
+
signature: defaultSignature,
|
|
100
|
+
doc,
|
|
101
|
+
location: { filePath },
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
*/
|
|
105
|
+
const parsed = info ? (0, _parseTypeFromQuickInfo().parseTypeFromQuickInfo)(info) : elem.getText();
|
|
106
|
+
return new (_semanticsEntities().InferenceTypeSchema)(context.getLocation(param), parsed, elem.name.getText());
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
exports.ParameterTransformer = ParameterTransformer;
|
|
111
|
+
|
|
112
|
+
//# sourceMappingURL=parameter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ParameterTransformer","predicate","node","kind","ts","SyntaxKind","Parameter","getIdentifiers","transform","context","ParameterSchema","getLocation","getName","getType","Boolean","questionToken","initializer","getText","undefined","getObjectBindingNodes","param","isIdentifier","name","elements","map","elem","elementsStr","join","ArrayBindingPattern","type","computeSchema","info","getQuickInfo","parsed","parseTypeFromQuickInfo","InferenceTypeSchema","pMapSeries","TupleTypeSchema","ObjectBindingPattern","TypeLiteralSchema","Error"],"sources":["parameter.ts"],"sourcesContent":["import ts, {\n BindingElement,\n isIdentifier,\n Node,\n ParameterDeclaration,\n SyntaxKind,\n ArrayBindingElement,\n} from 'typescript';\nimport {\n InferenceTypeSchema,\n ParameterSchema,\n SchemaNode,\n TupleTypeSchema,\n TypeLiteralSchema,\n} from '@teambit/semantics.entities.semantic-schema';\nimport pMapSeries from 'p-map-series';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { parseTypeFromQuickInfo } from './utils/parse-type-from-quick-info';\nimport { Identifier } from '../identifier';\n\nexport class ParameterTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.Parameter;\n }\n\n async getIdentifiers(): Promise<Identifier[]> {\n return [];\n }\n\n async transform(node: ParameterDeclaration, context: SchemaExtractorContext) {\n return new ParameterSchema(\n context.getLocation(node),\n this.getName(node),\n await this.getType(node, context),\n Boolean(node.questionToken),\n node.initializer ? node.initializer.getText() : undefined,\n undefined,\n await this.getObjectBindingNodes(node, context)\n );\n }\n\n getName(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\n async getType(param: ParameterDeclaration, context: SchemaExtractorContext): Promise<SchemaNode> {\n if (param.type) {\n return context.computeSchema(param.type);\n }\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\n async getObjectBindingNodes(\n param: ParameterDeclaration,\n context: SchemaExtractorContext\n ): Promise<SchemaNode[] | undefined> {\n if (param.name.kind !== SyntaxKind.ObjectBindingPattern) return undefined;\n return pMapSeries(param.name.elements, async (elem: BindingElement) => {\n const info =\n elem.name.kind === SyntaxKind.ObjectBindingPattern ? undefined : await context.getQuickInfo(elem.name);\n // @todo look into extracting nested objected binding patters\n /**\n * apiNode: {\n api: {\n name,\n signature: defaultSignature,\n doc, \n location: { filePath },\n },\n },\n */\n const parsed = info ? parseTypeFromQuickInfo(info) : elem.getText();\n return new InferenceTypeSchema(context.getLocation(param), parsed, elem.name.getText());\n });\n }\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Node, ParenthesizedTypeNode } from 'typescript';
|
|
2
|
+
import { ParenthesizedTypeSchema } from '@teambit/semantics.entities.semantic-schema';
|
|
3
|
+
import { SchemaTransformer } from '../schema-transformer';
|
|
4
|
+
import { SchemaExtractorContext } from '../schema-extractor-context';
|
|
5
|
+
import { Identifier } from '../identifier';
|
|
6
|
+
export declare class ParenthesizedTypeTransformer implements SchemaTransformer {
|
|
7
|
+
predicate(node: Node): boolean;
|
|
8
|
+
getIdentifiers(): Promise<Identifier[]>;
|
|
9
|
+
transform(node: ParenthesizedTypeNode, context: SchemaExtractorContext): Promise<ParenthesizedTypeSchema>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.promise.js");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.ParenthesizedTypeTransformer = void 0;
|
|
8
|
+
function _typescript() {
|
|
9
|
+
const data = require("typescript");
|
|
10
|
+
_typescript = function () {
|
|
11
|
+
return data;
|
|
12
|
+
};
|
|
13
|
+
return data;
|
|
14
|
+
}
|
|
15
|
+
function _semanticsEntities() {
|
|
16
|
+
const data = require("@teambit/semantics.entities.semantic-schema");
|
|
17
|
+
_semanticsEntities = function () {
|
|
18
|
+
return data;
|
|
19
|
+
};
|
|
20
|
+
return data;
|
|
21
|
+
}
|
|
22
|
+
class ParenthesizedTypeTransformer {
|
|
23
|
+
predicate(node) {
|
|
24
|
+
return node.kind === _typescript().SyntaxKind.ParenthesizedType;
|
|
25
|
+
}
|
|
26
|
+
async getIdentifiers() {
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
async transform(node, context) {
|
|
30
|
+
const type = await context.computeSchema(node.type);
|
|
31
|
+
return new (_semanticsEntities().ParenthesizedTypeSchema)(context.getLocation(node), type);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.ParenthesizedTypeTransformer = ParenthesizedTypeTransformer;
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=parenthesized-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ParenthesizedTypeTransformer","predicate","node","kind","SyntaxKind","ParenthesizedType","getIdentifiers","transform","context","type","computeSchema","ParenthesizedTypeSchema","getLocation"],"sources":["parenthesized-type.ts"],"sourcesContent":["import { Node, ParenthesizedTypeNode, SyntaxKind } from 'typescript';\nimport { ParenthesizedTypeSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { Identifier } from '../identifier';\n\nexport class ParenthesizedTypeTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === SyntaxKind.ParenthesizedType;\n }\n\n async getIdentifiers(): Promise<Identifier[]> {\n return [];\n }\n\n async transform(node: ParenthesizedTypeNode, context: SchemaExtractorContext) {\n const type = await context.computeSchema(node.type);\n return new ParenthesizedTypeSchema(context.getLocation(node), type);\n }\n}\n"],"mappings":";;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAKO,MAAMA,4BAA4B,CAA8B;EACrEC,SAAS,CAACC,IAAU,EAAE;IACpB,OAAOA,IAAI,CAACC,IAAI,KAAKC,wBAAU,CAACC,iBAAiB;EACnD;EAEA,MAAMC,cAAc,GAA0B;IAC5C,OAAO,EAAE;EACX;EAEA,MAAMC,SAAS,CAACL,IAA2B,EAAEM,OAA+B,EAAE;IAC5E,MAAMC,IAAI,GAAG,MAAMD,OAAO,CAACE,aAAa,CAACR,IAAI,CAACO,IAAI,CAAC;IACnD,OAAO,KAAIE,4CAAuB,EAACH,OAAO,CAACI,WAAW,CAACV,IAAI,CAAC,EAAEO,IAAI,CAAC;EACrE;AACF;AAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Node, PropertyDeclaration, PropertySignature } from 'typescript';
|
|
2
|
+
import { VariableLikeSchema } from '@teambit/semantics.entities.semantic-schema';
|
|
3
|
+
import { SchemaTransformer } from '../schema-transformer';
|
|
4
|
+
import { SchemaExtractorContext } from '../schema-extractor-context';
|
|
5
|
+
import { Identifier } from '../identifier';
|
|
6
|
+
export declare class PropertyDeclarationTransformer implements SchemaTransformer {
|
|
7
|
+
predicate(node: Node): boolean;
|
|
8
|
+
getIdentifiers(): Promise<Identifier[]>;
|
|
9
|
+
private isComputedProperty;
|
|
10
|
+
transform(node: PropertyDeclaration | PropertySignature, context: SchemaExtractorContext): Promise<VariableLikeSchema>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.promise.js");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.PropertyDeclarationTransformer = void 0;
|
|
8
|
+
function _typescript() {
|
|
9
|
+
const data = require("typescript");
|
|
10
|
+
_typescript = function () {
|
|
11
|
+
return data;
|
|
12
|
+
};
|
|
13
|
+
return data;
|
|
14
|
+
}
|
|
15
|
+
function _semanticsEntities() {
|
|
16
|
+
const data = require("@teambit/semantics.entities.semantic-schema");
|
|
17
|
+
_semanticsEntities = function () {
|
|
18
|
+
return data;
|
|
19
|
+
};
|
|
20
|
+
return data;
|
|
21
|
+
}
|
|
22
|
+
function _parseTypeFromQuickInfo() {
|
|
23
|
+
const data = require("./utils/parse-type-from-quick-info");
|
|
24
|
+
_parseTypeFromQuickInfo = function () {
|
|
25
|
+
return data;
|
|
26
|
+
};
|
|
27
|
+
return data;
|
|
28
|
+
}
|
|
29
|
+
class PropertyDeclarationTransformer {
|
|
30
|
+
predicate(node) {
|
|
31
|
+
return node.kind === _typescript().SyntaxKind.PropertyDeclaration || node.kind === _typescript().SyntaxKind.PropertySignature;
|
|
32
|
+
}
|
|
33
|
+
async getIdentifiers() {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// [computedName]: string
|
|
38
|
+
isComputedProperty(node) {
|
|
39
|
+
return node.name.kind === _typescript().SyntaxKind.ComputedPropertyName;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// @todo - handle arrow function objects
|
|
43
|
+
async transform(node, context) {
|
|
44
|
+
var _info$body;
|
|
45
|
+
const name = node.name.getText();
|
|
46
|
+
const info = this.isComputedProperty(node) ? undefined : await context.getQuickInfo(node.name);
|
|
47
|
+
const displaySig = (info === null || info === void 0 ? void 0 : (_info$body = info.body) === null || _info$body === void 0 ? void 0 : _info$body.displayString) || node.getText();
|
|
48
|
+
const typeStr = (0, _parseTypeFromQuickInfo().parseTypeFromQuickInfo)(info);
|
|
49
|
+
const type = await context.resolveType(node, typeStr);
|
|
50
|
+
const isOptional = Boolean(node.questionToken);
|
|
51
|
+
const doc = await context.jsDocToDocSchema(node);
|
|
52
|
+
return new (_semanticsEntities().VariableLikeSchema)(context.getLocation(node), name, displaySig, type, isOptional, doc);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.PropertyDeclarationTransformer = PropertyDeclarationTransformer;
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=property-declaration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["PropertyDeclarationTransformer","predicate","node","kind","SyntaxKind","PropertyDeclaration","PropertySignature","getIdentifiers","isComputedProperty","name","ComputedPropertyName","transform","context","getText","info","undefined","getQuickInfo","displaySig","body","displayString","typeStr","parseTypeFromQuickInfo","type","resolveType","isOptional","Boolean","questionToken","doc","jsDocToDocSchema","VariableLikeSchema","getLocation"],"sources":["property-declaration.ts"],"sourcesContent":["import { Node, PropertyDeclaration, PropertySignature, SyntaxKind } from 'typescript';\nimport { VariableLikeSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { parseTypeFromQuickInfo } from './utils/parse-type-from-quick-info';\nimport { Identifier } from '../identifier';\n\nexport class PropertyDeclarationTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature;\n }\n\n async getIdentifiers(): Promise<Identifier[]> {\n return [];\n }\n\n // [computedName]: string\n private isComputedProperty(node: PropertyDeclaration | PropertySignature) {\n return node.name.kind === SyntaxKind.ComputedPropertyName;\n }\n\n // @todo - handle arrow function objects\n async transform(node: PropertyDeclaration | PropertySignature, context: SchemaExtractorContext) {\n const name = node.name.getText();\n const info = this.isComputedProperty(node) ? undefined : await context.getQuickInfo(node.name);\n const displaySig = info?.body?.displayString || node.getText();\n const typeStr = parseTypeFromQuickInfo(info);\n const type = await context.resolveType(node, typeStr);\n const isOptional = Boolean(node.questionToken);\n const doc = await context.jsDocToDocSchema(node);\n return new VariableLikeSchema(context.getLocation(node), name, displaySig, type, isOptional, doc);\n }\n}\n"],"mappings":";;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGO,MAAMA,8BAA8B,CAA8B;EACvEC,SAAS,CAACC,IAAU,EAAE;IACpB,OAAOA,IAAI,CAACC,IAAI,KAAKC,wBAAU,CAACC,mBAAmB,IAAIH,IAAI,CAACC,IAAI,KAAKC,wBAAU,CAACE,iBAAiB;EACnG;EAEA,MAAMC,cAAc,GAA0B;IAC5C,OAAO,EAAE;EACX;;EAEA;EACQC,kBAAkB,CAACN,IAA6C,EAAE;IACxE,OAAOA,IAAI,CAACO,IAAI,CAACN,IAAI,KAAKC,wBAAU,CAACM,oBAAoB;EAC3D;;EAEA;EACA,MAAMC,SAAS,CAACT,IAA6C,EAAEU,OAA+B,EAAE;IAAA;IAC9F,MAAMH,IAAI,GAAGP,IAAI,CAACO,IAAI,CAACI,OAAO,EAAE;IAChC,MAAMC,IAAI,GAAG,IAAI,CAACN,kBAAkB,CAACN,IAAI,CAAC,GAAGa,SAAS,GAAG,MAAMH,OAAO,CAACI,YAAY,CAACd,IAAI,CAACO,IAAI,CAAC;IAC9F,MAAMQ,UAAU,GAAG,CAAAH,IAAI,aAAJA,IAAI,qCAAJA,IAAI,CAAEI,IAAI,+CAAV,WAAYC,aAAa,KAAIjB,IAAI,CAACW,OAAO,EAAE;IAC9D,MAAMO,OAAO,GAAG,IAAAC,gDAAsB,EAACP,IAAI,CAAC;IAC5C,MAAMQ,IAAI,GAAG,MAAMV,OAAO,CAACW,WAAW,CAACrB,IAAI,EAAEkB,OAAO,CAAC;IACrD,MAAMI,UAAU,GAAGC,OAAO,CAACvB,IAAI,CAACwB,aAAa,CAAC;IAC9C,MAAMC,GAAG,GAAG,MAAMf,OAAO,CAACgB,gBAAgB,CAAC1B,IAAI,CAAC;IAChD,OAAO,KAAI2B,uCAAkB,EAACjB,OAAO,CAACkB,WAAW,CAAC5B,IAAI,CAAC,EAAEO,IAAI,EAAEQ,UAAU,EAAEK,IAAI,EAAEE,UAAU,EAAEG,GAAG,CAAC;EACnG;AACF;AAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Node, SetAccessorDeclaration } from 'typescript';
|
|
2
|
+
import { SetAccessorSchema } from '@teambit/semantics.entities.semantic-schema';
|
|
3
|
+
import { SchemaTransformer } from '../schema-transformer';
|
|
4
|
+
import { SchemaExtractorContext } from '../schema-extractor-context';
|
|
5
|
+
import { Identifier } from '../identifier';
|
|
6
|
+
export declare class SetAccessorTransformer implements SchemaTransformer {
|
|
7
|
+
predicate(node: Node): boolean;
|
|
8
|
+
getIdentifiers(): Promise<Identifier[]>;
|
|
9
|
+
transform(node: SetAccessorDeclaration, context: SchemaExtractorContext): Promise<SetAccessorSchema>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
require("core-js/modules/es.promise.js");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.SetAccessorTransformer = void 0;
|
|
9
|
+
function _typescript() {
|
|
10
|
+
const data = _interopRequireDefault(require("typescript"));
|
|
11
|
+
_typescript = function () {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
return data;
|
|
15
|
+
}
|
|
16
|
+
function _semanticsEntities() {
|
|
17
|
+
const data = require("@teambit/semantics.entities.semantic-schema");
|
|
18
|
+
_semanticsEntities = function () {
|
|
19
|
+
return data;
|
|
20
|
+
};
|
|
21
|
+
return data;
|
|
22
|
+
}
|
|
23
|
+
function _pMapSeries() {
|
|
24
|
+
const data = _interopRequireDefault(require("p-map-series"));
|
|
25
|
+
_pMapSeries = function () {
|
|
26
|
+
return data;
|
|
27
|
+
};
|
|
28
|
+
return data;
|
|
29
|
+
}
|
|
30
|
+
class SetAccessorTransformer {
|
|
31
|
+
predicate(node) {
|
|
32
|
+
return node.kind === _typescript().default.SyntaxKind.SetAccessor;
|
|
33
|
+
}
|
|
34
|
+
async getIdentifiers() {
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
async transform(node, context) {
|
|
38
|
+
const params = await (0, _pMapSeries().default)(node.parameters, async param => context.computeSchema(param));
|
|
39
|
+
const displaySig = await context.getQuickInfoDisplayString(node.name);
|
|
40
|
+
return new (_semanticsEntities().SetAccessorSchema)(context.getLocation(node), node.name.getText(), params[0], displaySig);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.SetAccessorTransformer = SetAccessorTransformer;
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=set-accessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["SetAccessorTransformer","predicate","node","kind","ts","SyntaxKind","SetAccessor","getIdentifiers","transform","context","params","pMapSeries","parameters","param","computeSchema","displaySig","getQuickInfoDisplayString","name","SetAccessorSchema","getLocation","getText"],"sources":["set-accessor.ts"],"sourcesContent":["import ts, { Node, SetAccessorDeclaration } from 'typescript';\nimport { ParameterSchema, SetAccessorSchema } from '@teambit/semantics.entities.semantic-schema';\nimport pMapSeries from 'p-map-series';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { Identifier } from '../identifier';\n\nexport class SetAccessorTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.SetAccessor;\n }\n\n async getIdentifiers(): Promise<Identifier[]> {\n return [];\n }\n\n async transform(node: SetAccessorDeclaration, context: SchemaExtractorContext) {\n const params = (await pMapSeries(node.parameters, async (param) =>\n context.computeSchema(param)\n )) as ParameterSchema[];\n\n const displaySig = await context.getQuickInfoDisplayString(node.name);\n return new SetAccessorSchema(context.getLocation(node), node.name.getText(), params[0], displaySig);\n }\n}\n"],"mappings":";;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAKO,MAAMA,sBAAsB,CAA8B;EAC/DC,SAAS,CAACC,IAAU,EAAE;IACpB,OAAOA,IAAI,CAACC,IAAI,KAAKC,qBAAE,CAACC,UAAU,CAACC,WAAW;EAChD;EAEA,MAAMC,cAAc,GAA0B;IAC5C,OAAO,EAAE;EACX;EAEA,MAAMC,SAAS,CAACN,IAA4B,EAAEO,OAA+B,EAAE;IAC7E,MAAMC,MAAM,GAAI,MAAM,IAAAC,qBAAU,EAACT,IAAI,CAACU,UAAU,EAAE,MAAOC,KAAK,IAC5DJ,OAAO,CAACK,aAAa,CAACD,KAAK,CAAC,CACP;IAEvB,MAAME,UAAU,GAAG,MAAMN,OAAO,CAACO,yBAAyB,CAACd,IAAI,CAACe,IAAI,CAAC;IACrE,OAAO,KAAIC,sCAAiB,EAACT,OAAO,CAACU,WAAW,CAACjB,IAAI,CAAC,EAAEA,IAAI,CAACe,IAAI,CAACG,OAAO,EAAE,EAAEV,MAAM,CAAC,CAAC,CAAC,EAAEK,UAAU,CAAC;EACrG;AACF;AAAC"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { Node, SourceFile } from 'typescript';
|
|
2
2
|
import { ModuleSchema } from '@teambit/semantics.entities.semantic-schema';
|
|
3
3
|
import { SchemaTransformer } from '../schema-transformer';
|
|
4
|
-
import { ExportIdentifier } from '../export-identifier';
|
|
5
4
|
import { SchemaExtractorContext } from '../schema-extractor-context';
|
|
5
|
+
import { Identifier } from '../identifier';
|
|
6
6
|
export declare class SourceFileTransformer implements SchemaTransformer {
|
|
7
7
|
predicate(node: Node): boolean;
|
|
8
|
-
getIdentifiers(sourceFile: SourceFile, context: SchemaExtractorContext): Promise<
|
|
8
|
+
getIdentifiers(sourceFile: SourceFile, context: SchemaExtractorContext): Promise<Identifier[]>;
|
|
9
9
|
transform(node: SourceFile, context: SchemaExtractorContext): Promise<ModuleSchema>;
|
|
10
10
|
/**
|
|
11
11
|
* list all exports of a source file.
|
|
12
12
|
*/
|
|
13
13
|
private listExports;
|
|
14
|
+
private listInternalNodes;
|
|
14
15
|
}
|
|
@@ -35,45 +35,74 @@ function _semanticsEntities() {
|
|
|
35
35
|
};
|
|
36
36
|
return data;
|
|
37
37
|
}
|
|
38
|
+
function _exportIdentifier() {
|
|
39
|
+
const data = require("../export-identifier");
|
|
40
|
+
_exportIdentifier = function () {
|
|
41
|
+
return data;
|
|
42
|
+
};
|
|
43
|
+
return data;
|
|
44
|
+
}
|
|
38
45
|
class SourceFileTransformer {
|
|
39
46
|
predicate(node) {
|
|
40
47
|
return node.kind === _typescript().default.SyntaxKind.SourceFile;
|
|
41
48
|
}
|
|
42
49
|
async getIdentifiers(sourceFile, context) {
|
|
43
50
|
const exports = this.listExports(sourceFile);
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
|
|
51
|
+
const internals = this.listInternalNodes(sourceFile);
|
|
52
|
+
|
|
53
|
+
// change to pMap series
|
|
54
|
+
const exportIdentifiers = (0, _lodash().flatten)(await (0, _pMapSeries().default)(exports, node => {
|
|
55
|
+
return context.getIdentifiers(node);
|
|
56
|
+
})).reduce((acc, current) => {
|
|
57
|
+
const item = acc.find(exportIdentifier => exportIdentifier.isEqual(current));
|
|
58
|
+
if (!item) acc.push(new (_exportIdentifier().ExportIdentifier)(current.id, current.filePath, current.aliasId, current.sourceFilePath));
|
|
59
|
+
return acc;
|
|
60
|
+
}, []);
|
|
61
|
+
const internalIdentifiers = (0, _lodash().flatten)(await (0, _pMapSeries().default)(internals, node => {
|
|
62
|
+
return context.getIdentifiers(node);
|
|
63
|
+
})).reduce((acc, current) => {
|
|
64
|
+
const item = acc.find(internalIdentifier => internalIdentifier.isEqual(current));
|
|
49
65
|
if (!item) acc.push(current);
|
|
50
66
|
return acc;
|
|
51
67
|
}, []);
|
|
52
|
-
|
|
68
|
+
const identifiers = [...exportIdentifiers, ...internalIdentifiers];
|
|
69
|
+
return identifiers;
|
|
53
70
|
}
|
|
54
71
|
async transform(node, context) {
|
|
55
72
|
const exports = this.listExports(node);
|
|
56
|
-
const
|
|
73
|
+
const internals = this.listInternalNodes(node).filter(internal => internal.kind !== _typescript().default.SyntaxKind.ImportDeclaration);
|
|
74
|
+
const exportDeclarations = await (0, _pMapSeries().default)(exports, exportNode => {
|
|
57
75
|
return context.computeSchema(exportNode);
|
|
58
76
|
});
|
|
59
|
-
|
|
77
|
+
const internalDeclarations = await (0, _pMapSeries().default)(internals, internalNode => {
|
|
78
|
+
return context.computeSchema(internalNode);
|
|
79
|
+
});
|
|
80
|
+
return new (_semanticsEntities().ModuleSchema)(context.getLocation(node), exportDeclarations, internalDeclarations);
|
|
60
81
|
}
|
|
61
82
|
|
|
62
83
|
/**
|
|
63
84
|
* list all exports of a source file.
|
|
64
85
|
*/
|
|
65
86
|
listExports(ast) {
|
|
66
|
-
return
|
|
87
|
+
return ast.statements.filter(statement => {
|
|
67
88
|
var _statement$modifiers;
|
|
68
|
-
if (statement.kind === _typescript().default.SyntaxKind.ExportDeclaration) return
|
|
89
|
+
if (statement.kind === _typescript().default.SyntaxKind.ExportDeclaration || statement.kind === _typescript().default.SyntaxKind.ExportAssignment) return true;
|
|
69
90
|
const isExport = Boolean((_statement$modifiers = statement.modifiers) === null || _statement$modifiers === void 0 ? void 0 : _statement$modifiers.find(modifier => {
|
|
70
91
|
return modifier.kind === _typescript().default.SyntaxKind.ExportKeyword;
|
|
71
92
|
}));
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
93
|
+
return isExport;
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
listInternalNodes(ast) {
|
|
97
|
+
return ast.statements.filter(statement => {
|
|
98
|
+
var _statement$modifiers2;
|
|
99
|
+
if (!(statement.kind === _typescript().default.SyntaxKind.ExportDeclaration || statement.kind === _typescript().default.SyntaxKind.ExportAssignment) && !((_statement$modifiers2 = statement.modifiers) !== null && _statement$modifiers2 !== void 0 && _statement$modifiers2.find(modifier => {
|
|
100
|
+
return modifier.kind === _typescript().default.SyntaxKind.ExportKeyword;
|
|
101
|
+
}))) {
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
return false;
|
|
105
|
+
});
|
|
77
106
|
}
|
|
78
107
|
}
|
|
79
108
|
exports.SourceFileTransformer = SourceFileTransformer;
|