@teambit/typescript 0.0.729 → 0.0.732

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 (68) hide show
  1. package/dist/schema-extractor-context.d.ts +6 -4
  2. package/dist/schema-extractor-context.js +83 -25
  3. package/dist/schema-extractor-context.js.map +1 -1
  4. package/dist/transformers/class-deceleration.js +21 -6
  5. package/dist/transformers/class-deceleration.js.map +1 -1
  6. package/dist/transformers/function-declaration.js +4 -3
  7. package/dist/transformers/function-declaration.js.map +1 -1
  8. package/dist/transformers/index-signature.js +11 -1
  9. package/dist/transformers/index-signature.js.map +1 -1
  10. package/dist/transformers/index.d.ts +0 -4
  11. package/dist/transformers/index.js +0 -64
  12. package/dist/transformers/index.js.map +1 -1
  13. package/dist/transformers/method-declaration.js +6 -6
  14. package/dist/transformers/method-declaration.js.map +1 -1
  15. package/dist/transformers/method-signature.js +2 -2
  16. package/dist/transformers/method-signature.js.map +1 -1
  17. package/dist/transformers/property-declaration.js +2 -3
  18. package/dist/transformers/property-declaration.js.map +1 -1
  19. package/dist/transformers/property-signature.js +3 -4
  20. package/dist/transformers/property-signature.js.map +1 -1
  21. package/dist/transformers/type-alias.js +11 -2
  22. package/dist/transformers/type-alias.js.map +1 -1
  23. package/dist/transformers/utils/get-params.d.ts +2 -2
  24. package/dist/transformers/utils/get-params.js +14 -12
  25. package/dist/transformers/utils/get-params.js.map +1 -1
  26. package/dist/transformers/utils/parse-type-from-quick-info.d.ts +35 -2
  27. package/dist/transformers/utils/parse-type-from-quick-info.js +93 -7
  28. package/dist/transformers/utils/parse-type-from-quick-info.js.map +1 -1
  29. package/dist/transformers/utils/type-node-to-schema.d.ts +4 -0
  30. package/dist/transformers/utils/type-node-to-schema.js +251 -0
  31. package/dist/transformers/utils/type-node-to-schema.js.map +1 -0
  32. package/dist/transformers/variable-declaration.js +2 -2
  33. package/dist/transformers/variable-declaration.js.map +1 -1
  34. package/dist/typescript.main.runtime.js +1 -1
  35. package/dist/typescript.main.runtime.js.map +1 -1
  36. package/package-tar/teambit-typescript-0.0.732.tgz +0 -0
  37. package/package.json +15 -15
  38. package/{preview-1652239597845.js → preview-1652671504464.js} +2 -2
  39. package/transformers/class-deceleration.ts +8 -4
  40. package/transformers/function-declaration.ts +4 -3
  41. package/transformers/index-signature.ts +2 -1
  42. package/transformers/index.ts +0 -4
  43. package/transformers/method-declaration.ts +6 -6
  44. package/transformers/method-signature.ts +2 -2
  45. package/transformers/property-declaration.ts +2 -3
  46. package/transformers/property-signature.ts +3 -4
  47. package/transformers/type-alias.ts +3 -3
  48. package/transformers/utils/get-params.ts +11 -12
  49. package/transformers/utils/parse-type-from-quick-info.ts +79 -7
  50. package/transformers/utils/type-node-to-schema.ts +205 -0
  51. package/transformers/variable-declaration.ts +2 -2
  52. package/dist/transformers/type-intersection.d.ts +0 -9
  53. package/dist/transformers/type-intersection.js +0 -63
  54. package/dist/transformers/type-intersection.js.map +0 -1
  55. package/dist/transformers/type-literal.d.ts +0 -14
  56. package/dist/transformers/type-literal.js +0 -67
  57. package/dist/transformers/type-literal.js.map +0 -1
  58. package/dist/transformers/type-reference.d.ts +0 -8
  59. package/dist/transformers/type-reference.js +0 -41
  60. package/dist/transformers/type-reference.js.map +0 -1
  61. package/dist/transformers/type-union.d.ts +0 -9
  62. package/dist/transformers/type-union.js +0 -63
  63. package/dist/transformers/type-union.js.map +0 -1
  64. package/package-tar/teambit-typescript-0.0.729.tgz +0 -0
  65. package/transformers/type-intersection.ts +0 -23
  66. package/transformers/type-literal.ts +0 -28
  67. package/transformers/type-reference.ts +0 -19
  68. package/transformers/type-union.ts +0 -23
