@teambit/typescript 0.0.750 → 0.0.753

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 (50) hide show
  1. package/dist/exceptions/transformer-not-found.js +1 -1
  2. package/dist/exceptions/transformer-not-found.js.map +1 -1
  3. package/dist/schema-extractor-context.js +1 -1
  4. package/dist/schema-extractor-context.js.map +1 -1
  5. package/dist/transformers/binding-element.d.ts +17 -0
  6. package/dist/transformers/binding-element.js +83 -0
  7. package/dist/transformers/binding-element.js.map +1 -0
  8. package/dist/transformers/export-declaration.d.ts +1 -1
  9. package/dist/transformers/export-declaration.js +25 -25
  10. package/dist/transformers/export-declaration.js.map +1 -1
  11. package/dist/transformers/function-declaration.js +4 -4
  12. package/dist/transformers/function-declaration.js.map +1 -1
  13. package/dist/transformers/index.d.ts +1 -1
  14. package/dist/transformers/index.js +15 -15
  15. package/dist/transformers/index.js.map +1 -1
  16. package/dist/transformers/utils/class-element-to-schema.js +6 -5
  17. package/dist/transformers/utils/class-element-to-schema.js.map +1 -1
  18. package/dist/transformers/utils/get-params.js +1 -1
  19. package/dist/transformers/utils/get-params.js.map +1 -1
  20. package/dist/transformers/utils/{to-function-schema.d.ts → to-function-like-schema.d.ts} +0 -0
  21. package/dist/transformers/utils/{to-function-schema.js → to-function-like-schema.js} +4 -3
  22. package/dist/transformers/utils/to-function-like-schema.js.map +1 -0
  23. package/dist/transformers/utils/type-element-to-schema.js +12 -7
  24. package/dist/transformers/utils/type-element-to-schema.js.map +1 -1
  25. package/dist/transformers/variable-declaration.js +1 -1
  26. package/dist/transformers/variable-declaration.js.map +1 -1
  27. package/dist/typescript.extractor.d.ts +2 -2
  28. package/dist/typescript.extractor.js +7 -1
  29. package/dist/typescript.extractor.js.map +1 -1
  30. package/dist/typescript.main.runtime.js +1 -1
  31. package/dist/typescript.main.runtime.js.map +1 -1
  32. package/exceptions/transformer-not-found.ts +1 -1
  33. package/package-tar/teambit-typescript-0.0.753.tgz +0 -0
  34. package/package.json +16 -16
  35. package/{preview-1654226751250.js → preview-1654572446572.js} +2 -2
  36. package/transformers/binding-element.ts +32 -0
  37. package/transformers/export-declaration.ts +21 -19
  38. package/transformers/function-declaration.ts +1 -1
  39. package/transformers/index.ts +1 -1
  40. package/transformers/utils/class-element-to-schema.ts +3 -2
  41. package/transformers/utils/get-params.ts +1 -0
  42. package/transformers/utils/{to-function-schema.ts → to-function-like-schema.ts} +11 -1
  43. package/transformers/utils/type-element-to-schema.ts +9 -3
  44. package/transformers/variable-declaration.ts +1 -1
  45. package/dist/transformers/literal-type.d.ts +0 -9
  46. package/dist/transformers/literal-type.js +0 -50
  47. package/dist/transformers/literal-type.js.map +0 -1
  48. package/dist/transformers/utils/to-function-schema.js.map +0 -1
  49. package/package-tar/teambit-typescript-0.0.750.tgz +0 -0
  50. package/transformers/literal-type.ts +0 -19
@@ -7,6 +7,7 @@ import ts, {
7
7
  GetAccessorDeclaration,
8
8
  SetAccessorDeclaration,
9
9
  ConstructSignatureDeclaration,
10
+ CallSignatureDeclaration,
10
11
  } from 'typescript';
