@teambit/typescript 0.0.886 → 0.0.887

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.
@@ -1,5 +1,5 @@
1
1
  import { TsserverClient } from '@teambit/ts-server';
2
- import ts, { ExportDeclaration, Node, TypeNode } from 'typescript';
2
+ import ts, { ExportAssignment, ExportDeclaration, Node, TypeNode } from 'typescript';
3
3
  import protocol from 'typescript/lib/protocol';
4
4
  import type { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';
5
5
  import { Component } from '@teambit/component';
@@ -61,7 +61,7 @@ export declare class SchemaExtractorContext {
61
61
  references(): void;
62
62
  isExported(): void;
63
63
  isFromComponent(): void;
64
- getFileExports(exportDec: ExportDeclaration): Promise<import("./export-identifier").ExportIdentifier[]>;
64
+ getFileExports(exportDec: ExportDeclaration | ExportAssignment): Promise<import("./export-identifier").ExportIdentifier[]>;
65
65
  _exports: ExportList | undefined;
66
66
  setExports(exports: ExportList): this;
67
67
  getExportedIdentifiers(node: Node): Promise<import("./export-identifier").ExportIdentifier[]>;
@@ -16,7 +16,7 @@ function _defineProperty2() {
16
16
  return data;
17
17
  }
18
18
  function _typescript() {
19
- const data = _interopRequireDefault(require("typescript"));
19
+ const data = _interopRequireWildcard(require("typescript"));
20
20
  _typescript = function () {
21
21
  return data;
22
22
  };
@@ -78,6 +78,8 @@ function _parseTypeFromQuickInfo() {
78
78
  };
79
79
  return data;
80
80
  }
81
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
82
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
81
83
  class SchemaExtractorContext {
82
84
  constructor(tsserver, component, extractor, componentDeps) {
83
85
  this.tsserver = tsserver;
@@ -256,7 +258,7 @@ class SchemaExtractorContext {
256
258
  async getFileExports(exportDec) {
257
259
  var _exportDec$moduleSpec;
258
260
  const file = exportDec.getSourceFile().fileName;
259
- const specifierPathStr = ((_exportDec$moduleSpec = exportDec.moduleSpecifier) === null || _exportDec$moduleSpec === void 0 ? void 0 : _exportDec$moduleSpec.getText()) || '';
261
+ const specifierPathStr = exportDec.kind === _typescript().SyntaxKind.ExportDeclaration && ((_exportDec$moduleSpec = exportDec.moduleSpecifier) === null || _exportDec$moduleSpec === void 0 ? void 0 : _exportDec$moduleSpec.getText()) || '';
260
262
  const specifierPath = specifierPathStr.substring(1, specifierPathStr.length - 1);
261
263
  const absPath = (0, _path().resolve)(file, '..', specifierPath);
262
264
  const sourceFile = this.getSourceFileInsideComponent(absPath);
@@ -1 +1 @@
1
- {"version":3,"names":["SchemaExtractorContext","constructor","tsserver","component","extractor","componentDeps","undefined","computeSchema","node","getLocation","targetSourceFile","absolutePath","sourceFile","getSourceFile","position","getLineAndCharacterOfPosition","getStart","line","character","filePath","fileName","getPathRelativeToComponent","pathNormalizeToLinux","getLocationAsString","location","basePath","filesystem","files","base","relative","getSignature","getSignatureHelp","getPath","getPosition","offset","getPositionOfLineAndCharacter","getQuickInfo","err","message","Error","getQuickInfoDisplayString","quickInfo","body","displayString","typeDefinition","getTypeDefinition","visitTypeDefinition","findFileInComponent","find","file","path","includes","strings","map","format","endsWith","string","parsePackageNameFromPath","parts","split","length","lastPart","replace","sep","pkgParts","startsWith","pkgName","getSourceFileInsideComponent","parseSourceFile","getSourceFileFromNode","getFilePathByNode","def","getDefinition","firstDef","head","definitionInfo","definition","definitonInfo","startPosition","start","pos","nodeAtPos","getTokenAtPosition","visitDefinition","getTypeRefForExternalNode","visit","parent","references","isExported","isFromComponent","getFileExports","exportDec","specifierPathStr","moduleSpecifier","getText","specifierPath","substring","absPath","resolve","computeExportedIdentifiers","setExports","exports","_exports","getExportedIdentifiers","jump","TransformerNotFound","resolveType","typeStr","isTypeStrFromQuickInfo","TypeRefSchema","type","ts","isTypeNode","typeNodeToSchema","getDef","headTypeDefinition","unknownExactType","InferenceTypeSchema","info","parseTypeFromQuickInfo","isDefInSameLocation","loc","schemaNode","getTypeRefForExternalPath","getCompIdByPkgName","dep","packageName","componentId","compIdByPath","getComponentIDByPath","compIdByPkg"],"sources":["schema-extractor-context.ts"],"sourcesContent":["import { TsserverClient } from '@teambit/ts-server';\nimport ts, { ExportDeclaration, Node, TypeNode } from 'typescript';\nimport { getTokenAtPosition } from 'tsutils';\nimport { head } from 'lodash';\n// eslint-disable-next-line import/no-unresolved\nimport protocol from 'typescript/lib/protocol';\n// @ts-ignore david we should figure fix this.\nimport type { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';\nimport { pathNormalizeToLinux } from '@teambit/legacy/dist/utils';\nimport { resolve, sep, relative } from 'path';\nimport { Component, ComponentID } from '@teambit/component';\nimport { TypeRefSchema, SchemaNode, InferenceTypeSchema, Location } from '@teambit/semantics.entities.semantic-schema';\nimport { ComponentDependency } from '@teambit/dependency-resolver';\nimport { TypeScriptExtractor } from './typescript.extractor';\nimport { ExportList } from './export-list';\nimport { typeNodeToSchema } from './transformers/utils/type-node-to-schema';\nimport { TransformerNotFound } from './exceptions';\nimport { parseTypeFromQuickInfo } from './transformers/utils/parse-type-from-quick-info';\n\nexport class SchemaExtractorContext {\n constructor(\n readonly tsserver: TsserverClient,\n readonly component: Component,\n readonly extractor: TypeScriptExtractor,\n readonly componentDeps: ComponentDependency[]\n ) {}\n\n computeSchema(node: Node) {\n return this.extractor.computeSchema(node, this);\n }\n\n /**\n * returns the location of a node in a source file.\n */\n getLocation(node: Node, targetSourceFile?: ts.SourceFile, absolutePath = false): Location {\n const sourceFile = targetSourceFile || node.getSourceFile();\n const position = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n const line = position.line + 1;\n const character = position.character + 1;\n const filePath = absolutePath ? sourceFile.fileName : this.getPathRelativeToComponent(sourceFile.fileName);\n\n return {\n filePath: pathNormalizeToLinux(filePath),\n line,\n character,\n };\n }\n\n getLocationAsString(node: Node): string {\n const location = this.getLocation(node);\n return `${node.getSourceFile().fileName}, line: ${location.line}, character: ${location.character}`;\n }\n\n getPathRelativeToComponent(filePath: string): string {\n const basePath = this.component.filesystem.files[0].base;\n return relative(basePath, filePath);\n }\n\n /**\n * returns a signature for a node.\n */\n async getSignature(node: Node) {\n return this.tsserver.getSignatureHelp(this.getPath(node), this.getLocation(node));\n }\n\n /**\n * get the position for the tsserver.\n */\n getPosition(sourceFile: ts.SourceFile, line: number, offset: number): number {\n return sourceFile.getPositionOfLineAndCharacter(line - 1, offset - 1);\n }\n\n /**\n * get the path for a source file.\n */\n getPath(node: Node) {\n const sourceFile = node.getSourceFile();\n return sourceFile.fileName;\n }\n\n async getQuickInfo(node: Node) {\n const location = this.getLocation(node);\n try {\n return await this.tsserver.getQuickInfo(this.getPath(node), location);\n } catch (err: any) {\n if (err.message === 'No content available.') {\n throw new Error(\n `unable to get quickinfo data from tsserver at ${this.getPath(node)}, Ln ${location.line}, Col ${\n location.character\n }`\n );\n }\n throw err;\n }\n }\n\n async getQuickInfoDisplayString(node: Node): Promise<string> {\n const quickInfo = await this.getQuickInfo(node);\n return quickInfo?.body?.displayString || '';\n }\n\n /**\n * returns the type definition for a type.\n */\n typeDefinition(node: Node) {\n return this.tsserver.getTypeDefinition(this.getPath(node), this.getLocation(node));\n }\n\n visitTypeDefinition() {}\n\n private findFileInComponent(filePath: string) {\n return this.component.filesystem.files.find((file) => {\n // TODO: fix this line to support further extensions.\n if (file.path.includes(filePath)) {\n const strings = ['ts', 'tsx', 'js', 'jsx'].map((format) => {\n if (filePath.endsWith(format)) return filePath;\n return `${filePath}.${format}`;\n });\n\n return strings.find((string) => string === file.path);\n }\n\n return false;\n });\n }\n\n private parsePackageNameFromPath(path: string) {\n const parts = path.split('node_modules');\n if (parts.length === 1) return '';\n const lastPart = parts[parts.length - 1].replace(sep, '');\n const pkgParts = lastPart.split('/');\n if (lastPart.startsWith('@')) {\n // scoped package\n return `${pkgParts[0]}/${pkgParts[1]}`;\n }\n const pkgName = pkgParts[0];\n if (pkgName === 'typescript') {\n // it's a built-in type, such as \"string\".\n return '';\n }\n return pkgName;\n }\n\n /**\n * return the file if part of the component.\n * otherwise, a reference to the target package and the type name.\n */\n getSourceFileInsideComponent(filePath: string) {\n const file = this.findFileInComponent(filePath);\n if (!file) return undefined;\n return this.extractor.parseSourceFile(file);\n }\n\n async getSourceFileFromNode(node: Node) {\n const filePath = await this.getFilePathByNode(node);\n if (!filePath) {\n return undefined;\n }\n return this.getSourceFileInsideComponent(filePath);\n }\n\n async getFilePathByNode(node: Node) {\n const def = await this.tsserver.getDefinition(this.getPath(node), this.getLocation(node));\n\n const firstDef = head(def.body);\n return firstDef?.file;\n }\n\n async definitionInfo(node: Node): Promise<protocol.DefinitionInfo | undefined> {\n const location = this.getLocation(node);\n const filePath = this.getPath(node);\n\n const def = await this.tsserver.getDefinition(filePath, location);\n\n const firstDef = head(def.body);\n\n return firstDef;\n }\n\n /**\n * get a definition for a given node.\n */\n async definition(definitonInfo: protocol.DefinitionInfo): Promise<Node | undefined> {\n const startPosition = definitonInfo.start;\n const sourceFile = this.getSourceFileInsideComponent(definitonInfo.file);\n if (!sourceFile) {\n // it might be an external reference, cant get the node\n return undefined;\n }\n const pos = this.getPosition(sourceFile, startPosition.line, startPosition.offset);\n const nodeAtPos = getTokenAtPosition(sourceFile, pos);\n return nodeAtPos;\n }\n\n /**\n * visit a definition for node - e.g. return it's schema.\n */\n async visitDefinition(node: Node): Promise<SchemaNode | undefined> {\n const definitionInfo = await this.definitionInfo(node);\n if (!definitionInfo) {\n return undefined;\n }\n\n const definition = await this.definition(definitionInfo);\n if (!definition) {\n return this.getTypeRefForExternalNode(node);\n }\n\n return this.visit(definition.parent);\n }\n\n async visit(node: Node): Promise<SchemaNode> {\n return this.extractor.computeSchema(node, this);\n }\n\n references() {}\n\n isExported() {}\n\n isFromComponent() {}\n\n async getFileExports(exportDec: ExportDeclaration) {\n const file = exportDec.getSourceFile().fileName;\n const specifierPathStr = exportDec.moduleSpecifier?.getText() || '';\n const specifierPath = specifierPathStr.substring(1, specifierPathStr.length - 1);\n const absPath = resolve(file, '..', specifierPath);\n const sourceFile = this.getSourceFileInsideComponent(absPath);\n if (!sourceFile) return [];\n return this.extractor.computeExportedIdentifiers(sourceFile, this);\n }\n\n _exports: ExportList | undefined = undefined;\n\n setExports(exports: ExportList) {\n this._exports = exports;\n return this;\n }\n\n getExportedIdentifiers(node: Node) {\n return this.extractor.computeExportedIdentifiers(node, this);\n }\n\n async jump(file: AbstractVinyl, start: any): Promise<SchemaNode | undefined> {\n const sourceFile = this.extractor.parseSourceFile(file);\n const pos = this.getPosition(sourceFile, start.line, start.offset);\n const nodeAtPos = getTokenAtPosition(sourceFile, pos);\n if (!nodeAtPos) return undefined;\n\n // this causes some infinite loops. it's helpful for getting more data from types that are not exported.\n // e.g.\n // ```ts\n // class Bar {}\n // export const getBar = () => new Bar();\n // ```\n // if (nodeAtPos.kind === ts.SyntaxKind.Identifier) {\n // // @todo: make sure with Ran that it's fine. Maybe it's better to do: `this.visit(nodeAtPos.parent);`\n // return this.visitDefinition(nodeAtPos);\n // }\n try {\n return await this.visit(nodeAtPos);\n } catch (err) {\n if (err instanceof TransformerNotFound) {\n return undefined;\n }\n throw err;\n }\n }\n\n /**\n * resolve a type by a node and its identifier.\n */\n async resolveType(\n node: Node & { type?: TypeNode },\n typeStr: string,\n isTypeStrFromQuickInfo = true\n ): Promise<SchemaNode> {\n const location = this.getLocation(node);\n if (this._exports?.includes(typeStr)) {\n return new TypeRefSchema(location, typeStr);\n }\n if (node.type && ts.isTypeNode(node.type)) {\n // if a node has \"type\" prop, it has the type data of the node. this normally happens when the code has the type\n // explicitly, e.g. `const str: string` vs implicitly `const str = 'some-string'`, which the node won't have \"type\"\n return typeNodeToSchema(node.type, this);\n }\n /**\n * tsserver has two different calls: \"definition\" and \"typeDefinition\".\n * normally, we need the \"typeDefinition\" to get the type data of a node.\n * sometimes, it has no data, for example when the node is of type TypeReference, and then using \"definition\" is\n * helpful. (couldn't find a rule when to use each one. e.g. \"VariableDeclaration\" sometimes has data only in\n * \"definition\" but it's not clear when/why).\n */\n const getDef = async () => {\n const typeDefinition = await this.typeDefinition(node);\n const headTypeDefinition = head(typeDefinition?.body);\n if (headTypeDefinition) {\n return headTypeDefinition;\n }\n const definition = await this.tsserver.getDefinition(node.getSourceFile().fileName, this.getLocation(node));\n return head(definition?.body);\n };\n const definition = await getDef();\n\n // when we can't figure out the component/package/type of this node, we'll use the typeStr as the type.\n const unknownExactType = async () => {\n if (isTypeStrFromQuickInfo) {\n return new InferenceTypeSchema(location, typeStr || 'any');\n }\n const info = await this.getQuickInfo(node);\n const type = parseTypeFromQuickInfo(info);\n return new InferenceTypeSchema(location, type, typeStr);\n };\n if (!definition) {\n return unknownExactType();\n }\n\n // the reason for this check is to avoid infinite loop when calling `this.jump` with the same file+location\n const isDefInSameLocation = () => {\n if (definition.file !== node.getSourceFile().fileName) {\n return false;\n }\n const loc = this.getLocation(node);\n return loc.line === definition.start.line && loc.character === definition.start.offset;\n };\n\n const file = this.findFileInComponent(definition.file);\n if (file) {\n if (isDefInSameLocation()) {\n return unknownExactType();\n }\n const schemaNode = await this.jump(file, definition.start);\n return schemaNode || unknownExactType();\n }\n return this.getTypeRefForExternalPath(typeStr, definition.file, location);\n }\n\n private getCompIdByPkgName(pkgName: string): ComponentID | undefined {\n return this.componentDeps.find((dep) => dep.packageName === pkgName)?.componentId;\n }\n\n async getTypeRefForExternalNode(node: Node): Promise<TypeRefSchema> {\n const info = await this.getQuickInfo(node);\n const typeStr = parseTypeFromQuickInfo(info);\n const location = this.getLocation(node);\n const filePath = this.getPath(node);\n return this.getTypeRefForExternalPath(typeStr, filePath, location);\n }\n\n async getTypeRefForExternalPath(typeStr: string, filePath: string, location: Location): Promise<TypeRefSchema> {\n const compIdByPath = await this.extractor.getComponentIDByPath(filePath);\n if (compIdByPath) {\n return new TypeRefSchema(location, typeStr, compIdByPath);\n }\n const pkgName = this.parsePackageNameFromPath(filePath);\n const compIdByPkg = this.getCompIdByPkgName(pkgName);\n if (compIdByPkg) {\n return new TypeRefSchema(location, typeStr, compIdByPkg);\n }\n return new TypeRefSchema(location, typeStr, undefined, pkgName);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAKA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAIA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,MAAMA,sBAAsB,CAAC;EAClCC,WAAW,CACAC,QAAwB,EACxBC,SAAoB,EACpBC,SAA8B,EAC9BC,aAAoC,EAC7C;IAAA,KAJSH,QAAwB,GAAxBA,QAAwB;IAAA,KACxBC,SAAoB,GAApBA,SAAoB;IAAA,KACpBC,SAA8B,GAA9BA,SAA8B;IAAA,KAC9BC,aAAoC,GAApCA,aAAoC;IAAA,kDA+MZC,S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AC"}
1
+ {"version":3,"names":["SchemaExtractorContext","constructor","tsserver","component","extractor","componentDeps","undefined","computeSchema","node","getLocation","targetSourceFile","absolutePath","sourceFile","getSourceFile","position","getLineAndCharacterOfPosition","getStart","line","character","filePath","fileName","getPathRelativeToComponent","pathNormalizeToLinux","getLocationAsString","location","basePath","filesystem","files","base","relative","getSignature","getSignatureHelp","getPath","getPosition","offset","getPositionOfLineAndCharacter","getQuickInfo","err","message","Error","getQuickInfoDisplayString","quickInfo","body","displayString","typeDefinition","getTypeDefinition","visitTypeDefinition","findFileInComponent","find","file","path","includes","strings","map","format","endsWith","string","parsePackageNameFromPath","parts","split","length","lastPart","replace","sep","pkgParts","startsWith","pkgName","getSourceFileInsideComponent","parseSourceFile","getSourceFileFromNode","getFilePathByNode","def","getDefinition","firstDef","head","definitionInfo","definition","definitonInfo","startPosition","start","pos","nodeAtPos","getTokenAtPosition","visitDefinition","getTypeRefForExternalNode","visit","parent","references","isExported","isFromComponent","getFileExports","exportDec","specifierPathStr","kind","SyntaxKind","ExportDeclaration","moduleSpecifier","getText","specifierPath","substring","absPath","resolve","computeExportedIdentifiers","setExports","exports","_exports","getExportedIdentifiers","jump","TransformerNotFound","resolveType","typeStr","isTypeStrFromQuickInfo","TypeRefSchema","type","ts","isTypeNode","typeNodeToSchema","getDef","headTypeDefinition","unknownExactType","InferenceTypeSchema","info","parseTypeFromQuickInfo","isDefInSameLocation","loc","schemaNode","getTypeRefForExternalPath","getCompIdByPkgName","dep","packageName","componentId","compIdByPath","getComponentIDByPath","compIdByPkg"],"sources":["schema-extractor-context.ts"],"sourcesContent":["import { TsserverClient } from '@teambit/ts-server';\nimport ts, { ExportAssignment, ExportDeclaration, Node, SyntaxKind, TypeNode } from 'typescript';\nimport { getTokenAtPosition } from 'tsutils';\nimport { head } from 'lodash';\n// eslint-disable-next-line import/no-unresolved\nimport protocol from 'typescript/lib/protocol';\n// @ts-ignore david we should figure fix this.\nimport type { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';\nimport { pathNormalizeToLinux } from '@teambit/legacy/dist/utils';\nimport { resolve, sep, relative } from 'path';\nimport { Component, ComponentID } from '@teambit/component';\nimport { TypeRefSchema, SchemaNode, InferenceTypeSchema, Location } from '@teambit/semantics.entities.semantic-schema';\nimport { ComponentDependency } from '@teambit/dependency-resolver';\nimport { TypeScriptExtractor } from './typescript.extractor';\nimport { ExportList } from './export-list';\nimport { typeNodeToSchema } from './transformers/utils/type-node-to-schema';\nimport { TransformerNotFound } from './exceptions';\nimport { parseTypeFromQuickInfo } from './transformers/utils/parse-type-from-quick-info';\n\nexport class SchemaExtractorContext {\n constructor(\n readonly tsserver: TsserverClient,\n readonly component: Component,\n readonly extractor: TypeScriptExtractor,\n readonly componentDeps: ComponentDependency[]\n ) {}\n\n computeSchema(node: Node) {\n return this.extractor.computeSchema(node, this);\n }\n\n /**\n * returns the location of a node in a source file.\n */\n getLocation(node: Node, targetSourceFile?: ts.SourceFile, absolutePath = false): Location {\n const sourceFile = targetSourceFile || node.getSourceFile();\n const position = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n const line = position.line + 1;\n const character = position.character + 1;\n const filePath = absolutePath ? sourceFile.fileName : this.getPathRelativeToComponent(sourceFile.fileName);\n\n return {\n filePath: pathNormalizeToLinux(filePath),\n line,\n character,\n };\n }\n\n getLocationAsString(node: Node): string {\n const location = this.getLocation(node);\n return `${node.getSourceFile().fileName}, line: ${location.line}, character: ${location.character}`;\n }\n\n getPathRelativeToComponent(filePath: string): string {\n const basePath = this.component.filesystem.files[0].base;\n return relative(basePath, filePath);\n }\n\n /**\n * returns a signature for a node.\n */\n async getSignature(node: Node) {\n return this.tsserver.getSignatureHelp(this.getPath(node), this.getLocation(node));\n }\n\n /**\n * get the position for the tsserver.\n */\n getPosition(sourceFile: ts.SourceFile, line: number, offset: number): number {\n return sourceFile.getPositionOfLineAndCharacter(line - 1, offset - 1);\n }\n\n /**\n * get the path for a source file.\n */\n getPath(node: Node) {\n const sourceFile = node.getSourceFile();\n return sourceFile.fileName;\n }\n\n async getQuickInfo(node: Node) {\n const location = this.getLocation(node);\n try {\n return await this.tsserver.getQuickInfo(this.getPath(node), location);\n } catch (err: any) {\n if (err.message === 'No content available.') {\n throw new Error(\n `unable to get quickinfo data from tsserver at ${this.getPath(node)}, Ln ${location.line}, Col ${\n location.character\n }`\n );\n }\n throw err;\n }\n }\n\n async getQuickInfoDisplayString(node: Node): Promise<string> {\n const quickInfo = await this.getQuickInfo(node);\n return quickInfo?.body?.displayString || '';\n }\n\n /**\n * returns the type definition for a type.\n */\n typeDefinition(node: Node) {\n return this.tsserver.getTypeDefinition(this.getPath(node), this.getLocation(node));\n }\n\n visitTypeDefinition() {}\n\n private findFileInComponent(filePath: string) {\n return this.component.filesystem.files.find((file) => {\n // TODO: fix this line to support further extensions.\n if (file.path.includes(filePath)) {\n const strings = ['ts', 'tsx', 'js', 'jsx'].map((format) => {\n if (filePath.endsWith(format)) return filePath;\n return `${filePath}.${format}`;\n });\n\n return strings.find((string) => string === file.path);\n }\n\n return false;\n });\n }\n\n private parsePackageNameFromPath(path: string) {\n const parts = path.split('node_modules');\n if (parts.length === 1) return '';\n const lastPart = parts[parts.length - 1].replace(sep, '');\n const pkgParts = lastPart.split('/');\n if (lastPart.startsWith('@')) {\n // scoped package\n return `${pkgParts[0]}/${pkgParts[1]}`;\n }\n const pkgName = pkgParts[0];\n if (pkgName === 'typescript') {\n // it's a built-in type, such as \"string\".\n return '';\n }\n return pkgName;\n }\n\n /**\n * return the file if part of the component.\n * otherwise, a reference to the target package and the type name.\n */\n getSourceFileInsideComponent(filePath: string) {\n const file = this.findFileInComponent(filePath);\n if (!file) return undefined;\n return this.extractor.parseSourceFile(file);\n }\n\n async getSourceFileFromNode(node: Node) {\n const filePath = await this.getFilePathByNode(node);\n if (!filePath) {\n return undefined;\n }\n return this.getSourceFileInsideComponent(filePath);\n }\n\n async getFilePathByNode(node: Node) {\n const def = await this.tsserver.getDefinition(this.getPath(node), this.getLocation(node));\n\n const firstDef = head(def.body);\n return firstDef?.file;\n }\n\n async definitionInfo(node: Node): Promise<protocol.DefinitionInfo | undefined> {\n const location = this.getLocation(node);\n const filePath = this.getPath(node);\n\n const def = await this.tsserver.getDefinition(filePath, location);\n\n const firstDef = head(def.body);\n\n return firstDef;\n }\n\n /**\n * get a definition for a given node.\n */\n async definition(definitonInfo: protocol.DefinitionInfo): Promise<Node | undefined> {\n const startPosition = definitonInfo.start;\n const sourceFile = this.getSourceFileInsideComponent(definitonInfo.file);\n if (!sourceFile) {\n // it might be an external reference, cant get the node\n return undefined;\n }\n const pos = this.getPosition(sourceFile, startPosition.line, startPosition.offset);\n const nodeAtPos = getTokenAtPosition(sourceFile, pos);\n return nodeAtPos;\n }\n\n /**\n * visit a definition for node - e.g. return it's schema.\n */\n async visitDefinition(node: Node): Promise<SchemaNode | undefined> {\n const definitionInfo = await this.definitionInfo(node);\n if (!definitionInfo) {\n return undefined;\n }\n\n const definition = await this.definition(definitionInfo);\n if (!definition) {\n return this.getTypeRefForExternalNode(node);\n }\n\n return this.visit(definition.parent);\n }\n\n async visit(node: Node): Promise<SchemaNode> {\n return this.extractor.computeSchema(node, this);\n }\n\n references() {}\n\n isExported() {}\n\n isFromComponent() {}\n\n async getFileExports(exportDec: ExportDeclaration | ExportAssignment) {\n const file = exportDec.getSourceFile().fileName;\n const specifierPathStr =\n (exportDec.kind === SyntaxKind.ExportDeclaration && exportDec.moduleSpecifier?.getText()) || '';\n const specifierPath = specifierPathStr.substring(1, specifierPathStr.length - 1);\n const absPath = resolve(file, '..', specifierPath);\n const sourceFile = this.getSourceFileInsideComponent(absPath);\n if (!sourceFile) return [];\n return this.extractor.computeExportedIdentifiers(sourceFile, this);\n }\n\n _exports: ExportList | undefined = undefined;\n\n setExports(exports: ExportList) {\n this._exports = exports;\n return this;\n }\n\n getExportedIdentifiers(node: Node) {\n return this.extractor.computeExportedIdentifiers(node, this);\n }\n\n async jump(file: AbstractVinyl, start: any): Promise<SchemaNode | undefined> {\n const sourceFile = this.extractor.parseSourceFile(file);\n const pos = this.getPosition(sourceFile, start.line, start.offset);\n const nodeAtPos = getTokenAtPosition(sourceFile, pos);\n if (!nodeAtPos) return undefined;\n\n // this causes some infinite loops. it's helpful for getting more data from types that are not exported.\n // e.g.\n // ```ts\n // class Bar {}\n // export const getBar = () => new Bar();\n // ```\n // if (nodeAtPos.kind === ts.SyntaxKind.Identifier) {\n // // @todo: make sure with Ran that it's fine. Maybe it's better to do: `this.visit(nodeAtPos.parent);`\n // return this.visitDefinition(nodeAtPos);\n // }\n try {\n return await this.visit(nodeAtPos);\n } catch (err) {\n if (err instanceof TransformerNotFound) {\n return undefined;\n }\n throw err;\n }\n }\n\n /**\n * resolve a type by a node and its identifier.\n */\n async resolveType(\n node: Node & { type?: TypeNode },\n typeStr: string,\n isTypeStrFromQuickInfo = true\n ): Promise<SchemaNode> {\n const location = this.getLocation(node);\n if (this._exports?.includes(typeStr)) {\n return new TypeRefSchema(location, typeStr);\n }\n if (node.type && ts.isTypeNode(node.type)) {\n // if a node has \"type\" prop, it has the type data of the node. this normally happens when the code has the type\n // explicitly, e.g. `const str: string` vs implicitly `const str = 'some-string'`, which the node won't have \"type\"\n return typeNodeToSchema(node.type, this);\n }\n /**\n * tsserver has two different calls: \"definition\" and \"typeDefinition\".\n * normally, we need the \"typeDefinition\" to get the type data of a node.\n * sometimes, it has no data, for example when the node is of type TypeReference, and then using \"definition\" is\n * helpful. (couldn't find a rule when to use each one. e.g. \"VariableDeclaration\" sometimes has data only in\n * \"definition\" but it's not clear when/why).\n */\n const getDef = async () => {\n const typeDefinition = await this.typeDefinition(node);\n const headTypeDefinition = head(typeDefinition?.body);\n if (headTypeDefinition) {\n return headTypeDefinition;\n }\n const definition = await this.tsserver.getDefinition(node.getSourceFile().fileName, this.getLocation(node));\n return head(definition?.body);\n };\n const definition = await getDef();\n\n // when we can't figure out the component/package/type of this node, we'll use the typeStr as the type.\n const unknownExactType = async () => {\n if (isTypeStrFromQuickInfo) {\n return new InferenceTypeSchema(location, typeStr || 'any');\n }\n const info = await this.getQuickInfo(node);\n const type = parseTypeFromQuickInfo(info);\n return new InferenceTypeSchema(location, type, typeStr);\n };\n if (!definition) {\n return unknownExactType();\n }\n\n // the reason for this check is to avoid infinite loop when calling `this.jump` with the same file+location\n const isDefInSameLocation = () => {\n if (definition.file !== node.getSourceFile().fileName) {\n return false;\n }\n const loc = this.getLocation(node);\n return loc.line === definition.start.line && loc.character === definition.start.offset;\n };\n\n const file = this.findFileInComponent(definition.file);\n if (file) {\n if (isDefInSameLocation()) {\n return unknownExactType();\n }\n const schemaNode = await this.jump(file, definition.start);\n return schemaNode || unknownExactType();\n }\n return this.getTypeRefForExternalPath(typeStr, definition.file, location);\n }\n\n private getCompIdByPkgName(pkgName: string): ComponentID | undefined {\n return this.componentDeps.find((dep) => dep.packageName === pkgName)?.componentId;\n }\n\n async getTypeRefForExternalNode(node: Node): Promise<TypeRefSchema> {\n const info = await this.getQuickInfo(node);\n const typeStr = parseTypeFromQuickInfo(info);\n const location = this.getLocation(node);\n const filePath = this.getPath(node);\n return this.getTypeRefForExternalPath(typeStr, filePath, location);\n }\n\n async getTypeRefForExternalPath(typeStr: string, filePath: string, location: Location): Promise<TypeRefSchema> {\n const compIdByPath = await this.extractor.getComponentIDByPath(filePath);\n if (compIdByPath) {\n return new TypeRefSchema(location, typeStr, compIdByPath);\n }\n const pkgName = this.parsePackageNameFromPath(filePath);\n const compIdByPkg = this.getCompIdByPkgName(pkgName);\n if (compIdByPkg) {\n return new TypeRefSchema(location, typeStr, compIdByPkg);\n }\n return new TypeRefSchema(location, typeStr, undefined, pkgName);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAKA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;E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AAG,MAAM,IAAI,CAAC/H,SAAS,CAACgI,oBAAoB,CAACjH,QAAQ,CAAC;IACxE,IAAIgH,YAAY,EAAE;MAChB,OAAO,KAAInB,kCAAa,EAACxF,QAAQ,EAAEsF,OAAO,EAAEqB,YAAY,CAAC;IAC3D;IACA,MAAMjE,OAAO,GAAG,IAAI,CAACT,wBAAwB,CAACtC,QAAQ,CAAC;IACvD,MAAMkH,WAAW,GAAG,IAAI,CAACN,kBAAkB,CAAC7D,OAAO,CAAC;IACpD,IAAImE,WAAW,EAAE;MACf,OAAO,KAAIrB,kCAAa,EAACxF,QAAQ,EAAEsF,OAAO,EAAEuB,WAAW,CAAC;IAC1D;IACA,OAAO,KAAIrB,kCAAa,EAACxF,QAAQ,EAAEsF,OAAO,EAAExG,SAAS,EAAE4D,OAAO,CAAC;EACjE;AACF;AAAC"}
@@ -0,0 +1,9 @@
1
+ import { SchemaNode } from '@teambit/semantics.entities.semantic-schema';
2
+ import { Node, ExportAssignment as ExportAssignmentNode } from 'typescript';
3
+ import { SchemaExtractorContext } from '../schema-extractor-context';
4
+ import { SchemaTransformer } from '../schema-transformer';
5
+ export declare class ExportAssignmentDeclaration implements SchemaTransformer {
6
+ predicate(node: Node): boolean;
7
+ getIdentifiers(exportDec: ExportAssignmentNode, context: SchemaExtractorContext): Promise<import("../export-identifier").ExportIdentifier[]>;
8
+ transform(exportDec: ExportAssignmentNode, context: SchemaExtractorContext): Promise<SchemaNode>;
9
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.promise.js");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.ExportAssignmentDeclaration = void 0;
8
+ function _typescript() {
9
+ const data = require("typescript");
10
+ _typescript = function () {
11
+ return data;
12
+ };
13
+ return data;
14
+ }
15
+ class ExportAssignmentDeclaration {
16
+ predicate(node) {
17
+ return node.kind === _typescript().SyntaxKind.ExportAssignment;
18
+ }
19
+ async getIdentifiers(exportDec, context) {
20
+ return context.getFileExports(exportDec);
21
+ }
22
+ async transform(exportDec, context) {
23
+ const specifier = exportDec.expression;
24
+ return context.computeSchema(specifier);
25
+ }
26
+ }
27
+ exports.ExportAssignmentDeclaration = ExportAssignmentDeclaration;
28
+
29
+ //# sourceMappingURL=export-assignment-declaration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ExportAssignmentDeclaration","predicate","node","kind","SyntaxKind","ExportAssignment","getIdentifiers","exportDec","context","getFileExports","transform","specifier","expression","computeSchema"],"sources":["export-assignment-declaration.ts"],"sourcesContent":["import { SchemaNode } from '@teambit/semantics.entities.semantic-schema';\nimport { Node, SyntaxKind, ExportAssignment as ExportAssignmentNode } from 'typescript';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { SchemaTransformer } from '../schema-transformer';\n\nexport class ExportAssignmentDeclaration implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === SyntaxKind.ExportAssignment;\n }\n\n async getIdentifiers(exportDec: ExportAssignmentNode, context: SchemaExtractorContext) {\n return context.getFileExports(exportDec);\n }\n\n async transform(exportDec: ExportAssignmentNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n const specifier = exportDec.expression;\n return context.computeSchema(specifier);\n }\n}\n"],"mappings":";;;;;;;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAIO,MAAMA,2BAA2B,CAA8B;EACpEC,SAAS,CAACC,IAAU,EAAE;IACpB,OAAOA,IAAI,CAACC,IAAI,KAAKC,wBAAU,CAACC,gBAAgB;EAClD;EAEA,MAAMC,cAAc,CAACC,SAA+B,EAAEC,OAA+B,EAAE;IACrF,OAAOA,OAAO,CAACC,cAAc,CAACF,SAAS,CAAC;EAC1C;EAEA,MAAMG,SAAS,CAACH,SAA+B,EAAEC,OAA+B,EAAuB;IACrG,MAAMG,SAAS,GAAGJ,SAAS,CAACK,UAAU;IACtC,OAAOJ,OAAO,CAACK,aAAa,CAACF,SAAS,CAAC;EACzC;AACF;AAAC"}
@@ -29,7 +29,7 @@ function _toFunctionLikeSchema() {
29
29
  }
30
30
  class FunctionDeclaration {
31
31
  predicate(node) {
32
- return node.kind === _typescript().default.SyntaxKind.FunctionDeclaration;
32
+ return node.kind === _typescript().default.SyntaxKind.FunctionDeclaration || node.kind === _typescript().default.SyntaxKind.ArrowFunction;
33
33
  }
34
34
 
35
35
  // need to check for anonymous functions assigned for vars, const and let.
@@ -1 +1 @@
1
- {"version":3,"names":["FunctionDeclaration","predicate","node","kind","ts","SyntaxKind","getIdentifiers","funcDec","ExportIdentifier","getName","getSourceFile","fileName","name","getText","transform","context","toFunctionLikeSchema"],"sources":["function-declaration.ts"],"sourcesContent":["import { SchemaNode } from '@teambit/semantics.entities.semantic-schema';\nimport ts, { Node, FunctionDeclaration as FunctionDeclarationNode } from 'typescript';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { ExportIdentifier } from '../export-identifier';\nimport { toFunctionLikeSchema } from './utils/to-function-like-schema';\n\nexport class FunctionDeclaration implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.FunctionDeclaration;\n }\n\n // need to check for anonymous functions assigned for vars, const and let.\n async getIdentifiers(funcDec: FunctionDeclarationNode) {\n return [new ExportIdentifier(this.getName(funcDec), funcDec.getSourceFile().fileName)];\n }\n\n private getName(funcDec: FunctionDeclarationNode) {\n return funcDec.name?.getText() || '';\n }\n\n async transform(funcDec: FunctionDeclarationNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n return toFunctionLikeSchema(funcDec, context);\n }\n}\n"],"mappings":";;;;;;;;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,MAAMA,mBAAmB,CAA8B;EAC5DC,SAAS,CAACC,IAAU,EAAE;IACpB,OAAOA,IAAI,CAACC,IAAI,KAAKC,qBAAE,CAACC,UAAU,CAACL,mBAAmB;EACxD;;EAEA;EACA,MAAMM,cAAc,CAACC,OAAgC,EAAE;IACrD,OAAO,CAAC,KAAIC,oCAAgB,EAAC,IAAI,CAACC,OAAO,CAACF,OAAO,CAAC,EAAEA,OAAO,CAACG,aAAa,EAAE,CAACC,QAAQ,CAAC,CAAC;EACxF;EAEQF,OAAO,CAACF,OAAgC,EAAE;IAAA;IAChD,OAAO,kBAAAA,OAAO,CAACK,IAAI,kDAAZ,cAAcC,OAAO,EAAE,KAAI,EAAE;EACtC;EAEA,MAAMC,SAAS,CAACP,OAAgC,EAAEQ,OAA+B,EAAuB;IACtG,OAAO,IAAAC,4CAAoB,EAACT,OAAO,EAAEQ,OAAO,CAAC;EAC/C;AACF;AAAC"}
1
+ {"version":3,"names":["FunctionDeclaration","predicate","node","kind","ts","SyntaxKind","ArrowFunction","getIdentifiers","funcDec","ExportIdentifier","getName","getSourceFile","fileName","name","getText","transform","context","toFunctionLikeSchema"],"sources":["function-declaration.ts"],"sourcesContent":["import { SchemaNode } from '@teambit/semantics.entities.semantic-schema';\nimport ts, { Node, FunctionDeclaration as FunctionDeclarationNode } from 'typescript';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { ExportIdentifier } from '../export-identifier';\nimport { toFunctionLikeSchema } from './utils/to-function-like-schema';\n\nexport class FunctionDeclaration implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.FunctionDeclaration || node.kind === ts.SyntaxKind.ArrowFunction;\n }\n\n // need to check for anonymous functions assigned for vars, const and let.\n async getIdentifiers(funcDec: FunctionDeclarationNode) {\n return [new ExportIdentifier(this.getName(funcDec), funcDec.getSourceFile().fileName)];\n }\n\n private getName(funcDec: FunctionDeclarationNode) {\n return funcDec.name?.getText() || '';\n }\n\n async transform(funcDec: FunctionDeclarationNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n return toFunctionLikeSchema(funcDec, context);\n }\n}\n"],"mappings":";;;;;;;;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,MAAMA,mBAAmB,CAA8B;EAC5DC,SAAS,CAACC,IAAU,EAAE;IACpB,OAAOA,IAAI,CAACC,IAAI,KAAKC,qBAAE,CAACC,UAAU,CAACL,mBAAmB,IAAIE,IAAI,CAACC,IAAI,KAAKC,qBAAE,CAACC,UAAU,CAACC,aAAa;EACrG;;EAEA;EACA,MAAMC,cAAc,CAACC,OAAgC,EAAE;IACrD,OAAO,CAAC,KAAIC,oCAAgB,EAAC,IAAI,CAACC,OAAO,CAACF,OAAO,CAAC,EAAEA,OAAO,CAACG,aAAa,EAAE,CAACC,QAAQ,CAAC,CAAC;EACxF;EAEQF,OAAO,CAACF,OAAgC,EAAE;IAAA;IAChD,OAAO,kBAAAA,OAAO,CAACK,IAAI,kDAAZ,cAAcC,OAAO,EAAE,KAAI,EAAE;EACtC;EAEA,MAAMC,SAAS,CAACP,OAAgC,EAAEQ,OAA+B,EAAuB;IACtG,OAAO,IAAAC,4CAAoB,EAACT,OAAO,EAAEQ,OAAO,CAAC;EAC/C;AACF;AAAC"}
@@ -8,3 +8,4 @@ export { ClassDecelerationTransformer } from './class-deceleration';
8
8
  export { InterfaceDeclarationTransformer } from './interface-declaration';
9
9
  export { EnumDeclarationTransformer } from './enum-declaration';
10
10
  export { BindingElementTransformer } from './binding-element';
11
+ export { ExportAssignmentDeclaration } from './export-assignment-declaration';
@@ -21,6 +21,12 @@ Object.defineProperty(exports, "EnumDeclarationTransformer", {
21
21
  return _enumDeclaration().EnumDeclarationTransformer;
22
22
  }
23
23
  });
24
+ Object.defineProperty(exports, "ExportAssignmentDeclaration", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _exportAssignmentDeclaration().ExportAssignmentDeclaration;
28
+ }
29
+ });
24
30
  Object.defineProperty(exports, "ExportDeclaration", {
25
31
  enumerable: true,
26
32
  get: function () {
@@ -133,5 +139,12 @@ function _bindingElement() {
133
139
  };
134
140
  return data;
135
141
  }
142
+ function _exportAssignmentDeclaration() {
143
+ const data = require("./export-assignment-declaration");
144
+ _exportAssignmentDeclaration = function () {
145
+ return data;
146
+ };
147
+ return data;
148
+ }
136
149
 
137
150
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { ExportDeclaration } from './export-declaration';\nexport { FunctionDeclaration } from './function-declaration';\nexport { VariableStatementTransformer } from './variable-statement';\nexport { VariableDeclaration } from './variable-declaration';\nexport { SourceFileTransformer } from './source-file-transformer';\nexport { TypeAliasTransformer } from './type-alias';\nexport { ClassDecelerationTransformer } from './class-deceleration';\nexport { InterfaceDeclarationTransformer } from './interface-declaration';\nexport { EnumDeclarationTransformer } from './enum-declaration';\nexport { BindingElementTransformer } from './binding-element';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { ExportDeclaration } from './export-declaration';\nexport { FunctionDeclaration } from './function-declaration';\nexport { VariableStatementTransformer } from './variable-statement';\nexport { VariableDeclaration } from './variable-declaration';\nexport { SourceFileTransformer } from './source-file-transformer';\nexport { TypeAliasTransformer } from './type-alias';\nexport { ClassDecelerationTransformer } from './class-deceleration';\nexport { InterfaceDeclarationTransformer } from './interface-declaration';\nexport { EnumDeclarationTransformer } from './enum-declaration';\nexport { BindingElementTransformer } from './binding-element';\nexport { ExportAssignmentDeclaration } from './export-assignment-declaration';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA"}
@@ -5,6 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.toFunctionLikeSchema = toFunctionLikeSchema;
8
+ function _typescript() {
9
+ const data = require("typescript");
10
+ _typescript = function () {
11
+ return data;
12
+ };
13
+ return data;
14
+ }
8
15
  function _semanticsEntities() {
9
16
  const data = require("@teambit/semantics.entities.semantic-schema");
10
17
  _semanticsEntities = function () {
@@ -34,14 +41,21 @@ function _jsdocToDocSchema() {
34
41
  return data;
35
42
  }
36
43
  async function toFunctionLikeSchema(node, context, funcName) {
37
- var _node$name, _info$body, _node$modifiers, _node$typeParameters;
44
+ var _node$name, _info$body, _node$modifiers2, _node$typeParameters;
38
45
  const name = funcName || ((_node$name = node.name) === null || _node$name === void 0 ? void 0 : _node$name.getText()) || '';
39
- const info = node.name ? await context.getQuickInfo(node.name) : null;
46
+ const getQuickInfoFromDefaultModifier = async () => {
47
+ var _node$modifiers;
48
+ const defaultModifier = (_node$modifiers = node.modifiers) === null || _node$modifiers === void 0 ? void 0 : _node$modifiers.find(modifier => modifier.kind === _typescript().SyntaxKind.DefaultKeyword);
49
+ if (defaultModifier) return context.getQuickInfo(defaultModifier);
50
+ if (node.kind === _typescript().SyntaxKind.ArrowFunction) return context.getQuickInfo(node.equalsGreaterThanToken);
51
+ return null;
52
+ };
53
+ const info = node.name ? await context.getQuickInfo(node.name) : await getQuickInfoFromDefaultModifier();
40
54
  const returnTypeStr = info ? (0, _parseTypeFromQuickInfo().parseTypeFromQuickInfo)(info) : 'any';
41
55
  const displaySig = (info === null || info === void 0 ? void 0 : (_info$body = info.body) === null || _info$body === void 0 ? void 0 : _info$body.displayString) || '';
42
56
  const args = await (0, _getParams().getParams)(node.parameters, context);
43
57
  const returnType = await context.resolveType(node, returnTypeStr, Boolean(info));
44
- const modifiers = ((_node$modifiers = node.modifiers) === null || _node$modifiers === void 0 ? void 0 : _node$modifiers.map(modifier => modifier.getText())) || [];
58
+ const modifiers = ((_node$modifiers2 = node.modifiers) === null || _node$modifiers2 === void 0 ? void 0 : _node$modifiers2.map(modifier => modifier.getText())) || [];
45
59
  const typeParameters = (_node$typeParameters = node.typeParameters) === null || _node$typeParameters === void 0 ? void 0 : _node$typeParameters.map(typeParam => typeParam.name.getText());
46
60
  const location = context.getLocation(node);
47
61
  const doc = await (0, _jsdocToDocSchema().jsDocToDocSchema)(node, context);
@@ -1 +1 @@
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","typeParameters","typeParam","location","getLocation","doc","jsDocToDocSchema","FunctionLikeSchema"],"sources":["to-function-like-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 typeParameters = node.typeParameters?.map((typeParam) => typeParam.name.getText());\n const location = context.getLocation(node);\n const doc = await jsDocToDocSchema(node, context);\n return new FunctionLikeSchema(\n location,\n name,\n args,\n returnType,\n displaySig,\n modifiers as Modifier[],\n doc,\n typeParameters\n );\n}\n"],"mappings":";;;;;;;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,eAAeA,oBAAoB,CACxCC,IAA0B,EAC1BC,OAA+B,EAC/BC,QAAiB,EACjB;EAAA;EACA,MAAMC,IAAI,GAAGD,QAAQ,mBAAIF,IAAI,CAACG,IAAI,+CAAT,WAAWC,OAAO,EAAE,KAAI,EAAE;EACnD,MAAMC,IAAI,GAAGL,IAAI,CAACG,IAAI,GAAG,MAAMF,OAAO,CAACK,YAAY,CAACN,IAAI,CAACG,IAAI,CAAC,GAAG,IAAI;EACrE,MAAMI,aAAa,GAAGF,IAAI,GAAG,IAAAG,gDAAsB,EAACH,IAAI,CAAC,GAAG,KAAK;EACjE,MAAMI,UAAU,GAAG,CAAAJ,IAAI,aAAJA,IAAI,qCAAJA,IAAI,CAAEK,IAAI,+CAAV,WAAYC,aAAa,KAAI,EAAE;EAClD,MAAMC,IAAI,GAAG,MAAM,IAAAC,sBAAS,EAACb,IAAI,CAACc,UAAU,EAAEb,OAAO,CAAC;EACtD,MAAMc,UAAU,GAAG,MAAMd,OAAO,CAACe,WAAW,CAAChB,IAAI,EAAEO,aAAa,EAAEU,OAAO,CAACZ,IAAI,CAAC,CAAC;EAChF,MAAMa,SAAS,GAAG,oBAAAlB,IAAI,CAACkB,SAAS,oDAAd,gBAAgBC,GAAG,CAAEC,QAAQ,IAAKA,QAAQ,CAAChB,OAAO,EAAE,CAAC,KAAI,EAAE;EAC7E,MAAMiB,cAAc,2BAAGrB,IAAI,CAACqB,cAAc,yDAAnB,qBAAqBF,GAAG,CAAEG,SAAS,IAAKA,SAAS,CAACnB,IAAI,CAACC,OAAO,EAAE,CAAC;EACxF,MAAMmB,QAAQ,GAAGtB,OAAO,CAACuB,WAAW,CAACxB,IAAI,CAAC;EAC1C,MAAMyB,GAAG,GAAG,MAAM,IAAAC,oCAAgB,EAAC1B,IAAI,EAAEC,OAAO,CAAC;EACjD,OAAO,KAAI0B,uCAAkB,EAC3BJ,QAAQ,EACRpB,IAAI,EACJS,IAAI,EACJG,UAAU,EACVN,UAAU,EACVS,SAAS,EACTO,GAAG,EACHJ,cAAc,CACf;AACH"}
1
+ {"version":3,"names":["toFunctionLikeSchema","node","context","funcName","name","getText","getQuickInfoFromDefaultModifier","defaultModifier","modifiers","find","modifier","kind","SyntaxKind","DefaultKeyword","getQuickInfo","ArrowFunction","equalsGreaterThanToken","info","returnTypeStr","parseTypeFromQuickInfo","displaySig","body","displayString","args","getParams","parameters","returnType","resolveType","Boolean","map","typeParameters","typeParam","location","getLocation","doc","jsDocToDocSchema","FunctionLikeSchema"],"sources":["to-function-like-schema.ts"],"sourcesContent":["import { SignatureDeclaration, SyntaxKind } 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 getQuickInfoFromDefaultModifier = async () => {\n const defaultModifier = node.modifiers?.find((modifier) => modifier.kind === SyntaxKind.DefaultKeyword);\n if (defaultModifier) return context.getQuickInfo(defaultModifier);\n if (node.kind === SyntaxKind.ArrowFunction) return context.getQuickInfo(node.equalsGreaterThanToken);\n return null;\n };\n const info = node.name ? await context.getQuickInfo(node.name) : await getQuickInfoFromDefaultModifier();\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 typeParameters = node.typeParameters?.map((typeParam) => typeParam.name.getText());\n const location = context.getLocation(node);\n const doc = await jsDocToDocSchema(node, context);\n return new FunctionLikeSchema(\n location,\n name,\n args,\n returnType,\n displaySig,\n modifiers as Modifier[],\n doc,\n typeParameters\n );\n}\n"],"mappings":";;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,eAAeA,oBAAoB,CACxCC,IAA0B,EAC1BC,OAA+B,EAC/BC,QAAiB,EACjB;EAAA;EACA,MAAMC,IAAI,GAAGD,QAAQ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E,SAAS,IAAKA,SAAS,CAAC3B,IAAI,CAACC,OAAO,EAAE,CAAC;EACxF,MAAM2B,QAAQ,GAAG9B,OAAO,CAAC+B,WAAW,CAAChC,IAAI,CAAC;EAC1C,MAAMiC,GAAG,GAAG,MAAM,IAAAC,oCAAgB,EAAClC,IAAI,EAAEC,OAAO,CAAC;EACjD,OAAO,KAAIkC,uCAAkB,EAC3BJ,QAAQ,EACR5B,IAAI,EACJmB,IAAI,EACJG,UAAU,EACVN,UAAU,EACVZ,SAAS,EACT0B,GAAG,EACHJ,cAAc,CACf;AACH"}
@@ -109,14 +109,14 @@ async function typeNodeToSchema(node, context) {
109
109
  case _typescript().SyntaxKind.JSDocNamepathType:
110
110
  case _typescript().SyntaxKind.JSDocSignature:
111
111
  case _typescript().SyntaxKind.JSDocTypeLiteral:
112
- throw new Error(`TypeNode ${node.kind} (probably ${_typescript().SyntaxKind[node.kind]}) was not implemented yet.
113
- context: ${node.getText()}`);
112
+ return unimplementedSchema(node, context);
114
113
  default:
115
- throw new Error(`Node ${node.kind} (probably ${_typescript().SyntaxKind[node.kind]}) is not a TypeNode.
116
- context: ${node.getText()}`);
114
+ return unimplementedSchema(node, context);
117
115
  }
118
116
  }
119
-
117
+ function unimplementedSchema(node, context) {
118
+ return new (_semanticsEntities().UnImplementedSchema)(context.getLocation(node), node.getText(), _typescript().SyntaxKind[node.kind]);
119
+ }
120
120
  /**
121
121
  * whether it's kind of `ts.KeywordTypeSyntaxKind`
122
122
  */
@@ -1 +1 @@
1
- {"version":3,"names":["typeNodeToSchema","node","context","location","getLocation","isKeywordType","KeywordTypeSchema","getText","kind","SyntaxKind","IntersectionType","intersectionType","UnionType","unionType","TypeReference","typeReference","TypeLiteral","typeLiteral","LiteralType","LiteralTypeSchema","FunctionType","functionType","TypeQuery","typeQuery","ArrayType","arrayType","TypeOperator","typeOperator","TupleType","tupleType","ParenthesizedType","parenthesizedType","TypePredicate","typePredicate","IndexedAccessType","indexedAccessType","TemplateLiteralTypeSpan","templateLiteralTypeSpan","TemplateLiteralType","templateLiteralType","ThisType","thisType","ConditionalType","conditionalType","ConstructorType","NamedTupleMember","OptionalType","RestType","InferType","MappedType","ImportType","ExpressionWithTypeArguments","JSDocTypeExpression","JSDocAllType","JSDocUnknownType","JSDocNonNullableType","JSDocNullableType","JSDocOptionalType","JSDocFunctionType","JSDocVariadicType","JSDocNamepathType","JSDocSignature","JSDocTypeLiteral","Error","AnyKeyword","BigIntKeyword","BooleanKeyword","IntrinsicKeyword","NeverKeyword","NumberKeyword","ObjectKeyword","StringKeyword","SymbolKeyword","UndefinedKeyword","UnknownKeyword","VoidKeyword","types","pMapSeries","type","typeSchema","TypeIntersectionSchema","TypeUnionSchema","members","member","typeElementToSchema","TypeLiteralSchema","name","typeName","resolveType","typeArguments","TypeRefSchema","args","arg","typeArgs","params","getParams","parameters","returnType","modifiers","map","modifier","doc","jsDocToDocSchema","FunctionLikeSchema","displaySig","getQuickInfoDisplayString","exprName","TypeQuerySchema","elementType","TypeArraySchema","operatorName","getOperatorName","operator","TypeOperatorSchema","KeyOfKeyword","UniqueKeyword","ReadonlyKeyword","elements","elem","TupleTypeSchema","ParenthesizedTypeSchema","parameterName","isIdentifier","undefined","hasAssertsModifier","Boolean","assertsModifier","TypePredicateSchema","objectType","indexType","IndexedAccessSchema","templateSpans","span","head","text","TemplateLiteralTypeSchema","literal","TemplateLiteralTypeSpanSchema","ThisTypeSchema","checkType","extendsType","trueType","falseType","ConditionalTypeSchema"],"sources":["type-node-to-schema.ts"],"sourcesContent":["import {\n TypeNode,\n SyntaxKind,\n KeywordTypeNode,\n FunctionTypeNode,\n TypeQueryNode,\n TypeReferenceNode,\n ArrayTypeNode,\n TypeOperatorNode,\n TupleTypeNode,\n IntersectionTypeNode,\n UnionTypeNode,\n TypeLiteralNode,\n ParenthesizedTypeNode,\n TypePredicateNode,\n isIdentifier,\n IndexedAccessTypeNode,\n TemplateLiteralTypeNode,\n TemplateLiteralTypeSpan,\n ThisTypeNode,\n ConditionalTypeNode,\n} from 'typescript';\nimport {\n SchemaNode,\n TypeRefSchema,\n TypeIntersectionSchema,\n TypeUnionSchema,\n TypeLiteralSchema,\n TypeQuerySchema,\n LiteralTypeSchema,\n KeywordTypeSchema,\n TypeArraySchema,\n TypeOperatorSchema,\n TupleTypeSchema,\n FunctionLikeSchema,\n ParenthesizedTypeSchema,\n TypePredicateSchema,\n IndexedAccessSchema,\n TemplateLiteralTypeSpanSchema,\n TemplateLiteralTypeSchema,\n ThisTypeSchema,\n Modifier,\n ConditionalTypeSchema,\n} from '@teambit/semantics.entities.semantic-schema';\nimport pMapSeries from 'p-map-series';\nimport { SchemaExtractorContext } from '../../schema-extractor-context';\nimport { getParams } from './get-params';\nimport { typeElementToSchema } from './type-element-to-schema';\nimport { jsDocToDocSchema } from './jsdoc-to-doc-schema';\n\n// eslint-disable-next-line complexity\nexport async function typeNodeToSchema(node: TypeNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n const location = context.getLocation(node);\n if (isKeywordType(node)) {\n return new KeywordTypeSchema(location, node.getText());\n }\n switch (node.kind) {\n case SyntaxKind.IntersectionType:\n return intersectionType(node as IntersectionTypeNode, context);\n case SyntaxKind.UnionType:\n return unionType(node as UnionTypeNode, context);\n case SyntaxKind.TypeReference:\n return typeReference(node as TypeReferenceNode, context);\n case SyntaxKind.TypeLiteral:\n return typeLiteral(node as TypeLiteralNode, context);\n case SyntaxKind.LiteralType: // e.g. string/boolean\n return new LiteralTypeSchema(location, node.getText());\n case SyntaxKind.FunctionType:\n return functionType(node as FunctionTypeNode, context);\n case SyntaxKind.TypeQuery:\n return typeQuery(node as TypeQueryNode, context);\n case SyntaxKind.ArrayType:\n return arrayType(node as ArrayTypeNode, context);\n case SyntaxKind.TypeOperator:\n return typeOperator(node as TypeOperatorNode, context);\n case SyntaxKind.TupleType:\n return tupleType(node as TupleTypeNode, context);\n case SyntaxKind.ParenthesizedType:\n return parenthesizedType(node as ParenthesizedTypeNode, context);\n case SyntaxKind.TypePredicate:\n return typePredicate(node as TypePredicateNode, context);\n case SyntaxKind.IndexedAccessType:\n return indexedAccessType(node as IndexedAccessTypeNode, context);\n case SyntaxKind.TemplateLiteralTypeSpan:\n return templateLiteralTypeSpan(node as TemplateLiteralTypeSpan, context);\n case SyntaxKind.TemplateLiteralType:\n return templateLiteralType(node as TemplateLiteralTypeNode, context);\n case SyntaxKind.ThisType:\n return thisType(node as ThisTypeNode, context);\n case SyntaxKind.ConditionalType:\n return conditionalType(node as ConditionalTypeNode, context);\n case SyntaxKind.ConstructorType:\n case SyntaxKind.NamedTupleMember:\n case SyntaxKind.OptionalType:\n case SyntaxKind.RestType:\n case SyntaxKind.InferType:\n case SyntaxKind.MappedType:\n case SyntaxKind.ImportType:\n case SyntaxKind.ExpressionWithTypeArguments:\n case SyntaxKind.JSDocTypeExpression:\n case SyntaxKind.JSDocAllType:\n case SyntaxKind.JSDocUnknownType:\n case SyntaxKind.JSDocNonNullableType:\n case SyntaxKind.JSDocNullableType:\n case SyntaxKind.JSDocOptionalType:\n case SyntaxKind.JSDocFunctionType:\n case SyntaxKind.JSDocVariadicType:\n case SyntaxKind.JSDocNamepathType:\n case SyntaxKind.JSDocSignature:\n case SyntaxKind.JSDocTypeLiteral:\n throw new Error(`TypeNode ${node.kind} (probably ${SyntaxKind[node.kind]}) was not implemented yet.\ncontext: ${node.getText()}`);\n default:\n throw new Error(`Node ${node.kind} (probably ${SyntaxKind[node.kind]}) is not a TypeNode.\ncontext: ${node.getText()}`);\n }\n}\n\n/**\n * whether it's kind of `ts.KeywordTypeSyntaxKind`\n */\nfunction isKeywordType(node: TypeNode): node is KeywordTypeNode {\n switch (node.kind) {\n case SyntaxKind.AnyKeyword:\n case SyntaxKind.BigIntKeyword:\n case SyntaxKind.BooleanKeyword:\n case SyntaxKind.IntrinsicKeyword:\n case SyntaxKind.NeverKeyword:\n case SyntaxKind.NumberKeyword:\n case SyntaxKind.ObjectKeyword:\n case SyntaxKind.StringKeyword:\n case SyntaxKind.SymbolKeyword:\n case SyntaxKind.UndefinedKeyword:\n case SyntaxKind.UnknownKeyword:\n case SyntaxKind.VoidKeyword:\n return true;\n default:\n return false;\n }\n}\n\nasync function intersectionType(node: IntersectionTypeNode, context: SchemaExtractorContext) {\n const types = await pMapSeries(node.types, async (type) => {\n const typeSchema = await typeNodeToSchema(type, context);\n return typeSchema;\n });\n const location = context.getLocation(node);\n return new TypeIntersectionSchema(location, types);\n}\n\nasync function unionType(node: UnionTypeNode, context: SchemaExtractorContext) {\n const types = await pMapSeries(node.types, async (type) => {\n const typeSchema = await typeNodeToSchema(type, context);\n return typeSchema;\n });\n const location = context.getLocation(node);\n return new TypeUnionSchema(location, types);\n}\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 */\nasync function typeLiteral(node: TypeLiteralNode, context: SchemaExtractorContext) {\n const members = await pMapSeries(node.members, (member) => typeElementToSchema(member, context));\n const location = context.getLocation(node);\n return new TypeLiteralSchema(location, members);\n}\n\n/**\n * In the following example, `AriaButtonProps` is a type reference\n * ```ts\n * import type { AriaButtonProps } from '@react-types/button';\n * export type ButtonProps = AriaButtonProps & { a: string };\n * ```\n */\nasync function typeReference(node: TypeReferenceNode, context: SchemaExtractorContext) {\n const name = node.typeName.getText();\n const type = await context.resolveType(node, name, false);\n if (node.typeArguments && type instanceof TypeRefSchema) {\n const args = await pMapSeries(node.typeArguments, (arg) => typeNodeToSchema(arg, context));\n type.typeArgs = args;\n }\n return type;\n}\n\nasync function functionType(node: FunctionTypeNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n const name = node.name?.getText() || '';\n const params = await getParams(node.parameters, context);\n const returnType = await typeNodeToSchema(node.type, context);\n const location = context.getLocation(node);\n const modifiers = node.modifiers?.map((modifier) => modifier.getText()) || [];\n const doc = await jsDocToDocSchema(node, context);\n return new FunctionLikeSchema(location, name, params, returnType, '', modifiers as Modifier[], doc);\n}\n\n/**\n * e.g. `typeof Foo`\n */\nasync function typeQuery(node: TypeQueryNode, context: SchemaExtractorContext) {\n const displaySig = await context.getQuickInfoDisplayString(node.exprName);\n const type = await context.resolveType(node.exprName, node.exprName.getText(), false);\n const location = context.getLocation(node);\n return new TypeQuerySchema(location, type, displaySig);\n}\n\nasync function arrayType(node: ArrayTypeNode, context: SchemaExtractorContext) {\n const type = await typeNodeToSchema(node.elementType, context);\n const location = context.getLocation(node);\n return new TypeArraySchema(location, type);\n}\n\n/**\n * e.g. keyof typeof Foo\n */\nasync function typeOperator(node: TypeOperatorNode, context: SchemaExtractorContext) {\n const operatorName = getOperatorName(node.operator);\n const type = await typeNodeToSchema(node.type, context);\n return new TypeOperatorSchema(context.getLocation(node), operatorName, type);\n}\n\nfunction getOperatorName(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword) {\n switch (operator) {\n case SyntaxKind.KeyOfKeyword:\n return 'keyof';\n case SyntaxKind.UniqueKeyword:\n return 'unique';\n case SyntaxKind.ReadonlyKeyword:\n return 'readonly';\n default:\n throw new Error(`getOperatorName: unable to find operator name for ${operator}`);\n }\n}\n\nasync function tupleType(node: TupleTypeNode, context: SchemaExtractorContext) {\n const elements = await pMapSeries(node.elements, async (elem) => {\n const typeSchema = await typeNodeToSchema(elem, context);\n return typeSchema;\n });\n return new TupleTypeSchema(context.getLocation(node), elements);\n}\n\nasync function parenthesizedType(node: ParenthesizedTypeNode, context: SchemaExtractorContext) {\n const type = await typeNodeToSchema(node.type, context);\n return new ParenthesizedTypeSchema(context.getLocation(node), type);\n}\n\nasync function typePredicate(node: TypePredicateNode, context: SchemaExtractorContext) {\n const parameterName = isIdentifier(node.parameterName) ? node.parameterName.getText() : 'this';\n const type = node.type ? await typeNodeToSchema(node.type, context) : undefined;\n const hasAssertsModifier = Boolean(node.assertsModifier);\n return new TypePredicateSchema(context.getLocation(node), parameterName, type, hasAssertsModifier);\n}\n\nasync function indexedAccessType(node: IndexedAccessTypeNode, context: SchemaExtractorContext) {\n const objectType = await typeNodeToSchema(node.objectType, context);\n const indexType = await typeNodeToSchema(node.indexType, context);\n return new IndexedAccessSchema(context.getLocation(node), objectType, indexType);\n}\n\nasync function templateLiteralType(node: TemplateLiteralTypeNode, context: SchemaExtractorContext) {\n const templateSpans = await pMapSeries(node.templateSpans, (span) => templateLiteralTypeSpan(span, context));\n const head = node.head.text;\n return new TemplateLiteralTypeSchema(context.getLocation(node), head, templateSpans);\n}\n\nasync function templateLiteralTypeSpan(node: TemplateLiteralTypeSpan, context: SchemaExtractorContext) {\n const type = await typeNodeToSchema(node.type, context);\n const literal = node.literal.text;\n return new TemplateLiteralTypeSpanSchema(context.getLocation(node), literal, type);\n}\n\nasync function thisType(node: ThisTypeNode, context: SchemaExtractorContext) {\n return new ThisTypeSchema(context.getLocation(node));\n}\n\nasync function conditionalType(node: ConditionalTypeNode, context: SchemaExtractorContext) {\n const checkType = await typeNodeToSchema(node.checkType, context);\n const extendsType = await typeNodeToSchema(node.extendsType, context);\n const trueType = await typeNodeToSchema(node.trueType, context);\n const falseType = await typeNodeToSchema(node.falseType, context);\n return new ConditionalTypeSchema(context.getLocation(node), checkType, extendsType, trueType, falseType);\n}\n"],"mappings":";;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAsBA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAsBA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;AACO,eAAeA,gBAAgB,CAACC,IAAc,EAAEC,OAA+B,EAAuB;EAC3G,MAAMC,QAAQ,GAAGD,OAAO,CAACE,WAAW,CAACH,IAAI,CAAC;EAC1C,IAAII,aAAa,CAACJ,IAAI,CAAC,EAAE;IACvB,OAAO,KAAIK,sCAAiB,E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,OAAO,CAAC;EACjE,OAAO,KAAI6I,0CAAqB,EAAC7I,OAAO,CAACE,WAAW,CAACH,IAAI,CAAC,EAAE0I,SAAS,EAAEC,WAAW,EAAEC,QAAQ,EAAEC,SAAS,CAAC;AAC1G"}
1
+ {"version":3,"names":["typeNodeToSchema","node","context","location","getLocation","isKeywordType","KeywordTypeSchema","getText","kind","SyntaxKind","IntersectionType","intersectionType","UnionType","unionType","TypeReference","typeReference","TypeLiteral","typeLiteral","LiteralType","LiteralTypeSchema","FunctionType","functionType","TypeQuery","typeQuery","ArrayType","arrayType","TypeOperator","typeOperator","TupleType","tupleType","ParenthesizedType","parenthesizedType","TypePredicate","typePredicate","IndexedAccessType","indexedAccessType","TemplateLiteralTypeSpan","templateLiteralTypeSpan","TemplateLiteralType","templateLiteralType","ThisType","thisType","ConditionalType","conditionalType","ConstructorType","NamedTupleMember","OptionalType","RestType","InferType","MappedType","ImportType","ExpressionWithTypeArguments","JSDocTypeExpression","JSDocAllType","JSDocUnknownType","JSDocNonNullableType","JSDocNullableType","JSDocOptionalType","JSDocFunctionType","JSDocVariadicType","JSDocNamepathType","JSDocSignature","JSDocTypeLiteral","unimplementedSchema","UnImplementedSchema","AnyKeyword","BigIntKeyword","BooleanKeyword","IntrinsicKeyword","NeverKeyword","NumberKeyword","ObjectKeyword","StringKeyword","SymbolKeyword","UndefinedKeyword","UnknownKeyword","VoidKeyword","types","pMapSeries","type","typeSchema","TypeIntersectionSchema","TypeUnionSchema","members","member","typeElementToSchema","TypeLiteralSchema","name","typeName","resolveType","typeArguments","TypeRefSchema","args","arg","typeArgs","params","getParams","parameters","returnType","modifiers","map","modifier","doc","jsDocToDocSchema","FunctionLikeSchema","displaySig","getQuickInfoDisplayString","exprName","TypeQuerySchema","elementType","TypeArraySchema","operatorName","getOperatorName","operator","TypeOperatorSchema","KeyOfKeyword","UniqueKeyword","ReadonlyKeyword","Error","elements","elem","TupleTypeSchema","ParenthesizedTypeSchema","parameterName","isIdentifier","undefined","hasAssertsModifier","Boolean","assertsModifier","TypePredicateSchema","objectType","indexType","IndexedAccessSchema","templateSpans","span","head","text","TemplateLiteralTypeSchema","literal","TemplateLiteralTypeSpanSchema","ThisTypeSchema","checkType","extendsType","trueType","falseType","ConditionalTypeSchema"],"sources":["type-node-to-schema.ts"],"sourcesContent":["import {\n TypeNode,\n SyntaxKind,\n KeywordTypeNode,\n FunctionTypeNode,\n TypeQueryNode,\n TypeReferenceNode,\n ArrayTypeNode,\n TypeOperatorNode,\n TupleTypeNode,\n IntersectionTypeNode,\n UnionTypeNode,\n TypeLiteralNode,\n ParenthesizedTypeNode,\n TypePredicateNode,\n isIdentifier,\n IndexedAccessTypeNode,\n TemplateLiteralTypeNode,\n TemplateLiteralTypeSpan,\n ThisTypeNode,\n ConditionalTypeNode,\n} from 'typescript';\nimport {\n SchemaNode,\n TypeRefSchema,\n TypeIntersectionSchema,\n TypeUnionSchema,\n TypeLiteralSchema,\n TypeQuerySchema,\n LiteralTypeSchema,\n KeywordTypeSchema,\n TypeArraySchema,\n TypeOperatorSchema,\n TupleTypeSchema,\n FunctionLikeSchema,\n ParenthesizedTypeSchema,\n TypePredicateSchema,\n IndexedAccessSchema,\n TemplateLiteralTypeSpanSchema,\n TemplateLiteralTypeSchema,\n ThisTypeSchema,\n Modifier,\n ConditionalTypeSchema,\n UnImplementedSchema,\n} from '@teambit/semantics.entities.semantic-schema';\nimport pMapSeries from 'p-map-series';\nimport { SchemaExtractorContext } from '../../schema-extractor-context';\nimport { getParams } from './get-params';\nimport { typeElementToSchema } from './type-element-to-schema';\nimport { jsDocToDocSchema } from './jsdoc-to-doc-schema';\n\n// eslint-disable-next-line complexity\nexport async function typeNodeToSchema(node: TypeNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n const location = context.getLocation(node);\n if (isKeywordType(node)) {\n return new KeywordTypeSchema(location, node.getText());\n }\n switch (node.kind) {\n case SyntaxKind.IntersectionType:\n return intersectionType(node as IntersectionTypeNode, context);\n case SyntaxKind.UnionType:\n return unionType(node as UnionTypeNode, context);\n case SyntaxKind.TypeReference:\n return typeReference(node as TypeReferenceNode, context);\n case SyntaxKind.TypeLiteral:\n return typeLiteral(node as TypeLiteralNode, context);\n case SyntaxKind.LiteralType: // e.g. string/boolean\n return new LiteralTypeSchema(location, node.getText());\n case SyntaxKind.FunctionType:\n return functionType(node as FunctionTypeNode, context);\n case SyntaxKind.TypeQuery:\n return typeQuery(node as TypeQueryNode, context);\n case SyntaxKind.ArrayType:\n return arrayType(node as ArrayTypeNode, context);\n case SyntaxKind.TypeOperator:\n return typeOperator(node as TypeOperatorNode, context);\n case SyntaxKind.TupleType:\n return tupleType(node as TupleTypeNode, context);\n case SyntaxKind.ParenthesizedType:\n return parenthesizedType(node as ParenthesizedTypeNode, context);\n case SyntaxKind.TypePredicate:\n return typePredicate(node as TypePredicateNode, context);\n case SyntaxKind.IndexedAccessType:\n return indexedAccessType(node as IndexedAccessTypeNode, context);\n case SyntaxKind.TemplateLiteralTypeSpan:\n return templateLiteralTypeSpan(node as TemplateLiteralTypeSpan, context);\n case SyntaxKind.TemplateLiteralType:\n return templateLiteralType(node as TemplateLiteralTypeNode, context);\n case SyntaxKind.ThisType:\n return thisType(node as ThisTypeNode, context);\n case SyntaxKind.ConditionalType:\n return conditionalType(node as ConditionalTypeNode, context);\n case SyntaxKind.ConstructorType:\n case SyntaxKind.NamedTupleMember:\n case SyntaxKind.OptionalType:\n case SyntaxKind.RestType:\n case SyntaxKind.InferType:\n case SyntaxKind.MappedType:\n case SyntaxKind.ImportType:\n case SyntaxKind.ExpressionWithTypeArguments:\n case SyntaxKind.JSDocTypeExpression:\n case SyntaxKind.JSDocAllType:\n case SyntaxKind.JSDocUnknownType:\n case SyntaxKind.JSDocNonNullableType:\n case SyntaxKind.JSDocNullableType:\n case SyntaxKind.JSDocOptionalType:\n case SyntaxKind.JSDocFunctionType:\n case SyntaxKind.JSDocVariadicType:\n case SyntaxKind.JSDocNamepathType:\n case SyntaxKind.JSDocSignature:\n case SyntaxKind.JSDocTypeLiteral:\n return unimplementedSchema(node, context);\n default:\n return unimplementedSchema(node, context);\n }\n}\n\nfunction unimplementedSchema(node: TypeNode, context: SchemaExtractorContext) {\n return new UnImplementedSchema(context.getLocation(node), node.getText(), SyntaxKind[node.kind]);\n}\n/**\n * whether it's kind of `ts.KeywordTypeSyntaxKind`\n */\nfunction isKeywordType(node: TypeNode): node is KeywordTypeNode {\n switch (node.kind) {\n case SyntaxKind.AnyKeyword:\n case SyntaxKind.BigIntKeyword:\n case SyntaxKind.BooleanKeyword:\n case SyntaxKind.IntrinsicKeyword:\n case SyntaxKind.NeverKeyword:\n case SyntaxKind.NumberKeyword:\n case SyntaxKind.ObjectKeyword:\n case SyntaxKind.StringKeyword:\n case SyntaxKind.SymbolKeyword:\n case SyntaxKind.UndefinedKeyword:\n case SyntaxKind.UnknownKeyword:\n case SyntaxKind.VoidKeyword:\n return true;\n default:\n return false;\n }\n}\n\nasync function intersectionType(node: IntersectionTypeNode, context: SchemaExtractorContext) {\n const types = await pMapSeries(node.types, async (type) => {\n const typeSchema = await typeNodeToSchema(type, context);\n return typeSchema;\n });\n const location = context.getLocation(node);\n return new TypeIntersectionSchema(location, types);\n}\n\nasync function unionType(node: UnionTypeNode, context: SchemaExtractorContext) {\n const types = await pMapSeries(node.types, async (type) => {\n const typeSchema = await typeNodeToSchema(type, context);\n return typeSchema;\n });\n const location = context.getLocation(node);\n return new TypeUnionSchema(location, types);\n}\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 */\nasync function typeLiteral(node: TypeLiteralNode, context: SchemaExtractorContext) {\n const members = await pMapSeries(node.members, (member) => typeElementToSchema(member, context));\n const location = context.getLocation(node);\n return new TypeLiteralSchema(location, members);\n}\n\n/**\n * In the following example, `AriaButtonProps` is a type reference\n * ```ts\n * import type { AriaButtonProps } from '@react-types/button';\n * export type ButtonProps = AriaButtonProps & { a: string };\n * ```\n */\nasync function typeReference(node: TypeReferenceNode, context: SchemaExtractorContext) {\n const name = node.typeName.getText();\n const type = await context.resolveType(node, name, false);\n if (node.typeArguments && type instanceof TypeRefSchema) {\n const args = await pMapSeries(node.typeArguments, (arg) => typeNodeToSchema(arg, context));\n type.typeArgs = args;\n }\n return type;\n}\n\nasync function functionType(node: FunctionTypeNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n const name = node.name?.getText() || '';\n const params = await getParams(node.parameters, context);\n const returnType = await typeNodeToSchema(node.type, context);\n const location = context.getLocation(node);\n const modifiers = node.modifiers?.map((modifier) => modifier.getText()) || [];\n const doc = await jsDocToDocSchema(node, context);\n return new FunctionLikeSchema(location, name, params, returnType, '', modifiers as Modifier[], doc);\n}\n\n/**\n * e.g. `typeof Foo`\n */\nasync function typeQuery(node: TypeQueryNode, context: SchemaExtractorContext) {\n const displaySig = await context.getQuickInfoDisplayString(node.exprName);\n const type = await context.resolveType(node.exprName, node.exprName.getText(), false);\n const location = context.getLocation(node);\n return new TypeQuerySchema(location, type, displaySig);\n}\n\nasync function arrayType(node: ArrayTypeNode, context: SchemaExtractorContext) {\n const type = await typeNodeToSchema(node.elementType, context);\n const location = context.getLocation(node);\n return new TypeArraySchema(location, type);\n}\n\n/**\n * e.g. keyof typeof Foo\n */\nasync function typeOperator(node: TypeOperatorNode, context: SchemaExtractorContext) {\n const operatorName = getOperatorName(node.operator);\n const type = await typeNodeToSchema(node.type, context);\n return new TypeOperatorSchema(context.getLocation(node), operatorName, type);\n}\n\nfunction getOperatorName(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword) {\n switch (operator) {\n case SyntaxKind.KeyOfKeyword:\n return 'keyof';\n case SyntaxKind.UniqueKeyword:\n return 'unique';\n case SyntaxKind.ReadonlyKeyword:\n return 'readonly';\n default:\n throw new Error(`getOperatorName: unable to find operator name for ${operator}`);\n }\n}\n\nasync function tupleType(node: TupleTypeNode, context: SchemaExtractorContext) {\n const elements = await pMapSeries(node.elements, async (elem) => {\n const typeSchema = await typeNodeToSchema(elem, context);\n return typeSchema;\n });\n return new TupleTypeSchema(context.getLocation(node), elements);\n}\n\nasync function parenthesizedType(node: ParenthesizedTypeNode, context: SchemaExtractorContext) {\n const type = await typeNodeToSchema(node.type, context);\n return new ParenthesizedTypeSchema(context.getLocation(node), type);\n}\n\nasync function typePredicate(node: TypePredicateNode, context: SchemaExtractorContext) {\n const parameterName = isIdentifier(node.parameterName) ? node.parameterName.getText() : 'this';\n const type = node.type ? await typeNodeToSchema(node.type, context) : undefined;\n const hasAssertsModifier = Boolean(node.assertsModifier);\n return new TypePredicateSchema(context.getLocation(node), parameterName, type, hasAssertsModifier);\n}\n\nasync function indexedAccessType(node: IndexedAccessTypeNode, context: SchemaExtractorContext) {\n const objectType = await typeNodeToSchema(node.objectType, context);\n const indexType = await typeNodeToSchema(node.indexType, context);\n return new IndexedAccessSchema(context.getLocation(node), objectType, indexType);\n}\n\nasync function templateLiteralType(node: TemplateLiteralTypeNode, context: SchemaExtractorContext) {\n const templateSpans = await pMapSeries(node.templateSpans, (span) => templateLiteralTypeSpan(span, context));\n const head = node.head.text;\n return new TemplateLiteralTypeSchema(context.getLocation(node), head, templateSpans);\n}\n\nasync function templateLiteralTypeSpan(node: TemplateLiteralTypeSpan, context: SchemaExtractorContext) {\n const type = await typeNodeToSchema(node.type, context);\n const literal = node.literal.text;\n return new TemplateLiteralTypeSpanSchema(context.getLocation(node), literal, type);\n}\n\nasync function thisType(node: ThisTypeNode, context: SchemaExtractorContext) {\n return new ThisTypeSchema(context.getLocation(node));\n}\n\nasync function conditionalType(node: ConditionalTypeNode, context: SchemaExtractorContext) {\n const checkType = await typeNodeToSchema(node.checkType, context);\n const extendsType = await typeNodeToSchema(node.extendsType, context);\n const trueType = await typeNodeToSchema(node.trueType, context);\n const falseType = await typeNodeToSchema(node.falseType, context);\n return new ConditionalTypeSchema(context.getLocation(node), checkType, extendsType, trueType, falseType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,EAAE;EAC3E,OAAO,KAAI0I,mCAAc,EAAC1I,OAAO,CAACE,WAAW,CAACH,IAAI,CAAC,CAAC;AACtD;AAEA,eAAe0C,eAAe,CAAC1C,IAAyB,EAAEC,OAA+B,EAAE;EACzF,MAAM2I,SAAS,GAAG,MAAM7I,gBAAgB,CAACC,IAAI,CAAC4I,SAAS,EAAE3I,OAAO,CAAC;EACjE,MAAM4I,WAAW,GAAG,MAAM9I,gBAAgB,CAACC,IAAI,CAAC6I,WAAW,EAAE5I,OAAO,CAAC;EACrE,MAAM6I,QAAQ,GAAG,MAAM/I,gBAAgB,CAACC,IAAI,CAAC8I,QAAQ,EAAE7I,OAAO,CAAC;EAC/D,MAAM8I,SAAS,GAAG,MAAMhJ,gBAAgB,CAACC,IAAI,CAAC+I,SAAS,EAAE9I,OAAO,CAAC;EACjE,OAAO,KAAI+I,0CAAqB,EAAC/I,OAAO,CAACE,WAAW,CAACH,IAAI,CAAC,EAAE4I,SAAS,EAAEC,WAAW,EAAEC,QAAQ,EAAEC,SAAS,CAAC;AAC1G"}
@@ -164,6 +164,13 @@ function _writeTsconfig() {
164
164
  };
165
165
  return data;
166
166
  }
167
+ function _exportAssignmentDeclaration() {
168
+ const data = require("./transformers/export-assignment-declaration");
169
+ _exportAssignmentDeclaration = function () {
170
+ return data;
171
+ };
172
+ return data;
173
+ }
167
174
  class TypescriptMain {
168
175
  constructor(logger, schemaTransformerSlot, workspace, depResolver, envs, tsConfigWriter) {
169
176
  this.logger = logger;
@@ -352,7 +359,7 @@ class TypescriptMain {
352
359
  aspectLoader.registerPlugins([new (_schemaTransformer().SchemaTransformerPlugin)(schemaTransformerSlot)]);
353
360
  const tsconfigWriter = new (_tsconfigWriter().TsconfigWriter)(workspace, logger);
354
361
  const tsMain = new TypescriptMain(logger, schemaTransformerSlot, workspace, depResolver, envs, tsconfigWriter);
355
- schemaTransformerSlot.register([new (_transformers().ExportDeclaration)(), new (_transformers().FunctionDeclaration)(), new (_transformers().VariableStatementTransformer)(), new (_transformers().VariableDeclaration)(), new (_transformers().SourceFileTransformer)(), new (_transformers().TypeAliasTransformer)(), new (_transformers().ClassDecelerationTransformer)(), new (_transformers().InterfaceDeclarationTransformer)(), new (_transformers().EnumDeclarationTransformer)(), new (_transformers().BindingElementTransformer)()]);
362
+ schemaTransformerSlot.register([new (_transformers().ExportDeclaration)(), new (_exportAssignmentDeclaration().ExportAssignmentDeclaration)(), new (_transformers().FunctionDeclaration)(), new (_transformers().VariableStatementTransformer)(), new (_transformers().VariableDeclaration)(), new (_transformers().SourceFileTransformer)(), new (_transformers().TypeAliasTransformer)(), new (_transformers().ClassDecelerationTransformer)(), new (_transformers().InterfaceDeclarationTransformer)(), new (_transformers().EnumDeclarationTransformer)(), new (_transformers().BindingElementTransformer)()]);
356
363
  if (workspace) {
357
364
  workspace.registerOnPreWatch(tsMain.onPreWatch.bind(this));
358
365
  workspace.registerOnComponentChange(tsMain.onComponentChange.bind(this));
@@ -1 +1 @@
1
- {"version":3,"names":["TypescriptMain","constructor","logger","schemaTransformerSlot","workspace","depResolver","envs","tsConfigWriter","createCompiler","options","transformers","tsModule","ts","configMutator","TypescriptConfigMutator","transformerContext","afterMutation","runTransformersWithContext","clone","TypescriptCompiler","TypescriptAspect","id","raw","getTsserverClient","tsServer","initTsserverClient","projectPath","files","TsserverClient","init","initTsserverClientFromWorkspace","Error","path","createCjsCompiler","getCjsTransformer","createEsmCompiler","getEsmTransformer","cjsTransformer","config","setModule","esmTransformer","createSchemaExtractor","tsconfig","TypeScriptExtractor","getCjsPackageJsonProps","main","types","getEsmPackageJsonProps","type","getSupportedFilesForTsserver","components","map","c","filesystem","flat","f","filter","endsWith","cleanTsconfigJson","list","runtime","createEnvironment","execContext","getEnvExecutionContext","results","TsconfigWriter","clean","writeTsconfigJson","cleanResults","writeResults","write","onPreWatch","watchOpts","spawnTSServer","verbose","checkTypes","printTypeErrors","Boolean","onComponentChange","component","pMapSeries","file","onFileChange","provider","schema","loggerExt","aspectLoader","cli","registerParser","TypeScriptParser","createLogger","registerPlugins","SchemaTransformerPlugin","tsconfigWriter","tsMain","register","ExportDeclaration","FunctionDeclaration","VariableStatementTransformer","VariableDeclaration","SourceFileTransformer","TypeAliasTransformer","ClassDecelerationTransformer","InterfaceDeclarationTransformer","EnumDeclarationTransformer","BindingElementTransformer","registerOnPreWatch","bind","registerOnComponentChange","registerOnComponentAdd","checkTypesCmd","CheckTypesCmd","writeTsconfigCmd","WriteTsconfigCmd","MainRuntime","SchemaAspect","LoggerAspect","AspectLoaderAspect","WorkspaceAspect","CLIAspect","DependencyResolverAspect","EnvsAspect","Slot","withType","addRuntime","context","Array","isArray","newConfig","reduce","acc","transformer"],"sources":["typescript.main.runtime.ts"],"sourcesContent":["import ts from 'typescript';\nimport { Slot, SlotRegistry } from '@teambit/harmony';\nimport { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { Compiler } from '@teambit/compiler';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { SchemaAspect, SchemaExtractor, SchemaMain } from '@teambit/schema';\nimport { PackageJsonProps } from '@teambit/pkg';\nimport { TypescriptConfigMutator } from '@teambit/typescript.modules.ts-config-mutator';\nimport { WorkspaceAspect } from '@teambit/workspace';\nimport type { WatchOptions, Workspace } from '@teambit/workspace';\nimport { DependencyResolverAspect, DependencyResolverMain } from '@teambit/dependency-resolver';\nimport pMapSeries from 'p-map-series';\nimport { TsserverClient, TsserverClientOpts } from '@teambit/ts-server';\nimport AspectLoaderAspect, { AspectLoaderMain } from '@teambit/aspect-loader';\nimport type { Component } from '@teambit/component';\nimport EnvsAspect, { EnvsMain } from '@teambit/envs';\nimport { TypeScriptExtractor } from './typescript.extractor';\nimport { TypeScriptCompilerOptions } from './compiler-options';\nimport { TypescriptAspect } from './typescript.aspect';\nimport { TypescriptCompiler } from './typescript.compiler';\nimport { TypeScriptParser } from './typescript.parser';\nimport { SchemaTransformer } from './schema-transformer';\nimport { SchemaTransformerPlugin } from './schema-transformer.plugin';\nimport {\n ExportDeclaration,\n TypeAliasTransformer,\n FunctionDeclaration,\n VariableStatementTransformer,\n VariableDeclaration,\n SourceFileTransformer,\n ClassDecelerationTransformer,\n InterfaceDeclarationTransformer,\n EnumDeclarationTransformer,\n BindingElementTransformer,\n} from './transformers';\nimport { CheckTypesCmd } from './cmds/check-types.cmd';\nimport { TsconfigPathsPerEnv, TsconfigWriter } from './tsconfig-writer';\nimport WriteTsconfigCmd from './cmds/write-tsconfig.cmd';\n\nexport type TsMode = 'build' | 'dev';\n\nexport type SchemaTransformerSlot = SlotRegistry<SchemaTransformer[]>;\n\nexport type TsConfigTransformContext = {\n // mode: TsMode;\n};\n\nexport type TsconfigWriterOptions = {\n clean?: boolean;\n silent?: boolean; // no prompt\n dedupe?: boolean;\n dryRun?: boolean;\n dryRunWithTsconfig?: boolean;\n};\n\nexport type TsConfigTransformer = (\n config: TypescriptConfigMutator,\n context: TsConfigTransformContext\n) => TypescriptConfigMutator;\n\nexport class TypescriptMain {\n constructor(\n private logger: Logger,\n private schemaTransformerSlot: SchemaTransformerSlot,\n private workspace: Workspace,\n private depResolver: DependencyResolverMain,\n private envs: EnvsMain,\n private tsConfigWriter: TsconfigWriter\n ) {}\n\n private tsServer: TsserverClient;\n /**\n * create a new compiler.\n */\n createCompiler(\n options: TypeScriptCompilerOptions,\n transformers: TsConfigTransformer[] = [],\n tsModule = ts\n ): Compiler {\n const configMutator = new TypescriptConfigMutator(options);\n const transformerContext: TsConfigTransformContext = {};\n const afterMutation = runTransformersWithContext(configMutator.clone(), transformers, transformerContext);\n return new TypescriptCompiler(TypescriptAspect.id, this.logger, afterMutation.raw, tsModule);\n }\n\n /**\n * get TsserverClient instance if initiated already, otherwise, return undefined.\n */\n getTsserverClient(): TsserverClient | undefined {\n return this.tsServer;\n }\n\n /**\n * starts a tsserver process to communicate with its API.\n * @param projectPath absolute path of the project root directory\n * @param options TsserverClientOpts\n * @param files optionally, if check-types is enabled, provide files to open and type check.\n * @returns TsserverClient\n */\n async initTsserverClient(\n projectPath: string,\n options: TsserverClientOpts = {},\n files: string[] = []\n ): Promise<TsserverClient> {\n this.tsServer = new TsserverClient(projectPath, this.logger, options, files);\n this.tsServer.init();\n return this.tsServer;\n }\n\n /**\n * starts a tsserver process to communicate with its API. use only when running on the workspace.\n * @param options TsserverClientOpts\n * @param files optionally, if check-types is enabled, provide files to open and type check.\n * @returns TsserverClient\n */\n async initTsserverClientFromWorkspace(\n options: TsserverClientOpts = {},\n files: string[] = []\n ): Promise<TsserverClient> {\n if (!this.workspace) {\n throw new Error(`initTsserverClientFromWorkspace: workspace was not found`);\n }\n return this.initTsserverClient(this.workspace.path, options, files);\n }\n\n /**\n * Create a compiler instance and run the cjs transformer for it\n * @param options\n * @param transformers\n * @param tsModule\n * @returns\n */\n createCjsCompiler(options: TypeScriptCompilerOptions, transformers: TsConfigTransformer[] = [], tsModule = ts) {\n return this.createCompiler(options, [this.getCjsTransformer(), ...transformers], tsModule);\n }\n\n /**\n * Create a compiler instance and run the esm transformer for it\n * @param options\n * @param transformers\n * @param tsModule\n * @returns\n */\n createEsmCompiler(options: TypeScriptCompilerOptions, transformers: TsConfigTransformer[] = [], tsModule = ts) {\n return this.createCompiler(options, [this.getEsmTransformer(), ...transformers], tsModule);\n }\n\n /**\n * Create a transformer that change the ts module to CommonJS\n * @returns\n */\n getCjsTransformer(): TsConfigTransformer {\n const cjsTransformer = (config: TypescriptConfigMutator) => {\n config.setModule('CommonJS');\n return config;\n };\n return cjsTransformer;\n }\n\n /**\n * Create a transformer that change the ts module to ES2020\n * @returns\n */\n getEsmTransformer(): TsConfigTransformer {\n const esmTransformer = (config: TypescriptConfigMutator) => {\n config.setModule('ES2020');\n return config;\n };\n return esmTransformer;\n }\n\n /**\n * create an instance of a typescript semantic schema extractor.\n */\n createSchemaExtractor(tsconfig: any, path?: string): SchemaExtractor {\n return new TypeScriptExtractor(\n tsconfig,\n this.schemaTransformerSlot,\n this,\n path || this.workspace.path,\n this.depResolver,\n this.workspace\n );\n }\n\n /**\n * add the default package json properties to the component\n * :TODO @gilad why do we need this DSL? can't I just get the args here.\n */\n getCjsPackageJsonProps(): PackageJsonProps {\n return {\n main: 'dist/{main}.js',\n types: '{main}.ts',\n };\n }\n\n /**\n * add type: module to the package.json props and the default props\n * :TODO @gilad why do we need this DSL? can't I just get the args here.\n */\n getEsmPackageJsonProps(): PackageJsonProps {\n return {\n // main: 'dist-esm/{main}.js',\n main: 'dist/{main}.js',\n type: 'module',\n types: '{main}.ts',\n };\n }\n\n getSupportedFilesForTsserver(components: Component[]): string[] {\n const files = components\n .map((c) => c.filesystem.files)\n .flat()\n .map((f) => f.path);\n return files.filter((f) => f.endsWith('.ts') || f.endsWith('.tsx'));\n }\n\n async cleanTsconfigJson(options: TsconfigWriterOptions = {}) {\n const components = await this.workspace.list();\n const runtime = await this.envs.createEnvironment(components);\n const execContext = runtime.getEnvExecutionContext();\n\n const results = await new TsconfigWriter(this.workspace, this.logger).clean(execContext, options);\n\n return results;\n }\n\n async writeTsconfigJson(options: TsconfigWriterOptions = {}): Promise<{\n cleanResults?: string[];\n writeResults: TsconfigPathsPerEnv[];\n }> {\n const components = await this.workspace.list();\n const runtime = await this.envs.createEnvironment(components);\n const execContext = runtime.getEnvExecutionContext();\n\n let cleanResults: string[] | undefined;\n if (options.clean) {\n cleanResults = await this.tsConfigWriter.clean(execContext, options);\n }\n\n const writeResults = await this.tsConfigWriter.write(execContext, options);\n\n return { writeResults, cleanResults };\n }\n\n private async onPreWatch(components: Component[], watchOpts: WatchOptions) {\n const workspace = this.workspace;\n if (!workspace || !watchOpts.spawnTSServer) {\n return;\n }\n const { verbose, checkTypes } = watchOpts;\n const files = checkTypes ? this.getSupportedFilesForTsserver(components) : [];\n const printTypeErrors = Boolean(checkTypes);\n await this.initTsserverClientFromWorkspace({ verbose, checkTypes, printTypeErrors }, files);\n }\n\n private async onComponentChange(component: Component, files: string[]) {\n if (!this.tsServer) {\n return {\n results: 'N/A',\n };\n }\n await pMapSeries(files, (file) => this.tsServer.onFileChange(file));\n return {\n results: 'succeed',\n };\n }\n\n static runtime = MainRuntime;\n static dependencies = [\n SchemaAspect,\n LoggerAspect,\n AspectLoaderAspect,\n WorkspaceAspect,\n CLIAspect,\n DependencyResolverAspect,\n EnvsAspect,\n ];\n static slots = [Slot.withType<SchemaTransformer[]>()];\n\n static async provider(\n [schema, loggerExt, aspectLoader, workspace, cli, depResolver, envs]: [\n SchemaMain,\n LoggerMain,\n AspectLoaderMain,\n Workspace,\n CLIMain,\n DependencyResolverMain,\n EnvsMain\n ],\n config,\n [schemaTransformerSlot]: [SchemaTransformerSlot]\n ) {\n schema.registerParser(new TypeScriptParser());\n const logger = loggerExt.createLogger(TypescriptAspect.id);\n aspectLoader.registerPlugins([new SchemaTransformerPlugin(schemaTransformerSlot)]);\n const tsconfigWriter = new TsconfigWriter(workspace, logger);\n const tsMain = new TypescriptMain(logger, schemaTransformerSlot, workspace, depResolver, envs, tsconfigWriter);\n schemaTransformerSlot.register([\n new ExportDeclaration(),\n new FunctionDeclaration(),\n new VariableStatementTransformer(),\n new VariableDeclaration(),\n new SourceFileTransformer(),\n new TypeAliasTransformer(),\n new ClassDecelerationTransformer(),\n new InterfaceDeclarationTransformer(),\n new EnumDeclarationTransformer(),\n new BindingElementTransformer(),\n ]);\n\n if (workspace) {\n workspace.registerOnPreWatch(tsMain.onPreWatch.bind(this));\n workspace.registerOnComponentChange(tsMain.onComponentChange.bind(this));\n workspace.registerOnComponentAdd(tsMain.onComponentChange.bind(this));\n }\n\n const checkTypesCmd = new CheckTypesCmd(tsMain, workspace, logger);\n const writeTsconfigCmd = new WriteTsconfigCmd(tsMain);\n cli.register(checkTypesCmd, writeTsconfigCmd);\n\n return tsMain;\n }\n}\n\nTypescriptAspect.addRuntime(TypescriptMain);\n\nexport function runTransformersWithContext(\n config: TypescriptConfigMutator,\n transformers: TsConfigTransformer[] = [],\n context: TsConfigTransformContext\n): TypescriptConfigMutator {\n if (!Array.isArray(transformers)) return config;\n const newConfig = transformers.reduce((acc, transformer) => {\n return transformer(acc, context);\n }, config);\n return newConfig;\n}\n\nexport default TypescriptMain;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAYA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAuBO,MAAMA,cAAc,CAAC;EAC1BC,WAAW,CACDC,MAAc,EACdC,qBAA4C,EAC5CC,SAAoB,EACpBC,WAAmC,EACnCC,IAAc,EACdC,cAA8B,EACtC;IAAA,KANQL,MAAc,GAAdA,MAAc;IAAA,KACdC,qBAA4C,GAA5CA,qBAA4C;IAAA,KAC5CC,SAAoB,GAApBA,SAAoB;IAAA,KACpB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C;IACvE;IAEA,MAAMG,aAAa,GAAG,KAAIC,2BAAa,EAACjB,MAAM,EAAE1F,SAAS,EAAEF,MAAM,CAAC;IAClE,MAAM8G,gBAAgB,GAAG,KAAIC,wBAAgB,EAACnB,MAAM,CAAC;IACrDP,GAAG,CAACQ,QAAQ,CAACe,aAAa,EAAEE,gBAAgB,CAAC;IAE7C,OAAOlB,MAAM;EACf;AACF;AAAC;AAAA,gCAvQY9F,cAAc,aAgNRkH,kBAAW;AAAA,gCAhNjBlH,cAAc,kBAiNH,CACpBmH,sBAAY,EACZC,sBAAY,EACZC,uBAAkB,EAClBC,4BAAe,EACfC,gBAAS,EACTC,8CAAwB,EACxBC,eAAU,CACX;AAAA,gCAzNUzH,cAAc,WA0NV,CAAC0H,eAAI,CAACC,QAAQ,EAAuB,CAAC;AA+CvDvG,+BAAgB,CAACwG,UAAU,CAAC5H,cAAc,CAAC;AAEpC,SAASiB,0BAA0B,CACxCqB,MAA+B,EAC/B5B,YAAmC,GAAG,EAAE,EACxCmH,OAAiC,EACR;EACzB,IAAI,CAACC,KAAK,CAACC,OAAO,CAACrH,YAAY,CAAC,EAAE,OAAO4B,MAAM;EAC/C,MAAM0F,SAAS,GAAGtH,YAAY,CAACuH,MAAM,CAAC,CAACC,GAAG,EAAEC,WAAW,KAAK;IAC1D,OAAOA,WAAW,CAACD,GAAG,EAAEL,OAAO,CAAC;EAClC,CAAC,EAAEvF,MAAM,CAAC;EACV,OAAO0F,SAAS;AAClB;AAAC,eAEchI,cAAc;AAAA"}
1
+ {"version":3,"names":["TypescriptMain","constructor","logger","schemaTransformerSlot","workspace","depResolver","envs","tsConfigWriter","createCompiler","options","transformers","tsModule","ts","configMutator","TypescriptConfigMutator","transformerContext","afterMutation","runTransformersWithContext","clone","TypescriptCompiler","TypescriptAspect","id","raw","getTsserverClient","tsServer","initTsserverClient","projectPath","files","TsserverClient","init","initTsserverClientFromWorkspace","Error","path","createCjsCompiler","getCjsTransformer","createEsmCompiler","getEsmTransformer","cjsTransformer","config","setModule","esmTransformer","createSchemaExtractor","tsconfig","TypeScriptExtractor","getCjsPackageJsonProps","main","types","getEsmPackageJsonProps","type","getSupportedFilesForTsserver","components","map","c","filesystem","flat","f","filter","endsWith","cleanTsconfigJson","list","runtime","createEnvironment","execContext","getEnvExecutionContext","results","TsconfigWriter","clean","writeTsconfigJson","cleanResults","writeResults","write","onPreWatch","watchOpts","spawnTSServer","verbose","checkTypes","printTypeErrors","Boolean","onComponentChange","component","pMapSeries","file","onFileChange","provider","schema","loggerExt","aspectLoader","cli","registerParser","TypeScriptParser","createLogger","registerPlugins","SchemaTransformerPlugin","tsconfigWriter","tsMain","register","ExportDeclaration","ExportAssignmentDeclaration","FunctionDeclaration","VariableStatementTransformer","VariableDeclaration","SourceFileTransformer","TypeAliasTransformer","ClassDecelerationTransformer","InterfaceDeclarationTransformer","EnumDeclarationTransformer","BindingElementTransformer","registerOnPreWatch","bind","registerOnComponentChange","registerOnComponentAdd","checkTypesCmd","CheckTypesCmd","writeTsconfigCmd","WriteTsconfigCmd","MainRuntime","SchemaAspect","LoggerAspect","AspectLoaderAspect","WorkspaceAspect","CLIAspect","DependencyResolverAspect","EnvsAspect","Slot","withType","addRuntime","context","Array","isArray","newConfig","reduce","acc","transformer"],"sources":["typescript.main.runtime.ts"],"sourcesContent":["import ts from 'typescript';\nimport { Slot, SlotRegistry } from '@teambit/harmony';\nimport { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { Compiler } from '@teambit/compiler';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { SchemaAspect, SchemaExtractor, SchemaMain } from '@teambit/schema';\nimport { PackageJsonProps } from '@teambit/pkg';\nimport { TypescriptConfigMutator } from '@teambit/typescript.modules.ts-config-mutator';\nimport { WorkspaceAspect } from '@teambit/workspace';\nimport type { WatchOptions, Workspace } from '@teambit/workspace';\nimport { DependencyResolverAspect, DependencyResolverMain } from '@teambit/dependency-resolver';\nimport pMapSeries from 'p-map-series';\nimport { TsserverClient, TsserverClientOpts } from '@teambit/ts-server';\nimport AspectLoaderAspect, { AspectLoaderMain } from '@teambit/aspect-loader';\nimport type { Component } from '@teambit/component';\nimport EnvsAspect, { EnvsMain } from '@teambit/envs';\nimport { TypeScriptExtractor } from './typescript.extractor';\nimport { TypeScriptCompilerOptions } from './compiler-options';\nimport { TypescriptAspect } from './typescript.aspect';\nimport { TypescriptCompiler } from './typescript.compiler';\nimport { TypeScriptParser } from './typescript.parser';\nimport { SchemaTransformer } from './schema-transformer';\nimport { SchemaTransformerPlugin } from './schema-transformer.plugin';\nimport {\n ExportDeclaration,\n TypeAliasTransformer,\n FunctionDeclaration,\n VariableStatementTransformer,\n VariableDeclaration,\n SourceFileTransformer,\n ClassDecelerationTransformer,\n InterfaceDeclarationTransformer,\n EnumDeclarationTransformer,\n BindingElementTransformer,\n} from './transformers';\nimport { CheckTypesCmd } from './cmds/check-types.cmd';\nimport { TsconfigPathsPerEnv, TsconfigWriter } from './tsconfig-writer';\nimport WriteTsconfigCmd from './cmds/write-tsconfig.cmd';\nimport { ExportAssignmentDeclaration } from './transformers/export-assignment-declaration';\n\nexport type TsMode = 'build' | 'dev';\n\nexport type SchemaTransformerSlot = SlotRegistry<SchemaTransformer[]>;\n\nexport type TsConfigTransformContext = {\n // mode: TsMode;\n};\n\nexport type TsconfigWriterOptions = {\n clean?: boolean;\n silent?: boolean; // no prompt\n dedupe?: boolean;\n dryRun?: boolean;\n dryRunWithTsconfig?: boolean;\n};\n\nexport type TsConfigTransformer = (\n config: TypescriptConfigMutator,\n context: TsConfigTransformContext\n) => TypescriptConfigMutator;\n\nexport class TypescriptMain {\n constructor(\n private logger: Logger,\n private schemaTransformerSlot: SchemaTransformerSlot,\n private workspace: Workspace,\n private depResolver: DependencyResolverMain,\n private envs: EnvsMain,\n private tsConfigWriter: TsconfigWriter\n ) {}\n\n private tsServer: TsserverClient;\n /**\n * create a new compiler.\n */\n createCompiler(\n options: TypeScriptCompilerOptions,\n transformers: TsConfigTransformer[] = [],\n tsModule = ts\n ): Compiler {\n const configMutator = new TypescriptConfigMutator(options);\n const transformerContext: TsConfigTransformContext = {};\n const afterMutation = runTransformersWithContext(configMutator.clone(), transformers, transformerContext);\n return new TypescriptCompiler(TypescriptAspect.id, this.logger, afterMutation.raw, tsModule);\n }\n\n /**\n * get TsserverClient instance if initiated already, otherwise, return undefined.\n */\n getTsserverClient(): TsserverClient | undefined {\n return this.tsServer;\n }\n\n /**\n * starts a tsserver process to communicate with its API.\n * @param projectPath absolute path of the project root directory\n * @param options TsserverClientOpts\n * @param files optionally, if check-types is enabled, provide files to open and type check.\n * @returns TsserverClient\n */\n async initTsserverClient(\n projectPath: string,\n options: TsserverClientOpts = {},\n files: string[] = []\n ): Promise<TsserverClient> {\n this.tsServer = new TsserverClient(projectPath, this.logger, options, files);\n this.tsServer.init();\n return this.tsServer;\n }\n\n /**\n * starts a tsserver process to communicate with its API. use only when running on the workspace.\n * @param options TsserverClientOpts\n * @param files optionally, if check-types is enabled, provide files to open and type check.\n * @returns TsserverClient\n */\n async initTsserverClientFromWorkspace(\n options: TsserverClientOpts = {},\n files: string[] = []\n ): Promise<TsserverClient> {\n if (!this.workspace) {\n throw new Error(`initTsserverClientFromWorkspace: workspace was not found`);\n }\n return this.initTsserverClient(this.workspace.path, options, files);\n }\n\n /**\n * Create a compiler instance and run the cjs transformer for it\n * @param options\n * @param transformers\n * @param tsModule\n * @returns\n */\n createCjsCompiler(options: TypeScriptCompilerOptions, transformers: TsConfigTransformer[] = [], tsModule = ts) {\n return this.createCompiler(options, [this.getCjsTransformer(), ...transformers], tsModule);\n }\n\n /**\n * Create a compiler instance and run the esm transformer for it\n * @param options\n * @param transformers\n * @param tsModule\n * @returns\n */\n createEsmCompiler(options: TypeScriptCompilerOptions, transformers: TsConfigTransformer[] = [], tsModule = ts) {\n return this.createCompiler(options, [this.getEsmTransformer(), ...transformers], tsModule);\n }\n\n /**\n * Create a transformer that change the ts module to CommonJS\n * @returns\n */\n getCjsTransformer(): TsConfigTransformer {\n const cjsTransformer = (config: TypescriptConfigMutator) => {\n config.setModule('CommonJS');\n return config;\n };\n return cjsTransformer;\n }\n\n /**\n * Create a transformer that change the ts module to ES2020\n * @returns\n */\n getEsmTransformer(): TsConfigTransformer {\n const esmTransformer = (config: TypescriptConfigMutator) => {\n config.setModule('ES2020');\n return config;\n };\n return esmTransformer;\n }\n\n /**\n * create an instance of a typescript semantic schema extractor.\n */\n createSchemaExtractor(tsconfig: any, path?: string): SchemaExtractor {\n return new TypeScriptExtractor(\n tsconfig,\n this.schemaTransformerSlot,\n this,\n path || this.workspace.path,\n this.depResolver,\n this.workspace\n );\n }\n\n /**\n * add the default package json properties to the component\n * :TODO @gilad why do we need this DSL? can't I just get the args here.\n */\n getCjsPackageJsonProps(): PackageJsonProps {\n return {\n main: 'dist/{main}.js',\n types: '{main}.ts',\n };\n }\n\n /**\n * add type: module to the package.json props and the default props\n * :TODO @gilad why do we need this DSL? can't I just get the args here.\n */\n getEsmPackageJsonProps(): PackageJsonProps {\n return {\n // main: 'dist-esm/{main}.js',\n main: 'dist/{main}.js',\n type: 'module',\n types: '{main}.ts',\n };\n }\n\n getSupportedFilesForTsserver(components: Component[]): string[] {\n const files = components\n .map((c) => c.filesystem.files)\n .flat()\n .map((f) => f.path);\n return files.filter((f) => f.endsWith('.ts') || f.endsWith('.tsx'));\n }\n\n async cleanTsconfigJson(options: TsconfigWriterOptions = {}) {\n const components = await this.workspace.list();\n const runtime = await this.envs.createEnvironment(components);\n const execContext = runtime.getEnvExecutionContext();\n\n const results = await new TsconfigWriter(this.workspace, this.logger).clean(execContext, options);\n\n return results;\n }\n\n async writeTsconfigJson(options: TsconfigWriterOptions = {}): Promise<{\n cleanResults?: string[];\n writeResults: TsconfigPathsPerEnv[];\n }> {\n const components = await this.workspace.list();\n const runtime = await this.envs.createEnvironment(components);\n const execContext = runtime.getEnvExecutionContext();\n\n let cleanResults: string[] | undefined;\n if (options.clean) {\n cleanResults = await this.tsConfigWriter.clean(execContext, options);\n }\n\n const writeResults = await this.tsConfigWriter.write(execContext, options);\n\n return { writeResults, cleanResults };\n }\n\n private async onPreWatch(components: Component[], watchOpts: WatchOptions) {\n const workspace = this.workspace;\n if (!workspace || !watchOpts.spawnTSServer) {\n return;\n }\n const { verbose, checkTypes } = watchOpts;\n const files = checkTypes ? this.getSupportedFilesForTsserver(components) : [];\n const printTypeErrors = Boolean(checkTypes);\n await this.initTsserverClientFromWorkspace({ verbose, checkTypes, printTypeErrors }, files);\n }\n\n private async onComponentChange(component: Component, files: string[]) {\n if (!this.tsServer) {\n return {\n results: 'N/A',\n };\n }\n await pMapSeries(files, (file) => this.tsServer.onFileChange(file));\n return {\n results: 'succeed',\n };\n }\n\n static runtime = MainRuntime;\n static dependencies = [\n SchemaAspect,\n LoggerAspect,\n AspectLoaderAspect,\n WorkspaceAspect,\n CLIAspect,\n DependencyResolverAspect,\n EnvsAspect,\n ];\n static slots = [Slot.withType<SchemaTransformer[]>()];\n\n static async provider(\n [schema, loggerExt, aspectLoader, workspace, cli, depResolver, envs]: [\n SchemaMain,\n LoggerMain,\n AspectLoaderMain,\n Workspace,\n CLIMain,\n DependencyResolverMain,\n EnvsMain\n ],\n config,\n [schemaTransformerSlot]: [SchemaTransformerSlot]\n ) {\n schema.registerParser(new TypeScriptParser());\n const logger = loggerExt.createLogger(TypescriptAspect.id);\n aspectLoader.registerPlugins([new SchemaTransformerPlugin(schemaTransformerSlot)]);\n const tsconfigWriter = new TsconfigWriter(workspace, logger);\n const tsMain = new TypescriptMain(logger, schemaTransformerSlot, workspace, depResolver, envs, tsconfigWriter);\n schemaTransformerSlot.register([\n new ExportDeclaration(),\n new ExportAssignmentDeclaration(),\n new FunctionDeclaration(),\n new VariableStatementTransformer(),\n new VariableDeclaration(),\n new SourceFileTransformer(),\n new TypeAliasTransformer(),\n new ClassDecelerationTransformer(),\n new InterfaceDeclarationTransformer(),\n new EnumDeclarationTransformer(),\n new BindingElementTransformer(),\n ]);\n\n if (workspace) {\n workspace.registerOnPreWatch(tsMain.onPreWatch.bind(this));\n workspace.registerOnComponentChange(tsMain.onComponentChange.bind(this));\n workspace.registerOnComponentAdd(tsMain.onComponentChange.bind(this));\n }\n\n const checkTypesCmd = new CheckTypesCmd(tsMain, workspace, logger);\n const writeTsconfigCmd = new WriteTsconfigCmd(tsMain);\n cli.register(checkTypesCmd, writeTsconfigCmd);\n\n return tsMain;\n }\n}\n\nTypescriptAspect.addRuntime(TypescriptMain);\n\nexport function runTransformersWithContext(\n config: TypescriptConfigMutator,\n transformers: TsConfigTransformer[] = [],\n context: TsConfigTransformContext\n): TypescriptConfigMutator {\n if (!Array.isArray(transformers)) return config;\n const newConfig = transformers.reduce((acc, transformer) => {\n return transformer(acc, context);\n }, config);\n return newConfig;\n}\n\nexport default TypescriptMain;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA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S,GAAGvH,YAAY,CAACwH,MAAM,CAAC,CAACC,GAAG,EAAEC,WAAW,KAAK;IAC1D,OAAOA,WAAW,CAACD,GAAG,EAAEL,OAAO,CAAC;EAClC,CAAC,EAAExF,MAAM,CAAC;EACV,OAAO2F,SAAS;AAClB;AAAC,eAEcjI,cAAc;AAAA"}
package/package.json CHANGED
@@ -1,40 +1,40 @@
1
1
  {
2
2
  "name": "@teambit/typescript",
3
- "version": "0.0.886",
3
+ "version": "0.0.887",
4
4
  "homepage": "https://bit.dev/teambit/typescript/typescript",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.typescript",
8
8
  "name": "typescript",
9
- "version": "0.0.886"
9
+ "version": "0.0.887"
10
10
  },
11
11
  "dependencies": {
12
12
  "lodash": "4.17.21",
13
13
  "tsutils": "3.21.0",
14
- "typescript": "4.4.2",
14
+ "typescript": "4.7.4",
15
15
  "chalk": "2.4.2",
16
16
  "fs-extra": "10.0.0",
17
17
  "yesno": "0.4.0",
18
18
  "p-map-series": "2.1.0",
19
- "@babel/runtime": "7.12.18",
19
+ "@babel/runtime": "7.20.0",
20
20
  "core-js": "^3.0.0",
21
21
  "@teambit/harmony": "0.3.3",
22
- "@teambit/compiler": "0.0.886",
23
- "@teambit/typescript.modules.ts-config-mutator": "0.0.75",
24
- "@teambit/component": "0.0.886",
25
- "@teambit/dependency-resolver": "0.0.886",
26
- "@teambit/semantics.entities.semantic-schema": "0.0.39",
27
- "@teambit/ts-server": "0.0.38",
28
- "@teambit/aspect-loader": "0.0.886",
29
- "@teambit/envs": "0.0.886",
30
- "@teambit/logger": "0.0.687",
31
- "@teambit/workspace": "0.0.886",
32
- "@teambit/bit-error": "0.0.400",
33
- "@teambit/builder": "0.0.886",
34
- "@teambit/isolator": "0.0.886",
35
- "@teambit/schema": "0.0.886",
36
- "@teambit/cli": "0.0.594",
37
- "@teambit/pkg": "0.0.886"
22
+ "@teambit/compiler": "0.0.887",
23
+ "@teambit/typescript.modules.ts-config-mutator": "0.0.76",
24
+ "@teambit/component": "0.0.887",
25
+ "@teambit/dependency-resolver": "0.0.887",
26
+ "@teambit/semantics.entities.semantic-schema": "0.0.40",
27
+ "@teambit/ts-server": "0.0.39",
28
+ "@teambit/aspect-loader": "0.0.887",
29
+ "@teambit/envs": "0.0.887",
30
+ "@teambit/logger": "0.0.688",
31
+ "@teambit/workspace": "0.0.887",
32
+ "@teambit/bit-error": "0.0.401",
33
+ "@teambit/builder": "0.0.887",
34
+ "@teambit/isolator": "0.0.887",
35
+ "@teambit/schema": "0.0.887",
36
+ "@teambit/cli": "0.0.595",
37
+ "@teambit/pkg": "0.0.887"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/lodash": "4.14.165",
@@ -47,10 +47,10 @@
47
47
  "@types/jest": "^26.0.0",
48
48
  "@types/react-dom": "^17.0.5",
49
49
  "@types/node": "12.20.4",
50
- "@teambit/typescript.aspect-docs.typescript": "0.0.146"
50
+ "@teambit/typescript.aspect-docs.typescript": "0.0.147"
51
51
  },
52
52
  "peerDependencies": {
53
- "@teambit/legacy": "1.0.377",
53
+ "@teambit/legacy": "1.0.379",
54
54
  "react-dom": "^16.8.0 || ^17.0.0",
55
55
  "react": "^16.8.0 || ^17.0.0"
56
56
  },
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.typescript_typescript@0.0.886/dist/typescript.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.typescript_typescript@0.0.886/dist/typescript.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.typescript_typescript@0.0.887/dist/typescript.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.typescript_typescript@0.0.887/dist/typescript.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
@@ -0,0 +1,19 @@
1
+ import { SchemaNode } from '@teambit/semantics.entities.semantic-schema';
2
+ import { Node, SyntaxKind, ExportAssignment as ExportAssignmentNode } from 'typescript';
3
+ import { SchemaExtractorContext } from '../schema-extractor-context';
4
+ import { SchemaTransformer } from '../schema-transformer';
5
+
6
+ export class ExportAssignmentDeclaration implements SchemaTransformer {
7
+ predicate(node: Node) {
8
+ return node.kind === SyntaxKind.ExportAssignment;
9
+ }
10
+
11
+ async getIdentifiers(exportDec: ExportAssignmentNode, context: SchemaExtractorContext) {
12
+ return context.getFileExports(exportDec);
13
+ }
14
+
15
+ async transform(exportDec: ExportAssignmentNode, context: SchemaExtractorContext): Promise<SchemaNode> {
16
+ const specifier = exportDec.expression;
17
+ return context.computeSchema(specifier);
18
+ }
19
+ }
@@ -7,7 +7,7 @@ import { toFunctionLikeSchema } from './utils/to-function-like-schema';
7
7
 
8
8
  export class FunctionDeclaration implements SchemaTransformer {
9
9
  predicate(node: Node) {
10
- return node.kind === ts.SyntaxKind.FunctionDeclaration;
10
+ return node.kind === ts.SyntaxKind.FunctionDeclaration || node.kind === ts.SyntaxKind.ArrowFunction;
11
11
  }
12
12
 
13
13
  // need to check for anonymous functions assigned for vars, const and let.
@@ -8,3 +8,4 @@ export { ClassDecelerationTransformer } from './class-deceleration';
8
8
  export { InterfaceDeclarationTransformer } from './interface-declaration';
9
9
  export { EnumDeclarationTransformer } from './enum-declaration';
10
10
  export { BindingElementTransformer } from './binding-element';
11
+ export { ExportAssignmentDeclaration } from './export-assignment-declaration';
@@ -1,4 +1,4 @@
1
- import { SignatureDeclaration } from 'typescript';
1
+ import { SignatureDeclaration, SyntaxKind } from 'typescript';
2
2
  import { FunctionLikeSchema, Modifier } from '@teambit/semantics.entities.semantic-schema';
3
3
  import { SchemaExtractorContext } from '../../schema-extractor-context';
4
4
  import { getParams } from './get-params';
@@ -11,7 +11,13 @@ export async function toFunctionLikeSchema(
11
11
  funcName?: string
12
12
  ) {
13
13
  const name = funcName || node.name?.getText() || '';
14
- const info = node.name ? await context.getQuickInfo(node.name) : null;
14
+ const getQuickInfoFromDefaultModifier = async () => {
15
+ const defaultModifier = node.modifiers?.find((modifier) => modifier.kind === SyntaxKind.DefaultKeyword);
16
+ if (defaultModifier) return context.getQuickInfo(defaultModifier);
17
+ if (node.kind === SyntaxKind.ArrowFunction) return context.getQuickInfo(node.equalsGreaterThanToken);
18
+ return null;
19
+ };
20
+ const info = node.name ? await context.getQuickInfo(node.name) : await getQuickInfoFromDefaultModifier();
15
21
  const returnTypeStr = info ? parseTypeFromQuickInfo(info) : 'any';
16
22
  const displaySig = info?.body?.displayString || '';
17
23
  const args = await getParams(node.parameters, context);
@@ -41,6 +41,7 @@ import {
41
41
  ThisTypeSchema,
42
42
  Modifier,
43
43
  ConditionalTypeSchema,
44
+ UnImplementedSchema,
44
45
  } from '@teambit/semantics.entities.semantic-schema';
45
46
  import pMapSeries from 'p-map-series';
46
47
  import { SchemaExtractorContext } from '../../schema-extractor-context';
@@ -108,14 +109,15 @@ export async function typeNodeToSchema(node: TypeNode, context: SchemaExtractorC
108
109
  case SyntaxKind.JSDocNamepathType:
109
110
  case SyntaxKind.JSDocSignature:
110
111
  case SyntaxKind.JSDocTypeLiteral:
111
- throw new Error(`TypeNode ${node.kind} (probably ${SyntaxKind[node.kind]}) was not implemented yet.
112
- context: ${node.getText()}`);
112
+ return unimplementedSchema(node, context);
113
113
  default:
114
- throw new Error(`Node ${node.kind} (probably ${SyntaxKind[node.kind]}) is not a TypeNode.
115
- context: ${node.getText()}`);
114
+ return unimplementedSchema(node, context);
116
115
  }
117
116
  }
118
117
 
118
+ function unimplementedSchema(node: TypeNode, context: SchemaExtractorContext) {
119
+ return new UnImplementedSchema(context.getLocation(node), node.getText(), SyntaxKind[node.kind]);
120
+ }
119
121
  /**
120
122
  * whether it's kind of `ts.KeywordTypeSyntaxKind`
121
123
  */