@teambit/typescript 0.0.0-004aea01bc027e428dfd0f6583f49a1b8286bdd0
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/cmds/check-types.cmd.ts +81 -0
- package/dist/cmds/check-types.cmd.d.ts +35 -0
- package/dist/cmds/check-types.cmd.js +105 -0
- package/dist/cmds/check-types.cmd.js.map +1 -0
- package/dist/compiler-options.d.ts +22 -0
- package/dist/compiler-options.js +3 -0
- package/dist/compiler-options.js.map +1 -0
- package/dist/esm.mjs +21 -0
- package/dist/exceptions/index.d.ts +1 -0
- package/dist/exceptions/index.js +20 -0
- package/dist/exceptions/index.js.map +1 -0
- package/dist/exceptions/transformer-not-found.d.ts +8 -0
- package/dist/exceptions/transformer-not-found.js +26 -0
- package/dist/exceptions/transformer-not-found.js.map +1 -0
- package/dist/export-identifier.d.ts +6 -0
- package/dist/export-identifier.js +29 -0
- package/dist/export-identifier.js.map +1 -0
- package/dist/extractor-options.d.ts +26 -0
- package/dist/extractor-options.js +3 -0
- package/dist/extractor-options.js.map +1 -0
- 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 +11 -0
- package/dist/identifier.js +45 -0
- package/dist/identifier.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +91 -0
- package/dist/index.js.map +1 -0
- package/dist/preview-1760469561956.js +7 -0
- package/dist/remove-types-task.d.ts +12 -0
- package/dist/remove-types-task.js +64 -0
- package/dist/remove-types-task.js.map +1 -0
- package/dist/schema-extractor-context.d.ts +164 -0
- package/dist/schema-extractor-context.js +745 -0
- package/dist/schema-extractor-context.js.map +1 -0
- package/dist/schema-transformer.d.ts +19 -0
- package/dist/schema-transformer.js +3 -0
- package/dist/schema-transformer.js.map +1 -0
- package/dist/schema-transformer.plugin.d.ts +9 -0
- package/dist/schema-transformer.plugin.js +22 -0
- package/dist/schema-transformer.plugin.js.map +1 -0
- package/dist/sourceFileTransformers/class.d.ts +2 -0
- package/dist/sourceFileTransformers/class.js +57 -0
- package/dist/sourceFileTransformers/class.js.map +1 -0
- package/dist/sourceFileTransformers/empty-line-encoder.d.ts +14 -0
- package/dist/sourceFileTransformers/empty-line-encoder.js +62 -0
- package/dist/sourceFileTransformers/empty-line-encoder.js.map +1 -0
- package/dist/sourceFileTransformers/export.d.ts +2 -0
- package/dist/sourceFileTransformers/export.js +58 -0
- package/dist/sourceFileTransformers/export.js.map +1 -0
- package/dist/sourceFileTransformers/expression-statement.d.ts +2 -0
- package/dist/sourceFileTransformers/expression-statement.js +58 -0
- package/dist/sourceFileTransformers/expression-statement.js.map +1 -0
- package/dist/sourceFileTransformers/function.d.ts +2 -0
- package/dist/sourceFileTransformers/function.js +119 -0
- package/dist/sourceFileTransformers/function.js.map +1 -0
- package/dist/sourceFileTransformers/import.d.ts +2 -0
- package/dist/sourceFileTransformers/import.js +71 -0
- package/dist/sourceFileTransformers/import.js.map +1 -0
- package/dist/sourceFileTransformers/index.d.ts +12 -0
- package/dist/sourceFileTransformers/index.js +137 -0
- package/dist/sourceFileTransformers/index.js.map +1 -0
- package/dist/sourceFileTransformers/interface.d.ts +2 -0
- package/dist/sourceFileTransformers/interface.js +50 -0
- package/dist/sourceFileTransformers/interface.js.map +1 -0
- package/dist/sourceFileTransformers/replaceName.d.ts +1 -0
- package/dist/sourceFileTransformers/replaceName.js +19 -0
- package/dist/sourceFileTransformers/replaceName.js.map +1 -0
- package/dist/sourceFileTransformers/transform.d.ts +12 -0
- package/dist/sourceFileTransformers/transform.js +76 -0
- package/dist/sourceFileTransformers/transform.js.map +1 -0
- package/dist/sourceFileTransformers/type-reference.d.ts +2 -0
- package/dist/sourceFileTransformers/type-reference.js +38 -0
- package/dist/sourceFileTransformers/type-reference.js.map +1 -0
- package/dist/sourceFileTransformers/typeAlias.d.ts +2 -0
- package/dist/sourceFileTransformers/typeAlias.js +41 -0
- package/dist/sourceFileTransformers/typeAlias.js.map +1 -0
- package/dist/sourceFileTransformers/variable.d.ts +2 -0
- package/dist/sourceFileTransformers/variable.js +41 -0
- package/dist/sourceFileTransformers/variable.js.map +1 -0
- package/dist/transform-source-file.spec.d.ts +1 -0
- package/dist/transform-source-file.spec.js +182 -0
- package/dist/transform-source-file.spec.js.map +1 -0
- package/dist/transformers/array-literal-expression.d.ts +10 -0
- package/dist/transformers/array-literal-expression.js +51 -0
- package/dist/transformers/array-literal-expression.js.map +1 -0
- package/dist/transformers/array-type.d.ts +10 -0
- package/dist/transformers/array-type.js +37 -0
- package/dist/transformers/array-type.js.map +1 -0
- package/dist/transformers/binding-element.d.ts +17 -0
- package/dist/transformers/binding-element.js +63 -0
- package/dist/transformers/binding-element.js.map +1 -0
- package/dist/transformers/class-declaration.d.ts +12 -0
- package/dist/transformers/class-declaration.js +116 -0
- package/dist/transformers/class-declaration.js.map +1 -0
- package/dist/transformers/conditional-type.d.ts +10 -0
- package/dist/transformers/conditional-type.js +38 -0
- package/dist/transformers/conditional-type.js.map +1 -0
- package/dist/transformers/constructor.d.ts +10 -0
- package/dist/transformers/constructor.js +49 -0
- package/dist/transformers/constructor.js.map +1 -0
- package/dist/transformers/decorator.d.ts +10 -0
- package/dist/transformers/decorator.js +54 -0
- package/dist/transformers/decorator.js.map +1 -0
- package/dist/transformers/enum-declaration.d.ts +10 -0
- package/dist/transformers/enum-declaration.js +60 -0
- package/dist/transformers/enum-declaration.js.map +1 -0
- package/dist/transformers/export-assignment.d.ts +14 -0
- package/dist/transformers/export-assignment.js +54 -0
- package/dist/transformers/export-assignment.js.map +1 -0
- package/dist/transformers/export-declaration.d.ts +10 -0
- package/dist/transformers/export-declaration.js +154 -0
- package/dist/transformers/export-declaration.js.map +1 -0
- package/dist/transformers/expression-statement.d.ts +10 -0
- package/dist/transformers/expression-statement.js +36 -0
- package/dist/transformers/expression-statement.js.map +1 -0
- package/dist/transformers/function-like.d.ts +11 -0
- package/dist/transformers/function-like.js +81 -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 +46 -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 +72 -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 +41 -0
- package/dist/transformers/index-signature.js.map +1 -0
- package/dist/transformers/index.d.ts +43 -0
- package/dist/transformers/index.js +566 -0
- package/dist/transformers/index.js.map +1 -0
- package/dist/transformers/indexed-access-type.d.ts +10 -0
- package/dist/transformers/indexed-access-type.js +36 -0
- package/dist/transformers/indexed-access-type.js.map +1 -0
- package/dist/transformers/interface-declaration.d.ts +11 -0
- package/dist/transformers/interface-declaration.js +86 -0
- package/dist/transformers/interface-declaration.js.map +1 -0
- package/dist/transformers/intersection-type.d.ts +10 -0
- package/dist/transformers/intersection-type.js +47 -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 +54 -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 +39 -0
- package/dist/transformers/literal-type.js.map +1 -0
- package/dist/transformers/literal-value.d.ts +12 -0
- package/dist/transformers/literal-value.js +35 -0
- package/dist/transformers/literal-value.js.map +1 -0
- package/dist/transformers/module-declaration.d.ts +10 -0
- package/dist/transformers/module-declaration.js +36 -0
- package/dist/transformers/module-declaration.js.map +1 -0
- package/dist/transformers/named-tuple.d.ts +10 -0
- package/dist/transformers/named-tuple.js +37 -0
- package/dist/transformers/named-tuple.js.map +1 -0
- package/dist/transformers/object-literal-expression.d.ts +9 -0
- package/dist/transformers/object-literal-expression.js +51 -0
- package/dist/transformers/object-literal-expression.js.map +1 -0
- package/dist/transformers/parameter.d.ts +14 -0
- package/dist/transformers/parameter.js +109 -0
- package/dist/transformers/parameter.js.map +1 -0
- package/dist/transformers/parenthesized-type.d.ts +10 -0
- package/dist/transformers/parenthesized-type.js +35 -0
- package/dist/transformers/parenthesized-type.js.map +1 -0
- package/dist/transformers/property-assignment.d.ts +9 -0
- package/dist/transformers/property-assignment.js +39 -0
- package/dist/transformers/property-assignment.js.map +1 -0
- package/dist/transformers/property-declaration.d.ts +11 -0
- package/dist/transformers/property-declaration.js +56 -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 +44 -0
- package/dist/transformers/set-accessor.js.map +1 -0
- package/dist/transformers/source-file-transformer.d.ts +15 -0
- package/dist/transformers/source-file-transformer.js +108 -0
- package/dist/transformers/source-file-transformer.js.map +1 -0
- package/dist/transformers/template-literal-type-span.d.ts +10 -0
- package/dist/transformers/template-literal-type-span.js +36 -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 +44 -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 +34 -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 +46 -0
- package/dist/transformers/tuple-type.js.map +1 -0
- package/dist/transformers/type-alias.d.ts +11 -0
- package/dist/transformers/type-alias.js +48 -0
- package/dist/transformers/type-alias.js.map +1 -0
- package/dist/transformers/type-literal.d.ts +14 -0
- package/dist/transformers/type-literal.js +48 -0
- package/dist/transformers/type-literal.js.map +1 -0
- package/dist/transformers/type-operator.d.ts +15 -0
- package/dist/transformers/type-operator.js +51 -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 +37 -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 +41 -0
- package/dist/transformers/type-query.js.map +1 -0
- package/dist/transformers/type-reference.d.ts +17 -0
- package/dist/transformers/type-reference.js +58 -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 +47 -0
- package/dist/transformers/union-type.js.map +1 -0
- package/dist/transformers/utils/jsdoc-to-doc-schema.d.ts +5 -0
- package/dist/transformers/utils/jsdoc-to-doc-schema.js +114 -0
- package/dist/transformers/utils/jsdoc-to-doc-schema.js.map +1 -0
- package/dist/transformers/utils/parse-type-from-quick-info.d.ts +36 -0
- package/dist/transformers/utils/parse-type-from-quick-info.js +111 -0
- package/dist/transformers/utils/parse-type-from-quick-info.js.map +1 -0
- package/dist/transformers/variable-declaration.d.ts +11 -0
- package/dist/transformers/variable-declaration.js +102 -0
- package/dist/transformers/variable-declaration.js.map +1 -0
- package/dist/transformers/variable-statement.d.ts +14 -0
- package/dist/transformers/variable-statement.js +67 -0
- package/dist/transformers/variable-statement.js.map +1 -0
- package/dist/tsconfig.default.json +25 -0
- package/dist/typescript.aspect.d.ts +2 -0
- package/dist/typescript.aspect.js +18 -0
- package/dist/typescript.aspect.js.map +1 -0
- package/dist/typescript.composition.d.ts +1 -0
- package/dist/typescript.composition.js +29 -0
- package/dist/typescript.composition.js.map +1 -0
- package/dist/typescript.docs.mdx +8 -0
- package/dist/typescript.extractor.d.ts +52 -0
- package/dist/typescript.extractor.js +254 -0
- package/dist/typescript.extractor.js.map +1 -0
- package/dist/typescript.main.runtime.d.ts +130 -0
- package/dist/typescript.main.runtime.js +400 -0
- package/dist/typescript.main.runtime.js.map +1 -0
- package/dist/typescript.parser.d.ts +13 -0
- package/dist/typescript.parser.js +142 -0
- package/dist/typescript.parser.js.map +1 -0
- package/dist/typescript.parser.spec.d.ts +1 -0
- package/dist/typescript.parser.spec.js +189 -0
- package/dist/typescript.parser.spec.js.map +1 -0
- package/esm.mjs +21 -0
- package/exceptions/index.ts +1 -0
- package/exceptions/transformer-not-found.ts +20 -0
- package/package.json +86 -0
- package/sourceFileTransformers/class.ts +73 -0
- package/sourceFileTransformers/empty-line-encoder.ts +56 -0
- package/sourceFileTransformers/export.ts +65 -0
- package/sourceFileTransformers/expression-statement.ts +48 -0
- package/sourceFileTransformers/function.ts +170 -0
- package/sourceFileTransformers/import.ts +101 -0
- package/sourceFileTransformers/index.ts +14 -0
- package/sourceFileTransformers/interface.ts +41 -0
- package/sourceFileTransformers/replaceName.ts +11 -0
- package/sourceFileTransformers/transform.ts +70 -0
- package/sourceFileTransformers/type-reference.ts +19 -0
- package/sourceFileTransformers/typeAlias.ts +25 -0
- package/sourceFileTransformers/variable.ts +25 -0
- package/transformers/array-literal-expression.ts +31 -0
- package/transformers/array-type.ts +22 -0
- package/transformers/binding-element.ts +35 -0
- package/transformers/class-declaration.ts +109 -0
- package/transformers/conditional-type.ts +24 -0
- package/transformers/constructor.ts +37 -0
- package/transformers/decorator.ts +30 -0
- package/transformers/enum-declaration.ts +32 -0
- package/transformers/export-assignment.ts +48 -0
- package/transformers/export-declaration.ts +182 -0
- package/transformers/expression-statement.ts +21 -0
- package/transformers/function-like.ts +72 -0
- package/transformers/get-accessor.ts +25 -0
- package/transformers/import-declaration.ts +57 -0
- package/transformers/index-signature.ts +27 -0
- package/transformers/index.ts +43 -0
- package/transformers/indexed-access-type.ts +22 -0
- package/transformers/interface-declaration.ts +68 -0
- package/transformers/intersection-type.ts +26 -0
- package/transformers/keyword-type.ts +40 -0
- package/transformers/literal-type.ts +24 -0
- package/transformers/literal-value.ts +40 -0
- package/transformers/module-declaration.ts +21 -0
- package/transformers/named-tuple.ts +23 -0
- package/transformers/object-literal-expression.ts +29 -0
- package/transformers/parameter.ts +115 -0
- package/transformers/parenthesized-type.ts +21 -0
- package/transformers/property-assignment.ts +24 -0
- package/transformers/property-declaration.ts +35 -0
- package/transformers/set-accessor.ts +27 -0
- package/transformers/source-file-transformer.ts +95 -0
- package/transformers/template-literal-type-span.ts +22 -0
- package/transformers/template-literal-type.ts +26 -0
- package/transformers/this-type.ts +20 -0
- package/transformers/tuple-type.ts +25 -0
- package/transformers/type-alias.ts +27 -0
- package/transformers/type-literal.ts +27 -0
- package/transformers/type-operator.ts +38 -0
- package/transformers/type-predicate.ts +23 -0
- package/transformers/type-query.ts +26 -0
- package/transformers/type-reference.ts +37 -0
- package/transformers/union-type.ts +26 -0
- package/transformers/utils/jsdoc-to-doc-schema.ts +114 -0
- package/transformers/utils/parse-type-from-quick-info.ts +99 -0
- package/transformers/variable-declaration.ts +111 -0
- package/transformers/variable-statement.ts +34 -0
- package/types/asset.d.ts +41 -0
- package/types/style.d.ts +42 -0
- package/typescript.composition.tsx +7 -0
- package/typescript.docs.mdx +8 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ClassDeclarationTransformer = void 0;
|
|
7
|
+
function _pMapSeries() {
|
|
8
|
+
const data = _interopRequireDefault(require("p-map-series"));
|
|
9
|
+
_pMapSeries = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _lodash() {
|
|
15
|
+
const data = require("lodash");
|
|
16
|
+
_lodash = function () {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
function _semanticsEntities() {
|
|
22
|
+
const data = require("@teambit/semantics.entities.semantic-schema");
|
|
23
|
+
_semanticsEntities = function () {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
function _typescript() {
|
|
29
|
+
const data = _interopRequireDefault(require("typescript"));
|
|
30
|
+
_typescript = function () {
|
|
31
|
+
return data;
|
|
32
|
+
};
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
35
|
+
function _identifier() {
|
|
36
|
+
const data = require("../identifier");
|
|
37
|
+
_identifier = function () {
|
|
38
|
+
return data;
|
|
39
|
+
};
|
|
40
|
+
return data;
|
|
41
|
+
}
|
|
42
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
43
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
44
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
45
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
46
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
47
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
48
|
+
class ClassDeclarationTransformer {
|
|
49
|
+
predicate(node) {
|
|
50
|
+
if (node.kind !== _typescript().default.SyntaxKind.ClassDeclaration) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
const classNode = node;
|
|
54
|
+
if (!classNode.members || classNode.members.isMissingList) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// @todo: in case of `export default class` the class has no name.
|
|
61
|
+
getName(node) {
|
|
62
|
+
return node.name?.getText() || 'default';
|
|
63
|
+
}
|
|
64
|
+
async getIdentifiers(node) {
|
|
65
|
+
return [new (_identifier().Identifier)(this.getName(node), node.getSourceFile().fileName)];
|
|
66
|
+
}
|
|
67
|
+
async getExpressionWithTypeArgs(node, context, token) {
|
|
68
|
+
if (!node.heritageClauses) return [];
|
|
69
|
+
return (0, _pMapSeries().default)(node.heritageClauses.filter(heritageClause => heritageClause.token === token).flatMap(h => {
|
|
70
|
+
const {
|
|
71
|
+
types
|
|
72
|
+
} = h;
|
|
73
|
+
const name = h.getText();
|
|
74
|
+
return types.map(type => _objectSpread(_objectSpread({}, type), {}, {
|
|
75
|
+
name
|
|
76
|
+
}));
|
|
77
|
+
}), async expressionWithTypeArgs => {
|
|
78
|
+
const {
|
|
79
|
+
typeArguments,
|
|
80
|
+
expression,
|
|
81
|
+
name
|
|
82
|
+
} = expressionWithTypeArgs;
|
|
83
|
+
const typeArgsNodes = typeArguments ? await (0, _pMapSeries().default)(typeArguments, t => context.computeSchema(t)) : [];
|
|
84
|
+
const location = context.getLocation(expression);
|
|
85
|
+
const expressionNode = (await context.visitDefinition(expression)) || new (_semanticsEntities().UnresolvedSchema)(location, expression.getText());
|
|
86
|
+
return new (_semanticsEntities().ExpressionWithTypeArgumentsSchema)(typeArgsNodes, expressionNode, name, location);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
async transform(node, context) {
|
|
90
|
+
const nodeDecorators = _typescript().default.canHaveDecorators(node) ? _typescript().default.getDecorators(node) : undefined;
|
|
91
|
+
const decorators = nodeDecorators?.length ? await (0, _pMapSeries().default)(nodeDecorators, decorator => context.computeSchema(decorator)) : undefined;
|
|
92
|
+
const className = this.getName(node);
|
|
93
|
+
const extendsExpressionsWithTypeArgs = await this.getExpressionWithTypeArgs(node, context, _typescript().default.SyntaxKind.ExtendsKeyword);
|
|
94
|
+
const implementsExpressionsWithTypeArgs = await this.getExpressionWithTypeArgs(node, context, _typescript().default.SyntaxKind.ImplementsKeyword);
|
|
95
|
+
const typeParameters = node.typeParameters?.map(typeParam => {
|
|
96
|
+
return typeParam.name.getText();
|
|
97
|
+
});
|
|
98
|
+
const signature = node.name ? await context.getQuickInfoDisplayString(node.name) : undefined;
|
|
99
|
+
const members = await (0, _pMapSeries().default)(node.members, async member => {
|
|
100
|
+
const memberModifiers = _typescript().default.canHaveModifiers(member) ? _typescript().default.getModifiers(member) : undefined;
|
|
101
|
+
const isPrivate = memberModifiers?.some(modifier => modifier.kind === _typescript().default.SyntaxKind.PrivateKeyword);
|
|
102
|
+
if (isPrivate) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
return context.computeSchema(member);
|
|
106
|
+
});
|
|
107
|
+
const doc = await context.jsDocToDocSchema(node);
|
|
108
|
+
if (!signature) {
|
|
109
|
+
throw Error(`Missing signature for class ${className} declaration`);
|
|
110
|
+
}
|
|
111
|
+
return new (_semanticsEntities().ClassSchema)(className, (0, _lodash().compact)(members), context.getLocation(node), signature, doc, typeParameters, extendsExpressionsWithTypeArgs, implementsExpressionsWithTypeArgs, decorators);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
exports.ClassDeclarationTransformer = ClassDeclarationTransformer;
|
|
115
|
+
|
|
116
|
+
//# sourceMappingURL=class-declaration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_pMapSeries","data","_interopRequireDefault","require","_lodash","_semanticsEntities","_typescript","_identifier","e","__esModule","default","ownKeys","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","ClassDeclarationTransformer","predicate","node","kind","ts","SyntaxKind","ClassDeclaration","classNode","members","isMissingList","getName","name","getText","getIdentifiers","Identifier","getSourceFile","fileName","getExpressionWithTypeArgs","context","token","heritageClauses","pMapSeries","heritageClause","flatMap","h","types","map","type","expressionWithTypeArgs","typeArguments","expression","typeArgsNodes","computeSchema","location","getLocation","expressionNode","visitDefinition","UnresolvedSchema","ExpressionWithTypeArgumentsSchema","transform","nodeDecorators","canHaveDecorators","getDecorators","undefined","decorators","decorator","className","extendsExpressionsWithTypeArgs","ExtendsKeyword","implementsExpressionsWithTypeArgs","ImplementsKeyword","typeParameters","typeParam","signature","getQuickInfoDisplayString","member","memberModifiers","canHaveModifiers","getModifiers","isPrivate","some","modifier","PrivateKeyword","doc","jsDocToDocSchema","Error","ClassSchema","compact","exports"],"sources":["class-declaration.ts"],"sourcesContent":["import pMapSeries from 'p-map-series';\nimport { compact } from 'lodash';\nimport {\n ClassSchema,\n UnresolvedSchema,\n ExpressionWithTypeArgumentsSchema,\n} from '@teambit/semantics.entities.semantic-schema';\nimport type { Node, ClassDeclaration } from 'typescript';\nimport ts from 'typescript';\nimport type { SchemaTransformer } from '../schema-transformer';\nimport type { SchemaExtractorContext } from '../schema-extractor-context';\nimport { Identifier } from '../identifier';\n\nexport class ClassDeclarationTransformer implements SchemaTransformer {\n predicate(node: Node) {\n if (node.kind !== ts.SyntaxKind.ClassDeclaration) {\n return false;\n }\n const classNode = node as ClassDeclaration;\n if (!classNode.members || (classNode.members as any).isMissingList) {\n return false;\n }\n return true;\n }\n\n // @todo: in case of `export default class` the class has no name.\n private getName(node: ClassDeclaration) {\n return node.name?.getText() || 'default';\n }\n\n async getIdentifiers(node: ClassDeclaration) {\n return [new Identifier(this.getName(node), node.getSourceFile().fileName)];\n }\n\n private async getExpressionWithTypeArgs(\n node: ClassDeclaration,\n context: SchemaExtractorContext,\n token: ts.SyntaxKind.ExtendsKeyword | ts.SyntaxKind.ImplementsKeyword\n ) {\n if (!node.heritageClauses) return [];\n\n return pMapSeries(\n node.heritageClauses\n .filter((heritageClause: ts.HeritageClause) => heritageClause.token === token)\n .flatMap((h: ts.HeritageClause) => {\n const { types } = h;\n const name = h.getText();\n return types.map((type) => ({ ...type, name }));\n }),\n async (expressionWithTypeArgs: ts.ExpressionWithTypeArguments & { name: string }) => {\n const { typeArguments, expression, name } = expressionWithTypeArgs;\n const typeArgsNodes = typeArguments ? await pMapSeries(typeArguments, (t) => context.computeSchema(t)) : [];\n const location = context.getLocation(expression);\n const expressionNode =\n (await context.visitDefinition(expression)) || new UnresolvedSchema(location, expression.getText());\n return new ExpressionWithTypeArgumentsSchema(typeArgsNodes, expressionNode, name, location);\n }\n );\n }\n\n async transform(node: ClassDeclaration, context: SchemaExtractorContext) {\n const nodeDecorators = ts.canHaveDecorators(node) ? ts.getDecorators(node) : undefined;\n const decorators = nodeDecorators?.length\n ? await pMapSeries(nodeDecorators, (decorator) => context.computeSchema(decorator))\n : undefined;\n const className = this.getName(node);\n const extendsExpressionsWithTypeArgs = await this.getExpressionWithTypeArgs(\n node,\n context,\n ts.SyntaxKind.ExtendsKeyword\n );\n\n const implementsExpressionsWithTypeArgs = await this.getExpressionWithTypeArgs(\n node,\n context,\n ts.SyntaxKind.ImplementsKeyword\n );\n\n const typeParameters = node.typeParameters?.map((typeParam) => {\n return typeParam.name.getText();\n });\n const signature = node.name ? await context.getQuickInfoDisplayString(node.name) : undefined;\n const members = await pMapSeries(node.members, async (member) => {\n const memberModifiers = ts.canHaveModifiers(member) ? ts.getModifiers(member) : undefined;\n const isPrivate = memberModifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.PrivateKeyword);\n if (isPrivate) {\n return null;\n }\n return context.computeSchema(member);\n });\n const doc = await context.jsDocToDocSchema(node);\n\n if (!signature) {\n throw Error(`Missing signature for class ${className} declaration`);\n }\n\n return new ClassSchema(\n className,\n compact(members),\n context.getLocation(node),\n signature,\n doc,\n typeParameters,\n extendsExpressionsWithTypeArgs,\n implementsExpressionsWithTypeArgs,\n decorators\n );\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,YAAA;E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
+
import type { Node, ConditionalTypeNode } from 'typescript';
|
|
2
|
+
import { ConditionalTypeSchema } from '@teambit/semantics.entities.semantic-schema';
|
|
3
|
+
import type { SchemaTransformer } from '../schema-transformer';
|
|
4
|
+
import type { SchemaExtractorContext } from '../schema-extractor-context';
|
|
5
|
+
import type { Identifier } from '../identifier';
|
|
6
|
+
export declare class ConditionalTypeTransformer implements SchemaTransformer {
|
|
7
|
+
predicate(node: Node): boolean;
|
|
8
|
+
getIdentifiers(): Promise<Identifier[]>;
|
|
9
|
+
transform(node: ConditionalTypeNode, context: SchemaExtractorContext): Promise<ConditionalTypeSchema>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ConditionalTypeTransformer = void 0;
|
|
7
|
+
function _typescript() {
|
|
8
|
+
const data = require("typescript");
|
|
9
|
+
_typescript = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _semanticsEntities() {
|
|
15
|
+
const data = require("@teambit/semantics.entities.semantic-schema");
|
|
16
|
+
_semanticsEntities = function () {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
class ConditionalTypeTransformer {
|
|
22
|
+
predicate(node) {
|
|
23
|
+
return node.kind === _typescript().SyntaxKind.ConditionalType;
|
|
24
|
+
}
|
|
25
|
+
async getIdentifiers() {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
async transform(node, context) {
|
|
29
|
+
const checkType = await context.computeSchema(node.checkType);
|
|
30
|
+
const extendsType = await context.computeSchema(node.extendsType);
|
|
31
|
+
const trueType = await context.computeSchema(node.trueType);
|
|
32
|
+
const falseType = await context.computeSchema(node.falseType);
|
|
33
|
+
return new (_semanticsEntities().ConditionalTypeSchema)(context.getLocation(node), checkType, extendsType, trueType, falseType);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.ConditionalTypeTransformer = ConditionalTypeTransformer;
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=conditional-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_typescript","data","require","_semanticsEntities","ConditionalTypeTransformer","predicate","node","kind","SyntaxKind","ConditionalType","getIdentifiers","transform","context","checkType","computeSchema","extendsType","trueType","falseType","ConditionalTypeSchema","getLocation","exports"],"sources":["conditional-type.ts"],"sourcesContent":["import type { Node, ConditionalTypeNode } from 'typescript';\nimport { SyntaxKind } from 'typescript';\nimport { ConditionalTypeSchema } from '@teambit/semantics.entities.semantic-schema';\nimport type { SchemaTransformer } from '../schema-transformer';\nimport type { SchemaExtractorContext } from '../schema-extractor-context';\nimport type { Identifier } from '../identifier';\n\nexport class ConditionalTypeTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === SyntaxKind.ConditionalType;\n }\n\n async getIdentifiers(): Promise<Identifier[]> {\n return [];\n }\n\n async transform(node: ConditionalTypeNode, context: SchemaExtractorContext) {\n const checkType = await context.computeSchema(node.checkType);\n const extendsType = await context.computeSchema(node.extendsType);\n const trueType = await context.computeSchema(node.trueType);\n const falseType = await context.computeSchema(node.falseType);\n return new ConditionalTypeSchema(context.getLocation(node), checkType, extendsType, trueType, falseType);\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,mBAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,kBAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAKO,MAAMG,0BAA0B,CAA8B;EACnEC,SAASA,CAACC,IAAU,EAAE;IACpB,OAAOA,IAAI,CAACC,IAAI,KAAKC,wBAAU,CAACC,eAAe;EACjD;EAEA,MAAMC,cAAcA,CAAA,EAA0B;IAC5C,OAAO,EAAE;EACX;EAEA,MAAMC,SAASA,CAACL,IAAyB,EAAEM,OAA+B,EAAE;IAC1E,MAAMC,SAAS,GAAG,MAAMD,OAAO,CAACE,aAAa,CAACR,IAAI,CAACO,SAAS,CAAC;IAC7D,MAAME,WAAW,GAAG,MAAMH,OAAO,CAACE,aAAa,CAACR,IAAI,CAACS,WAAW,CAAC;IACjE,MAAMC,QAAQ,GAAG,MAAMJ,OAAO,CAACE,aAAa,CAACR,IAAI,CAACU,QAAQ,CAAC;IAC3D,MAAMC,SAAS,GAAG,MAAML,OAAO,CAACE,aAAa,CAACR,IAAI,CAACW,SAAS,CAAC;IAC7D,OAAO,KAAIC,0CAAqB,EAACN,OAAO,CAACO,WAAW,CAACb,IAAI,CAAC,EAAEO,SAAS,EAAEE,WAAW,EAAEC,QAAQ,EAAEC,SAAS,CAAC;EAC1G;AACF;AAACG,OAAA,CAAAhB,0BAAA,GAAAA,0BAAA","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Node, ConstructorDeclaration } from 'typescript';
|
|
2
|
+
import { ConstructorSchema } from '@teambit/semantics.entities.semantic-schema';
|
|
3
|
+
import type { SchemaTransformer } from '../schema-transformer';
|
|
4
|
+
import type { SchemaExtractorContext } from '../schema-extractor-context';
|
|
5
|
+
import type { Identifier } from '../identifier';
|
|
6
|
+
export declare class ConstructorTransformer implements SchemaTransformer {
|
|
7
|
+
predicate(node: Node): boolean;
|
|
8
|
+
getIdentifiers(): Promise<Identifier[]>;
|
|
9
|
+
transform(node: ConstructorDeclaration, context: SchemaExtractorContext): Promise<ConstructorSchema>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ConstructorTransformer = void 0;
|
|
7
|
+
function _typescript() {
|
|
8
|
+
const data = _interopRequireDefault(require("typescript"));
|
|
9
|
+
_typescript = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _semanticsEntities() {
|
|
15
|
+
const data = require("@teambit/semantics.entities.semantic-schema");
|
|
16
|
+
_semanticsEntities = function () {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
function _pMapSeries() {
|
|
22
|
+
const data = _interopRequireDefault(require("p-map-series"));
|
|
23
|
+
_pMapSeries = function () {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
29
|
+
class ConstructorTransformer {
|
|
30
|
+
predicate(node) {
|
|
31
|
+
return node.kind === _typescript().default.SyntaxKind.Constructor;
|
|
32
|
+
}
|
|
33
|
+
async getIdentifiers() {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
async transform(node, context) {
|
|
37
|
+
const args = await (0, _pMapSeries().default)(node.parameters, async param => context.computeSchema(param));
|
|
38
|
+
const info = await context.getQuickInfo(node);
|
|
39
|
+
const displaySig = info?.body?.displayString || '';
|
|
40
|
+
const name = node.parent?.name?.getText() || '';
|
|
41
|
+
const returns = new (_semanticsEntities().ThisTypeSchema)(context.getLocation(node.parent), name);
|
|
42
|
+
const modifiers = node.modifiers?.map(modifier => modifier.getText()) || [];
|
|
43
|
+
const doc = await context.jsDocToDocSchema(node);
|
|
44
|
+
return new (_semanticsEntities().ConstructorSchema)(context.getLocation(node), args, returns, displaySig, modifiers, doc);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.ConstructorTransformer = ConstructorTransformer;
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=constructor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_typescript","data","_interopRequireDefault","require","_semanticsEntities","_pMapSeries","e","__esModule","default","ConstructorTransformer","predicate","node","kind","ts","SyntaxKind","Constructor","getIdentifiers","transform","context","args","pMapSeries","parameters","param","computeSchema","info","getQuickInfo","displaySig","body","displayString","name","parent","getText","returns","ThisTypeSchema","getLocation","modifiers","map","modifier","doc","jsDocToDocSchema","ConstructorSchema","exports"],"sources":["constructor.ts"],"sourcesContent":["import type { Node, ConstructorDeclaration } from 'typescript';\nimport ts from 'typescript';\nimport type { ParameterSchema, Modifier } from '@teambit/semantics.entities.semantic-schema';\nimport { ConstructorSchema, ThisTypeSchema } from '@teambit/semantics.entities.semantic-schema';\nimport pMapSeries from 'p-map-series';\nimport type { SchemaTransformer } from '../schema-transformer';\nimport type { SchemaExtractorContext } from '../schema-extractor-context';\nimport type { Identifier } from '../identifier';\n\nexport class ConstructorTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.Constructor;\n }\n\n async getIdentifiers(): Promise<Identifier[]> {\n return [];\n }\n\n async transform(node: ConstructorDeclaration, context: SchemaExtractorContext) {\n const args = await pMapSeries(node.parameters, async (param) => context.computeSchema(param));\n const info = await context.getQuickInfo(node);\n const displaySig = info?.body?.displayString || '';\n const name = node.parent?.name?.getText() || '';\n const returns = new ThisTypeSchema(context.getLocation(node.parent), name);\n const modifiers = node.modifiers?.map((modifier) => modifier.getText()) || [];\n const doc = await context.jsDocToDocSchema(node);\n\n return new ConstructorSchema(\n context.getLocation(node),\n args as ParameterSchema[],\n returns,\n displaySig,\n modifiers as Modifier[],\n doc\n );\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,mBAAA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I,EAAE;IAC7E,MAAMO,GAAG,GAAG,MAAMpB,OAAO,CAACqB,gBAAgB,CAAC5B,IAAI,CAAC;IAEhD,OAAO,KAAI6B,sCAAiB,EAC1BtB,OAAO,CAACgB,WAAW,CAACvB,IAAI,CAAC,EACzBQ,IAAI,EACJa,OAAO,EACPN,UAAU,EACVS,SAAS,EACTG,GACF,CAAC;EACH;AACF;AAACG,OAAA,CAAAhC,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SchemaNode } from '@teambit/semantics.entities.semantic-schema';
|
|
2
|
+
import type { Decorator, Node } from 'typescript';
|
|
3
|
+
import type { SchemaExtractorContext } from '../schema-extractor-context';
|
|
4
|
+
import type { SchemaTransformer } from '../schema-transformer';
|
|
5
|
+
import { Identifier } from '../identifier';
|
|
6
|
+
export declare class DecoratorTransformer implements SchemaTransformer {
|
|
7
|
+
predicate(node: Node): boolean;
|
|
8
|
+
getIdentifiers(decorator: Decorator): Promise<Identifier[]>;
|
|
9
|
+
transform(node: Decorator, context: SchemaExtractorContext): Promise<SchemaNode>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DecoratorTransformer = void 0;
|
|
7
|
+
function _semanticsEntities() {
|
|
8
|
+
const data = require("@teambit/semantics.entities.semantic-schema");
|
|
9
|
+
_semanticsEntities = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _typescript() {
|
|
15
|
+
const data = _interopRequireDefault(require("typescript"));
|
|
16
|
+
_typescript = function () {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
function _pMapSeries() {
|
|
22
|
+
const data = _interopRequireDefault(require("p-map-series"));
|
|
23
|
+
_pMapSeries = function () {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
function _identifier() {
|
|
29
|
+
const data = require("../identifier");
|
|
30
|
+
_identifier = function () {
|
|
31
|
+
return data;
|
|
32
|
+
};
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
35
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
36
|
+
class DecoratorTransformer {
|
|
37
|
+
predicate(node) {
|
|
38
|
+
return node.kind === _typescript().default.SyntaxKind.Decorator;
|
|
39
|
+
}
|
|
40
|
+
async getIdentifiers(decorator) {
|
|
41
|
+
const identifierText = decorator.expression.getFirstToken()?.getText() || '';
|
|
42
|
+
return [new (_identifier().Identifier)(identifierText, decorator.getSourceFile().fileName)];
|
|
43
|
+
}
|
|
44
|
+
async transform(node, context) {
|
|
45
|
+
const name = node.expression.getFirstToken()?.getText() || '';
|
|
46
|
+
const location = context.getLocation(node);
|
|
47
|
+
const doc = await context.jsDocToDocSchema(node);
|
|
48
|
+
const args = _typescript().default.isCallExpression(node.expression) && node.expression.arguments.length ? await (0, _pMapSeries().default)(node.expression.arguments, arg => context.computeSchema(arg)) : undefined;
|
|
49
|
+
return new (_semanticsEntities().DecoratorSchema)(location, name, doc, args);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.DecoratorTransformer = DecoratorTransformer;
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_semanticsEntities","data","require","_typescript","_interopRequireDefault","_pMapSeries","_identifier","e","__esModule","default","DecoratorTransformer","predicate","node","kind","ts","SyntaxKind","Decorator","getIdentifiers","decorator","identifierText","expression","getFirstToken","getText","Identifier","getSourceFile","fileName","transform","context","name","location","getLocation","doc","jsDocToDocSchema","args","isCallExpression","arguments","length","pMapSeries","arg","computeSchema","undefined","DecoratorSchema","exports"],"sources":["decorator.ts"],"sourcesContent":["import type { SchemaNode } from '@teambit/semantics.entities.semantic-schema';\nimport { DecoratorSchema } from '@teambit/semantics.entities.semantic-schema';\nimport type { Decorator, Node } from 'typescript';\nimport ts from 'typescript';\nimport pMapSeries from 'p-map-series';\nimport type { SchemaExtractorContext } from '../schema-extractor-context';\nimport type { SchemaTransformer } from '../schema-transformer';\nimport { Identifier } from '../identifier';\n\nexport class DecoratorTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.Decorator;\n }\n\n async getIdentifiers(decorator: Decorator) {\n const identifierText = decorator.expression.getFirstToken()?.getText() || '';\n return [new Identifier(identifierText, decorator.getSourceFile().fileName)];\n }\n\n async transform(node: Decorator, context: SchemaExtractorContext): Promise<SchemaNode> {\n const name = node.expression.getFirstToken()?.getText() || '';\n const location = context.getLocation(node);\n const doc = await context.jsDocToDocSchema(node);\n const args =\n ts.isCallExpression(node.expression) && node.expression.arguments.length\n ? await pMapSeries(node.expression.arguments, (arg) => context.computeSchema(arg))\n : undefined;\n return new DecoratorSchema(location, name, doc, args);\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,mBAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,kBAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,YAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,YAAA;EAAA,MAAAJ,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAG,WAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAK,YAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,WAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;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A,GAAAA,oBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Node, EnumDeclaration } from 'typescript';
|
|
2
|
+
import { EnumSchema } from '@teambit/semantics.entities.semantic-schema';
|
|
3
|
+
import type { SchemaTransformer } from '../schema-transformer';
|
|
4
|
+
import type { SchemaExtractorContext } from '../schema-extractor-context';
|
|
5
|
+
import { Identifier } from '../identifier';
|
|
6
|
+
export declare class EnumDeclarationTransformer implements SchemaTransformer {
|
|
7
|
+
predicate(node: Node): boolean;
|
|
8
|
+
getIdentifiers(node: EnumDeclaration): Promise<Identifier[]>;
|
|
9
|
+
transform(enumDec: EnumDeclaration, context: SchemaExtractorContext): Promise<EnumSchema>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.EnumDeclarationTransformer = void 0;
|
|
7
|
+
function _typescript() {
|
|
8
|
+
const data = _interopRequireDefault(require("typescript"));
|
|
9
|
+
_typescript = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _semanticsEntities() {
|
|
15
|
+
const data = require("@teambit/semantics.entities.semantic-schema");
|
|
16
|
+
_semanticsEntities = function () {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
function _pMapSeries() {
|
|
22
|
+
const data = _interopRequireDefault(require("p-map-series"));
|
|
23
|
+
_pMapSeries = function () {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
function _identifier() {
|
|
29
|
+
const data = require("../identifier");
|
|
30
|
+
_identifier = function () {
|
|
31
|
+
return data;
|
|
32
|
+
};
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
35
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
36
|
+
class EnumDeclarationTransformer {
|
|
37
|
+
predicate(node) {
|
|
38
|
+
return node.kind === _typescript().default.SyntaxKind.EnumDeclaration;
|
|
39
|
+
}
|
|
40
|
+
async getIdentifiers(node) {
|
|
41
|
+
return [new (_identifier().Identifier)(node.name.getText(), node.getSourceFile().fileName)];
|
|
42
|
+
}
|
|
43
|
+
async transform(enumDec, context) {
|
|
44
|
+
const name = enumDec.name.getText();
|
|
45
|
+
const members = await (0, _pMapSeries().default)(enumDec.members, async member => {
|
|
46
|
+
const memberName = member.name.getText();
|
|
47
|
+
const memberSignature = await context.getQuickInfoDisplayString(member);
|
|
48
|
+
const memberDoc = await context.jsDocToDocSchema(member);
|
|
49
|
+
const memberLocation = await context.getLocation(member);
|
|
50
|
+
const memberValue = member.initializer?.getText();
|
|
51
|
+
return new (_semanticsEntities().EnumMemberSchema)(memberLocation, memberName, memberSignature, memberValue, memberDoc);
|
|
52
|
+
});
|
|
53
|
+
const signature = await context.getQuickInfoDisplayString(enumDec.name);
|
|
54
|
+
const doc = await context.jsDocToDocSchema(enumDec);
|
|
55
|
+
return new (_semanticsEntities().EnumSchema)(context.getLocation(enumDec), name, members, signature, doc);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.EnumDeclarationTransformer = EnumDeclarationTransformer;
|
|
59
|
+
|
|
60
|
+
//# sourceMappingURL=enum-declaration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_typescript","data","_interopRequireDefault","require","_semanticsEntities","_pMapSeries","_identifier","e","__esModule","default","EnumDeclarationTransformer","predicate","node","kind","ts","SyntaxKind","EnumDeclaration","getIdentifiers","Identifier","name","getText","getSourceFile","fileName","transform","enumDec","context","members","pMapSeries","member","memberName","memberSignature","getQuickInfoDisplayString","memberDoc","jsDocToDocSchema","memberLocation","getLocation","memberValue","initializer","EnumMemberSchema","signature","doc","EnumSchema","exports"],"sources":["enum-declaration.ts"],"sourcesContent":["import type { Node, EnumDeclaration } from 'typescript';\nimport ts from 'typescript';\nimport { EnumMemberSchema, EnumSchema } from '@teambit/semantics.entities.semantic-schema';\nimport pMapSeries from 'p-map-series';\nimport type { SchemaTransformer } from '../schema-transformer';\nimport type { SchemaExtractorContext } from '../schema-extractor-context';\nimport { Identifier } from '../identifier';\n\nexport class EnumDeclarationTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.EnumDeclaration;\n }\n\n async getIdentifiers(node: EnumDeclaration): Promise<Identifier[]> {\n return [new Identifier(node.name.getText(), node.getSourceFile().fileName)];\n }\n\n async transform(enumDec: EnumDeclaration, context: SchemaExtractorContext) {\n const name = enumDec.name.getText();\n const members = await pMapSeries(enumDec.members, async (member) => {\n const memberName = member.name.getText();\n const memberSignature = await context.getQuickInfoDisplayString(member);\n const memberDoc = await context.jsDocToDocSchema(member);\n const memberLocation = await context.getLocation(member);\n const memberValue = member.initializer?.getText();\n return new EnumMemberSchema(memberLocation, memberName, memberSignature, memberValue, memberDoc);\n });\n const signature = await context.getQuickInfoDisplayString(enumDec.name);\n const doc = await context.jsDocToDocSchema(enumDec);\n return new EnumSchema(context.getLocation(enumDec), name, members, signature, doc);\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,mBAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,kBAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,YAAA;EAAA,MAAAJ,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAE,WAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAK,YAAA;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;IACF,MAAMO,SAAS,GAAG,MAAMd,OAAO,CAACM,yBAAyB,CAACP,OAAO,CAACL,IAAI,CAAC;IACvE,MAAMqB,GAAG,GAAG,MAAMf,OAAO,CAACQ,gBAAgB,CAACT,OAAO,CAAC;IACnD,OAAO,KAAIiB,+BAAU,EAAChB,OAAO,CAACU,WAAW,CAACX,OAAO,CAAC,EAAEL,IAAI,EAAEO,OAAO,EAAEa,SAAS,EAAEC,GAAG,CAAC;EACpF;AACF;AAACE,OAAA,CAAAhC,0BAAA,GAAAA,0BAAA","ignoreList":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { SchemaNode } from '@teambit/semantics.entities.semantic-schema';
|
|
2
|
+
import type { Node, ExportAssignment as ExportAssignmentNode } from 'typescript';
|
|
3
|
+
import { ExportIdentifier } from '../export-identifier';
|
|
4
|
+
import type { SchemaExtractorContext } from '../schema-extractor-context';
|
|
5
|
+
import type { SchemaTransformer } from '../schema-transformer';
|
|
6
|
+
/**
|
|
7
|
+
* This is either an export = or an export default declaration.
|
|
8
|
+
* Unless isExportEquals is set, this node was parsed as an export default
|
|
9
|
+
*/
|
|
10
|
+
export declare class ExportAssignmentTransformer implements SchemaTransformer {
|
|
11
|
+
predicate(node: Node): boolean;
|
|
12
|
+
getIdentifiers(exportDec: ExportAssignmentNode): Promise<ExportIdentifier[]>;
|
|
13
|
+
transform(exportDec: ExportAssignmentNode, context: SchemaExtractorContext): Promise<SchemaNode>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ExportAssignmentTransformer = void 0;
|
|
7
|
+
function _semanticsEntities() {
|
|
8
|
+
const data = require("@teambit/semantics.entities.semantic-schema");
|
|
9
|
+
_semanticsEntities = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _typescript() {
|
|
15
|
+
const data = require("typescript");
|
|
16
|
+
_typescript = function () {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
function _exportIdentifier() {
|
|
22
|
+
const data = require("../export-identifier");
|
|
23
|
+
_exportIdentifier = function () {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* This is either an export = or an export default declaration.
|
|
30
|
+
* Unless isExportEquals is set, this node was parsed as an export default
|
|
31
|
+
*/
|
|
32
|
+
class ExportAssignmentTransformer {
|
|
33
|
+
predicate(node) {
|
|
34
|
+
return node.kind === _typescript().SyntaxKind.ExportAssignment;
|
|
35
|
+
}
|
|
36
|
+
async getIdentifiers(exportDec) {
|
|
37
|
+
return [new (_exportIdentifier().ExportIdentifier)('default', exportDec.getSourceFile().fileName)];
|
|
38
|
+
}
|
|
39
|
+
async transform(exportDec, context) {
|
|
40
|
+
const specifier = exportDec.expression;
|
|
41
|
+
const location = context.getLocation(exportDec);
|
|
42
|
+
const absoluteFilePath = exportDec.getSourceFile().fileName;
|
|
43
|
+
const exportNode = await context.getTypeRef(specifier.getText(), absoluteFilePath, location);
|
|
44
|
+
if (exportNode) {
|
|
45
|
+
return new (_semanticsEntities().ExportSchema)(location, `${exportNode.name} (default)`, new (_semanticsEntities().TypeRefSchema)(exportNode.location, exportNode.name, exportNode.componentId, exportNode.packageName, exportNode.internalFilePath), `${exportNode.name} (default)`);
|
|
46
|
+
}
|
|
47
|
+
const schemaNode = await context.computeSchema(specifier);
|
|
48
|
+
const nodeName = schemaNode.name ? `${schemaNode.name} (default)` : 'default';
|
|
49
|
+
return new (_semanticsEntities().ExportSchema)(location, nodeName, schemaNode, nodeName);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.ExportAssignmentTransformer = ExportAssignmentTransformer;
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=export-assignment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_semanticsEntities","data","require","_typescript","_exportIdentifier","ExportAssignmentTransformer","predicate","node","kind","SyntaxKind","ExportAssignment","getIdentifiers","exportDec","ExportIdentifier","getSourceFile","fileName","transform","context","specifier","expression","location","getLocation","absoluteFilePath","exportNode","getTypeRef","getText","ExportSchema","name","TypeRefSchema","componentId","packageName","internalFilePath","schemaNode","computeSchema","nodeName","exports"],"sources":["export-assignment.ts"],"sourcesContent":["import type { SchemaNode } from '@teambit/semantics.entities.semantic-schema';\nimport { ExportSchema, TypeRefSchema } from '@teambit/semantics.entities.semantic-schema';\nimport type { Node, ExportAssignment as ExportAssignmentNode } from 'typescript';\nimport { SyntaxKind } from 'typescript';\nimport { ExportIdentifier } from '../export-identifier';\nimport type { SchemaExtractorContext } from '../schema-extractor-context';\nimport type { SchemaTransformer } from '../schema-transformer';\n\n/**\n * This is either an export = or an export default declaration.\n * Unless isExportEquals is set, this node was parsed as an export default\n */\nexport class ExportAssignmentTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === SyntaxKind.ExportAssignment;\n }\n\n async getIdentifiers(exportDec: ExportAssignmentNode) {\n return [new ExportIdentifier('default', exportDec.getSourceFile().fileName)];\n }\n\n async transform(exportDec: ExportAssignmentNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n const specifier = exportDec.expression;\n const location = context.getLocation(exportDec);\n const absoluteFilePath = exportDec.getSourceFile().fileName;\n\n const exportNode = await context.getTypeRef(specifier.getText(), absoluteFilePath, location);\n\n if (exportNode) {\n return new ExportSchema(\n location,\n `${exportNode.name} (default)`,\n new TypeRefSchema(\n exportNode.location,\n exportNode.name,\n exportNode.componentId,\n exportNode.packageName,\n exportNode.internalFilePath\n ),\n `${exportNode.name} (default)`\n );\n }\n\n const schemaNode = await context.computeSchema(specifier);\n const nodeName = schemaNode.name ? `${schemaNode.name} (default)` : 'default';\n return new ExportS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AAU,CAACH,QAAQ,EACnBG,UAAU,CAACI,IAAI,EACfJ,UAAU,CAACM,WAAW,EACtBN,UAAU,CAACO,WAAW,EACtBP,UAAU,CAACQ,gBACb,CAAC,EACD,GAAGR,UAAU,CAACI,IAAI,YACpB,CAAC;IACH;IAEA,MAAMK,UAAU,GAAG,MAAMf,OAAO,CAACgB,aAAa,CAACf,SAAS,CAAC;IACzD,MAAMgB,QAAQ,GAAGF,UAAU,CAACL,IAAI,GAAG,GAAGK,UAAU,CAACL,IAAI,YAAY,GAAG,SAAS;IAC7E,OAAO,KAAID,iCAAY,EAACN,QAAQ,EAAEc,QAAQ,EAAEF,UAAU,EAAEE,QAAQ,CAAC;EACnE;AACF;AAACC,OAAA,CAAA9B,2BAAA,GAAAA,2BAAA","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SchemaNode } from '@teambit/semantics.entities.semantic-schema';
|
|
2
|
+
import type { Node, ExportDeclaration as ExportDeclarationNode } from 'typescript';
|
|
3
|
+
import type { SchemaExtractorContext } from '../schema-extractor-context';
|
|
4
|
+
import type { SchemaTransformer } from '../schema-transformer';
|
|
5
|
+
import { ExportIdentifier } from '../export-identifier';
|
|
6
|
+
export declare class ExportDeclarationTransformer implements SchemaTransformer {
|
|
7
|
+
predicate(node: Node): boolean;
|
|
8
|
+
getIdentifiers(exportDec: ExportDeclarationNode, context: SchemaExtractorContext): Promise<ExportIdentifier[]>;
|
|
9
|
+
transform(exportDec: ExportDeclarationNode, context: SchemaExtractorContext): Promise<SchemaNode>;
|
|
10
|
+
}
|