11
12
  import {
12
13
  GetAccessorSchema,
@@ -15,7 +16,7 @@ import {
15
16
  SetAccessorSchema,
16
17
  VariableSchema,
17
18
  } from '@teambit/semantics.entities.semantic-schema';
18
- import { toFunctionLikeSchema } from './to-function-schema';
19
+ import { toFunctionLikeSchema } from './to-function-like-schema';
19
20
  import { SchemaExtractorContext } from '../../schema-extractor-context';
20
21
  import { parseTypeFromQuickInfo } from './parse-type-from-quick-info';
21
22
  import { typeNodeToSchema } from './type-node-to-schema';
@@ -28,7 +29,7 @@ export async function typeElementToSchema(node: TypeElement, context: SchemaExtr
28
29
  case SyntaxKind.ConstructSignature:
29
30
  return toFunctionLikeSchema(node as ConstructSignatureDeclaration, context, 'new');
30
31
  case SyntaxKind.CallSignature:
31
- throw new Error(`CallSignature was not implemented yet`);
32
+ return callSignature(node as CallSignatureDeclaration, context);
32
33
  case SyntaxKind.PropertySignature:
33
34
  return propertySignature(node as ts.PropertySignature, context);
34
35
  case SyntaxKind.IndexSignature:
@@ -48,7 +49,8 @@ async function propertySignature(node: ts.PropertySignature, context: SchemaExtr
48
49
  const displaySig = info?.body?.displayString || '';
49
50
  const typeStr = parseTypeFromQuickInfo(info);
50
51
  const type = await context.resolveType(node, typeStr);
51
- return new VariableSchema(context.getLocation(node), name, displaySig, type);
52
+ const isOptional = Boolean(node.questionToken);
53
+ return new VariableSchema(context.getLocation(node), name, displaySig, type, isOptional);
52
54
  }
53
55
 
54
56
  export async function indexSignature(node: IndexSignatureDeclaration, context: SchemaExtractorContext) {
@@ -70,3 +72,7 @@ export async function setAccessor(node: SetAccessorDeclaration, context: SchemaE
70
72
  const displaySig = await context.getQuickInfoDisplayString(node.name);
71
73
  return new SetAccessorSchema(context.getLocation(node), node.name.getText(), params[0], displaySig);
72
74
  }
75
+
76
+ async function callSignature(node: CallSignatureDeclaration, context: SchemaExtractorContext) {
77
+ return toFunctionLikeSchema(node, context);
78
+ }
@@ -35,6 +35,6 @@ export class VariableDeclaration implements SchemaTransformer {
35
35
  }
36
36
  const typeStr = parseTypeFromQuickInfo(info);
37
37
  const type = await context.resolveType(varDec, typeStr);
38
- return new VariableSchema(location, name, displaySig, type);
38
+ return new VariableSchema(location, name, displaySig, type, false);
39
39
  }
40
40
  }
@@ -1,9 +0,0 @@
1
- import { LiteralTypeNode, Node } from 'typescript';
2
- import { TypeRefSchema } from '@teambit/semantics.entities.semantic-schema';
3
- import { SchemaTransformer } from '../schema-transformer';
4
- import { SchemaExtractorContext } from '../schema-extractor-context';
5
- export declare class LiteralTypeTransformer implements SchemaTransformer {
6
- predicate(node: Node): boolean;
7
- getIdentifiers(): Promise<never[]>;
8
- transform(literalType: LiteralTypeNode, context: SchemaExtractorContext): Promise<TypeRefSchema>;
9
- }
@@ -1,50 +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.LiteralTypeTransformer = 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 _semanticsEntities() {
23
- const data = require("@teambit/semantics.entities.semantic-schema");
24
-
25
- _semanticsEntities = function () {
26
- return data;
27
- };
28
-
29
- return data;
30
- }
31
-
32
- class LiteralTypeTransformer {
33
- predicate(node) {
34
- return node.kind === _typescript().default.SyntaxKind.LiteralType;
35
- }
36
-
37
- async getIdentifiers() {
38
- return [];
39
- }
40
-
41
- async transform(literalType, context) {
42
- const type = literalType.literal.getText();
43
- return new (_semanticsEntities().TypeRefSchema)(context.getLocation(literalType), type);
44
- }
45
-
46
- }
47
-
48
- exports.LiteralTypeTransformer = LiteralTypeTransformer;
49
-
50
- //# sourceMappingURL=literal-type.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["LiteralTypeTransformer","predicate","node","kind","ts","SyntaxKind","LiteralType","getIdentifiers","transform","literalType","context","type","literal","getText","TypeRefSchema","getLocation"],"sources":["literal-type.ts"],"sourcesContent":["import ts, { LiteralTypeNode, Node } from 'typescript';\nimport { TypeRefSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\n\nexport class LiteralTypeTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.LiteralType;\n }\n\n async getIdentifiers() {\n return [];\n }\n\n async transform(literalType: LiteralTypeNode, context: SchemaExtractorContext) {\n const type = literalType.literal.getText();\n return new TypeRefSchema(context.getLocation(literalType), type);\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAIO,MAAMA,sBAAN,CAA0D;EAC/DC,SAAS,CAACC,IAAD,EAAa;IACpB,OAAOA,IAAI,CAACC,IAAL,KAAcC,qBAAA,CAAGC,UAAH,CAAcC,WAAnC;EACD;;EAEmB,MAAdC,cAAc,GAAG;IACrB,OAAO,EAAP;EACD;;EAEc,MAATC,SAAS,CAACC,WAAD,EAA+BC,OAA/B,EAAgE;IAC7E,MAAMC,IAAI,GAAGF,WAAW,CAACG,OAAZ,CAAoBC,OAApB,EAAb;IACA,OAAO,KAAIC,kCAAJ,EAAkBJ,OAAO,CAACK,WAAR,CAAoBN,WAApB,CAAlB,EAAoDE,IAApD,CAAP;EACD;;AAZ8D"}
@@ -1 +0,0 @@
1
- {"version":3,"names":["toFunctionLikeSchema","node","context","funcName","name","getText","info","getQuickInfo","returnTypeStr","parseTypeFromQuickInfo","displaySig","body","displayString","args","getParams","parameters","returnType","resolveType","Boolean","modifiers","map","modifier","location","getLocation","doc","jsDocToDocSchema","FunctionLikeSchema"],"sources":["to-function-schema.ts"],"sourcesContent":["import { SignatureDeclaration } from 'typescript';\nimport { FunctionLikeSchema, Modifier } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaExtractorContext } from '../../schema-extractor-context';\nimport { getParams } from './get-params';\nimport { parseTypeFromQuickInfo } from './parse-type-from-quick-info';\nimport { jsDocToDocSchema } from './jsdoc-to-doc-schema';\n\nexport async function toFunctionLikeSchema(\n node: SignatureDeclaration,\n context: SchemaExtractorContext,\n funcName?: string\n) {\n const name = funcName || node.name?.getText() || '';\n const info = node.name ? await context.getQuickInfo(node.name) : null;\n const returnTypeStr = info ? parseTypeFromQuickInfo(info) : 'any';\n const displaySig = info?.body?.displayString || '';\n const args = await getParams(node.parameters, context);\n const returnType = await context.resolveType(node, returnTypeStr, Boolean(info));\n const modifiers = node.modifiers?.map((modifier) => modifier.getText()) || [];\n const location = context.getLocation(node);\n const doc = await jsDocToDocSchema(node, context);\n return new FunctionLikeSchema(location, name, args, returnType, displaySig, modifiers as Modifier[], doc);\n}\n"],"m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uCAAJ,EAAuBJ,QAAvB,EAAiClB,IAAjC,EAAuCS,IAAvC,EAA6CG,UAA7C,EAAyDN,UAAzD,EAAqES,SAArE,EAA8FK,GAA9F,CAAP;AACD"}
@@ -1,19 +0,0 @@
1
- import ts, { LiteralTypeNode, Node } from 'typescript';
2
- import { TypeRefSchema } from '@teambit/semantics.entities.semantic-schema';
3
- import { SchemaTransformer } from '../schema-transformer';
4
- import { SchemaExtractorContext } from '../schema-extractor-context';
5
-
6
- export class LiteralTypeTransformer implements SchemaTransformer {
7
- predicate(node: Node) {
8
- return node.kind === ts.SyntaxKind.LiteralType;
9
- }
10
-
11
- async getIdentifiers() {
12
- return [];
13
- }
14
-
15
- async transform(literalType: LiteralTypeNode, context: SchemaExtractorContext) {
16
- const type = literalType.literal.getText();
17
- return new TypeRefSchema(context.getLocation(literalType), type);
18
- }
19
- }