@@ -20,10 +20,9 @@ export class PropertyDeclaration implements SchemaTransformer {
20
20
 
21
21
  async transform(propertyDec: PropertyDeclarationNode, context: SchemaExtractorContext): Promise<SchemaNode> {
22
22
  const name = this.getName(propertyDec);
23
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
24
- const info = await context.getQuickInfo(propertyDec.name!);
23
+ const info = await context.getQuickInfo(propertyDec.name);
25
24
  const displaySig = info?.body?.displayString;
26
- const typeStr = parseTypeFromQuickInfo(displaySig);
25
+ const typeStr = parseTypeFromQuickInfo(info);
27
26
  const type = await context.resolveType(propertyDec, typeStr);
28
27
 
29
28
  return new VariableSchema(name || '', displaySig || '', type);
@@ -20,18 +20,17 @@ export class PropertySignature implements SchemaTransformer {
20
20
 
21
21
  async transform(prop: PropertySignatureNode, context: SchemaExtractorContext): Promise<SchemaNode> {
22
22
  const name = this.getName(prop);
23
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
24
- const info = await context.getQuickInfo(prop.name!);
23
+ const info = await context.getQuickInfo(prop.name);
25
24
  const displaySig = info?.body?.displayString || '';
26
25
  if (prop.type?.kind === ts.SyntaxKind.FunctionType) {
27
26
  // e.g. `propertySig: () => void;` inside interface
28
27
  const propType = prop.type as FunctionTypeNode;
29
28
  const args = await getParams(propType.parameters, context);
30
- const typeStr = parseReturnTypeFromQuickInfo(displaySig);
29
+ const typeStr = parseReturnTypeFromQuickInfo(info);
31
30
  const returnType = await context.resolveType(propType, typeStr);
32
31
  return new FunctionSchema(name, args, returnType, displaySig);
33
32
  }
34
- const typeStr = parseTypeFromQuickInfo(displaySig);
33
+ const typeStr = parseTypeFromQuickInfo(info);
35
34
  const type = await context.resolveType(prop, typeStr);
36
35
  return new VariableSchema(name, displaySig, type);
37
36
  }
@@ -3,6 +3,7 @@ import { TypeSchema } from '@teambit/semantics.entities.semantic-schema';
3
3
  import { SchemaTransformer } from '../schema-transformer';
4
4
  import { SchemaExtractorContext } from '../schema-extractor-context';
5
5
  import { ExportIdentifier } from '../export-identifier';
6
+ import { typeNodeToSchema } from './utils/type-node-to-schema';
6
7
 
7
8
  export class TypeAliasTransformer implements SchemaTransformer {
8
9
  predicate(node: Node) {
@@ -18,10 +19,9 @@ export class TypeAliasTransformer implements SchemaTransformer {
18
19
  }
19
20
 
20
21
  async transform(typeAlias: TypeAliasDeclaration, context: SchemaExtractorContext) {
21
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
22
- const info = await context.getQuickInfo(typeAlias.name!);
22
+ const type = await typeNodeToSchema(typeAlias.type, context);
23
+ const info = await context.getQuickInfo(typeAlias.name);
23
24
  const displaySig = info?.body?.displayString;
24
- const type = await context.computeSchema(typeAlias.type);
25
25
  return new TypeSchema(this.getName(typeAlias), type, displaySig as string);
26
26
  }
27
27
  }
@@ -1,30 +1,29 @@
1
- import { Parameter, TypeRefSchema } from '@teambit/semantics.entities.semantic-schema';
1
+ import { ParameterSchema, SchemaNode, TypeRefSchema } from '@teambit/semantics.entities.semantic-schema';
2
2
  import pMapSeries from 'p-map-series';
3
3
  import { ParameterDeclaration, NodeArray } from 'typescript';
4
4
  import { SchemaExtractorContext } from '../../schema-extractor-context';
5
5
  import { parseTypeFromQuickInfo } from './parse-type-from-quick-info';
6
+ import { typeNodeToSchema } from './type-node-to-schema';
6
7
 
7
8
  export async function getParams(
8
9
  parameterNodes: NodeArray<ParameterDeclaration>,
9
10
  context: SchemaExtractorContext
10
- ): Promise<Parameter[]> {
11
+ ): Promise<ParameterSchema[]> {
11
12
  return pMapSeries(parameterNodes, async (param) => {
12
- return {
13
- name: param.name.getText(),
14
- type: await getParamType(param, context),
15
- defaultValue: param.initializer ? param.initializer.getText() : undefined,
16
- };
13
+ return new ParameterSchema(
14
+ param.name.getText(),
15
+ await getParamType(param, context),
16
+ param.initializer ? param.initializer.getText() : undefined
17
+ );
17
18
  });
18
19
  }
19
20
 
20
- async function getParamType(param: ParameterDeclaration, context: SchemaExtractorContext): Promise<TypeRefSchema> {
21
+ async function getParamType(param: ParameterDeclaration, context: SchemaExtractorContext): Promise<SchemaNode> {
21
22
  if (param.type) {
22
23
  const type = param.type;
23
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
24
- return context.resolveType(type!, type?.getText() || 'any');
24
+ return typeNodeToSchema(type, context);
25
25
  }
26
26
  const info = await context.getQuickInfo(param.name);
27
- const displaySig = info?.body?.displayString;
28
- const parsed = parseTypeFromQuickInfo(displaySig);
27
+ const parsed = parseTypeFromQuickInfo(info);
29
28
  return new TypeRefSchema(parsed || 'any');
30
29
  }
@@ -1,12 +1,84 @@
1
- export function parseTypeFromQuickInfo(displayString?: string) {
2
- if (!displayString) return '';
3
- const array = displayString.split(':');
4
- return array[array.length - 1].trim();
1
+ // eslint-disable-next-line import/no-unresolved
2
+ import protocol from 'typescript/lib/protocol';
3
+
4
+ /**
5
+ * try to parse the type from the quickinfo.
6
+ * this is an error-prone process, we do our best here.
7
+ *
8
+ * an example of a function with many ":"
9
+ * `export function getObj(a: string, func: (b: number) => {}) { return { a: 1, b: 2 } };`
10
+ * which produce the following quickinfo:
11
+ * ```ts
12
+ * function getObj(a: string, func: (b: number) => {}): {
13
+ * a: number;
14
+ * b: number;
15
+ * }
16
+ * ```
17
+ *
18
+ * some examples of quickinfo:
19
+ *
20
+ * function ts.signatureToDisplayParts(typechecker: TypeChecker, signature: Signature, enclosingDeclaration?: Node | undefined, flags?: TypeFormatFlags): SymbolDisplayPart[]
21
+ *
22
+ * const enum ts.TypeFormatFlags
23
+ *
24
+ * (method) ts.TypeChecker.writeSignature(signature: Signature, enclosingDeclaration?: Node | undefined, flags?: TypeFormatFlags | undefined, kind?: SignatureKind | undefined, writer?: EmitTextWriter | undefined): string
25
+ *
26
+ * const obj: {
27
+ * a: number;
28
+ * b: number;
29
+ * }
30
+ *
31
+ * function getObj(a: string): {
32
+ * a: number;
33
+ * b: number;
34
+ * }
35
+ */
36
+ export function parseTypeFromQuickInfo(quickInfo: protocol.QuickInfoResponse | undefined): string {
37
+ if (!quickInfo?.body?.displayString) return '';
38
+ const displayString = quickInfo.body.displayString;
39
+ const splitByColon = displayString.split(':');
40
+ switch (quickInfo.body.kind) {
41
+ case 'const':
42
+ case 'property':
43
+ case 'let':
44
+ case 'var': {
45
+ const [, ...tail] = splitByColon;
46
+ return tail.join(':').trim();
47
+ }
48
+ case 'method':
49
+ case 'function': {
50
+ const split = displayString.split('): ');
51
+ if (split.length !== 2) {
52
+ throw new Error(`quickinfo of a function below was not implemented.\n${displayString}`);
53
+ }
54
+ return split[1].trim();
55
+ }
56
+ case 'alias': {
57
+ // e.g. (alias) class BuilderService\nimport BuilderService
58
+ // e.g. '(alias) type Serializable = {\n' +
59
+ // ' toString(): string;\n' +
60
+ // '}\n' +
61
+ // 'import Serializable'
62
+ const firstLine = displayString.split('\n')[0];
63
+ const splitBySpace = firstLine.trim().split(' ');
64
+ // first two are alias keyword and alias type
65
+ const [, , typeName] = splitBySpace;
66
+ return typeName;
67
+ }
68
+ case 'type': {
69
+ // e.g. `type TaskSlot = SlotRegistry<BuildTask[]>`
70
+ const splitByEqual = displayString.split('=');
71
+ const [, ...tail] = splitByEqual;
72
+ return tail.join('=').trim();
73
+ }
74
+ default:
75
+ return splitByColon[splitByColon.length - 1].trim();
76
+ }
5
77
  }
6
78
 
7
- export function parseReturnTypeFromQuickInfo(displayString?: string) {
8
- if (!displayString) return '';
9
- const typeStr = parseTypeFromQuickInfo(displayString);
79
+ export function parseReturnTypeFromQuickInfo(quickInfo: protocol.QuickInfoResponse | undefined): string {
80
+ if (!quickInfo) return '';
81
+ const typeStr = parseTypeFromQuickInfo(quickInfo);
10
82
  const array = typeStr.split('=>');
11
83
  return array[array.length - 1].trim();
12
84
  }
@@ -0,0 +1,205 @@
1
+ import {
2
+ TypeNode,
3
+ SyntaxKind,
4
+ KeywordTypeNode,
5
+ FunctionTypeNode,
6
+ TypeQueryNode,
7
+ TypeReferenceNode,
8
+ ArrayTypeNode,
9
+ TypeOperatorNode,
10
+ TupleTypeNode,
11
+ IntersectionTypeNode,
12
+ UnionTypeNode,
13
+ TypeLiteralNode,
14
+ } from 'typescript';
15
+ import {
16
+ SchemaNode,
17
+ TypeIntersectionSchema,
18
+ TypeUnionSchema,
19
+ TypeLiteralSchema,
20
+ FunctionSchema,
21
+ TypeQuerySchema,
22
+ LiteralTypeSchema,
23
+ KeywordTypeSchema,
24
+ TypeArraySchema,
25
+ TypeOperatorSchema,
26
+ TupleTypeSchema,
27
+ } from '@teambit/semantics.entities.semantic-schema';
28
+ import pMapSeries from 'p-map-series';
29
+ import { SchemaExtractorContext } from '../../schema-extractor-context';
30
+ import { getParams } from './get-params';
31
+
32
+ // eslint-disable-next-line complexity
33
+ export async function typeNodeToSchema(node: TypeNode, context: SchemaExtractorContext): Promise<SchemaNode> {
34
+ if (isKeywordType(node)) {
35
+ return new KeywordTypeSchema(node.getText());
36
+ }
37
+ switch (node.kind) {
38
+ case SyntaxKind.IntersectionType:
39
+ return intersectionType(node as IntersectionTypeNode, context);
40
+ case SyntaxKind.UnionType:
41
+ return unionType(node as UnionTypeNode, context);
42
+ case SyntaxKind.TypeReference:
43
+ return typeReference(node as TypeReferenceNode, context);
44
+ case SyntaxKind.TypeLiteral:
45
+ return typeLiteral(node as TypeLiteralNode, context);
46
+ case SyntaxKind.LiteralType: // e.g. string/boolean
47
+ return new LiteralTypeSchema(node.getText());
48
+ case SyntaxKind.FunctionType:
49
+ return functionType(node as FunctionTypeNode, context);
50
+ case SyntaxKind.TypeQuery:
51
+ return typeQuery(node as TypeQueryNode, context);
52
+ case SyntaxKind.ArrayType:
53
+ return arrayType(node as ArrayTypeNode, context);
54
+ case SyntaxKind.TypeOperator:
55
+ return typeOperator(node as TypeOperatorNode, context);
56
+ case SyntaxKind.TupleType:
57
+ return tupleType(node as TupleTypeNode, context);
58
+ case SyntaxKind.TypePredicate:
59
+ case SyntaxKind.ConstructorType:
60
+ case SyntaxKind.NamedTupleMember:
61
+ case SyntaxKind.OptionalType:
62
+ case SyntaxKind.RestType:
63
+ case SyntaxKind.ConditionalType:
64
+ case SyntaxKind.InferType:
65
+ case SyntaxKind.ParenthesizedType:
66
+ case SyntaxKind.ThisType:
67
+ case SyntaxKind.IndexedAccessType:
68
+ case SyntaxKind.MappedType:
69
+ case SyntaxKind.TemplateLiteralType:
70
+ case SyntaxKind.TemplateLiteralTypeSpan:
71
+ case SyntaxKind.ImportType:
72
+ case SyntaxKind.ExpressionWithTypeArguments:
73
+ case SyntaxKind.JSDocTypeExpression:
74
+ case SyntaxKind.JSDocAllType:
75
+ case SyntaxKind.JSDocUnknownType:
76
+ case SyntaxKind.JSDocNonNullableType:
77
+ case SyntaxKind.JSDocNullableType:
78
+ case SyntaxKind.JSDocOptionalType:
79
+ case SyntaxKind.JSDocFunctionType:
80
+ case SyntaxKind.JSDocVariadicType:
81
+ case SyntaxKind.JSDocNamepathType:
82
+ case SyntaxKind.JSDocSignature:
83
+ case SyntaxKind.JSDocTypeLiteral:
84
+ throw new Error(`TypeNode "${SyntaxKind[node.kind]}" was not implemented yet.
85
+ context: ${node.getText()}`);
86
+ default:
87
+ throw new Error(`Node "${SyntaxKind[node.kind]}" is not a TypeNode.
88
+ context: ${node.getText()}`);
89
+ }
90
+ }
91
+
92
+ /**
93
+ * whether it's kind of `ts.KeywordTypeSyntaxKind`
94
+ */
95
+ function isKeywordType(node: TypeNode): node is KeywordTypeNode {
96
+ switch (node.kind) {
97
+ case SyntaxKind.AnyKeyword:
98
+ case SyntaxKind.BigIntKeyword:
99
+ case SyntaxKind.BooleanKeyword:
100
+ case SyntaxKind.IntrinsicKeyword:
101
+ case SyntaxKind.NeverKeyword:
102
+ case SyntaxKind.NumberKeyword:
103
+ case SyntaxKind.ObjectKeyword:
104
+ case SyntaxKind.StringKeyword:
105
+ case SyntaxKind.SymbolKeyword:
106
+ case SyntaxKind.UndefinedKeyword:
107
+ case SyntaxKind.UnknownKeyword:
108
+ case SyntaxKind.VoidKeyword:
109
+ return true;
110
+ default:
111
+ return false;
112
+ }
113
+ }
114
+
115
+ async function intersectionType(node: IntersectionTypeNode, context: SchemaExtractorContext) {
116
+ const types = await pMapSeries(node.types, async (type) => {
117
+ const typeSchema = await typeNodeToSchema(type, context);
118
+ return typeSchema;
119
+ });
120
+ return new TypeIntersectionSchema(types);
121
+ }
122
+
123
+ async function unionType(node: UnionTypeNode, context: SchemaExtractorContext) {
124
+ const types = await pMapSeries(node.types, async (type) => {
125
+ const typeSchema = await typeNodeToSchema(type, context);
126
+ return typeSchema;
127
+ });
128
+ return new TypeUnionSchema(types);
129
+ }
130
+
131
+ /**
132
+ * not to be confused with "LiteralType", which is string/boolean/null.
133
+ * this "TypeLiteral" is an object with properties, such as: `{ a: string; b: number }`, similar to Interface.
134
+ */
135
+ async function typeLiteral(node: TypeLiteralNode, context: SchemaExtractorContext) {
136
+ const members = await pMapSeries(node.members, async (member) => {
137
+ const typeSchema = await context.computeSchema(member);
138
+ return typeSchema;
139
+ });
140
+ return new TypeLiteralSchema(members);
141
+ }
142
+
143
+ /**
144
+ * In the following example, `AriaButtonProps` is a type reference
145
+ * ```ts
146
+ * import type { AriaButtonProps } from '@react-types/button';
147
+ * export type ButtonProps = AriaButtonProps & { a: string };
148
+ * ```
149
+ */
150
+ async function typeReference(node: TypeReferenceNode, context: SchemaExtractorContext) {
151
+ const name = node.typeName.getText();
152
+ const type = await context.resolveType(node, name, false);
153
+ return type;
154
+ }
155
+
156
+ async function functionType(node: FunctionTypeNode, context: SchemaExtractorContext): Promise<SchemaNode> {
157
+ const name = node.name?.getText() || '';
158
+ const params = await getParams(node.parameters, context);
159
+ const returnType = await typeNodeToSchema(node.type, context);
160
+ return new FunctionSchema(name, params, returnType, '');
161
+ }
162
+
163
+ /**
164
+ * e.g. `typeof Foo`
165
+ */
166
+ async function typeQuery(node: TypeQueryNode, context: SchemaExtractorContext) {
167
+ const displaySig = await context.getQuickInfoDisplayString(node.exprName);
168
+ const type = await context.resolveType(node.exprName, node.exprName.getText(), false);
169
+ return new TypeQuerySchema(type, displaySig);
170
+ }
171
+
172
+ async function arrayType(node: ArrayTypeNode, context: SchemaExtractorContext) {
173
+ const type = await typeNodeToSchema(node.elementType, context);
174
+ return new TypeArraySchema(type);
175
+ }
176
+
177
+ /**
178
+ * e.g. keyof typeof Foo
179
+ */
180
+ async function typeOperator(node: TypeOperatorNode, context: SchemaExtractorContext) {
181
+ const operatorName = getOperatorName(node.operator);
182
+ const type = await typeNodeToSchema(node.type, context);
183
+ return new TypeOperatorSchema(operatorName, type);
184
+ }
185
+
186
+ function getOperatorName(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword) {
187
+ switch (operator) {
188
+ case SyntaxKind.KeyOfKeyword:
189
+ return 'keyof';
190
+ case SyntaxKind.UniqueKeyword:
191
+ return 'unique';
192
+ case SyntaxKind.ReadonlyKeyword:
193
+ return 'readonly';
194
+ default:
195
+ throw new Error(`getOperatorName: unable to find operator name for ${operator}`);
196
+ }
197
+ }
198
+
199
+ async function tupleType(node: TupleTypeNode, context: SchemaExtractorContext) {
200
+ const elements = await pMapSeries(node.elements, async (elem) => {
201
+ const typeSchema = await typeNodeToSchema(elem, context);
202
+ return typeSchema;
203
+ });
204
+ return new TupleTypeSchema(elements);
205
+ }
@@ -25,11 +25,11 @@ export class VariableDeclaration implements SchemaTransformer {
25
25
  const displaySig = info?.body?.displayString || '';
26
26
  if (varDec.initializer?.kind === ts.SyntaxKind.ArrowFunction) {
27
27
  const args = await getParams((varDec.initializer as ArrowFunction).parameters, context);
28
- const typeStr = parseReturnTypeFromQuickInfo(displaySig);
28
+ const typeStr = parseReturnTypeFromQuickInfo(info);
29
29
  const returnType = await context.resolveType(varDec, typeStr);
30
30
  return new FunctionSchema(name, args, returnType, displaySig);
31
31
  }
32
- const typeStr = parseTypeFromQuickInfo(displaySig);
32
+ const typeStr = parseTypeFromQuickInfo(info);
33
33
  const type = await context.resolveType(varDec, typeStr);
34
34
  return new VariableSchema(name, displaySig, type);
35
35
  }
@@ -1,9 +0,0 @@
1
- import { Node, IntersectionTypeNode } from 'typescript';
2
- import { TypeIntersectionSchema } from '@teambit/semantics.entities.semantic-schema';
3
- import { SchemaTransformer } from '../schema-transformer';
4
- import { SchemaExtractorContext } from '../schema-extractor-context';
5
- export declare class TypeIntersectionTransformer implements SchemaTransformer {
6
- predicate(node: Node): boolean;
7
- getIdentifiers(): Promise<never[]>;
8
- transform(intersectionType: IntersectionTypeNode, context: SchemaExtractorContext): Promise<TypeIntersectionSchema>;
9
- }
@@ -1,63 +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.TypeIntersectionTransformer = void 0;
11
-
12
- function _typescript() {
13
- const data = _interopRequireDefault(require("typescript"));
14
-
15
- _typescript = function () {
16
- return data;
17
- };
18
-
19
- return data;
20
- }
21
-
22
- function _pMapSeries() {
23
- const data = _interopRequireDefault(require("p-map-series"));
24
-
25
- _pMapSeries = function () {
26
- return data;
27
- };
28
-
29
- return data;
30
- }
31
-
32
- function _semanticsEntities() {
33
- const data = require("@teambit/semantics.entities.semantic-schema");
34
-
35
- _semanticsEntities = function () {
36
- return data;
37
- };
38
-
39
- return data;
40
- }
41
-
42
- class TypeIntersectionTransformer {
43
- predicate(node) {
44
- return node.kind === _typescript().default.SyntaxKind.IntersectionType;
45
- }
46
-
47
- async getIdentifiers() {
48
- return [];
49
- }
50
-
51
- async transform(intersectionType, context) {
52
- const types = await (0, _pMapSeries().default)(intersectionType.types, async type => {
53
- const typeSchema = await context.computeSchema(type);
54
- return typeSchema;
55
- });
56
- return new (_semanticsEntities().TypeIntersectionSchema)(types);
57
- }
58
-
59
- }
60
-
61
- exports.TypeIntersectionTransformer = TypeIntersectionTransformer;
62
-
63
- //# sourceMappingURL=type-intersection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["type-intersection.ts"],"names":["TypeIntersectionTransformer","predicate","node","kind","ts","SyntaxKind","IntersectionType","getIdentifiers","transform","intersectionType","context","types","type","typeSchema","computeSchema","TypeIntersectionSchema"],"mappings":";;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAIO,MAAMA,2BAAN,CAA+D;AACpEC,EAAAA,SAAS,CAACC,IAAD,EAAa;AACpB,WAAOA,IAAI,CAACC,IAAL,KAAcC,sBAAGC,UAAH,CAAcC,gBAAnC;AACD;;AAEmB,QAAdC,cAAc,GAAG;AACrB,WAAO,EAAP;AACD;;AAEc,QAATC,SAAS,CAACC,gBAAD,EAAyCC,OAAzC,EAA0E;AACvF,UAAMC,KAAK,GAAG,MAAM,2BAAWF,gBAAgB,CAACE,KAA5B,EAAmC,MAAOC,IAAP,IAAgB;AACrE,YAAMC,UAAU,GAAG,MAAMH,OAAO,CAACI,aAAR,CAAsBF,IAAtB,CAAzB;AACA,aAAOC,UAAP;AACD,KAHmB,CAApB;AAIA,WAAO,KAAIE,2CAAJ,EAA2BJ,KAA3B,CAAP;AACD;;AAfmE","sourcesContent":["import ts, { Node, IntersectionTypeNode } from 'typescript';\nimport pMapSeries from 'p-map-series';\nimport { TypeIntersectionSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\n\nexport class TypeIntersectionTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.IntersectionType;\n }\n\n async getIdentifiers() {\n return [];\n }\n\n async transform(intersectionType: IntersectionTypeNode, context: SchemaExtractorContext) {\n const types = await pMapSeries(intersectionType.types, async (type) => {\n const typeSchema = await context.computeSchema(type);\n return typeSchema;\n });\n return new TypeIntersectionSchema(types);\n }\n}\n"]}
@@ -1,14 +0,0 @@
1
- import { Node, TypeLiteralNode } from 'typescript';
2
- import { TypeLiteralSchema } from '@teambit/semantics.entities.semantic-schema';
3
- import { SchemaTransformer } from '../schema-transformer';
4
- import { SchemaExtractorContext } from '../schema-extractor-context';
5
- import { ExportIdentifier } from '../export-identifier';
6
- /**
7
- * not to be confused with "LiteralType", which is string/boolean/null.
8
- * this "TypeLiteral" is an object with properties, such as: `{ a: string; b: number }`, similar to Interface.
9
- */
10
- export declare class TypeLiteralTransformer implements SchemaTransformer {
11
- predicate(node: Node): boolean;
12
- getIdentifiers(): Promise<ExportIdentifier[]>;
13
- transform(typeLiteral: TypeLiteralNode, context: SchemaExtractorContext): Promise<TypeLiteralSchema>;
14
- }
@@ -1,67 +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.TypeLiteralTransformer = void 0;
11
-
12
- function _typescript() {
13
- const data = _interopRequireDefault(require("typescript"));
14
-
15
- _typescript = function () {
16
- return data;
17
- };
18
-
19
- return data;
20
- }
21
-
22
- function _pMapSeries() {
23
- const data = _interopRequireDefault(require("p-map-series"));
24
-
25
- _pMapSeries = function () {
26
- return data;
27
- };
28
-
29
- return data;
30
- }
31
-
32
- function _semanticsEntities() {
33
- const data = require("@teambit/semantics.entities.semantic-schema");
34
-
35
- _semanticsEntities = function () {
36
- return data;
37
- };
38
-
39
- return data;
40
- }
41
-
42
- /**
43
- * not to be confused with "LiteralType", which is string/boolean/null.
44
- * this "TypeLiteral" is an object with properties, such as: `{ a: string; b: number }`, similar to Interface.
45
- */
46
- class TypeLiteralTransformer {
47
- predicate(node) {
48
- return node.kind === _typescript().default.SyntaxKind.TypeLiteral;
49
- }
50
-
51
- async getIdentifiers() {
52
- return [];
53
- }
54
-
55
- async transform(typeLiteral, context) {
56
- const members = await (0, _pMapSeries().default)(typeLiteral.members, async member => {
57
- const typeSchema = await context.computeSchema(member);
58
- return typeSchema;
59
- });
60
- return new (_semanticsEntities().TypeLiteralSchema)(members);
61
- }
62
-
63
- }
64
-
65
- exports.TypeLiteralTransformer = TypeLiteralTransformer;
66
-
67
- //# sourceMappingURL=type-literal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["type-literal.ts"],"names":["TypeLiteralTransformer","predicate","node","kind","ts","SyntaxKind","TypeLiteral","getIdentifiers","transform","typeLiteral","context","members","member","typeSchema","computeSchema","TypeLiteralSchema"],"mappings":";;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAKA;AACA;AACA;AACA;AACO,MAAMA,sBAAN,CAA0D;AAC/DC,EAAAA,SAAS,CAACC,IAAD,EAAa;AACpB,WAAOA,IAAI,CAACC,IAAL,KAAcC,sBAAGC,UAAH,CAAcC,WAAnC;AACD;;AAEmB,QAAdC,cAAc,GAAgC;AAClD,WAAO,EAAP;AACD;;AAEc,QAATC,SAAS,CAACC,WAAD,EAA+BC,OAA/B,EAAgE;AAC7E,UAAMC,OAAO,GAAG,MAAM,2BAAWF,WAAW,CAACE,OAAvB,EAAgC,MAAOC,MAAP,IAAkB;AACtE,YAAMC,UAAU,GAAG,MAAMH,OAAO,CAACI,aAAR,CAAsBF,MAAtB,CAAzB;AACA,aAAOC,UAAP;AACD,KAHqB,CAAtB;AAIA,WAAO,KAAIE,sCAAJ,EAAsBJ,OAAtB,CAAP;AACD;;AAf8D","sourcesContent":["import ts, { Node, TypeLiteralNode } from 'typescript';\nimport pMapSeries from 'p-map-series';\nimport { TypeLiteralSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\n\n/**\n * not to be confused with \"LiteralType\", which is string/boolean/null.\n * this \"TypeLiteral\" is an object with properties, such as: `{ a: string; b: number }`, similar to Interface.\n */\nexport class TypeLiteralTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.TypeLiteral;\n }\n\n async getIdentifiers(): Promise<ExportIdentifier[]> {\n return [];\n }\n\n async transform(typeLiteral: TypeLiteralNode, context: SchemaExtractorContext) {\n const members = await pMapSeries(typeLiteral.members, async (member) => {\n const typeSchema = await context.computeSchema(member);\n return typeSchema;\n });\n return new TypeLiteralSchema(members);\n }\n}\n"]}
@@ -1,8 +0,0 @@
1
- import { Node, TypeReferenceNode } from 'typescript';
2
- import { SchemaTransformer } from '../schema-transformer';
3
- import { SchemaExtractorContext } from '../schema-extractor-context';
4
- export declare class TypeReferenceTransformer implements SchemaTransformer {
5
- predicate(node: Node): boolean;
6
- getIdentifiers(): Promise<never[]>;
7
- transform(typeReference: TypeReferenceNode, context: SchemaExtractorContext): Promise<import("@teambit/semantics.entities.semantic-schema").TypeRefSchema>;
8
- }
@@ -1,41 +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.TypeReferenceTransformer = void 0;
11
-
12
- function _typescript() {
13
- const data = _interopRequireDefault(require("typescript"));
14
-
15
- _typescript = function () {
16
- return data;
17
- };
18
-
19
- return data;
20
- }
21
-
22
- class TypeReferenceTransformer {
23
- predicate(node) {
24
- return node.kind === _typescript().default.SyntaxKind.TypeReference;
25
- }
26
-
27
- async getIdentifiers() {
28
- return [];
29
- }
30
-
31
- async transform(typeReference, context) {
32
- const name = typeReference.typeName.getText();
33
- const type = await context.resolveType(typeReference, name);
34
- return type;
35
- }
36
-
37
- }
38
-
39
- exports.TypeReferenceTransformer = TypeReferenceTransformer;
40
-
41
- //# sourceMappingURL=type-reference.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["type-reference.ts"],"names":["TypeReferenceTransformer","predicate","node","kind","ts","SyntaxKind","TypeReference","getIdentifiers","transform","typeReference","context","name","typeName","getText","type","resolveType"],"mappings":";;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAIO,MAAMA,wBAAN,CAA4D;AACjEC,EAAAA,SAAS,CAACC,IAAD,EAAa;AACpB,WAAOA,IAAI,CAACC,IAAL,KAAcC,sBAAGC,UAAH,CAAcC,aAAnC;AACD;;AAEmB,QAAdC,cAAc,GAAG;AACrB,WAAO,EAAP;AACD;;AAEc,QAATC,SAAS,CAACC,aAAD,EAAmCC,OAAnC,EAAoE;AACjF,UAAMC,IAAI,GAAGF,aAAa,CAACG,QAAd,CAAuBC,OAAvB,EAAb;AACA,UAAMC,IAAI,GAAG,MAAMJ,OAAO,CAACK,WAAR,CAAoBN,aAApB,EAAmCE,IAAnC,CAAnB;AACA,WAAOG,IAAP;AACD;;AAbgE","sourcesContent":["import ts, { Node, TypeReferenceNode } from 'typescript';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\n\nexport class TypeReferenceTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.TypeReference;\n }\n\n async getIdentifiers() {\n return [];\n }\n\n async transform(typeReference: TypeReferenceNode, context: SchemaExtractorContext) {\n const name = typeReference.typeName.getText();\n const type = await context.resolveType(typeReference, name);\n return type;\n }\n}\n"]}
@@ -1,9 +0,0 @@
1
- import { Node, UnionTypeNode } from 'typescript';
2
- import { TypeUnionSchema } from '@teambit/semantics.entities.semantic-schema';
3
- import { SchemaTransformer } from '../schema-transformer';
4
- import { SchemaExtractorContext } from '../schema-extractor-context';
5
- export declare class TypeUnionTransformer implements SchemaTransformer {
6
- predicate(node: Node): boolean;
7
- getIdentifiers(): Promise<never[]>;
8
- transform(unionType: UnionTypeNode, context: SchemaExtractorContext): Promise<TypeUnionSchema>;
9
- }