@teambit/typescript 0.0.1076 → 0.0.1077

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
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.typescript_typescript@0.0.1076/dist/typescript.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.typescript_typescript@0.0.1076/dist/typescript.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.typescript_typescript@0.0.1077/dist/typescript.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.typescript_typescript@0.0.1077/dist/typescript.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
@@ -197,10 +197,10 @@ class SchemaExtractorContext {
197
197
  */
198
198
  getLocation(node, targetSourceFile, absolutePath = false) {
199
199
  const sourceFile = targetSourceFile || node.getSourceFile();
200
+ const filePath = absolutePath ? sourceFile.fileName : this.getPathRelativeToComponent(sourceFile.fileName);
200
201
  const position = sourceFile.getLineAndCharacterOfPosition(node.getStart());
201
202
  const line = position.line + 1;
202
203
  const character = position.character + 1;
203
- const filePath = absolutePath ? sourceFile.fileName : this.getPathRelativeToComponent(sourceFile.fileName);
204
204
  return {
205
205
  filePath: (0, _utils().pathNormalizeToLinux)(filePath),
206
206
  line,
@@ -262,26 +262,24 @@ class SchemaExtractorContext {
262
262
  }
263
263
  visitTypeDefinition() {}
264
264
  findFileInComponent(filePath) {
265
- const filePathToCompare = (0, _utils().pathNormalizeToLinux)(filePath);
266
- const fileNameToCompare = (0, _path().basename)(filePathToCompare); // Get the filename from the filePath
267
-
265
+ const normalizedFilePath = (0, _utils().pathNormalizeToLinux)(filePath);
266
+ const fileNameToCompare = (0, _path().basename)(normalizedFilePath);
267
+ const pathWithoutExtension = fileNameToCompare.replace(/\.[^/.]+$/, '');
268
+ const possibleFormats = new Set(['ts', 'tsx', 'js', 'jsx']);
268
269
  const matchingFile = this.component.filesystem.files.find(file => {
269
270
  const currentFilePath = (0, _utils().pathNormalizeToLinux)(file.path);
270
- const currentFileName = (0, _path().basename)(currentFilePath); // Get the filename from the current file path
271
-
272
- // TODO: fix this line to support further extensions.
273
- if (currentFileName === fileNameToCompare || currentFilePath.includes(fileNameToCompare)) {
274
- const strings = ['ts', 'tsx', 'js', 'jsx'].map(format => {
275
- if (fileNameToCompare.endsWith(`.${format}`)) return fileNameToCompare;
276
- return `${fileNameToCompare}.${format}`;
277
- });
278
- const matchesWithExtension = !!strings.find(string => string === currentFileName);
279
- // check if it is an index file export
280
- const matchesIndexFile = !matchesWithExtension && ['ts', 'js'].some(format => {
281
- const indexFilePath = (0, _path().join)(filePathToCompare, `index.${format}`);
282
- return (0, _utils().pathNormalizeToLinux)(indexFilePath) === currentFilePath;
283
- });
284
- return matchesWithExtension || matchesIndexFile;
271
+ const currentFileName = (0, _path().basename)(currentFilePath);
272
+ const currentFileExtension = (0, _path().extname)(currentFilePath).substring(1);
273
+ const isSameBaseName = pathWithoutExtension === (0, _path().basename)(currentFileName, `.${currentFileExtension}`);
274
+ const isValidExtension = possibleFormats.has(currentFileExtension);
275
+ if (isSameBaseName && isValidExtension) {
276
+ return true;
277
+ }
278
+ if (['ts', 'js'].some(format => {
279
+ const indexFilePath = (0, _path().join)(normalizedFilePath, `index.${format}`);
280
+ return (0, _utils().pathNormalizeToLinux)(indexFilePath) === currentFilePath;
281
+ })) {
282
+ return true;
285
283
  }
286
284
  return false;
287
285
  });
@@ -1 +1 @@
1
- {"version":3,"names":["SchemaExtractorContext","mainFile","pathNormalizeToLinux","getPathRelativeToComponent","component","path","identifiers","_identifiers","internalIdentifiers","_internalIdentifiers","computed","_computed","mainFileIdentifierKey","getIdentifierKey","mainModuleIdentifiers","get","constructor","tsserver","extractor","componentDeps","formatter","Map","getComputedNodeKey","filePath","line","character","getIdentifierKeyForNode","node","getSourceFile","fileName","setComputed","location","key","set","setIdentifiers","setInternalIdentifiers","existing","uniqueIdentifiers","uniqBy","concat","k","aliasId","id","IdentifierList","computeSchema","getLocation","existingComputedSchema","computedSchema","targetSourceFile","absolutePath","sourceFile","position","getLineAndCharacterOfPosition","getStart","getLocationAsString","basePath","filesystem","files","base","relative","getSignature","getSignatureHelp","getPath","getPosition","offset","getPositionOfLineAndCharacter","getQuickInfo","err","message","Error","getQuickInfoDisplayString","quickInfo","body","displayString","typeDefinition","getTypeDefinition","visitTypeDefinition","findFileInComponent","filePathToCompare","fileNameToCompare","basename","matchingFile","find","file","currentFilePath","currentFileName","includes","strings","map","format","endsWith","matchesWithExtension","string","matchesIndexFile","some","indexFilePath","join","parsePackageNameFromPath","parts","split","length","lastPart","replace","sep","pkgParts","startsWith","pkgName","getSourceFileInsideComponent","parseSourceFile","getSourceFileFromNode","getFilePathByNode","undefined","def","getDefinition","firstDef","head","definitionInfo","definition","startPosition","start","pos","nodeAtPos","getTokenAtPosition","visitDefinition","getTypeRefForExternalNode","visit","parent","kind","SyntaxKind","Identifier","SourceFile","references","isExported","isFromComponent","getFileIdentifiers","exportDec","specifierPathStr","ExportDeclaration","moduleSpecifier","getText","specifierPath","substring","absPath","resolve","getIdentifiers","getFileExports","filter","identifier","ExportIdentifier","isExportIdentifier","getFileInternals","computeIdentifiers","headTypeDefinition","unknownExactType","typeStr","isTypeStrFromQuickInfo","InferenceTypeSchema","info","type","parseTypeFromQuickInfo","isDefInSameLocation","loc","resolveType","internalRef","getTypeRef","ts","isTypeNode","getTypeRefForExternalPath","definitionNode","definitionNodeName","definitionInternalRef","transformer","getTransformer","schemaNode","getCompIdByPkgName","dep","packageName","componentId","nodeIdentifierKey","nodeIdentifierList","mainIdentifierList","nodeIdentifier","mainIdentifier","parsedNodeIdentifier","parsedMainIdentifier","isExportedFromMain","resolveTypeRef","sourceFilePath","TypeRefSchema","isRelativeImport","compIdByPkg","compIdByPath","getComponentIDByPath","relativeDir","lastIndexOf","absFilePath","compFilePath","idKey","exportedIdentifier","i","jsDocToDocSchema","canHaveJsDoc","jsDocs","getJsDoc","jsDoc","comment","getTextOfJSDocComment","tags","pMapSeries","tag","tagParser","DocSchema"],"sources":["schema-extractor-context.ts"],"sourcesContent":["import { TsserverClient } from '@teambit/ts-server';\nimport { getTokenAtPosition, canHaveJsDoc, getJsDoc } from 'tsutils';\nimport ts, { ExportAssignment, getTextOfJSDocComment, ExportDeclaration, Node, SyntaxKind, TypeNode } from 'typescript';\nimport { head, uniqBy } from 'lodash';\n// @ts-ignore david we should figure fix this.\n// eslint-disable-next-line import/no-unresolved\nimport protocol from 'typescript/lib/protocol';\nimport { pathNormalizeToLinux } from '@teambit/legacy/dist/utils';\nimport { resolve, sep, relative, basename, join } from 'path';\nimport { Component, ComponentID } from '@teambit/component';\nimport {\n TypeRefSchema,\n SchemaNode,\n InferenceTypeSchema,\n Location,\n DocSchema,\n} from '@teambit/semantics.entities.semantic-schema';\nimport isRelativeImport from '@teambit/legacy/dist/utils/is-relative-import';\nimport { ComponentDependency } from '@teambit/dependency-resolver';\nimport { Formatter } from '@teambit/formatter';\nimport pMapSeries from 'p-map-series';\nimport { TypeScriptExtractor } from './typescript.extractor';\nimport { IdentifierList } from './identifier-list';\nimport { parseTypeFromQuickInfo } from './transformers/utils/parse-type-from-quick-info';\nimport { tagParser } from './transformers/utils/jsdoc-to-doc-schema';\nimport { Identifier } from './identifier';\nimport { ExportIdentifier } from './export-identifier';\n\nexport class SchemaExtractorContext {\n /**\n * list of all declared identifiers (exported and internal) by filename\n */\n private _identifiers = new Map<string, IdentifierList>();\n private _internalIdentifiers = new Map<string, IdentifierList>();\n\n /**\n * computed nodes by filename and (position (line:character))\n */\n private _computed = new Map<string, SchemaNode>();\n\n get mainFile() {\n return pathNormalizeToLinux(this.getPathRelativeToComponent(this.component.mainFile.path));\n }\n\n get identifiers() {\n return this._identifiers;\n }\n\n get internalIdentifiers() {\n return this._internalIdentifiers;\n }\n\n get computed() {\n return this._computed;\n }\n\n get mainFileIdentifierKey() {\n const mainFile = this.component.mainFile;\n return this.getIdentifierKey(mainFile.path);\n }\n\n get mainModuleIdentifiers() {\n return this.identifiers.get(this.mainFileIdentifierKey);\n }\n\n constructor(\n readonly tsserver: TsserverClient,\n readonly component: Component,\n readonly extractor: TypeScriptExtractor,\n readonly componentDeps: ComponentDependency[],\n readonly formatter?: Formatter\n ) {}\n\n getComputedNodeKey({ filePath, line, character }: Location) {\n return `${filePath}:${line}:${character}`;\n }\n\n getIdentifierKeyForNode(node: Node) {\n const filePath = node.getSourceFile().fileName;\n return this.getIdentifierKey(filePath);\n }\n\n getIdentifierKey(filePath: string) {\n return pathNormalizeToLinux(filePath);\n }\n\n setComputed(node: SchemaNode) {\n const { location } = node;\n const key = this.getComputedNodeKey(location);\n this.computed.set(key, node);\n }\n\n setIdentifiers(filePath: string, identifiers: IdentifierList) {\n this._identifiers.set(this.getIdentifierKey(filePath), identifiers);\n }\n\n setInternalIdentifiers(filePath: string, identifiers: IdentifierList) {\n const existing = this._internalIdentifiers.get(filePath);\n if (!existing) {\n this._internalIdentifiers.set(filePath, identifiers);\n } else {\n const uniqueIdentifiers = uniqBy(existing.identifiers.concat(identifiers.identifiers), (k) => k.aliasId || k.id);\n this._internalIdentifiers.set(filePath, new IdentifierList(uniqueIdentifiers));\n }\n }\n\n async computeSchema(node: Node) {\n const location = this.getLocation(node);\n const key = this.getComputedNodeKey(location);\n const existingComputedSchema = this.computed.get(key);\n if (existingComputedSchema) {\n return existingComputedSchema;\n }\n\n const computedSchema = await this.extractor.computeSchema(node, this);\n this.setComputed(computedSchema);\n return computedSchema;\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 findFileInComponent(filePath: string) {\n const filePathToCompare = pathNormalizeToLinux(filePath);\n const fileNameToCompare = basename(filePathToCompare); // Get the filename from the filePath\n\n const matchingFile = this.component.filesystem.files.find((file) => {\n const currentFilePath = pathNormalizeToLinux(file.path);\n const currentFileName = basename(currentFilePath); // Get the filename from the current file path\n\n // TODO: fix this line to support further extensions.\n if (currentFileName === fileNameToCompare || currentFilePath.includes(fileNameToCompare)) {\n const strings = ['ts', 'tsx', 'js', 'jsx'].map((format) => {\n if (fileNameToCompare.endsWith(`.${format}`)) return fileNameToCompare;\n\n return `${fileNameToCompare}.${format}`;\n });\n\n const matchesWithExtension = !!strings.find((string) => string === currentFileName);\n // check if it is an index file export\n const matchesIndexFile =\n !matchesWithExtension &&\n ['ts', 'js'].some((format) => {\n const indexFilePath = join(filePathToCompare, `index.${format}`);\n return pathNormalizeToLinux(indexFilePath) === currentFilePath;\n });\n\n return matchesWithExtension || matchesIndexFile;\n }\n\n return false;\n });\n\n return matchingFile;\n }\n\n private parsePackageNameFromPath(path: string) {\n const parts = path.split('node_modules');\n\n if (parts.length === 1) {\n return path;\n }\n\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 return file && 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(definition: protocol.DefinitionInfo): Promise<Node | undefined> {\n const startPosition = definition.start;\n const sourceFile = this.getSourceFileInsideComponent(definition.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 if (node.kind === SyntaxKind.Identifier && node.parent.parent.kind !== SyntaxKind.SourceFile) {\n return this.visit(node.parent);\n }\n return this.extractor.computeSchema(node, this);\n }\n\n references() {}\n\n isExported() {}\n\n isFromComponent() {}\n\n async getFileIdentifiers(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.getIdentifiers(sourceFile);\n }\n\n async getFileExports(exportDec: ExportDeclaration | ExportAssignment) {\n const identifiers = await this.getFileIdentifiers(exportDec);\n return identifiers.filter((identifier) => ExportIdentifier.isExportIdentifier(identifier));\n }\n\n async getFileInternals(exportDec: ExportDeclaration | ExportAssignment) {\n const identifiers = await this.getFileIdentifiers(exportDec);\n return identifiers.filter((identifier) => !ExportIdentifier.isExportIdentifier(identifier));\n }\n\n getIdentifiers(node: Node) {\n return this.extractor.computeIdentifiers(node, this);\n }\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 async getDefinition(node: Node) {\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\n // when we can't figure out the component/package/type of this node, we'll use the typeStr as the type.\n private async unknownExactType(node: Node, location: Location, typeStr = 'any', isTypeStrFromQuickInfo = true) {\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\n // the reason for this check is to avoid infinite loop when calling `this.jump` with the same file+location\n private isDefInSameLocation(node: Node, definition: protocol.FileSpanWithContext) {\n if (definition.file !== node.getSourceFile().fileName) {\n return false;\n }\n const loc = this.getLocation(node);\n\n return loc.line === definition.start.line && loc.character === definition.start.offset;\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\n // check if internal ref with typeInfo\n const internalRef = await this.getTypeRef(typeStr, this.getIdentifierKeyForNode(node), location);\n\n if (internalRef) return internalRef;\n\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 if (node.type && ts.isTypeNode(node.type)) {\n return this.computeSchema(node.type);\n }\n\n const definition = await this.getDefinition(node);\n if (!definition) {\n return this.unknownExactType(node, location, typeStr, isTypeStrFromQuickInfo);\n }\n\n const file = this.findFileInComponent(definition.file);\n\n if (!file) return this.getTypeRefForExternalPath(typeStr, definition.file, location);\n\n if (this.isDefInSameLocation(node, definition)) {\n return this.unknownExactType(node, location, typeStr, isTypeStrFromQuickInfo);\n }\n\n const definitionNode = await this.definition(definition);\n\n if (!definitionNode) {\n return this.unknownExactType(node, location, typeStr, isTypeStrFromQuickInfo);\n }\n\n const definitionNodeName = definitionNode?.getText();\n\n // check if internal ref with definition info\n const definitionInternalRef = await this.getTypeRef(\n definitionNodeName,\n this.getIdentifierKeyForNode(definitionNode),\n location\n );\n\n if (definitionInternalRef) return definitionInternalRef;\n\n const transformer = this.extractor.getTransformer(definitionNode, this);\n\n if (transformer === undefined) {\n return this.unknownExactType(node, location, typeStr, isTypeStrFromQuickInfo);\n }\n const schemaNode = await this.visit(definitionNode);\n return schemaNode || this.unknownExactType(node, location, typeStr, isTypeStrFromQuickInfo);\n }\n\n private getCompIdByPkgName(pkgName: string): ComponentID | undefined {\n return this.componentDeps.find((dep) => dep.packageName === pkgName)?.componentId;\n }\n\n async getTypeRef(typeStr: string, filePath: string, location: Location): Promise<TypeRefSchema | undefined> {\n const nodeIdentifierKey = this.getIdentifierKey(filePath);\n const mainFileIdentifierKey = this.mainFileIdentifierKey;\n\n const nodeIdentifierList = this.identifiers.get(nodeIdentifierKey);\n const mainIdentifierList = this.identifiers.get(mainFileIdentifierKey);\n\n const nodeIdentifier = new Identifier(typeStr, nodeIdentifierKey);\n const mainIdentifier = new Identifier(typeStr, mainFileIdentifierKey);\n\n const parsedNodeIdentifier = nodeIdentifierList?.find(nodeIdentifier);\n const parsedMainIdentifier = mainIdentifierList?.find(mainIdentifier);\n const isExportedFromMain = parsedMainIdentifier && ExportIdentifier.isExportIdentifier(parsedMainIdentifier);\n\n if (!parsedNodeIdentifier) return undefined;\n\n const internalRef = !isExportedFromMain;\n\n if (internalRef) {\n this.setInternalIdentifiers(filePath, new IdentifierList([parsedNodeIdentifier]));\n }\n\n return this.resolveTypeRef(parsedNodeIdentifier, location, isExportedFromMain);\n }\n\n async resolveTypeRef(\n identifier: Identifier,\n location: Location,\n isExportedFromMain?: boolean\n ): Promise<TypeRefSchema> {\n const sourceFilePath = identifier.sourceFilePath;\n\n if (!sourceFilePath || isExportedFromMain) {\n return new TypeRefSchema(\n location,\n identifier.id,\n undefined,\n undefined,\n !isExportedFromMain ? this.getPathRelativeToComponent(identifier.filePath) : undefined\n );\n }\n\n if (!isRelativeImport(sourceFilePath)) {\n const pkgName = this.parsePackageNameFromPath(sourceFilePath);\n const compIdByPkg = this.getCompIdByPkgName(pkgName);\n\n const compIdByPath = await this.extractor.getComponentIDByPath(sourceFilePath);\n\n if (compIdByPath) {\n return new TypeRefSchema(location, identifier.id, compIdByPath);\n }\n\n if (compIdByPkg) {\n return new TypeRefSchema(location, identifier.id, compIdByPkg);\n }\n\n // package without comp id\n return new TypeRefSchema(location, identifier.id, undefined, pkgName);\n }\n\n const relativeDir = identifier.filePath.substring(0, identifier.filePath.lastIndexOf('/'));\n const absFilePath = resolve(relativeDir, sourceFilePath);\n const compFilePath = this.findFileInComponent(absFilePath);\n if (!compFilePath) {\n // @todo handle this better\n throw new Error(\n `cannot find file in component \\n absolute path: ${absFilePath}\\n source file path ${sourceFilePath}\\n identifier file path ${identifier.filePath} \\n relative dir ${relativeDir}`\n );\n return new TypeRefSchema(location, identifier.id);\n }\n\n const idKey = this.getIdentifierKey(compFilePath?.path);\n\n // if re exported from a file, recurse until definition\n const exportedIdentifier = (this.identifiers.get(idKey)?.identifiers || []).find((i) => i.id === identifier.id);\n\n if (exportedIdentifier) {\n return this.resolveTypeRef(exportedIdentifier, location, isExportedFromMain);\n }\n\n return new TypeRefSchema(location, identifier.id);\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 async jsDocToDocSchema(node: Node): Promise<DocSchema | undefined> {\n if (!canHaveJsDoc(node)) {\n return undefined;\n }\n const jsDocs = getJsDoc(node);\n if (!jsDocs.length) {\n return undefined;\n }\n // not sure how common it is to have multiple JSDocs. never seen it before.\n // regardless, in typescript implementation of methods like `getJSDocDeprecatedTag()`, they use the first one. (`getFirstJSDocTag()`)\n const jsDoc = jsDocs[0];\n const location = this.getLocation(jsDoc);\n const comment = getTextOfJSDocComment(jsDoc.comment);\n const tags = jsDoc.tags ? await pMapSeries(jsDoc.tags, (tag) => tagParser(tag, this, this.formatter)) : undefined;\n return new DocSchema(location, jsDoc.getText(), comment, tags);\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;AAIA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAOA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;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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mainFile","pathNormalizeToLinux","getPathRelativeToComponent","component","path","identifiers","_identifiers","internalIdentifiers","_internalIdentifiers","computed","_computed","mainFileIdentifierKey","getIdentifierKey","mainModuleIdentifiers","get","constructor","tsserver","extractor","componentDeps","formatter","Map","getComputedNodeKey","filePath","line","character","getIdentifierKeyForNode","node","getSourceFile","fileName","setComputed","location","key","set","setIdentifiers","setInternalIdentifiers","existing","uniqueIdentifiers","uniqBy","concat","k","aliasId","id","IdentifierList","computeSchema","getLocation","existingComputedSchema","computedSchema","targetSourceFile","absolutePath","sourceFile","position","getLineAndCharacterOfPosition","getStart","getLocationAsString","basePath","filesystem","files","base","relative","getSignature","getSignatureHelp","getPath","getPosition","offset","getPositionOfLineAndCharacter","getQuickInfo","err","message","Error","getQuickInfoDisplayString","quickInfo","body","displayString","typeDefinition","getTypeDefinition","visitTypeDefinition","findFileInComponent","normalizedFilePath","fileNameToCompare","basename","pathWithoutExtension","replace","possibleFormats","Set","matchingFile","find","file","currentFilePath","currentFileName","currentFileExtension","extname","substring","isSameBaseName","isValidExtension","has","some","format","indexFilePath","join","parsePackageNameFromPath","parts","split","length","lastPart","sep","pkgParts","startsWith","pkgName","getSourceFileInsideComponent","parseSourceFile","getSourceFileFromNode","getFilePathByNode","undefined","def","getDefinition","firstDef","head","definitionInfo","definition","startPosition","start","pos","nodeAtPos","getTokenAtPosition","visitDefinition","getTypeRefForExternalNode","visit","parent","kind","SyntaxKind","Identifier","SourceFile","references","isExported","isFromComponent","getFileIdentifiers","exportDec","specifierPathStr","ExportDeclaration","moduleSpecifier","getText","specifierPath","absPath","resolve","getIdentifiers","getFileExports","filter","identifier","ExportIdentifier","isExportIdentifier","getFileInternals","computeIdentifiers","headTypeDefinition","unknownExactType","typeStr","isTypeStrFromQuickInfo","InferenceTypeSchema","info","type","parseTypeFromQuickInfo","isDefInSameLocation","loc","resolveType","internalRef","getTypeRef","ts","isTypeNode","getTypeRefForExternalPath","definitionNode","definitionNodeName","definitionInternalRef","transformer","getTransformer","schemaNode","getCompIdByPkgName","dep","packageName","componentId","nodeIdentifierKey","nodeIdentifierList","mainIdentifierList","nodeIdentifier","mainIdentifier","parsedNodeIdentifier","parsedMainIdentifier","isExportedFromMain","resolveTypeRef","sourceFilePath","TypeRefSchema","isRelativeImport","compIdByPkg","compIdByPath","getComponentIDByPath","relativeDir","lastIndexOf","absFilePath","compFilePath","idKey","exportedIdentifier","i","jsDocToDocSchema","canHaveJsDoc","jsDocs","getJsDoc","jsDoc","comment","getTextOfJSDocComment","tags","pMapSeries","tag","tagParser","DocSchema"],"sources":["schema-extractor-context.ts"],"sourcesContent":["import { TsserverClient } from '@teambit/ts-server';\nimport { getTokenAtPosition, canHaveJsDoc, getJsDoc } from 'tsutils';\nimport ts, { ExportAssignment, getTextOfJSDocComment, ExportDeclaration, Node, SyntaxKind, TypeNode } from 'typescript';\nimport { head, uniqBy } from 'lodash';\n// @ts-ignore david we should figure fix this.\n// eslint-disable-next-line import/no-unresolved\nimport protocol from 'typescript/lib/protocol';\nimport { pathNormalizeToLinux } from '@teambit/legacy/dist/utils';\nimport { resolve, sep, relative, basename, join, extname } from 'path';\nimport { Component, ComponentID } from '@teambit/component';\nimport {\n TypeRefSchema,\n SchemaNode,\n InferenceTypeSchema,\n Location,\n DocSchema,\n} from '@teambit/semantics.entities.semantic-schema';\nimport isRelativeImport from '@teambit/legacy/dist/utils/is-relative-import';\nimport { ComponentDependency } from '@teambit/dependency-resolver';\nimport { Formatter } from '@teambit/formatter';\nimport pMapSeries from 'p-map-series';\nimport { TypeScriptExtractor } from './typescript.extractor';\nimport { IdentifierList } from './identifier-list';\nimport { parseTypeFromQuickInfo } from './transformers/utils/parse-type-from-quick-info';\nimport { tagParser } from './transformers/utils/jsdoc-to-doc-schema';\nimport { Identifier } from './identifier';\nimport { ExportIdentifier } from './export-identifier';\n\nexport class SchemaExtractorContext {\n /**\n * list of all declared identifiers (exported and internal) by filename\n */\n private _identifiers = new Map<string, IdentifierList>();\n private _internalIdentifiers = new Map<string, IdentifierList>();\n\n /**\n * computed nodes by filename and (position (line:character))\n */\n private _computed = new Map<string, SchemaNode>();\n\n get mainFile() {\n return pathNormalizeToLinux(this.getPathRelativeToComponent(this.component.mainFile.path));\n }\n\n get identifiers() {\n return this._identifiers;\n }\n\n get internalIdentifiers() {\n return this._internalIdentifiers;\n }\n\n get computed() {\n return this._computed;\n }\n\n get mainFileIdentifierKey() {\n const mainFile = this.component.mainFile;\n return this.getIdentifierKey(mainFile.path);\n }\n\n get mainModuleIdentifiers() {\n return this.identifiers.get(this.mainFileIdentifierKey);\n }\n\n constructor(\n readonly tsserver: TsserverClient,\n readonly component: Component,\n readonly extractor: TypeScriptExtractor,\n readonly componentDeps: ComponentDependency[],\n readonly formatter?: Formatter\n ) {}\n\n getComputedNodeKey({ filePath, line, character }: Location) {\n return `${filePath}:${line}:${character}`;\n }\n\n getIdentifierKeyForNode(node: Node) {\n const filePath = node.getSourceFile().fileName;\n return this.getIdentifierKey(filePath);\n }\n\n getIdentifierKey(filePath: string) {\n return pathNormalizeToLinux(filePath);\n }\n\n setComputed(node: SchemaNode) {\n const { location } = node;\n const key = this.getComputedNodeKey(location);\n this.computed.set(key, node);\n }\n\n setIdentifiers(filePath: string, identifiers: IdentifierList) {\n this._identifiers.set(this.getIdentifierKey(filePath), identifiers);\n }\n\n setInternalIdentifiers(filePath: string, identifiers: IdentifierList) {\n const existing = this._internalIdentifiers.get(filePath);\n if (!existing) {\n this._internalIdentifiers.set(filePath, identifiers);\n } else {\n const uniqueIdentifiers = uniqBy(existing.identifiers.concat(identifiers.identifiers), (k) => k.aliasId || k.id);\n this._internalIdentifiers.set(filePath, new IdentifierList(uniqueIdentifiers));\n }\n }\n\n async computeSchema(node: Node) {\n const location = this.getLocation(node);\n const key = this.getComputedNodeKey(location);\n const existingComputedSchema = this.computed.get(key);\n if (existingComputedSchema) {\n return existingComputedSchema;\n }\n\n const computedSchema = await this.extractor.computeSchema(node, this);\n this.setComputed(computedSchema);\n return computedSchema;\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 filePath = absolutePath ? sourceFile.fileName : this.getPathRelativeToComponent(sourceFile.fileName);\n const position = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n const line = position.line + 1;\n const character = position.character + 1;\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 findFileInComponent(filePath: string) {\n const normalizedFilePath = pathNormalizeToLinux(filePath);\n const fileNameToCompare = basename(normalizedFilePath);\n const pathWithoutExtension = fileNameToCompare.replace(/\\.[^/.]+$/, '');\n const possibleFormats = new Set(['ts', 'tsx', 'js', 'jsx']);\n\n const matchingFile = this.component.filesystem.files.find((file) => {\n const currentFilePath = pathNormalizeToLinux(file.path);\n const currentFileName = basename(currentFilePath);\n const currentFileExtension = extname(currentFilePath).substring(1);\n\n const isSameBaseName = pathWithoutExtension === basename(currentFileName, `.${currentFileExtension}`);\n const isValidExtension = possibleFormats.has(currentFileExtension);\n\n if (isSameBaseName && isValidExtension) {\n return true;\n }\n\n if (\n ['ts', 'js'].some((format) => {\n const indexFilePath = join(normalizedFilePath, `index.${format}`);\n return pathNormalizeToLinux(indexFilePath) === currentFilePath;\n })\n ) {\n return true;\n }\n\n return false;\n });\n\n return matchingFile;\n }\n\n private parsePackageNameFromPath(path: string) {\n const parts = path.split('node_modules');\n\n if (parts.length === 1) {\n return path;\n }\n\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 return file && 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(definition: protocol.DefinitionInfo): Promise<Node | undefined> {\n const startPosition = definition.start;\n const sourceFile = this.getSourceFileInsideComponent(definition.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 if (node.kind === SyntaxKind.Identifier && node.parent.parent.kind !== SyntaxKind.SourceFile) {\n return this.visit(node.parent);\n }\n return this.extractor.computeSchema(node, this);\n }\n\n references() {}\n\n isExported() {}\n\n isFromComponent() {}\n\n async getFileIdentifiers(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.getIdentifiers(sourceFile);\n }\n\n async getFileExports(exportDec: ExportDeclaration | ExportAssignment) {\n const identifiers = await this.getFileIdentifiers(exportDec);\n return identifiers.filter((identifier) => ExportIdentifier.isExportIdentifier(identifier));\n }\n\n async getFileInternals(exportDec: ExportDeclaration | ExportAssignment) {\n const identifiers = await this.getFileIdentifiers(exportDec);\n return identifiers.filter((identifier) => !ExportIdentifier.isExportIdentifier(identifier));\n }\n\n getIdentifiers(node: Node) {\n return this.extractor.computeIdentifiers(node, this);\n }\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 async getDefinition(node: Node) {\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\n // when we can't figure out the component/package/type of this node, we'll use the typeStr as the type.\n private async unknownExactType(node: Node, location: Location, typeStr = 'any', isTypeStrFromQuickInfo = true) {\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\n // the reason for this check is to avoid infinite loop when calling `this.jump` with the same file+location\n private isDefInSameLocation(node: Node, definition: protocol.FileSpanWithContext) {\n if (definition.file !== node.getSourceFile().fileName) {\n return false;\n }\n const loc = this.getLocation(node);\n\n return loc.line === definition.start.line && loc.character === definition.start.offset;\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\n // check if internal ref with typeInfo\n const internalRef = await this.getTypeRef(typeStr, this.getIdentifierKeyForNode(node), location);\n\n if (internalRef) return internalRef;\n\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 if (node.type && ts.isTypeNode(node.type)) {\n return this.computeSchema(node.type);\n }\n\n const definition = await this.getDefinition(node);\n if (!definition) {\n return this.unknownExactType(node, location, typeStr, isTypeStrFromQuickInfo);\n }\n\n const file = this.findFileInComponent(definition.file);\n\n if (!file) return this.getTypeRefForExternalPath(typeStr, definition.file, location);\n\n if (this.isDefInSameLocation(node, definition)) {\n return this.unknownExactType(node, location, typeStr, isTypeStrFromQuickInfo);\n }\n\n const definitionNode = await this.definition(definition);\n\n if (!definitionNode) {\n return this.unknownExactType(node, location, typeStr, isTypeStrFromQuickInfo);\n }\n\n const definitionNodeName = definitionNode?.getText();\n\n // check if internal ref with definition info\n const definitionInternalRef = await this.getTypeRef(\n definitionNodeName,\n this.getIdentifierKeyForNode(definitionNode),\n location\n );\n\n if (definitionInternalRef) return definitionInternalRef;\n\n const transformer = this.extractor.getTransformer(definitionNode, this);\n\n if (transformer === undefined) {\n return this.unknownExactType(node, location, typeStr, isTypeStrFromQuickInfo);\n }\n const schemaNode = await this.visit(definitionNode);\n return schemaNode || this.unknownExactType(node, location, typeStr, isTypeStrFromQuickInfo);\n }\n\n private getCompIdByPkgName(pkgName: string): ComponentID | undefined {\n return this.componentDeps.find((dep) => dep.packageName === pkgName)?.componentId;\n }\n\n async getTypeRef(typeStr: string, filePath: string, location: Location): Promise<TypeRefSchema | undefined> {\n const nodeIdentifierKey = this.getIdentifierKey(filePath);\n const mainFileIdentifierKey = this.mainFileIdentifierKey;\n\n const nodeIdentifierList = this.identifiers.get(nodeIdentifierKey);\n const mainIdentifierList = this.identifiers.get(mainFileIdentifierKey);\n\n const nodeIdentifier = new Identifier(typeStr, nodeIdentifierKey);\n const mainIdentifier = new Identifier(typeStr, mainFileIdentifierKey);\n\n const parsedNodeIdentifier = nodeIdentifierList?.find(nodeIdentifier);\n const parsedMainIdentifier = mainIdentifierList?.find(mainIdentifier);\n const isExportedFromMain = parsedMainIdentifier && ExportIdentifier.isExportIdentifier(parsedMainIdentifier);\n\n if (!parsedNodeIdentifier) return undefined;\n\n const internalRef = !isExportedFromMain;\n\n if (internalRef) {\n this.setInternalIdentifiers(filePath, new IdentifierList([parsedNodeIdentifier]));\n }\n\n return this.resolveTypeRef(parsedNodeIdentifier, location, isExportedFromMain);\n }\n\n async resolveTypeRef(\n identifier: Identifier,\n location: Location,\n isExportedFromMain?: boolean\n ): Promise<TypeRefSchema> {\n const sourceFilePath = identifier.sourceFilePath;\n\n if (!sourceFilePath || isExportedFromMain) {\n return new TypeRefSchema(\n location,\n identifier.id,\n undefined,\n undefined,\n !isExportedFromMain ? this.getPathRelativeToComponent(identifier.filePath) : undefined\n );\n }\n\n if (!isRelativeImport(sourceFilePath)) {\n const pkgName = this.parsePackageNameFromPath(sourceFilePath);\n const compIdByPkg = this.getCompIdByPkgName(pkgName);\n\n const compIdByPath = await this.extractor.getComponentIDByPath(sourceFilePath);\n\n if (compIdByPath) {\n return new TypeRefSchema(location, identifier.id, compIdByPath);\n }\n\n if (compIdByPkg) {\n return new TypeRefSchema(location, identifier.id, compIdByPkg);\n }\n\n // package without comp id\n return new TypeRefSchema(location, identifier.id, undefined, pkgName);\n }\n\n const relativeDir = identifier.filePath.substring(0, identifier.filePath.lastIndexOf('/'));\n const absFilePath = resolve(relativeDir, sourceFilePath);\n const compFilePath = this.findFileInComponent(absFilePath);\n if (!compFilePath) {\n // @todo handle this better\n throw new Error(\n `cannot find file in component \\n absolute path: ${absFilePath}\\n source file path ${sourceFilePath}\\n identifier file path ${identifier.filePath} \\n relative dir ${relativeDir}`\n );\n return new TypeRefSchema(location, identifier.id);\n }\n\n const idKey = this.getIdentifierKey(compFilePath?.path);\n\n // if re exported from a file, recurse until definition\n const exportedIdentifier = (this.identifiers.get(idKey)?.identifiers || []).find((i) => i.id === identifier.id);\n\n if (exportedIdentifier) {\n return this.resolveTypeRef(exportedIdentifier, location, isExportedFromMain);\n }\n\n return new TypeRefSchema(location, identifier.id);\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 async jsDocToDocSchema(node: Node): Promise<DocSchema | undefined> {\n if (!canHaveJsDoc(node)) {\n return undefined;\n }\n const jsDocs = getJsDoc(node);\n if (!jsDocs.length) {\n return undefined;\n }\n // not sure how common it is to have multiple JSDocs. never seen it before.\n // regardless, in typescript implementation of methods like `getJSDocDeprecatedTag()`, they use the first one. (`getFirstJSDocTag()`)\n const jsDoc = jsDocs[0];\n const location = this.getLocation(jsDoc);\n const comment = getTextOfJSDocComment(jsDoc.comment);\n const tags = jsDoc.tags ? await pMapSeries(jsDoc.tags, (tag) => tagParser(tag, this, this.formatter)) : undefined;\n return new DocSchema(location, jsDoc.getText(), comment, tags);\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;AAIA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAOA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;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;A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Clause, context) {
101
101
  return schemas;
102
102
  }
103
103
  async function exportSpecifierToSchemaNode(element, context) {
104
- const definitionInfo = await context.definitionInfo(element);
105
- if (!definitionInfo) {
106
- // happens for example when the main index.ts file exports variable from an mdx file.
107
- // tsserver is unable to get the definition node because it doesn't know to parse mdx files.
108
- return new (_semanticsEntities().UnresolvedSchema)(context.getLocation(element.name), element.name.getText());
109
- }
110
- const definitionNode = await context.definition(definitionInfo);
111
- if (!definitionNode) {
112
- return context.resolveType(element, element.name.getText(), false);
113
- }
104
+ try {
105
+ const definitionInfo = await context.definitionInfo(element);
106
+ if (!definitionInfo) {
107
+ // happens for example when the main index.ts file exports variable from an mdx file.
108
+ // tsserver is unable to get the definition node because it doesn't know to parse mdx files.
109
+ return new (_semanticsEntities().UnresolvedSchema)(context.getLocation(element.name), element.name.getText());
110
+ }
111
+ const definitionNode = await context.definition(definitionInfo);
112
+ if (!definitionNode) {
113
+ return await context.resolveType(element, element.name.getText(), false);
114
+ }
114
115
 
115
- // if it is reexported from another export
116
- if (isSameNode(element, definitionNode.parent)) {
117
- // the definition node is the same node as element.name. tsserver wasn't able to find the source for it
118
- // normally, "bit install" should fix it. another option is to open vscode and look for errors.
119
- throw new Error(`error: tsserver is unable to locate the identifier "${element.name.getText()}" at ${context.getLocationAsString(element.name)}.
116
+ // if it is reexported from another export
117
+ if (isSameNode(element, definitionNode.parent)) {
118
+ // the definition node is the same node as element.name. tsserver wasn't able to find the source for it
119
+ // normally, "bit install" should fix it. another option is to open vscode and look for errors.
120
+ throw new Error(`error: tsserver is unable to locate the identifier "${element.name.getText()}" at ${context.getLocationAsString(element.name)}.
120
121
  make sure "bit status" is clean and there are no errors about missing packages/links.
121
122
  also, make sure the tsconfig.json in the root has the "jsx" setting defined.`);
123
+ }
124
+ if (definitionNode.parent.kind === _typescript().SyntaxKind.ExportSpecifier) return exportSpecifierToSchemaNode(definitionNode.parent, context);
125
+ return await context.computeSchema(definitionNode.parent);
126
+ } catch (e) {
127
+ return new (_semanticsEntities().UnresolvedSchema)(context.getLocation(element.name), element.name.getText());
122
128
  }
123
- if (definitionNode.parent.kind === _typescript().SyntaxKind.ExportSpecifier) return exportSpecifierToSchemaNode(definitionNode.parent, context);
124
- return context.computeSchema(definitionNode.parent);
125
129
  }
126
130
  async function namespaceExport(exportClause, exportDec, context) {
127
131
  const namespace = exportClause.name.getText();
@@ -1 +1 @@
1
- {"version":3,"names":["ExportDeclarationTransformer","predicate","node","kind","SyntaxKind","ExportDeclaration","getIdentifiers","exportDec","context","rawSourceFilePath","moduleSpecifier","getText","sourceFilePath","substring","length","exportClause","ts","NamedExports","elements","map","elm","alias","propertyName","name","undefined","id","fileName","getSourceFile","ExportIdentifier","NamespaceExport","getFileExports","transform","specifier","Error","sourceFile","getSourceFileFromNode","UnImplementedSchema","getLocation","computeSchema","schemas","namedExport","ModuleSchema","namespaceExport","isSameNode","nodeA","nodeB","pos","end","Promise","all","element","exportSpecifierToSchemaNode","definitionInfo","UnresolvedSchema","definitionNode","definition","resolveType","parent","getLocationAsString","ExportSpecifier","namespace","filePath","getFilePathByNode","getSourceFileInsideComponent","getTypeRefForExternalPath","result"],"sources":["export-declaration.ts"],"sourcesContent":["import {\n SchemaNode,\n ModuleSchema,\n UnresolvedSchema,\n UnImplementedSchema,\n} from '@teambit/semantics.entities.semantic-schema';\nimport ts, {\n Node,\n SyntaxKind,\n ExportDeclaration as ExportDeclarationNode,\n NamedExports,\n NamespaceExport,\n ExportSpecifier,\n} from 'typescript';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { ExportIdentifier } from '../export-identifier';\n\nexport class ExportDeclarationTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === SyntaxKind.ExportDeclaration;\n }\n\n async getIdentifiers(exportDec: ExportDeclarationNode, context: SchemaExtractorContext) {\n // e.g. `export { button1, button2 } as Composition from './button';\n const rawSourceFilePath = exportDec.moduleSpecifier?.getText();\n\n // strip off quotes ''\n const sourceFilePath = rawSourceFilePath && rawSourceFilePath.substring(1, rawSourceFilePath?.length - 1);\n\n if (exportDec.exportClause?.kind === ts.SyntaxKind.NamedExports) {\n return exportDec.exportClause.elements.map((elm) => {\n const alias = (elm.propertyName && elm.name.getText()) || undefined;\n const id = elm.propertyName?.getText() || elm.name.getText();\n const fileName = elm.getSourceFile().fileName;\n\n return new ExportIdentifier(id, fileName, alias, sourceFilePath);\n });\n }\n\n // e.g. `export * as Composition from './button';\n if (exportDec.exportClause?.kind === ts.SyntaxKind.NamespaceExport) {\n return [\n new ExportIdentifier(\n exportDec.exportClause.name.getText(),\n exportDec.getSourceFile().fileName,\n undefined,\n sourceFilePath\n ),\n ];\n }\n\n if (exportDec.moduleSpecifier) {\n return context.getFileExports(exportDec);\n }\n\n return [];\n }\n\n async transform(exportDec: ExportDeclarationNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n const exportClause = exportDec.exportClause;\n\n // it's export-all, e.g. `export * from './button'`;\n if (!exportClause) {\n const specifier = exportDec.moduleSpecifier;\n if (!specifier) {\n throw new Error(`fatal: no specifier`);\n }\n const sourceFile = await context.getSourceFileFromNode(specifier);\n // export * from 'webpack', export-all from a package\n if (!sourceFile) {\n return new UnImplementedSchema(\n context.getLocation(exportDec),\n exportDec.getText(),\n SyntaxKind[SyntaxKind.ExportDeclaration]\n );\n }\n return context.computeSchema(sourceFile);\n }\n\n // e.g. `export { button1, button2 } as Composition from './button';\n if (exportClause.kind === SyntaxKind.NamedExports) {\n const schemas = await namedExport(exportClause, context);\n return new ModuleSchema(context.getLocation(exportDec), schemas, []);\n }\n // e.g. `export * as Composition from './button';\n if (exportClause.kind === SyntaxKind.NamespaceExport) {\n return namespaceExport(exportClause, exportDec, context);\n }\n\n // should never reach here. exportClause can be either NamespaceExport or NamedExports\n throw new Error(`unrecognized exportClause type`);\n }\n}\n\nfunction isSameNode(nodeA: Node, nodeB: Node): boolean {\n return nodeA.kind === nodeB.kind && nodeA.pos === nodeB.pos && nodeA.end === nodeB.end;\n}\n\nasync function namedExport(exportClause: NamedExports, context: SchemaExtractorContext): Promise<SchemaNode[]> {\n const schemas = await Promise.all(\n exportClause.elements.map(async (element) => {\n return exportSpecifierToSchemaNode(element, context);\n })\n );\n\n return schemas;\n}\n\nasync function exportSpecifierToSchemaNode(element: ExportSpecifier, context: SchemaExtractorContext) {\n const definitionInfo = await context.definitionInfo(element);\n\n if (!definitionInfo) {\n // happens for example when the main index.ts file exports variable from an mdx file.\n // tsserver is unable to get the definition node because it doesn't know to parse mdx files.\n return new UnresolvedSchema(context.getLocation(element.name), element.name.getText());\n }\n\n const definitionNode = await context.definition(definitionInfo);\n\n if (!definitionNode) {\n return context.resolveType(element, element.name.getText(), false);\n }\n\n // if it is reexported from another export\n if (isSameNode(element, definitionNode.parent)) {\n // the definition node is the same node as element.name. tsserver wasn't able to find the source for it\n // normally, \"bit install\" should fix it. another option is to open vscode and look for errors.\n throw new Error(`error: tsserver is unable to locate the identifier \"${element.name.getText()}\" at ${context.getLocationAsString(\n element.name\n )}.\nmake sure \"bit status\" is clean and there are no errors about missing packages/links.\nalso, make sure the tsconfig.json in the root has the \"jsx\" setting defined.`);\n }\n\n if (definitionNode.parent.kind === SyntaxKind.ExportSpecifier)\n return exportSpecifierToSchemaNode(definitionNode.parent as ExportSpecifier, context);\n\n return context.computeSchema(definitionNode.parent);\n}\n\nasync function namespaceExport(\n exportClause: NamespaceExport,\n exportDec: ExportDeclarationNode,\n context: SchemaExtractorContext\n) {\n const namespace = exportClause.name.getText();\n const filePath = await context.getFilePathByNode(exportClause.name);\n if (!filePath) {\n throw new Error(`unable to find the file-path for \"${namespace}\"`);\n }\n const sourceFile = context.getSourceFileInsideComponent(filePath);\n if (!sourceFile) {\n // it's a namespace from another component or an external package.\n return context.getTypeRefForExternalPath(namespace, filePath, context.getLocation(exportDec));\n }\n const result = await context.computeSchema(sourceFile);\n if (!(result instanceof ModuleSchema)) {\n throw new Error(`expect result to be instance of Module`);\n }\n result.namespace = namesp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,KAAK,CAAE,wCAAuC,CAAC;EAC3D;EACAgC,MAAM,CAACL,SAAS,GAAGA,SAAS;EAC5B,OAAOK,MAAM;AACf"}
1
+ {"version":3,"names":["ExportDeclarationTransformer","predicate","node","kind","SyntaxKind","ExportDeclaration","getIdentifiers","exportDec","context","rawSourceFilePath","moduleSpecifier","getText","sourceFilePath","substring","length","exportClause","ts","NamedExports","elements","map","elm","alias","propertyName","name","undefined","id","fileName","getSourceFile","ExportIdentifier","NamespaceExport","getFileExports","transform","specifier","Error","sourceFile","getSourceFileFromNode","UnImplementedSchema","getLocation","computeSchema","schemas","namedExport","ModuleSchema","namespaceExport","isSameNode","nodeA","nodeB","pos","end","Promise","all","element","exportSpecifierToSchemaNode","definitionInfo","UnresolvedSchema","definitionNode","definition","resolveType","parent","getLocationAsString","ExportSpecifier","e","namespace","filePath","getFilePathByNode","getSourceFileInsideComponent","getTypeRefForExternalPath","result"],"sources":["export-declaration.ts"],"sourcesContent":["import {\n SchemaNode,\n ModuleSchema,\n UnresolvedSchema,\n UnImplementedSchema,\n} from '@teambit/semantics.entities.semantic-schema';\nimport ts, {\n Node,\n SyntaxKind,\n ExportDeclaration as ExportDeclarationNode,\n NamedExports,\n NamespaceExport,\n ExportSpecifier,\n} from 'typescript';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { ExportIdentifier } from '../export-identifier';\n\nexport class ExportDeclarationTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === SyntaxKind.ExportDeclaration;\n }\n\n async getIdentifiers(exportDec: ExportDeclarationNode, context: SchemaExtractorContext) {\n // e.g. `export { button1, button2 } as Composition from './button';\n const rawSourceFilePath = exportDec.moduleSpecifier?.getText();\n\n // strip off quotes ''\n const sourceFilePath = rawSourceFilePath && rawSourceFilePath.substring(1, rawSourceFilePath?.length - 1);\n\n if (exportDec.exportClause?.kind === ts.SyntaxKind.NamedExports) {\n return exportDec.exportClause.elements.map((elm) => {\n const alias = (elm.propertyName && elm.name.getText()) || undefined;\n const id = elm.propertyName?.getText() || elm.name.getText();\n const fileName = elm.getSourceFile().fileName;\n\n return new ExportIdentifier(id, fileName, alias, sourceFilePath);\n });\n }\n\n // e.g. `export * as Composition from './button';\n if (exportDec.exportClause?.kind === ts.SyntaxKind.NamespaceExport) {\n return [\n new ExportIdentifier(\n exportDec.exportClause.name.getText(),\n exportDec.getSourceFile().fileName,\n undefined,\n sourceFilePath\n ),\n ];\n }\n\n if (exportDec.moduleSpecifier) {\n return context.getFileExports(exportDec);\n }\n\n return [];\n }\n\n async transform(exportDec: ExportDeclarationNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n const exportClause = exportDec.exportClause;\n\n // it's export-all, e.g. `export * from './button'`;\n if (!exportClause) {\n const specifier = exportDec.moduleSpecifier;\n if (!specifier) {\n throw new Error(`fatal: no specifier`);\n }\n const sourceFile = await context.getSourceFileFromNode(specifier);\n // export * from 'webpack', export-all from a package\n if (!sourceFile) {\n return new UnImplementedSchema(\n context.getLocation(exportDec),\n exportDec.getText(),\n SyntaxKind[SyntaxKind.ExportDeclaration]\n );\n }\n return context.computeSchema(sourceFile);\n }\n\n // e.g. `export { button1, button2 } as Composition from './button';\n if (exportClause.kind === SyntaxKind.NamedExports) {\n const schemas = await namedExport(exportClause, context);\n return new ModuleSchema(context.getLocation(exportDec), schemas, []);\n }\n // e.g. `export * as Composition from './button';\n if (exportClause.kind === SyntaxKind.NamespaceExport) {\n return namespaceExport(exportClause, exportDec, context);\n }\n\n // should never reach here. exportClause can be either NamespaceExport or NamedExports\n throw new Error(`unrecognized exportClause type`);\n }\n}\n\nfunction isSameNode(nodeA: Node, nodeB: Node): boolean {\n return nodeA.kind === nodeB.kind && nodeA.pos === nodeB.pos && nodeA.end === nodeB.end;\n}\n\nasync function namedExport(exportClause: NamedExports, context: SchemaExtractorContext): Promise<SchemaNode[]> {\n const schemas = await Promise.all(\n exportClause.elements.map(async (element) => {\n return exportSpecifierToSchemaNode(element, context);\n })\n );\n\n return schemas;\n}\n\nasync function exportSpecifierToSchemaNode(element: ExportSpecifier, context: SchemaExtractorContext) {\n try {\n const definitionInfo = await context.definitionInfo(element);\n if (!definitionInfo) {\n // happens for example when the main index.ts file exports variable from an mdx file.\n // tsserver is unable to get the definition node because it doesn't know to parse mdx files.\n return new UnresolvedSchema(context.getLocation(element.name), element.name.getText());\n }\n\n const definitionNode = await context.definition(definitionInfo);\n\n if (!definitionNode) {\n return await context.resolveType(element, element.name.getText(), false);\n }\n\n // if it is reexported from another export\n if (isSameNode(element, definitionNode.parent)) {\n // the definition node is the same node as element.name. tsserver wasn't able to find the source for it\n // normally, \"bit install\" should fix it. another option is to open vscode and look for errors.\n throw new Error(`error: tsserver is unable to locate the identifier \"${element.name.getText()}\" at ${context.getLocationAsString(\n element.name\n )}.\nmake sure \"bit status\" is clean and there are no errors about missing packages/links.\nalso, make sure the tsconfig.json in the root has the \"jsx\" setting defined.`);\n }\n\n if (definitionNode.parent.kind === SyntaxKind.ExportSpecifier)\n return exportSpecifierToSchemaNode(definitionNode.parent as ExportSpecifier, context);\n\n return await context.computeSchema(definitionNode.parent);\n } catch (e) {\n return new UnresolvedSchema(context.getLocation(element.name), element.name.getText());\n }\n}\n\nasync function namespaceExport(\n exportClause: NamespaceExport,\n exportDec: ExportDeclarationNode,\n context: SchemaExtractorContext\n) {\n const namespace = exportClause.name.getText();\n const filePath = await context.getFilePathByNode(exportClause.name);\n if (!filePath) {\n throw new Error(`unable to find the file-path for \"${namespace}\"`);\n }\n const sourceFile = context.getSourceFileInsideComponent(filePath);\n if (!sourceFile) {\n // it's a namespace from another component or an external package.\n return context.getTypeRefForExternalPath(namespace, filePath, context.getLocation(exportDec));\n }\n const result = await context.computeSchema(sourceFile);\n if (!(result instanceof ModuleSchema)) {\n throw new Error(`expect result to be instance of Module`);\n }\n result.namespace = namespace;\n return result;\n}\n"],"mappings":";;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAMA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MAAM,GAAG,MAAM1D,OAAO,CAAC8B,aAAa,CAACJ,UAAU,CAAC;EACtD,IAAI,EAAEgC,MAAM,YAAYzB,iCAAY,CAAC,EAAE;IACrC,MAAM,IAAIR,KAAK,CAAE,wCAAuC,CAAC;EAC3D;EACAiC,MAAM,CAACL,SAAS,GAAGA,SAAS;EAC5B,OAAOK,MAAM;AACf"}
@@ -113,7 +113,7 @@ class TypeScriptExtractor {
113
113
  async extract(component, formatter) {
114
114
  const tsserver = await this.getTsServer();
115
115
  const mainFile = component.mainFile;
116
- const compatibleExts = ['.tsx', '.ts', '.jsx', '.js'];
116
+ const compatibleExts = ['.tsx', '.ts'];
117
117
  const internalFiles = component.filesystem.files.filter(file => compatibleExts.includes(file.extname) && file.path !== mainFile.path);
118
118
  const allFiles = [mainFile, ...internalFiles];
119
119
  const context = await this.createContext(tsserver, component, formatter);
@@ -1 +1 @@
1
- {"version":3,"names":["TypeScriptExtractor","constructor","tsconfig","schemaTransformerSlot","tsMain","rootPath","depResolver","workspace","scope","aspectLoader","logger","undefined","parseSourceFile","file","sourceFile","ts","createSourceFile","path","contents","toString","ScriptTarget","Latest","extract","component","formatter","tsserver","getTsServer","mainFile","compatibleExts","internalFiles","filesystem","files","filter","includes","extname","allFiles","context","createContext","pMapSeries","ast","identifiers","computeIdentifiers","cacheKey","getIdentifierKeyForNode","setIdentifiers","IdentifierList","mainAst","moduleSchema","computeSchema","flatExportsRecursively","apiScheme","internals","computeInternalModules","location","getLocation","APISchema","id","compact","Promise","all","internalIdentifiers","entries","map","filePath","find","internalFile","fileAst","dispose","killTsServer","node","transformer","getTransformer","getIdentifiers","warn","TransformerNotFound","componentDeps","getComponentDeps","SchemaExtractorContext","deps","getDependencies","getComponentDependencies","getTsserverClient","initTsserverClient","UnImplementedSchema","getText","SyntaxKind","kind","transform","getComponentIDByPath","coreAspectIds","getCoreAspectIds","matchingCoreAspect","c","getCoreAspectPackageName","resolveComponentId","getComponentIdByPath","transformers","flatten","values","singleTransformer","predicate","from","options","getTsconfig","config","compilerOptions","getAspect","TypescriptAspect","aspectLoaderMain","AspectLoaderAspect","wsPath","createLogger","name"],"sources":["typescript.extractor.ts"],"sourcesContent":["import ts, { Node, SourceFile, SyntaxKind } from 'typescript';\nimport { getTsconfig } from 'get-tsconfig';\nimport { SchemaExtractor } from '@teambit/schema';\nimport { TsserverClient } from '@teambit/ts-server';\nimport type { Workspace } from '@teambit/workspace';\nimport { ComponentDependency, DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { SchemaNode, APISchema, ModuleSchema, UnImplementedSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { Component } from '@teambit/component';\nimport { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';\nimport { EnvContext } from '@teambit/envs';\nimport { Formatter } from '@teambit/formatter';\nimport { Logger } from '@teambit/logger';\nimport AspectLoaderAspect, { AspectLoaderMain, getCoreAspectPackageName } from '@teambit/aspect-loader';\nimport { ScopeMain } from '@teambit/scope';\nimport pMapSeries from 'p-map-series';\nimport { compact, flatten } from 'lodash';\nimport { TypescriptMain, SchemaTransformerSlot } from './typescript.main.runtime';\nimport { TransformerNotFound } from './exceptions';\nimport { SchemaExtractorContext } from './schema-extractor-context';\nimport { Identifier } from './identifier';\nimport { IdentifierList } from './identifier-list';\nimport { ExtractorOptions } from './extractor-options';\nimport { TypescriptAspect } from './typescript.aspect';\n\nexport class TypeScriptExtractor implements SchemaExtractor {\n constructor(\n private tsconfig: any,\n private schemaTransformerSlot: SchemaTransformerSlot,\n private tsMain: TypescriptMain,\n private rootPath: string,\n private depResolver: DependencyResolverMain,\n private workspace: Workspace | undefined,\n private scope: ScopeMain,\n private aspectLoader: AspectLoaderMain,\n private logger: Logger\n ) {}\n\n parseSourceFile(file: AbstractVinyl): SourceFile {\n const sourceFile = ts.createSourceFile(\n file.path,\n file.contents.toString('utf8'),\n ts.ScriptTarget.Latest,\n true\n /** don't pass the scriptKind, it'll be determined automatically by typescript by the filepath */\n );\n // leave this commented out, it's helpful when there are issues with ASTs. consider throwing in this case.\n // console.log(\"sourceFile Errors\", file.path, sourceFile.parseDiagnostics);\n return sourceFile;\n }\n\n /**\n * extract a component schema.\n */\n async extract(component: Component, formatter?: Formatter): Promise<APISchema> {\n const tsserver = await this.getTsServer();\n const mainFile = component.mainFile;\n const compatibleExts = ['.tsx', '.ts', '.jsx', '.js'];\n const internalFiles = component.filesystem.files.filter(\n (file) => compatibleExts.includes(file.extname) && file.path !== mainFile.path\n );\n const allFiles = [mainFile, ...internalFiles];\n\n const context = await this.createContext(tsserver, component, formatter);\n\n await pMapSeries(allFiles, async (file) => {\n const ast = this.parseSourceFile(file);\n const identifiers = await this.computeIdentifiers(ast, context); // compute for every file\n const cacheKey = context.getIdentifierKeyForNode(ast);\n context.setIdentifiers(cacheKey, new IdentifierList(identifiers));\n });\n\n const mainAst = this.parseSourceFile(mainFile);\n const moduleSchema = (await this.computeSchema(mainAst, context)) as ModuleSchema;\n moduleSchema.flatExportsRecursively();\n const apiScheme = moduleSchema;\n const internals = await this.computeInternalModules(context, internalFiles);\n\n const location = context.getLocation(mainAst);\n\n return new APISchema(location, apiScheme, internals, component.id);\n }\n\n async computeInternalModules(context: SchemaExtractorContext, internalFiles: AbstractVinyl[]) {\n const internals = compact(\n await Promise.all(\n [...context.internalIdentifiers.entries()].map(async ([filePath]) => {\n const file = internalFiles.find((internalFile) => internalFile.path === filePath);\n if (!file) return undefined;\n const fileAst = this.parseSourceFile(file);\n const moduleSchema = (await this.computeSchema(fileAst, context)) as ModuleSchema;\n moduleSchema.flatExportsRecursively();\n return moduleSchema;\n })\n )\n );\n return internals;\n }\n\n dispose() {\n if (!this.tsserver) return;\n this.tsserver.killTsServer();\n }\n\n async computeIdentifiers(node: Node, context: SchemaExtractorContext) {\n const transformer = this.getTransformer(node, context);\n let identifiers: Identifier[] = [];\n if (!transformer || !transformer.getIdentifiers) {\n this.logger.warn(new TransformerNotFound(node, context.component, context.getLocation(node)).toString());\n } else {\n identifiers = await transformer.getIdentifiers(node, context);\n }\n return identifiers;\n }\n\n private async createContext(\n tsserver: TsserverClient,\n component: Component,\n formatter?: Formatter\n ): Promise<SchemaExtractorContext> {\n const componentDeps = await this.getComponentDeps(component);\n return new SchemaExtractorContext(tsserver, component, this, componentDeps, formatter);\n }\n\n private async getComponentDeps(component: Component): Promise<ComponentDependency[]> {\n const deps = await this.depResolver.getDependencies(component);\n const componentDeps = deps.getComponentDependencies();\n return componentDeps;\n }\n\n private tsserver: TsserverClient | undefined = undefined;\n\n private async getTsServer() {\n if (!this.tsserver) {\n const tsserver = this.tsMain.getTsserverClient();\n if (tsserver) {\n this.tsserver = tsserver;\n return tsserver;\n }\n\n this.tsserver = await this.tsMain.initTsserverClient(this.rootPath);\n return this.tsserver;\n }\n\n return this.tsserver;\n }\n\n async computeSchema(node: Node, context: SchemaExtractorContext): Promise<SchemaNode> {\n const transformer = this.getTransformer(node, context);\n\n if (!transformer) {\n return new UnImplementedSchema(context.getLocation(node), node.getText(), SyntaxKind[node.kind]);\n }\n return transformer.transform(node, context);\n }\n\n async getComponentIDByPath(file: string) {\n const coreAspectIds = this.aspectLoader.getCoreAspectIds();\n const matchingCoreAspect = coreAspectIds.find((c) => file === getCoreAspectPackageName(c));\n\n if (matchingCoreAspect) {\n return (this.workspace || this.scope).resolveComponentId(matchingCoreAspect);\n }\n\n if (this.workspace) {\n return this.workspace.getComponentIdByPath(file);\n }\n return null;\n }\n\n /**\n * select the correct transformer for a node.\n */\n getTransformer(node: Node, context: SchemaExtractorContext) {\n const transformers = flatten(this.schemaTransformerSlot.values());\n const transformer = transformers.find((singleTransformer) => {\n return singleTransformer.predicate(node);\n });\n if (!transformer) {\n this.logger.warn(new TransformerNotFound(node, context.component, context.getLocation(node)).toString());\n return undefined;\n }\n\n return transformer;\n }\n\n static from(options: ExtractorOptions) {\n return (context: EnvContext) => {\n const tsconfig = getTsconfig(options.tsconfig)?.config || { compilerOptions: options.compilerOptions };\n const tsMain = context.getAspect<TypescriptMain>(TypescriptAspect.id);\n const aspectLoaderMain = context.getAspect<AspectLoaderMain>(AspectLoaderAspect.id);\n\n // When loading the env from a scope you don't have a workspace\n const wsPath = tsMain.workspace?.path || '';\n return new TypeScriptExtractor(\n tsconfig,\n tsMain.schemaTransformerSlot,\n tsMain,\n wsPath,\n tsMain.depResolver,\n tsMain.workspace,\n tsMain.scope,\n aspectLoaderMain,\n context.createLogger(options.name)\n );\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAKA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAMA;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;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAuD;AAAA;AAEhD,MAAMA,mBAAmB,CAA4B;EAC1DC,WAAW,CACDC,QAAa,EACbC,qBAA4C,EAC5CC,MAAsB,EACtBC,QAAgB,EAChBC,WAAmC,EACnCC,SAAgC,EAChCC,KAAgB,EAChBC,YAA8B,EAC9BC,MAAc,EACtB;IAAA,KATQR,QAAa,GAAbA,QAAa;IAAA,KACbC,qBAA4C,GAA5CA,qBAA4C;IAAA,KAC5CC,MAAsB,GAAtBA,MAAsB;IAAA,KACtBC,QAAgB,GAAhBA,QAAgB;IAAA,KAChBC,WAAmC,GAAnCA,WAAmC;IAAA,KACnCC,SAAgC,GAAhCA,SAAgC;IAAA,KAChCC,KAAgB,GAAhBA,KAAgB;IAAA,KAChBC,YAA8B,GAA9BA,YAA8B;IAAA,KAC9BC,MAAc,GAAdA,MAAc;IAAA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CAACU,IAAI,CAAC,CACnC;IACH,CAAC;EACH;AACF;AAAC"}
1
+ {"version":3,"names":["TypeScriptExtractor","constructor","tsconfig","schemaTransformerSlot","tsMain","rootPath","depResolver","workspace","scope","aspectLoader","logger","undefined","parseSourceFile","file","sourceFile","ts","createSourceFile","path","contents","toString","ScriptTarget","Latest","extract","component","formatter","tsserver","getTsServer","mainFile","compatibleExts","internalFiles","filesystem","files","filter","includes","extname","allFiles","context","createContext","pMapSeries","ast","identifiers","computeIdentifiers","cacheKey","getIdentifierKeyForNode","setIdentifiers","IdentifierList","mainAst","moduleSchema","computeSchema","flatExportsRecursively","apiScheme","internals","computeInternalModules","location","getLocation","APISchema","id","compact","Promise","all","internalIdentifiers","entries","map","filePath","find","internalFile","fileAst","dispose","killTsServer","node","transformer","getTransformer","getIdentifiers","warn","TransformerNotFound","componentDeps","getComponentDeps","SchemaExtractorContext","deps","getDependencies","getComponentDependencies","getTsserverClient","initTsserverClient","UnImplementedSchema","getText","SyntaxKind","kind","transform","getComponentIDByPath","coreAspectIds","getCoreAspectIds","matchingCoreAspect","c","getCoreAspectPackageName","resolveComponentId","getComponentIdByPath","transformers","flatten","values","singleTransformer","predicate","from","options","getTsconfig","config","compilerOptions","getAspect","TypescriptAspect","aspectLoaderMain","AspectLoaderAspect","wsPath","createLogger","name"],"sources":["typescript.extractor.ts"],"sourcesContent":["import ts, { Node, SourceFile, SyntaxKind } from 'typescript';\nimport { getTsconfig } from 'get-tsconfig';\nimport { SchemaExtractor } from '@teambit/schema';\nimport { TsserverClient } from '@teambit/ts-server';\nimport type { Workspace } from '@teambit/workspace';\nimport { ComponentDependency, DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { SchemaNode, APISchema, ModuleSchema, UnImplementedSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { Component } from '@teambit/component';\nimport { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';\nimport { EnvContext } from '@teambit/envs';\nimport { Formatter } from '@teambit/formatter';\nimport { Logger } from '@teambit/logger';\nimport AspectLoaderAspect, { AspectLoaderMain, getCoreAspectPackageName } from '@teambit/aspect-loader';\nimport { ScopeMain } from '@teambit/scope';\nimport pMapSeries from 'p-map-series';\nimport { compact, flatten } from 'lodash';\nimport { TypescriptMain, SchemaTransformerSlot } from './typescript.main.runtime';\nimport { TransformerNotFound } from './exceptions';\nimport { SchemaExtractorContext } from './schema-extractor-context';\nimport { Identifier } from './identifier';\nimport { IdentifierList } from './identifier-list';\nimport { ExtractorOptions } from './extractor-options';\nimport { TypescriptAspect } from './typescript.aspect';\n\nexport class TypeScriptExtractor implements SchemaExtractor {\n constructor(\n private tsconfig: any,\n private schemaTransformerSlot: SchemaTransformerSlot,\n private tsMain: TypescriptMain,\n private rootPath: string,\n private depResolver: DependencyResolverMain,\n private workspace: Workspace | undefined,\n private scope: ScopeMain,\n private aspectLoader: AspectLoaderMain,\n private logger: Logger\n ) {}\n\n parseSourceFile(file: AbstractVinyl): SourceFile {\n const sourceFile = ts.createSourceFile(\n file.path,\n file.contents.toString('utf8'),\n ts.ScriptTarget.Latest,\n true\n /** don't pass the scriptKind, it'll be determined automatically by typescript by the filepath */\n );\n // leave this commented out, it's helpful when there are issues with ASTs. consider throwing in this case.\n // console.log(\"sourceFile Errors\", file.path, sourceFile.parseDiagnostics);\n return sourceFile;\n }\n\n /**\n * extract a component schema.\n */\n async extract(component: Component, formatter?: Formatter): Promise<APISchema> {\n const tsserver = await this.getTsServer();\n const mainFile = component.mainFile;\n const compatibleExts = ['.tsx', '.ts'];\n const internalFiles = component.filesystem.files.filter(\n (file) => compatibleExts.includes(file.extname) && file.path !== mainFile.path\n );\n const allFiles = [mainFile, ...internalFiles];\n\n const context = await this.createContext(tsserver, component, formatter);\n\n await pMapSeries(allFiles, async (file) => {\n const ast = this.parseSourceFile(file);\n const identifiers = await this.computeIdentifiers(ast, context); // compute for every file\n const cacheKey = context.getIdentifierKeyForNode(ast);\n context.setIdentifiers(cacheKey, new IdentifierList(identifiers));\n });\n\n const mainAst = this.parseSourceFile(mainFile);\n const moduleSchema = (await this.computeSchema(mainAst, context)) as ModuleSchema;\n moduleSchema.flatExportsRecursively();\n const apiScheme = moduleSchema;\n const internals = await this.computeInternalModules(context, internalFiles);\n\n const location = context.getLocation(mainAst);\n\n return new APISchema(location, apiScheme, internals, component.id);\n }\n\n async computeInternalModules(context: SchemaExtractorContext, internalFiles: AbstractVinyl[]) {\n const internals = compact(\n await Promise.all(\n [...context.internalIdentifiers.entries()].map(async ([filePath]) => {\n const file = internalFiles.find((internalFile) => internalFile.path === filePath);\n if (!file) return undefined;\n const fileAst = this.parseSourceFile(file);\n const moduleSchema = (await this.computeSchema(fileAst, context)) as ModuleSchema;\n moduleSchema.flatExportsRecursively();\n return moduleSchema;\n })\n )\n );\n return internals;\n }\n\n dispose() {\n if (!this.tsserver) return;\n this.tsserver.killTsServer();\n }\n\n async computeIdentifiers(node: Node, context: SchemaExtractorContext) {\n const transformer = this.getTransformer(node, context);\n let identifiers: Identifier[] = [];\n if (!transformer || !transformer.getIdentifiers) {\n this.logger.warn(new TransformerNotFound(node, context.component, context.getLocation(node)).toString());\n } else {\n identifiers = await transformer.getIdentifiers(node, context);\n }\n return identifiers;\n }\n\n private async createContext(\n tsserver: TsserverClient,\n component: Component,\n formatter?: Formatter\n ): Promise<SchemaExtractorContext> {\n const componentDeps = await this.getComponentDeps(component);\n return new SchemaExtractorContext(tsserver, component, this, componentDeps, formatter);\n }\n\n private async getComponentDeps(component: Component): Promise<ComponentDependency[]> {\n const deps = await this.depResolver.getDependencies(component);\n const componentDeps = deps.getComponentDependencies();\n return componentDeps;\n }\n\n private tsserver: TsserverClient | undefined = undefined;\n\n private async getTsServer() {\n if (!this.tsserver) {\n const tsserver = this.tsMain.getTsserverClient();\n if (tsserver) {\n this.tsserver = tsserver;\n return tsserver;\n }\n\n this.tsserver = await this.tsMain.initTsserverClient(this.rootPath);\n return this.tsserver;\n }\n\n return this.tsserver;\n }\n\n async computeSchema(node: Node, context: SchemaExtractorContext): Promise<SchemaNode> {\n const transformer = this.getTransformer(node, context);\n\n if (!transformer) {\n return new UnImplementedSchema(context.getLocation(node), node.getText(), SyntaxKind[node.kind]);\n }\n return transformer.transform(node, context);\n }\n\n async getComponentIDByPath(file: string) {\n const coreAspectIds = this.aspectLoader.getCoreAspectIds();\n const matchingCoreAspect = coreAspectIds.find((c) => file === getCoreAspectPackageName(c));\n\n if (matchingCoreAspect) {\n return (this.workspace || this.scope).resolveComponentId(matchingCoreAspect);\n }\n\n if (this.workspace) {\n return this.workspace.getComponentIdByPath(file);\n }\n return null;\n }\n\n /**\n * select the correct transformer for a node.\n */\n getTransformer(node: Node, context: SchemaExtractorContext) {\n const transformers = flatten(this.schemaTransformerSlot.values());\n const transformer = transformers.find((singleTransformer) => {\n return singleTransformer.predicate(node);\n });\n if (!transformer) {\n this.logger.warn(new TransformerNotFound(node, context.component, context.getLocation(node)).toString());\n return undefined;\n }\n\n return transformer;\n }\n\n static from(options: ExtractorOptions) {\n return (context: EnvContext) => {\n const tsconfig = getTsconfig(options.tsconfig)?.config || { compilerOptions: options.compilerOptions };\n const tsMain = context.getAspect<TypescriptMain>(TypescriptAspect.id);\n const aspectLoaderMain = context.getAspect<AspectLoaderMain>(AspectLoaderAspect.id);\n\n // When loading the env from a scope you don't have a workspace\n const wsPath = tsMain.workspace?.path || '';\n return new TypeScriptExtractor(\n tsconfig,\n tsMain.schemaTransformerSlot,\n tsMain,\n wsPath,\n tsMain.depResolver,\n tsMain.workspace,\n tsMain.scope,\n aspectLoaderMain,\n context.createLogger(options.name)\n );\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAKA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAMA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;E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,EAAE;IACrC,OAAQlE,OAAmB,IAAK;MAAA;MAC9B,MAAMlC,QAAQ,GAAG,qBAAAqG,2BAAW,EAACD,OAAO,CAACpG,QAAQ,CAAC,iDAA7B,aAA+BsG,MAAM,KAAI;QAAEC,eAAe,EAAEH,OAAO,CAACG;MAAgB,CAAC;MACtG,MAAMrG,MAAM,GAAGgC,OAAO,CAACsE,SAAS,CAAiBC,+BAAgB,CAACnD,EAAE,CAAC;MACrE,MAAMoD,gBAAgB,GAAGxE,OAAO,CAACsE,SAAS,CAAmBG,uBAAkB,CAACrD,EAAE,CAAC;;MAEnF;MACA,MAAMsD,MAAM,GAAG,sBAAA1G,MAAM,CAACG,SAAS,sDAAhB,kBAAkBU,IAAI,KAAI,EAAE;MAC3C,OAAO,IAAIjB,mBAAmB,CAC5BE,QAAQ,EACRE,MAAM,CAACD,qBAAqB,EAC5BC,MAAM,EACN0G,MAAM,EACN1G,MAAM,CAACE,WAAW,EAClBF,MAAM,CAACG,SAAS,EAChBH,MAAM,CAACI,KAAK,EACZoG,gBAAgB,EAChBxE,OAAO,CAAC2E,YAAY,CAACT,OAAO,CAACU,IAAI,CAAC,CACnC;IACH,CAAC;EACH;AACF;AAAC"}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/typescript",
3
- "version": "0.0.1076",
3
+ "version": "0.0.1077",
4
4
  "homepage": "https://bit.cloud/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.1076"
9
+ "version": "0.0.1077"
10
10
  },
11
11
  "dependencies": {
12
12
  "get-tsconfig": "4.2.0",
@@ -21,26 +21,26 @@
21
21
  "core-js": "^3.0.0",
22
22
  "@babel/runtime": "7.20.0",
23
23
  "@teambit/harmony": "0.4.6",
24
- "@teambit/compiler": "0.0.1076",
24
+ "@teambit/compiler": "0.0.1077",
25
25
  "@teambit/typescript.modules.ts-config-mutator": "0.0.76",
26
- "@teambit/builder": "0.0.1076",
27
- "@teambit/isolator": "0.0.1076",
28
- "@teambit/component": "0.0.1076",
29
- "@teambit/dependency-resolver": "0.0.1076",
30
- "@teambit/formatter": "0.0.627",
26
+ "@teambit/builder": "0.0.1077",
27
+ "@teambit/isolator": "0.0.1077",
28
+ "@teambit/component": "0.0.1077",
29
+ "@teambit/dependency-resolver": "0.0.1077",
30
+ "@teambit/formatter": "0.0.628",
31
31
  "@teambit/semantics.entities.semantic-schema": "0.0.53",
32
- "@teambit/ts-server": "0.0.46",
33
- "@teambit/aspect-loader": "0.0.1076",
34
- "@teambit/envs": "0.0.1076",
32
+ "@teambit/ts-server": "0.0.47",
33
+ "@teambit/aspect-loader": "0.0.1077",
34
+ "@teambit/envs": "0.0.1077",
35
35
  "@teambit/logger": "0.0.818",
36
- "@teambit/workspace-config-files": "0.0.56",
37
- "@teambit/workspace": "0.0.1076",
36
+ "@teambit/workspace-config-files": "0.0.57",
37
+ "@teambit/workspace": "0.0.1077",
38
38
  "@teambit/bit-error": "0.0.402",
39
- "@teambit/schema": "0.0.1076",
40
- "@teambit/scope": "0.0.1076",
39
+ "@teambit/schema": "0.0.1077",
40
+ "@teambit/scope": "0.0.1077",
41
41
  "@teambit/cli": "0.0.725",
42
- "@teambit/pkg": "0.0.1076",
43
- "@teambit/watcher": "0.0.88"
42
+ "@teambit/pkg": "0.0.1077",
43
+ "@teambit/watcher": "0.0.89"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/lodash": "4.14.165",
@@ -108,35 +108,38 @@ async function namedExport(exportClause: NamedExports, context: SchemaExtractorC
108
108
  }
109
109
 
110
110
  async function exportSpecifierToSchemaNode(element: ExportSpecifier, context: SchemaExtractorContext) {
111
- const definitionInfo = await context.definitionInfo(element);
112
-
113
- if (!definitionInfo) {
114
- // happens for example when the main index.ts file exports variable from an mdx file.
115
- // tsserver is unable to get the definition node because it doesn't know to parse mdx files.
116
- return new UnresolvedSchema(context.getLocation(element.name), element.name.getText());
117
- }
111
+ try {
112
+ const definitionInfo = await context.definitionInfo(element);
113
+ if (!definitionInfo) {
114
+ // happens for example when the main index.ts file exports variable from an mdx file.
115
+ // tsserver is unable to get the definition node because it doesn't know to parse mdx files.
116
+ return new UnresolvedSchema(context.getLocation(element.name), element.name.getText());
117
+ }
118
118
 
119
- const definitionNode = await context.definition(definitionInfo);
119
+ const definitionNode = await context.definition(definitionInfo);
120
120
 
121
- if (!definitionNode) {
122
- return context.resolveType(element, element.name.getText(), false);
123
- }
121
+ if (!definitionNode) {
122
+ return await context.resolveType(element, element.name.getText(), false);
123
+ }
124
124
 
125
- // if it is reexported from another export
126
- if (isSameNode(element, definitionNode.parent)) {
127
- // the definition node is the same node as element.name. tsserver wasn't able to find the source for it
128
- // normally, "bit install" should fix it. another option is to open vscode and look for errors.
129
- throw new Error(`error: tsserver is unable to locate the identifier "${element.name.getText()}" at ${context.getLocationAsString(
130
- element.name
131
- )}.
125
+ // if it is reexported from another export
126
+ if (isSameNode(element, definitionNode.parent)) {
127
+ // the definition node is the same node as element.name. tsserver wasn't able to find the source for it
128
+ // normally, "bit install" should fix it. another option is to open vscode and look for errors.
129
+ throw new Error(`error: tsserver is unable to locate the identifier "${element.name.getText()}" at ${context.getLocationAsString(
130
+ element.name
131
+ )}.
132
132
  make sure "bit status" is clean and there are no errors about missing packages/links.
133
133
  also, make sure the tsconfig.json in the root has the "jsx" setting defined.`);
134
- }
134
+ }
135
135
 
136
- if (definitionNode.parent.kind === SyntaxKind.ExportSpecifier)
137
- return exportSpecifierToSchemaNode(definitionNode.parent as ExportSpecifier, context);
136
+ if (definitionNode.parent.kind === SyntaxKind.ExportSpecifier)
137
+ return exportSpecifierToSchemaNode(definitionNode.parent as ExportSpecifier, context);
138
138
 
139
- return context.computeSchema(definitionNode.parent);
139
+ return await context.computeSchema(definitionNode.parent);
140
+ } catch (e) {
141
+ return new UnresolvedSchema(context.getLocation(element.name), element.name.getText());
142
+ }
140
143
  }
141
144
 
142
145
  async function namespaceExport(