@teambit/typescript 0.0.740 → 0.0.743

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.
Files changed (73) hide show
  1. package/dist/schema-extractor-context.d.ts +4 -6
  2. package/dist/schema-extractor-context.js +37 -27
  3. package/dist/schema-extractor-context.js.map +1 -1
  4. package/dist/transformers/class-deceleration.js +10 -40
  5. package/dist/transformers/class-deceleration.js.map +1 -1
  6. package/dist/transformers/export-declaration.js +9 -2
  7. package/dist/transformers/export-declaration.js.map +1 -1
  8. package/dist/transformers/index.d.ts +0 -6
  9. package/dist/transformers/index.js +0 -96
  10. package/dist/transformers/index.js.map +1 -1
  11. package/dist/transformers/interface-declaration.js +13 -6
  12. package/dist/transformers/interface-declaration.js.map +1 -1
  13. package/dist/transformers/type-alias.js +2 -5
  14. package/dist/transformers/type-alias.js.map +1 -1
  15. package/dist/transformers/utils/class-element-to-schema.d.ts +4 -0
  16. package/dist/transformers/utils/class-element-to-schema.js +122 -0
  17. package/dist/transformers/utils/class-element-to-schema.js.map +1 -0
  18. package/dist/transformers/utils/jsdoc-to-doc-schema.d.ts +4 -0
  19. package/dist/transformers/utils/jsdoc-to-doc-schema.js +163 -0
  20. package/dist/transformers/utils/jsdoc-to-doc-schema.js.map +1 -0
  21. package/dist/transformers/utils/to-function-schema.d.ts +1 -1
  22. package/dist/transformers/utils/to-function-schema.js +17 -7
  23. package/dist/transformers/utils/to-function-schema.js.map +1 -1
  24. package/dist/transformers/utils/type-element-to-schema.d.ts +7 -0
  25. package/dist/transformers/utils/type-element-to-schema.js +134 -0
  26. package/dist/transformers/utils/type-element-to-schema.js.map +1 -0
  27. package/dist/transformers/utils/type-node-to-schema.js +50 -9
  28. package/dist/transformers/utils/type-node-to-schema.js.map +1 -1
  29. package/dist/transformers/variable-declaration.js +15 -1
  30. package/dist/transformers/variable-declaration.js.map +1 -1
  31. package/dist/typescript.extractor.js +1 -1
  32. package/dist/typescript.extractor.js.map +1 -1
  33. package/dist/typescript.main.runtime.js +1 -1
  34. package/dist/typescript.main.runtime.js.map +1 -1
  35. package/package-tar/teambit-typescript-0.0.743.tgz +0 -0
  36. package/package.json +16 -16
  37. package/{preview-1653449228788.js → preview-1653708349111.js} +2 -2
  38. package/transformers/class-deceleration.ts +7 -26
  39. package/transformers/export-declaration.ts +7 -2
  40. package/transformers/index.ts +0 -6
  41. package/transformers/interface-declaration.ts +4 -6
  42. package/transformers/type-alias.ts +2 -3
  43. package/transformers/utils/class-element-to-schema.ts +61 -0
  44. package/transformers/utils/jsdoc-to-doc-schema.ts +81 -0
  45. package/transformers/utils/to-function-schema.ts +12 -8
  46. package/transformers/utils/type-element-to-schema.ts +72 -0
  47. package/transformers/utils/type-node-to-schema.ts +35 -8
  48. package/transformers/variable-declaration.ts +5 -2
  49. package/dist/transformers/constructor.d.ts +0 -10
  50. package/dist/transformers/constructor.js +0 -70
  51. package/dist/transformers/constructor.js.map +0 -1
  52. package/dist/transformers/index-signature.d.ts +0 -9
  53. package/dist/transformers/index-signature.js +0 -71
  54. package/dist/transformers/index-signature.js.map +0 -1
  55. package/dist/transformers/method-declaration.d.ts +0 -11
  56. package/dist/transformers/method-declaration.js +0 -65
  57. package/dist/transformers/method-declaration.js.map +0 -1
  58. package/dist/transformers/method-signature.d.ts +0 -10
  59. package/dist/transformers/method-signature.js +0 -53
  60. package/dist/transformers/method-signature.js.map +0 -1
  61. package/dist/transformers/property-declaration.d.ts +0 -11
  62. package/dist/transformers/property-declaration.js +0 -80
  63. package/dist/transformers/property-declaration.js.map +0 -1
  64. package/dist/transformers/property-signature.d.ts +0 -10
  65. package/dist/transformers/property-signature.js +0 -87
  66. package/dist/transformers/property-signature.js.map +0 -1
  67. package/package-tar/teambit-typescript-0.0.740.tgz +0 -0
  68. package/transformers/constructor.ts +0 -22
  69. package/transformers/index-signature.ts +0 -22
  70. package/transformers/method-declaration.ts +0 -24
  71. package/transformers/method-signature.ts +0 -23
  72. package/transformers/property-declaration.ts +0 -30
  73. package/transformers/property-signature.ts +0 -34
@@ -1,10 +0,0 @@
1
- import { SchemaNode } from '@teambit/semantics.entities.semantic-schema';
2
- import { Node, MethodSignature as MethodSignatureNode } from 'typescript';
3
- import { SchemaTransformer } from '../schema-transformer';
4
- import { SchemaExtractorContext } from '../schema-extractor-context';
5
- export declare class MethodSignatureTransformer implements SchemaTransformer {
6
- predicate(node: Node): boolean;
7
- getName(node: MethodSignatureNode): string;
8
- getIdentifiers(): Promise<never[]>;
9
- transform(methodSig: MethodSignatureNode, context: SchemaExtractorContext): Promise<SchemaNode>;
10
- }
@@ -1,53 +0,0 @@
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.MethodSignatureTransformer = 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 _toFunctionSchema() {
23
- const data = require("./utils/to-function-schema");
24
-
25
- _toFunctionSchema = function () {
26
- return data;
27
- };
28
-
29
- return data;
30
- }
31
-
32
- class MethodSignatureTransformer {
33
- predicate(node) {
34
- return node.kind === _typescript().default.SyntaxKind.MethodSignature;
35
- }
36
-
37
- getName(node) {
38
- return node.name.getText();
39
- }
40
-
41
- async getIdentifiers() {
42
- return [];
43
- }
44
-
45
- async transform(methodSig, context) {
46
- return (0, _toFunctionSchema().toFunctionLikeSchema)(methodSig, context);
47
- }
48
-
49
- }
50
-
51
- exports.MethodSignatureTransformer = MethodSignatureTransformer;
52
-
53
- //# sourceMappingURL=method-signature.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["MethodSignatureTransformer","predicate","node","kind","ts","SyntaxKind","MethodSignature","getName","name","getText","getIdentifiers","transform","methodSig","context","toFunctionLikeSchema"],"sources":["method-signature.ts"],"sourcesContent":["import { SchemaNode } from '@teambit/semantics.entities.semantic-schema';\nimport ts, { Node, MethodSignature as MethodSignatureNode } from 'typescript';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { toFunctionLikeSchema } from './utils/to-function-schema';\n\nexport class MethodSignatureTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.MethodSignature;\n }\n\n getName(node: MethodSignatureNode) {\n return node.name.getText();\n }\n\n async getIdentifiers() {\n return [];\n }\n\n async transform(methodSig: MethodSignatureNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n return toFunctionLikeSchema(methodSig, context);\n }\n}\n"],"mappings":";;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAAMA,0BAAN,CAA8D;EACnEC,SAAS,CAACC,IAAD,EAAa;IACpB,OAAOA,IAAI,CAACC,IAAL,KAAcC,qBAAA,CAAGC,UAAH,CAAcC,eAAnC;EACD;;EAEDC,OAAO,CAACL,IAAD,EAA4B;IACjC,OAAOA,IAAI,CAACM,IAAL,CAAUC,OAAV,EAAP;EACD;;EAEmB,MAAdC,cAAc,GAAG;IACrB,OAAO,EAAP;EACD;;EAEc,MAATC,SAAS,CAACC,SAAD,EAAiCC,OAAjC,EAAuF;IACpG,OAAO,IAAAC,wCAAA,EAAqBF,SAArB,EAAgCC,OAAhC,CAAP;EACD;;AAfkE"}
@@ -1,11 +0,0 @@
1
- import { SchemaNode } from '@teambit/semantics.entities.semantic-schema';
2
- import { Node, PropertyDeclaration as PropertyDeclarationNode } from 'typescript';
3
- import { SchemaTransformer } from '../schema-transformer';
4
- import { SchemaExtractorContext } from '../schema-extractor-context';
5
- import { ExportIdentifier } from '../export-identifier';
6
- export declare class PropertyDeclaration implements SchemaTransformer {
7
- predicate(node: Node): boolean;
8
- getName(node: PropertyDeclarationNode): string;
9
- getIdentifiers(node: PropertyDeclarationNode): Promise<ExportIdentifier[]>;
10
- transform(propertyDec: PropertyDeclarationNode, context: SchemaExtractorContext): Promise<SchemaNode>;
11
- }
@@ -1,80 +0,0 @@
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);
69
- const info = await context.getQuickInfo(propertyDec.name);
70
- const displaySig = info === null || info === void 0 ? void 0 : (_info$body = info.body) === null || _info$body === void 0 ? void 0 : _info$body.displayString;
71
- const typeStr = (0, _parseTypeFromQuickInfo().parseTypeFromQuickInfo)(info);
72
- const type = await context.resolveType(propertyDec, typeStr);
73
- return new (_semanticsEntities().VariableSchema)(context.getLocation(propertyDec), name, displaySig || '', type);
74
- }
75
-
76
- }
77
-
78
- exports.PropertyDeclaration = PropertyDeclaration;
79
-
80
- //# sourceMappingURL=property-declaration.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["PropertyDeclaration","predicate","node","kind","ts","SyntaxKind","getName","name","getText","getIdentifiers","ExportIdentifier","getSourceFile","fileName","transform","propertyDec","context","info","getQuickInfo","displaySig","body","displayString","typeStr","parseTypeFromQuickInfo","type","resolveType","VariableSchema","getLocation"],"sources":["property-declaration.ts"],"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 const info = await context.getQuickInfo(propertyDec.name);\n const displaySig = info?.body?.displayString;\n const typeStr = parseTypeFromQuickInfo(info);\n const type = await context.resolveType(propertyDec, typeStr);\n\n return new VariableSchema(context.getLocation(propertyDec), name, displaySig || '', type);\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;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAAMA,mBAAN,CAAuD;EAC5DC,SAAS,CAACC,IAAD,EAAa;IACpB,OAAOA,IAAI,CAACC,IAAL,KAAcC,qBAAA,CAAGC,UAAH,CAAcL,mBAAnC;EACD;;EAEDM,OAAO,CAACJ,IAAD,EAAgC;IACrC,OAAOA,IAAI,CAACK,IAAL,CAAUC,OAAV,EAAP;EACD;;EAEmB,MAAdC,cAAc,CAACP,IAAD,EAAgC;IAClD,OAAO,CAAC,KAAIQ,oCAAJ,EAAqBR,IAAI,CAACK,IAAL,CAAUC,OAAV,EAArB,EAA0CN,IAAI,CAACS,aAAL,GAAqBC,QAA/D,CAAD,CAAP;EACD;;EAEc,MAATC,SAAS,CAACC,WAAD,EAAuCC,OAAvC,EAA6F;IAAA;;IAC1G,MAAMR,IAAI,GAAG,KAAKD,OAAL,CAAaQ,WAAb,CAAb;IACA,MAAME,IAAI,GAAG,MAAMD,OAAO,CAACE,YAAR,CAAqBH,WAAW,CAACP,IAAjC,CAAnB;IACA,MAAMW,UAAU,GAAGF,IAAH,aAAGA,IAAH,qCAAGA,IAAI,CAAEG,IAAT,+CAAG,WAAYC,aAA/B;IACA,MAAMC,OAAO,GAAG,IAAAC,gDAAA,EAAuBN,IAAvB,CAAhB;IACA,MAAMO,IAAI,GAAG,MAAMR,OAAO,CAACS,WAAR,CAAoBV,WAApB,EAAiCO,OAAjC,CAAnB;IAEA,OAAO,KAAII,mCAAJ,EAAmBV,OAAO,CAACW,WAAR,CAAoBZ,WAApB,CAAnB,EAAqDP,IAArD,EAA2DW,UAAU,IAAI,EAAzE,EAA6EK,IAA7E,CAAP;EACD;;AArB2D"}
@@ -1,10 +0,0 @@
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
- }
@@ -1,87 +0,0 @@
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 _parseTypeFromQuickInfo() {
33
- const data = require("./utils/parse-type-from-quick-info");
34
-
35
- _parseTypeFromQuickInfo = function () {
36
- return data;
37
- };
38
-
39
- return data;
40
- }
41
-
42
- function _typeNodeToSchema() {
43
- const data = require("./utils/type-node-to-schema");
44
-
45
- _typeNodeToSchema = 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);
69
- const info = await context.getQuickInfo(prop.name);
70
- const displaySig = (info === null || info === void 0 ? void 0 : (_info$body = info.body) === null || _info$body === void 0 ? void 0 : _info$body.displayString) || '';
71
-
72
- if (((_prop$type = prop.type) === null || _prop$type === void 0 ? void 0 : _prop$type.kind) === _typescript().default.SyntaxKind.FunctionType) {
73
- // e.g. `propertySig: () => void;` inside interface
74
- const propType = prop.type;
75
- return (0, _typeNodeToSchema().typeNodeToSchema)(propType, context);
76
- }
77
-
78
- const typeStr = (0, _parseTypeFromQuickInfo().parseTypeFromQuickInfo)(info);
79
- const type = await context.resolveType(prop, typeStr);
80
- return new (_semanticsEntities().VariableSchema)(context.getLocation(prop), name, displaySig, type);
81
- }
82
-
83
- }
84
-
85
- exports.PropertySignature = PropertySignature;
86
-
87
- //# sourceMappingURL=property-signature.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["PropertySignature","predicate","node","kind","ts","SyntaxKind","getName","name","getText","getIdentifiers","transform","prop","context","info","getQuickInfo","displaySig","body","displayString","type","FunctionType","propType","typeNodeToSchema","typeStr","parseTypeFromQuickInfo","resolveType","VariableSchema","getLocation"],"sources":["property-signature.ts"],"sourcesContent":["import { SchemaNode, VariableSchema } from '@teambit/semantics.entities.semantic-schema';\nimport ts, { FunctionTypeNode, Node, PropertySignature as PropertySignatureNode } from 'typescript';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { parseTypeFromQuickInfo } from './utils/parse-type-from-quick-info';\nimport { typeNodeToSchema } from './utils/type-node-to-schema';\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 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 return typeNodeToSchema(propType, context);\n }\n const typeStr = parseTypeFromQuickInfo(info);\n const type = await context.resolveType(prop, typeStr);\n return new VariableSchema(context.getLocation(prop), name, displaySig, type);\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;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAAMA,iBAAN,CAAqD;EAC1DC,SAAS,CAACC,IAAD,EAAa;IACpB,OAAOA,IAAI,CAACC,IAAL,KAAcC,qBAAA,CAAGC,UAAH,CAAcL,iBAAnC;EACD;;EAEDM,OAAO,CAACJ,IAAD,EAA8B;IACnC,OAAOA,IAAI,CAACK,IAAL,CAAUC,OAAV,EAAP;EACD;;EAEmB,MAAdC,cAAc,GAAG;IACrB,OAAO,EAAP;EACD;;EAEc,MAATC,SAAS,CAACC,IAAD,EAA8BC,OAA9B,EAAoF;IAAA;;IACjG,MAAML,IAAI,GAAG,KAAKD,OAAL,CAAaK,IAAb,CAAb;IACA,MAAME,IAAI,GAAG,MAAMD,OAAO,CAACE,YAAR,CAAqBH,IAAI,CAACJ,IAA1B,CAAnB;IACA,MAAMQ,UAAU,GAAG,CAAAF,IAAI,SAAJ,IAAAA,IAAI,WAAJ,0BAAAA,IAAI,CAAEG,IAAN,0DAAYC,aAAZ,KAA6B,EAAhD;;IACA,IAAI,eAAAN,IAAI,CAACO,IAAL,0DAAWf,IAAX,MAAoBC,qBAAA,CAAGC,UAAH,CAAcc,YAAtC,EAAoD;MAClD;MACA,MAAMC,QAAQ,GAAGT,IAAI,CAACO,IAAtB;MACA,OAAO,IAAAG,oCAAA,EAAiBD,QAAjB,EAA2BR,OAA3B,CAAP;IACD;;IACD,MAAMU,OAAO,GAAG,IAAAC,gDAAA,EAAuBV,IAAvB,CAAhB;IACA,MAAMK,IAAI,GAAG,MAAMN,OAAO,CAACY,WAAR,CAAoBb,IAApB,EAA0BW,OAA1B,CAAnB;IACA,OAAO,KAAIG,mCAAJ,EAAmBb,OAAO,CAACc,WAAR,CAAoBf,IAApB,CAAnB,EAA8CJ,IAA9C,EAAoDQ,UAApD,EAAgEG,IAAhE,CAAP;EACD;;AAzByD"}
@@ -1,22 +0,0 @@
1
- import { SchemaNode, ConstructorSchema } from '@teambit/semantics.entities.semantic-schema';
2
- import ts, { Node, ConstructorDeclaration } from 'typescript';
3
- import { SchemaExtractorContext } from '../schema-extractor-context';
4
- import { SchemaTransformer } from '../schema-transformer';
5
- import { ExportIdentifier } from '../export-identifier';
6
- import { getParams } from './utils/get-params';
7
-
8
- export class Constructor implements SchemaTransformer {
9
- predicate(node: Node) {
10
- return node.kind === ts.SyntaxKind.Constructor;
11
- }
12
-
13
- async getIdentifiers(node: ConstructorDeclaration) {
14
- return [new ExportIdentifier('constructor', node.getSourceFile().fileName)];
15
- }
16
-
17
- async transform(constructorDec: ConstructorDeclaration, context: SchemaExtractorContext): Promise<SchemaNode> {
18
- const args = await getParams(constructorDec.parameters, context);
19
-
20
- return new ConstructorSchema(context.getLocation(constructorDec), args);
21
- }
22
- }
@@ -1,22 +0,0 @@
1
- import { SchemaNode, IndexSignatureSchema } from '@teambit/semantics.entities.semantic-schema';
2
- import ts, { Node, IndexSignatureDeclaration } from 'typescript';
3
- import { SchemaTransformer } from '../schema-transformer';
4
- import { SchemaExtractorContext } from '../schema-extractor-context';
5
- import { getParams } from './utils/get-params';
6
- import { typeNodeToSchema } from './utils/type-node-to-schema';
7
-
8
- export class IndexSignature implements SchemaTransformer {
9
- predicate(node: Node) {
10
- return node.kind === ts.SyntaxKind.IndexSignature;
11
- }
12
-
13
- async getIdentifiers() {
14
- return [];
15
- }
16
-
17
- async transform(indexSig: IndexSignatureDeclaration, context: SchemaExtractorContext): Promise<SchemaNode> {
18
- const params = await getParams(indexSig.parameters, context);
19
- const type = await typeNodeToSchema(indexSig.type, context);
20
- return new IndexSignatureSchema(context.getLocation(indexSig), params, type);
21
- }
22
- }
@@ -1,24 +0,0 @@
1
- import { SchemaNode } from '@teambit/semantics.entities.semantic-schema';
2
- import ts, { Node, MethodDeclaration as MethodDeclarationNode } from 'typescript';
3
- import { SchemaExtractorContext } from '../schema-extractor-context';
4
- import { SchemaTransformer } from '../schema-transformer';
5
- import { ExportIdentifier } from '../export-identifier';
6
- import { toFunctionLikeSchema } from './utils/to-function-schema';
7
-
8
- export class MethodDeclaration implements SchemaTransformer {
9
- predicate(node: Node) {
10
- return node.kind === ts.SyntaxKind.MethodDeclaration;
11
- }
12
-
13
- async getIdentifiers(funcDec: MethodDeclarationNode) {
14
- return [new ExportIdentifier(this.getName(funcDec), funcDec.getSourceFile().fileName)];
15
- }
16
-
17
- private getName(funcDec: MethodDeclarationNode) {
18
- return funcDec.name?.getText() || '';
19
- }
20
-
21
- async transform(methodDec: MethodDeclarationNode, context: SchemaExtractorContext): Promise<SchemaNode> {
22
- return toFunctionLikeSchema(methodDec, context);
23
- }
24
- }
@@ -1,23 +0,0 @@
1
- import { SchemaNode } from '@teambit/semantics.entities.semantic-schema';
2
- import ts, { Node, MethodSignature as MethodSignatureNode } from 'typescript';
3
- import { SchemaTransformer } from '../schema-transformer';
4
- import { SchemaExtractorContext } from '../schema-extractor-context';
5
- import { toFunctionLikeSchema } from './utils/to-function-schema';
6
-
7
- export class MethodSignatureTransformer implements SchemaTransformer {
8
- predicate(node: Node) {
9
- return node.kind === ts.SyntaxKind.MethodSignature;
10
- }
11
-
12
- getName(node: MethodSignatureNode) {
13
- return node.name.getText();
14
- }
15
-
16
- async getIdentifiers() {
17
- return [];
18
- }
19
-
20
- async transform(methodSig: MethodSignatureNode, context: SchemaExtractorContext): Promise<SchemaNode> {
21
- return toFunctionLikeSchema(methodSig, context);
22
- }
23
- }
@@ -1,30 +0,0 @@
1
- import { SchemaNode, VariableSchema } from '@teambit/semantics.entities.semantic-schema';
2
- import ts, { Node, PropertyDeclaration as PropertyDeclarationNode } from 'typescript';
3
- import { SchemaTransformer } from '../schema-transformer';
4
- import { SchemaExtractorContext } from '../schema-extractor-context';
5
- import { ExportIdentifier } from '../export-identifier';
6
- import { parseTypeFromQuickInfo } from './utils/parse-type-from-quick-info';
7
-
8
- export class PropertyDeclaration implements SchemaTransformer {
9
- predicate(node: Node) {
10
- return node.kind === ts.SyntaxKind.PropertyDeclaration;
11
- }
12
-
13
- getName(node: PropertyDeclarationNode) {
14
- return node.name.getText();
15
- }
16
-
17
- async getIdentifiers(node: PropertyDeclarationNode) {
18
- return [new ExportIdentifier(node.name.getText(), node.getSourceFile().fileName)];
19
- }
20
-
21
- async transform(propertyDec: PropertyDeclarationNode, context: SchemaExtractorContext): Promise<SchemaNode> {
22
- const name = this.getName(propertyDec);
23
- const info = await context.getQuickInfo(propertyDec.name);
24
- const displaySig = info?.body?.displayString;
25
- const typeStr = parseTypeFromQuickInfo(info);
26
- const type = await context.resolveType(propertyDec, typeStr);
27
-
28
- return new VariableSchema(context.getLocation(propertyDec), name, displaySig || '', type);
29
- }
30
- }
@@ -1,34 +0,0 @@
1
- import { SchemaNode, VariableSchema } from '@teambit/semantics.entities.semantic-schema';
2
- import ts, { FunctionTypeNode, Node, PropertySignature as PropertySignatureNode } from 'typescript';
3
- import { SchemaTransformer } from '../schema-transformer';
4
- import { SchemaExtractorContext } from '../schema-extractor-context';
5
- import { parseTypeFromQuickInfo } from './utils/parse-type-from-quick-info';
6
- import { typeNodeToSchema } from './utils/type-node-to-schema';
7
-
8
- export class PropertySignature implements SchemaTransformer {
9
- predicate(node: Node) {
10
- return node.kind === ts.SyntaxKind.PropertySignature;
11
- }
12
-
13
- getName(node: PropertySignatureNode) {
14
- return node.name.getText();
15
- }
16
-
17
- async getIdentifiers() {
18
- return [];
19
- }
20
-
21
- async transform(prop: PropertySignatureNode, context: SchemaExtractorContext): Promise<SchemaNode> {
22
- const name = this.getName(prop);
23
- const info = await context.getQuickInfo(prop.name);
24
- const displaySig = info?.body?.displayString || '';
25
- if (prop.type?.kind === ts.SyntaxKind.FunctionType) {
26
- // e.g. `propertySig: () => void;` inside interface
27
- const propType = prop.type as FunctionTypeNode;
28
- return typeNodeToSchema(propType, context);
29
- }
30
- const typeStr = parseTypeFromQuickInfo(info);
31
- const type = await context.resolveType(prop, typeStr);
32
- return new VariableSchema(context.getLocation(prop), name, displaySig, type);
33
- }
34
- }