@teambit/typescript 0.0.762 → 0.0.765

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/cmds/check-types.cmd.ts +5 -3
  2. package/dist/cmds/check-types.cmd.d.ts +5 -1
  3. package/dist/cmds/check-types.cmd.js +17 -3
  4. package/dist/cmds/check-types.cmd.js.map +1 -1
  5. package/dist/schema-extractor-context.js +1 -1
  6. package/dist/schema-extractor-context.js.map +1 -1
  7. package/dist/transformers/binding-element.js +12 -1
  8. package/dist/transformers/binding-element.js.map +1 -1
  9. package/dist/transformers/interface-declaration.js +12 -1
  10. package/dist/transformers/interface-declaration.js.map +1 -1
  11. package/dist/transformers/type-alias.js +12 -1
  12. package/dist/transformers/type-alias.js.map +1 -1
  13. package/dist/transformers/utils/class-element-to-schema.js +12 -1
  14. package/dist/transformers/utils/class-element-to-schema.js.map +1 -1
  15. package/dist/transformers/utils/type-element-to-schema.js +12 -1
  16. package/dist/transformers/utils/type-element-to-schema.js.map +1 -1
  17. package/dist/transformers/utils/type-node-to-schema.js +11 -1
  18. package/dist/transformers/utils/type-node-to-schema.js.map +1 -1
  19. package/dist/transformers/variable-declaration.js +2 -2
  20. package/dist/transformers/variable-declaration.js.map +1 -1
  21. package/package-tar/teambit-typescript-0.0.765.tgz +0 -0
  22. package/package.json +16 -16
  23. package/{preview-1655279906398.js → preview-1655522887639.js} +2 -2
  24. package/transformers/binding-element.ts +3 -1
  25. package/transformers/interface-declaration.ts +3 -1
  26. package/transformers/type-alias.ts +3 -1
  27. package/transformers/utils/class-element-to-schema.ts +3 -2
  28. package/transformers/utils/type-element-to-schema.ts +3 -1
  29. package/transformers/utils/type-node-to-schema.ts +12 -1
  30. package/transformers/variable-declaration.ts +2 -2
  31. package/package-tar/teambit-typescript-0.0.762.tgz +0 -0
@@ -3,11 +3,13 @@ import { ConsumerNotFound } from '@teambit/legacy/dist/consumer/exceptions';
3
3
  import { Logger } from '@teambit/logger';
4
4
  import { Workspace } from '@teambit/workspace';
5
5
  import chalk from 'chalk';
6
+ import { COMPONENT_PATTERN_HELP } from '@teambit/legacy/dist/constants';
6
7
  import { TypescriptMain } from '../typescript.main.runtime';
7
8
 
8
9
  export class CheckTypesCmd implements Command {
9
- name = 'check-types [pattern]';
10
+ name = 'check-types [component-pattern]';
10
11
  description = 'check typescript types';
12
+ arguments = [{ name: 'component-pattern', description: COMPONENT_PATTERN_HELP }];
11
13
  alias = '';
12
14
  group = 'development';
13
15
  options = [
@@ -17,9 +19,9 @@ export class CheckTypesCmd implements Command {
17
19
 
18
20
  constructor(private typescript: TypescriptMain, private workspace: Workspace, private logger: Logger) {}
19
21
 
20
- async report([userPattern]: [string], { all = false, strict = false }: { all: boolean; strict: boolean }) {
22
+ async report([pattern]: [string], { all = false, strict = false }: { all: boolean; strict: boolean }) {
21
23
  if (!this.workspace) throw new ConsumerNotFound();
22
- const components = await this.workspace.getComponentsByUserInput(all, userPattern);
24
+ const components = await this.workspace.getComponentsByUserInput(all, pattern);
23
25
  this.logger.setStatusLine(`checking types for ${components.length} components`);
24
26
  const files = this.typescript.getSupportedFilesForTsserver(components);
25
27
  await this.typescript.initTsserverClientFromWorkspace({ printTypeErrors: true }, files);
@@ -8,11 +8,15 @@ export declare class CheckTypesCmd implements Command {
8
8
  private logger;
9
9
  name: string;
10
10
  description: string;
11
+ arguments: {
12
+ name: string;
13
+ description: string;
14
+ }[];
11
15
  alias: string;
12
16
  group: string;
13
17
  options: CommandOptions;
14
18
  constructor(typescript: TypescriptMain, workspace: Workspace, logger: Logger);
15
- report([userPattern]: [string], { all, strict }: {
19
+ report([pattern]: [string], { all, strict }: {
16
20
  all: boolean;
17
21
  strict: boolean;
18
22
  }): Promise<{
@@ -41,24 +41,38 @@ function _chalk() {
41
41
  return data;
42
42
  }
43
43
 
44
+ function _constants() {
45
+ const data = require("@teambit/legacy/dist/constants");
46
+
47
+ _constants = function () {
48
+ return data;
49
+ };
50
+
51
+ return data;
52
+ }
53
+
44
54
  class CheckTypesCmd {
45
55
  constructor(typescript, workspace, logger) {
46
56
  this.typescript = typescript;
47
57
  this.workspace = workspace;
48
58
  this.logger = logger;
49
- (0, _defineProperty2().default)(this, "name", 'check-types [pattern]');
59
+ (0, _defineProperty2().default)(this, "name", 'check-types [component-pattern]');
50
60
  (0, _defineProperty2().default)(this, "description", 'check typescript types');
61
+ (0, _defineProperty2().default)(this, "arguments", [{
62
+ name: 'component-pattern',
63
+ description: _constants().COMPONENT_PATTERN_HELP
64
+ }]);
51
65
  (0, _defineProperty2().default)(this, "alias", '');
52
66
  (0, _defineProperty2().default)(this, "group", 'development');
53
67
  (0, _defineProperty2().default)(this, "options", [['a', 'all', 'check-types for all components, not only modified and new'], ['', 'strict', 'in case issues found, exit with code 1']]);
54
68
  }
55
69
 
56
- async report([userPattern], {
70
+ async report([pattern], {
57
71
  all = false,
58
72
  strict = false
59
73
  }) {
60
74
  if (!this.workspace) throw new (_exceptions().ConsumerNotFound)();
61
- const components = await this.workspace.getComponentsByUserInput(all, userPattern);
75
+ const components = await this.workspace.getComponentsByUserInput(all, pattern);
62
76
  this.logger.setStatusLine(`checking types for ${components.length} components`);
63
77
  const files = this.typescript.getSupportedFilesForTsserver(components);
64
78
  await this.typescript.initTsserverClientFromWorkspace({
@@ -1 +1 @@
1
- {"version":3,"names":["CheckTypesCmd","constructor","typescript","workspace","logger","report","userPattern","all","strict","ConsumerNotFound","components","getComponentsByUserInput","setStatusLine","length","files","getSupportedFilesForTsserver","initTsserverClientFromWorkspace","printTypeErrors","tsserver","getTsserverClient","Error","start","Date","now","getDiagnostic","end","msg","killTsServer","lastDiagnostics","code","data","chalk","red","green"],"sources":["check-types.cmd.ts"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport { ConsumerNotFound } from '@teambit/legacy/dist/consumer/exceptions';\nimport { Logger } from '@teambit/logger';\nimport { Workspace } from '@teambit/workspace';\nimport chalk from 'chalk';\nimport { TypescriptMain } from '../typescript.main.runtime';\n\nexport class CheckTypesCmd implements Command {\n name = 'check-types [pattern]';\n description = 'check typescript types';\n alias = '';\n group = 'development';\n options = [\n ['a', 'all', 'check-types for all components, not only modified and new'],\n ['', 'strict', 'in case issues found, exit with code 1'],\n ] as CommandOptions;\n\n constructor(private typescript: TypescriptMain, private workspace: Workspace, private logger: Logger) {}\n\n async report([userPattern]: [string], { all = false, strict = false }: { all: boolean; strict: boolean }) {\n if (!this.workspace) throw new ConsumerNotFound();\n const components = await this.workspace.getComponentsByUserInput(all, userPattern);\n this.logger.setStatusLine(`checking types for ${components.length} components`);\n const files = this.typescript.getSupportedFilesForTsserver(components);\n await this.typescript.initTsserverClientFromWorkspace({ printTypeErrors: true }, files);\n const tsserver = this.typescript.getTsserverClient();\n if (!tsserver) throw new Error(`unable to start tsserver`);\n const start = Date.now();\n await tsserver.getDiagnostic(files);\n const end = Date.now() - start;\n const msg = `completed type checking (${end / 1000} sec)`;\n tsserver.killTsServer();\n if (tsserver.lastDiagnostics.length) {\n return {\n code: strict ? 1 : 0,\n data: chalk.red(`${msg}. found errors in ${tsserver.lastDiagnostics.length} files.`),\n };\n }\n return {\n code: 0,\n data: chalk.green(`${msg}. no errors were found.`),\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGO,MAAMA,aAAN,CAAuC;EAU5CC,WAAW,CAASC,UAAT,EAA6CC,SAA7C,EAA2EC,MAA3E,EAA2F;IAAA,KAAlFF,UAAkF,GAAlFA,UAAkF;IAAA,KAA9CC,SAA8C,GAA9CA,SAA8C;IAAA,KAAhBC,MAAgB,GAAhBA,MAAgB;IAAA,8CAT/F,uBAS+F;IAAA,qDARxF,wBAQwF;IAAA,+CAP9F,EAO8F;IAAA,+CAN9F,aAM8F;IAAA,iDAL5F,CACR,CAAC,GAAD,EAAM,KAAN,EAAa,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AID;;IACD,OAAO;MACLgB,IAAI,EAAE,CADD;MAELC,IAAI,EAAEC,gBAAA,CAAME,KAAN,CAAa,GAAEP,GAAI,yBAAnB;IAFD,CAAP;EAID;;AAnC2C"}
1
+ {"version":3,"names":["CheckTypesCmd","constructor","typescript","workspace","logger","name","description","COMPONENT_PATTERN_HELP","report","pattern","all","strict","ConsumerNotFound","components","getComponentsByUserInput","setStatusLine","length","files","getSupportedFilesForTsserver","initTsserverClientFromWorkspace","printTypeErrors","tsserver","getTsserverClient","Error","start","Date","now","getDiagnostic","end","msg","killTsServer","lastDiagnostics","code","data","chalk","red","green"],"sources":["check-types.cmd.ts"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport { ConsumerNotFound } from '@teambit/legacy/dist/consumer/exceptions';\nimport { Logger } from '@teambit/logger';\nimport { Workspace } from '@teambit/workspace';\nimport chalk from 'chalk';\nimport { COMPONENT_PATTERN_HELP } from '@teambit/legacy/dist/constants';\nimport { TypescriptMain } from '../typescript.main.runtime';\n\nexport class CheckTypesCmd implements Command {\n name = 'check-types [component-pattern]';\n description = 'check typescript types';\n arguments = [{ name: 'component-pattern', description: COMPONENT_PATTERN_HELP }];\n alias = '';\n group = 'development';\n options = [\n ['a', 'all', 'check-types for all components, not only modified and new'],\n ['', 'strict', 'in case issues found, exit with code 1'],\n ] as CommandOptions;\n\n constructor(private typescript: TypescriptMain, private workspace: Workspace, private logger: Logger) {}\n\n async report([pattern]: [string], { all = false, strict = false }: { all: boolean; strict: boolean }) {\n if (!this.workspace) throw new ConsumerNotFound();\n const components = await this.workspace.getComponentsByUserInput(all, pattern);\n this.logger.setStatusLine(`checking types for ${components.length} components`);\n const files = this.typescript.getSupportedFilesForTsserver(components);\n await this.typescript.initTsserverClientFromWorkspace({ printTypeErrors: true }, files);\n const tsserver = this.typescript.getTsserverClient();\n if (!tsserver) throw new Error(`unable to start tsserver`);\n const start = Date.now();\n await tsserver.getDiagnostic(files);\n const end = Date.now() - start;\n const msg = `completed type checking (${end / 1000} sec)`;\n tsserver.killTsServer();\n if (tsserver.lastDiagnostics.length) {\n return {\n code: strict ? 1 : 0,\n data: chalk.red(`${msg}. found errors in ${tsserver.lastDiagnostics.length} files.`),\n };\n }\n return {\n code: 0,\n data: chalk.green(`${msg}. no errors were found.`),\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGO,MAAMA,aAAN,CAAuC;EAW5CC,WAAW,CAASC,UAAT,EAA6CC,SAA7C,EAA2EC,MAA3E,EAA2F;IAAA,KAAlFF,UAAkF,GAAlFA,UAAkF;IAAA,KAA9CC,SAA8C,GAA9CA,SAA8C;IAAA,KAAhBC,MAAgB,GAAhBA,MAAgB;IAAA,8CAV/F,iCAU+F;IAAA,qDATxF,wBASwF;IAAA,mDAR1F,CAAC;MAAEC,IAAI,EAAE,mBAAR;MAA6BC,WAAW,EAAEC;IAA1C,CAAD,CAQ0F;IAAA,+CAP9F,EAO8F;IAAA,+CAN9F,aAM8F;IAAA,iDAL5F,CACR,CAAC,GAAD,EAAM,KAAN,EAAa,2DAAb,CADQ,EAER,CAAC,EAAD,EAAK,QAAL,EAAe,wCAAf,CAFQ,CAK4F;EAAE;;EAE5F,MAANC,MAAM,CAAC,CAACC,OAAD,CAAD,EAAsB;IAAEC,GAAG,GAAG,KAAR;IAAeC,MAAM,GAAG;EAAxB,CAAtB,EAA0F;IACpG,IAAI,CAAC,KAAKR,SAAV,EAAqB,MAAM,KAAIS,8BAAJ,GAAN;IACrB,MAAMC,UAAU,GAAG,MAAM,KAAKV,SAAL,CAAeW,wBAAf,CAAwCJ,GAAxC,EAA6CD,OAA7C,CAAzB;IACA,KAAKL,MAAL,CAAYW,aAAZ,CAA2B,sBAAqBF,UAAU,CAACG,MAAO,aAAlE;IACA,MAAMC,KAAK,GAAG,KAAKf,UAAL,CAAgBgB,4BAAhB,CAA6CL,UAA7C,CAAd;IACA,MAAM,KAAKX,UAAL,CAAgBiB,+BAAhB,CAAgD;MAAEC,eAAe,EAAE;IAAnB,CAAhD,EAA2EH,KAA3E,CAAN;IACA,MAAMI,QAAQ,GAAG,KAAKnB,UAAL,CAAgBoB,iBAAhB,EAAjB;IACA,IAAI,CAACD,QAAL,EAAe,MAAM,IAAIE,KAAJ,CAAW,0BAAX,CAAN;IACf,MAAMC,KAAK,GAAGC,IAAI,CAACC,GAAL,EAAd;IACA,MAAML,QAAQ,CAACM,aAAT,CAAuBV,KAAvB,CAAN;IACA,MAAMW,GAAG,GAAGH,IAAI,CAACC,GAAL,KAAaF,KAAzB;IACA,MAAMK,GAAG,GAAI,4BAA2BD,GAAG,GAAG,IAAK,OAAnD;IACAP,QAAQ,CAACS,YAAT;;IACA,IAAIT,QAAQ,CAACU,eAAT,CAAyBf,MAA7B,EAAqC;MACnC,OAAO;QACLgB,IAAI,EAAErB,MAAM,GAAG,CAAH,GAAO,CADd;QAELsB,IAAI,EAAEC,gBAAA,CAAMC,GAAN,CAAW,GAAEN,GAAI,qBAAoBR,QAAQ,CAACU,eAAT,CAAyBf,MAAO,SAArE;MAFD,CAAP;IAID;;IACD,OAAO;MACLgB,IAAI,EAAE,CADD;MAELC,IAAI,EAAEC,gBAAA,CAAME,KAAN,CAAa,GAAEP,GAAI,yBAAnB;IAFD,CAAP;EAID;;AApC2C"}
@@ -415,7 +415,7 @@ class SchemaExtractorContext {
415
415
 
416
416
  const info = await this.getQuickInfo(node);
417
417
  const type = (0, _parseTypeFromQuickInfo().parseTypeFromQuickInfo)(info);
418
- return new (_semanticsEntities().InferenceTypeSchema)(location, type);
418
+ return new (_semanticsEntities().InferenceTypeSchema)(location, type, typeStr);
419
419
  };
420
420
 
421
421
  if (!definition) {
@@ -1 +1 @@
1
- {"version":3,"names":["SchemaExtractorContext","constructor","tsserver","component","extractor","componentDeps","undefined","computeSchema","node","getLocation","targetSourceFile","absolutePath","sourceFile","getSourceFile","position","getLineAndCharacterOfPosition","getStart","line","character","filePath","fileName","getPathRelativeToComponent","pathNormalizeToLinux","getLocationAsString","location","basePath","filesystem","files","base","relative","getSignature","getSignatureHelp","getPath","getPosition","offset","getPositionOfLineAndCharacter","getQuickInfo","err","message","Error","getQuickInfoDisplayString","quickInfo","body","displayString","typeDefinition","getTypeDefinition","visitTypeDefinition","findFileInComponent","find","file","path","includes","strings","map","format","endsWith","string","parsePackageNameFromPath","parts","split","length","lastPart","replace","sep","pkgParts","startsWith","pkgName","getSourceFileInsideComponent","parseSourceFile","getSourceFileFromNode","getFilePathByNode","def","getDefinition","firstDef","head","definition","startPosition","start","pos","nodeAtPos","getTokenAtPosition","visitDefinition","visit","parent","references","isExported","isFromComponent","getFileExports","exportDec","specifierPathStr","moduleSpecifier","getText","specifierPath","substring","absPath","resolve","computeExportedIdentifiers","setExports","exports","_exports","getExportedIdentifiers","jump","TransformerNotFound","resolveType","typeStr","isTypeStrFromQuickInfo","TypeRefSchema","type","ts","isTypeNode","typeNodeToSchema","getDef","headTypeDefinition","unknownExactType","InferenceTypeSchema","info","parseTypeFromQuickInfo","isDefInSameLocation","loc","schemaNode","getTypeRefForExternalPath","getCompIdByPkgName","dep","packageName","componentId","compIdByPath","getComponentIDByPath","compIdByPkg"],"sources":["schema-extractor-context.ts"],"sourcesContent":["import { TsserverClient } from '@teambit/ts-server';\nimport ts, { ExportDeclaration, Node, TypeNode } from 'typescript';\nimport { getTokenAtPosition } from 'tsutils';\nimport { head } from 'lodash';\n// @ts-ignore david we should figure fix this.\nimport type { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';\nimport { pathNormalizeToLinux } from '@teambit/legacy/dist/utils';\nimport { resolve, sep, relative } from 'path';\nimport { Component, ComponentID } from '@teambit/component';\nimport { TypeRefSchema, SchemaNode, InferenceTypeSchema, Location } from '@teambit/semantics.entities.semantic-schema';\nimport { ComponentDependency } from '@teambit/dependency-resolver';\nimport { TypeScriptExtractor } from './typescript.extractor';\nimport { ExportList } from './export-list';\nimport { typeNodeToSchema } from './transformers/utils/type-node-to-schema';\nimport { TransformerNotFound } from './exceptions';\nimport { parseTypeFromQuickInfo } from './transformers/utils/parse-type-from-quick-info';\n\nexport class SchemaExtractorContext {\n constructor(\n readonly tsserver: TsserverClient,\n readonly component: Component,\n readonly extractor: TypeScriptExtractor,\n readonly componentDeps: ComponentDependency[]\n ) {}\n\n computeSchema(node: Node) {\n return this.extractor.computeSchema(node, this);\n }\n\n /**\n * returns the location of a node in a source file.\n */\n getLocation(node: Node, targetSourceFile?: ts.SourceFile, absolutePath = false): Location {\n const sourceFile = targetSourceFile || node.getSourceFile();\n const position = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n const line = position.line + 1;\n const character = position.character + 1;\n const filePath = absolutePath ? sourceFile.fileName : this.getPathRelativeToComponent(sourceFile.fileName);\n\n return {\n filePath: pathNormalizeToLinux(filePath),\n line,\n character,\n };\n }\n\n getLocationAsString(node: Node): string {\n const location = this.getLocation(node);\n return `${node.getSourceFile().fileName}, line: ${location.line}, character: ${location.character}`;\n }\n\n getPathRelativeToComponent(filePath: string): string {\n const basePath = this.component.filesystem.files[0].base;\n return relative(basePath, filePath);\n }\n\n /**\n * returns a signature for a node.\n */\n async getSignature(node: Node) {\n return this.tsserver.getSignatureHelp(this.getPath(node), this.getLocation(node));\n }\n\n /**\n * get the position for the tsserver.\n */\n getPosition(sourceFile: ts.SourceFile, line: number, offset: number): number {\n return sourceFile.getPositionOfLineAndCharacter(line - 1, offset - 1);\n }\n\n /**\n * get the path for a source file.\n */\n getPath(node: Node) {\n const sourceFile = node.getSourceFile();\n return sourceFile.fileName;\n }\n\n async getQuickInfo(node: Node) {\n const location = this.getLocation(node);\n try {\n return await this.tsserver.getQuickInfo(this.getPath(node), location);\n } catch (err: any) {\n if (err.message === 'No content available.') {\n throw new Error(\n `unable to get quickinfo data from tsserver at ${this.getPath(node)}, Ln ${location.line}, Col ${\n location.character\n }`\n );\n }\n throw err;\n }\n }\n\n async getQuickInfoDisplayString(node: Node): Promise<string> {\n const quickInfo = await this.getQuickInfo(node);\n return quickInfo?.body?.displayString || '';\n }\n\n /**\n * returns the type definition for a type.\n */\n typeDefinition(node: Node) {\n return this.tsserver.getTypeDefinition(this.getPath(node), this.getLocation(node));\n }\n\n visitTypeDefinition() {}\n\n private findFileInComponent(filePath: string) {\n return this.component.filesystem.files.find((file) => {\n // TODO: fix this line to support further extensions.\n if (file.path.includes(filePath)) {\n const strings = ['ts', 'tsx', 'js', 'jsx'].map((format) => {\n if (filePath.endsWith(format)) return filePath;\n return `${filePath}.${format}`;\n });\n\n return strings.find((string) => string === file.path);\n }\n\n return false;\n });\n }\n\n private parsePackageNameFromPath(path: string) {\n const parts = path.split('node_modules');\n if (parts.length === 1) return '';\n const lastPart = parts[parts.length - 1].replace(sep, '');\n const pkgParts = lastPart.split('/');\n if (lastPart.startsWith('@')) {\n // scoped package\n return `${pkgParts[0]}/${pkgParts[1]}`;\n }\n const pkgName = pkgParts[0];\n if (pkgName === 'typescript') {\n // it's a built-in type, such as \"string\".\n return '';\n }\n return pkgName;\n }\n\n /**\n * return the file if part of the component.\n * otherwise, a reference to the target package and the type name.\n */\n getSourceFileInsideComponent(filePath: string) {\n const file = this.findFileInComponent(filePath);\n if (!file) return undefined;\n return this.extractor.parseSourceFile(file);\n }\n\n async getSourceFileFromNode(node: Node) {\n const filePath = await this.getFilePathByNode(node);\n if (!filePath) {\n return undefined;\n }\n return this.getSourceFileInsideComponent(filePath);\n }\n\n async getFilePathByNode(node: Node) {\n const def = await this.tsserver.getDefinition(this.getPath(node), this.getLocation(node));\n\n const firstDef = head(def.body);\n return firstDef?.file;\n }\n\n /**\n * get a definition for a given node.\n */\n async definition(node: Node): Promise<Node | undefined> {\n const def = await this.tsserver.getDefinition(this.getPath(node), this.getLocation(node));\n\n const firstDef = head(def.body);\n if (!firstDef) {\n return undefined;\n }\n\n const startPosition = firstDef.start;\n const sourceFile = this.getSourceFileInsideComponent(firstDef.file);\n if (!sourceFile) {\n return undefined; // learn how to return a reference to a different component here.\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 definition = await this.definition(node);\n if (!definition) {\n return undefined;\n }\n return this.visit(definition.parent);\n }\n\n async visit(node: Node): Promise<SchemaNode> {\n return this.extractor.computeSchema(node, this);\n }\n\n references() {}\n\n isExported() {}\n\n isFromComponent() {}\n\n async getFileExports(exportDec: ExportDeclaration) {\n const file = exportDec.getSourceFile().fileName;\n const specifierPathStr = exportDec.moduleSpecifier?.getText() || '';\n const specifierPath = specifierPathStr.substring(1, specifierPathStr.length - 1);\n const absPath = resolve(file, '..', specifierPath);\n const sourceFile = this.getSourceFileInsideComponent(absPath);\n if (!sourceFile) return [];\n return this.extractor.computeExportedIdentifiers(sourceFile, this);\n }\n\n _exports: ExportList | undefined = undefined;\n\n setExports(exports: ExportList) {\n this._exports = exports;\n return this;\n }\n\n getExportedIdentifiers(node: Node) {\n return this.extractor.computeExportedIdentifiers(node, this);\n }\n\n async jump(file: AbstractVinyl, start: any): Promise<SchemaNode | undefined> {\n const sourceFile = this.extractor.parseSourceFile(file);\n const pos = this.getPosition(sourceFile, start.line, start.offset);\n const nodeAtPos = getTokenAtPosition(sourceFile, pos);\n if (!nodeAtPos) return undefined;\n\n // this causes some infinite loops. it's helpful for getting more data from types that are not exported.\n // e.g.\n // ```ts\n // class Bar {}\n // export const getBar = () => new Bar();\n // ```\n // if (nodeAtPos.kind === ts.SyntaxKind.Identifier) {\n // // @todo: make sure with Ran that it's fine. Maybe it's better to do: `this.visit(nodeAtPos.parent);`\n // return this.visitDefinition(nodeAtPos);\n // }\n try {\n return await this.visit(nodeAtPos);\n } catch (err) {\n if (err instanceof TransformerNotFound) {\n return undefined;\n }\n throw err;\n }\n }\n\n /**\n * resolve a type by a node and its identifier.\n */\n async resolveType(\n node: Node & { type?: TypeNode },\n typeStr: string,\n isTypeStrFromQuickInfo = true\n ): Promise<SchemaNode> {\n const location = this.getLocation(node);\n if (this._exports?.includes(typeStr)) {\n return new TypeRefSchema(location, typeStr);\n }\n if (node.type && ts.isTypeNode(node.type)) {\n // if a node has \"type\" prop, it has the type data of the node. this normally happens when the code has the type\n // explicitly, e.g. `const str: string` vs implicitly `const str = 'some-string'`, which the node won't have \"type\"\n return typeNodeToSchema(node.type, this);\n }\n /**\n * tsserver has two different calls: \"definition\" and \"typeDefinition\".\n * normally, we need the \"typeDefinition\" to get the type data of a node.\n * sometimes, it has no data, for example when the node is of type TypeReference, and then using \"definition\" is\n * helpful. (couldn't find a rule when to use each one. e.g. \"VariableDeclaration\" sometimes has data only in\n * \"definition\" but it's not clear when/why).\n */\n const getDef = async () => {\n const typeDefinition = await this.typeDefinition(node);\n const headTypeDefinition = head(typeDefinition?.body);\n if (headTypeDefinition) {\n return headTypeDefinition;\n }\n const definition = await this.tsserver.getDefinition(node.getSourceFile().fileName, this.getLocation(node));\n return head(definition?.body);\n };\n const definition = await getDef();\n\n // when we can't figure out the component/package/type of this node, we'll use the typeStr as the type.\n const unknownExactType = async () => {\n if (isTypeStrFromQuickInfo) {\n return new InferenceTypeSchema(location, typeStr || 'any');\n }\n const info = await this.getQuickInfo(node);\n const type = parseTypeFromQuickInfo(info);\n return new InferenceTypeSchema(location, type);\n };\n if (!definition) {\n return unknownExactType();\n }\n\n // the reason for this check is to avoid infinite loop when calling `this.jump` with the same file+location\n const isDefInSameLocation = () => {\n if (definition.file !== node.getSourceFile().fileName) {\n return false;\n }\n const loc = this.getLocation(node);\n return loc.line === definition.start.line && loc.character === definition.start.offset;\n };\n\n const file = this.findFileInComponent(definition.file);\n if (file) {\n if (isDefInSameLocation()) {\n return unknownExactType();\n }\n const schemaNode = await this.jump(file, definition.start);\n return schemaNode || unknownExactType();\n }\n return this.getTypeRefForExternalPath(typeStr, definition.file, location);\n }\n\n private getCompIdByPkgName(pkgName: string): ComponentID | undefined {\n return this.componentDeps.find((dep) => dep.packageName === pkgName)?.componentId;\n }\n\n async getTypeRefForExternalPath(typeStr: string, filePath: string, location: Location): Promise<TypeRefSchema> {\n const compIdByPath = await this.extractor.getComponentIDByPath(filePath);\n if (compIdByPath) {\n return new TypeRefSchema(location, typeStr, compIdByPath);\n }\n const pkgName = this.parsePackageNameFromPath(filePath);\n const compIdByPkg = this.getCompIdByPkgName(pkgName);\n if (compIdByPkg) {\n return new TypeRefSchema(location, typeStr, compIdByPkg);\n }\n return new TypeRefSchema(location, typeStr, undefined, pkgName);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAIA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAAMA,sBAAN,CAA6B;EAClCC,WAAW,CACAC,QADA,EAEAC,SAFA,EAGAC,SAHA,EAIAC,aAJA,EAKT;IAAA,KAJSH,QAIT,GAJSA,QAIT;IAAA,KAHSC,SAGT,GAHSA,SAGT;IAAA,KAFSC,SAET,GAFSA,SAET;IAAA,KADSC,aACT,GADSA,aACT;IAAA,kDAmMiCC,SAnMjC;EAAE;;EAEJC,aAAa,CAACC,IAAD,EAAa;IACxB,OAAO,KAAKJ,SAAL,CAAeG,aAAf,CAA6B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gF;IAC7G,MAAMqG,YAAY,GAAG,MAAM,KAAKzH,SAAL,CAAe0H,oBAAf,CAAoC3G,QAApC,CAA3B;;IACA,IAAI0G,YAAJ,EAAkB;MAChB,OAAO,KAAInB,kCAAJ,EAAkBlF,QAAlB,EAA4BgF,OAA5B,EAAqCqB,YAArC,CAAP;IACD;;IACD,MAAM3D,OAAO,GAAG,KAAKT,wBAAL,CAA8BtC,QAA9B,CAAhB;IACA,MAAM4G,WAAW,GAAG,KAAKN,kBAAL,CAAwBvD,OAAxB,CAApB;;IACA,IAAI6D,WAAJ,EAAiB;MACf,OAAO,KAAIrB,kCAAJ,EAAkBlF,QAAlB,EAA4BgF,OAA5B,EAAqCuB,WAArC,CAAP;IACD;;IACD,OAAO,KAAIrB,kCAAJ,EAAkBlF,QAAlB,EAA4BgF,OAA5B,EAAqClG,SAArC,EAAgD4D,OAAhD,CAAP;EACD;;AAjUiC"}
1
+ {"version":3,"names":["SchemaExtractorContext","constructor","tsserver","component","extractor","componentDeps","undefined","computeSchema","node","getLocation","targetSourceFile","absolutePath","sourceFile","getSourceFile","position","getLineAndCharacterOfPosition","getStart","line","character","filePath","fileName","getPathRelativeToComponent","pathNormalizeToLinux","getLocationAsString","location","basePath","filesystem","files","base","relative","getSignature","getSignatureHelp","getPath","getPosition","offset","getPositionOfLineAndCharacter","getQuickInfo","err","message","Error","getQuickInfoDisplayString","quickInfo","body","displayString","typeDefinition","getTypeDefinition","visitTypeDefinition","findFileInComponent","find","file","path","includes","strings","map","format","endsWith","string","parsePackageNameFromPath","parts","split","length","lastPart","replace","sep","pkgParts","startsWith","pkgName","getSourceFileInsideComponent","parseSourceFile","getSourceFileFromNode","getFilePathByNode","def","getDefinition","firstDef","head","definition","startPosition","start","pos","nodeAtPos","getTokenAtPosition","visitDefinition","visit","parent","references","isExported","isFromComponent","getFileExports","exportDec","specifierPathStr","moduleSpecifier","getText","specifierPath","substring","absPath","resolve","computeExportedIdentifiers","setExports","exports","_exports","getExportedIdentifiers","jump","TransformerNotFound","resolveType","typeStr","isTypeStrFromQuickInfo","TypeRefSchema","type","ts","isTypeNode","typeNodeToSchema","getDef","headTypeDefinition","unknownExactType","InferenceTypeSchema","info","parseTypeFromQuickInfo","isDefInSameLocation","loc","schemaNode","getTypeRefForExternalPath","getCompIdByPkgName","dep","packageName","componentId","compIdByPath","getComponentIDByPath","compIdByPkg"],"sources":["schema-extractor-context.ts"],"sourcesContent":["import { TsserverClient } from '@teambit/ts-server';\nimport ts, { ExportDeclaration, Node, TypeNode } from 'typescript';\nimport { getTokenAtPosition } from 'tsutils';\nimport { head } from 'lodash';\n// @ts-ignore david we should figure fix this.\nimport type { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';\nimport { pathNormalizeToLinux } from '@teambit/legacy/dist/utils';\nimport { resolve, sep, relative } from 'path';\nimport { Component, ComponentID } from '@teambit/component';\nimport { TypeRefSchema, SchemaNode, InferenceTypeSchema, Location } from '@teambit/semantics.entities.semantic-schema';\nimport { ComponentDependency } from '@teambit/dependency-resolver';\nimport { TypeScriptExtractor } from './typescript.extractor';\nimport { ExportList } from './export-list';\nimport { typeNodeToSchema } from './transformers/utils/type-node-to-schema';\nimport { TransformerNotFound } from './exceptions';\nimport { parseTypeFromQuickInfo } from './transformers/utils/parse-type-from-quick-info';\n\nexport class SchemaExtractorContext {\n constructor(\n readonly tsserver: TsserverClient,\n readonly component: Component,\n readonly extractor: TypeScriptExtractor,\n readonly componentDeps: ComponentDependency[]\n ) {}\n\n computeSchema(node: Node) {\n return this.extractor.computeSchema(node, this);\n }\n\n /**\n * returns the location of a node in a source file.\n */\n getLocation(node: Node, targetSourceFile?: ts.SourceFile, absolutePath = false): Location {\n const sourceFile = targetSourceFile || node.getSourceFile();\n const position = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n const line = position.line + 1;\n const character = position.character + 1;\n const filePath = absolutePath ? sourceFile.fileName : this.getPathRelativeToComponent(sourceFile.fileName);\n\n return {\n filePath: pathNormalizeToLinux(filePath),\n line,\n character,\n };\n }\n\n getLocationAsString(node: Node): string {\n const location = this.getLocation(node);\n return `${node.getSourceFile().fileName}, line: ${location.line}, character: ${location.character}`;\n }\n\n getPathRelativeToComponent(filePath: string): string {\n const basePath = this.component.filesystem.files[0].base;\n return relative(basePath, filePath);\n }\n\n /**\n * returns a signature for a node.\n */\n async getSignature(node: Node) {\n return this.tsserver.getSignatureHelp(this.getPath(node), this.getLocation(node));\n }\n\n /**\n * get the position for the tsserver.\n */\n getPosition(sourceFile: ts.SourceFile, line: number, offset: number): number {\n return sourceFile.getPositionOfLineAndCharacter(line - 1, offset - 1);\n }\n\n /**\n * get the path for a source file.\n */\n getPath(node: Node) {\n const sourceFile = node.getSourceFile();\n return sourceFile.fileName;\n }\n\n async getQuickInfo(node: Node) {\n const location = this.getLocation(node);\n try {\n return await this.tsserver.getQuickInfo(this.getPath(node), location);\n } catch (err: any) {\n if (err.message === 'No content available.') {\n throw new Error(\n `unable to get quickinfo data from tsserver at ${this.getPath(node)}, Ln ${location.line}, Col ${\n location.character\n }`\n );\n }\n throw err;\n }\n }\n\n async getQuickInfoDisplayString(node: Node): Promise<string> {\n const quickInfo = await this.getQuickInfo(node);\n return quickInfo?.body?.displayString || '';\n }\n\n /**\n * returns the type definition for a type.\n */\n typeDefinition(node: Node) {\n return this.tsserver.getTypeDefinition(this.getPath(node), this.getLocation(node));\n }\n\n visitTypeDefinition() {}\n\n private findFileInComponent(filePath: string) {\n return this.component.filesystem.files.find((file) => {\n // TODO: fix this line to support further extensions.\n if (file.path.includes(filePath)) {\n const strings = ['ts', 'tsx', 'js', 'jsx'].map((format) => {\n if (filePath.endsWith(format)) return filePath;\n return `${filePath}.${format}`;\n });\n\n return strings.find((string) => string === file.path);\n }\n\n return false;\n });\n }\n\n private parsePackageNameFromPath(path: string) {\n const parts = path.split('node_modules');\n if (parts.length === 1) return '';\n const lastPart = parts[parts.length - 1].replace(sep, '');\n const pkgParts = lastPart.split('/');\n if (lastPart.startsWith('@')) {\n // scoped package\n return `${pkgParts[0]}/${pkgParts[1]}`;\n }\n const pkgName = pkgParts[0];\n if (pkgName === 'typescript') {\n // it's a built-in type, such as \"string\".\n return '';\n }\n return pkgName;\n }\n\n /**\n * return the file if part of the component.\n * otherwise, a reference to the target package and the type name.\n */\n getSourceFileInsideComponent(filePath: string) {\n const file = this.findFileInComponent(filePath);\n if (!file) return undefined;\n return this.extractor.parseSourceFile(file);\n }\n\n async getSourceFileFromNode(node: Node) {\n const filePath = await this.getFilePathByNode(node);\n if (!filePath) {\n return undefined;\n }\n return this.getSourceFileInsideComponent(filePath);\n }\n\n async getFilePathByNode(node: Node) {\n const def = await this.tsserver.getDefinition(this.getPath(node), this.getLocation(node));\n\n const firstDef = head(def.body);\n return firstDef?.file;\n }\n\n /**\n * get a definition for a given node.\n */\n async definition(node: Node): Promise<Node | undefined> {\n const def = await this.tsserver.getDefinition(this.getPath(node), this.getLocation(node));\n\n const firstDef = head(def.body);\n if (!firstDef) {\n return undefined;\n }\n\n const startPosition = firstDef.start;\n const sourceFile = this.getSourceFileInsideComponent(firstDef.file);\n if (!sourceFile) {\n return undefined; // learn how to return a reference to a different component here.\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 definition = await this.definition(node);\n if (!definition) {\n return undefined;\n }\n return this.visit(definition.parent);\n }\n\n async visit(node: Node): Promise<SchemaNode> {\n return this.extractor.computeSchema(node, this);\n }\n\n references() {}\n\n isExported() {}\n\n isFromComponent() {}\n\n async getFileExports(exportDec: ExportDeclaration) {\n const file = exportDec.getSourceFile().fileName;\n const specifierPathStr = exportDec.moduleSpecifier?.getText() || '';\n const specifierPath = specifierPathStr.substring(1, specifierPathStr.length - 1);\n const absPath = resolve(file, '..', specifierPath);\n const sourceFile = this.getSourceFileInsideComponent(absPath);\n if (!sourceFile) return [];\n return this.extractor.computeExportedIdentifiers(sourceFile, this);\n }\n\n _exports: ExportList | undefined = undefined;\n\n setExports(exports: ExportList) {\n this._exports = exports;\n return this;\n }\n\n getExportedIdentifiers(node: Node) {\n return this.extractor.computeExportedIdentifiers(node, this);\n }\n\n async jump(file: AbstractVinyl, start: any): Promise<SchemaNode | undefined> {\n const sourceFile = this.extractor.parseSourceFile(file);\n const pos = this.getPosition(sourceFile, start.line, start.offset);\n const nodeAtPos = getTokenAtPosition(sourceFile, pos);\n if (!nodeAtPos) return undefined;\n\n // this causes some infinite loops. it's helpful for getting more data from types that are not exported.\n // e.g.\n // ```ts\n // class Bar {}\n // export const getBar = () => new Bar();\n // ```\n // if (nodeAtPos.kind === ts.SyntaxKind.Identifier) {\n // // @todo: make sure with Ran that it's fine. Maybe it's better to do: `this.visit(nodeAtPos.parent);`\n // return this.visitDefinition(nodeAtPos);\n // }\n try {\n return await this.visit(nodeAtPos);\n } catch (err) {\n if (err instanceof TransformerNotFound) {\n return undefined;\n }\n throw err;\n }\n }\n\n /**\n * resolve a type by a node and its identifier.\n */\n async resolveType(\n node: Node & { type?: TypeNode },\n typeStr: string,\n isTypeStrFromQuickInfo = true\n ): Promise<SchemaNode> {\n const location = this.getLocation(node);\n if (this._exports?.includes(typeStr)) {\n return new TypeRefSchema(location, typeStr);\n }\n if (node.type && ts.isTypeNode(node.type)) {\n // if a node has \"type\" prop, it has the type data of the node. this normally happens when the code has the type\n // explicitly, e.g. `const str: string` vs implicitly `const str = 'some-string'`, which the node won't have \"type\"\n return typeNodeToSchema(node.type, this);\n }\n /**\n * tsserver has two different calls: \"definition\" and \"typeDefinition\".\n * normally, we need the \"typeDefinition\" to get the type data of a node.\n * sometimes, it has no data, for example when the node is of type TypeReference, and then using \"definition\" is\n * helpful. (couldn't find a rule when to use each one. e.g. \"VariableDeclaration\" sometimes has data only in\n * \"definition\" but it's not clear when/why).\n */\n const getDef = async () => {\n const typeDefinition = await this.typeDefinition(node);\n const headTypeDefinition = head(typeDefinition?.body);\n if (headTypeDefinition) {\n return headTypeDefinition;\n }\n const definition = await this.tsserver.getDefinition(node.getSourceFile().fileName, this.getLocation(node));\n return head(definition?.body);\n };\n const definition = await getDef();\n\n // when we can't figure out the component/package/type of this node, we'll use the typeStr as the type.\n const unknownExactType = async () => {\n if (isTypeStrFromQuickInfo) {\n return new InferenceTypeSchema(location, typeStr || 'any');\n }\n const info = await this.getQuickInfo(node);\n const type = parseTypeFromQuickInfo(info);\n return new InferenceTypeSchema(location, type, typeStr);\n };\n if (!definition) {\n return unknownExactType();\n }\n\n // the reason for this check is to avoid infinite loop when calling `this.jump` with the same file+location\n const isDefInSameLocation = () => {\n if (definition.file !== node.getSourceFile().fileName) {\n return false;\n }\n const loc = this.getLocation(node);\n return loc.line === definition.start.line && loc.character === definition.start.offset;\n };\n\n const file = this.findFileInComponent(definition.file);\n if (file) {\n if (isDefInSameLocation()) {\n return unknownExactType();\n }\n const schemaNode = await this.jump(file, definition.start);\n return schemaNode || unknownExactType();\n }\n return this.getTypeRefForExternalPath(typeStr, definition.file, location);\n }\n\n private getCompIdByPkgName(pkgName: string): ComponentID | undefined {\n return this.componentDeps.find((dep) => dep.packageName === pkgName)?.componentId;\n }\n\n async getTypeRefForExternalPath(typeStr: string, filePath: string, location: Location): Promise<TypeRefSchema> {\n const compIdByPath = await this.extractor.getComponentIDByPath(filePath);\n if (compIdByPath) {\n return new TypeRefSchema(location, typeStr, compIdByPath);\n }\n const pkgName = this.parsePackageNameFromPath(filePath);\n const compIdByPkg = this.getCompIdByPkgName(pkgName);\n if (compIdByPkg) {\n return new TypeRefSchema(location, typeStr, compIdByPkg);\n }\n return new TypeRefSchema(location, typeStr, undefined, pkgName);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;I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parseTypeFromQuickInfo() {
49
49
  return data;
50
50
  }
51
51
 
52
+ function _jsdocToDocSchema() {
53
+ const data = require("./utils/jsdoc-to-doc-schema");
54
+
55
+ _jsdocToDocSchema = function () {
56
+ return data;
57
+ };
58
+
59
+ return data;
60
+ }
61
+
52
62
  /**
53
63
  * for example:
54
64
  *
@@ -73,7 +83,8 @@ class BindingElementTransformer {
73
83
  const displaySig = (info === null || info === void 0 ? void 0 : (_info$body = info.body) === null || _info$body === void 0 ? void 0 : _info$body.displayString) || '';
74
84
  const typeStr = (0, _parseTypeFromQuickInfo().parseTypeFromQuickInfo)(info);
75
85
  const type = await context.resolveType(node, typeStr);
76
- return new (_semanticsEntities().VariableLikeSchema)(context.getLocation(node), name, displaySig, type, false);
86
+ const doc = await (0, _jsdocToDocSchema().jsDocToDocSchema)(node, context);
87
+ return new (_semanticsEntities().VariableLikeSchema)(context.getLocation(node), name, displaySig, type, false, doc);
77
88
  }
78
89
 
79
90
  }
@@ -1 +1 @@
1
- {"version":3,"names":["BindingElementTransformer","predicate","node","kind","ts","SyntaxKind","BindingElement","getIdentifiers","ExportIdentifier","name","getText","getSourceFile","fileName","transform","context","info","getQuickInfo","displaySig","body","displayString","typeStr","parseTypeFromQuickInfo","type","resolveType","VariableLikeSchema","getLocation"],"sources":["binding-element.ts"],"sourcesContent":["import ts, { BindingElement, Node } from 'typescript';\nimport { VariableLikeSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\nimport { parseTypeFromQuickInfo } from './utils/parse-type-from-quick-info';\n\n/**\n * for example:\n *\n * const objBindingElem = { elem1: 1, elem2: 2 };\n * const { elem1 } = objBindingElem;\n * export { elem1 };\n */\nexport class BindingElementTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.BindingElement;\n }\n\n async getIdentifiers(node: BindingElement) {\n return [new ExportIdentifier(node.name.getText(), node.getSourceFile().fileName)];\n }\n\n async transform(node: BindingElement, context: SchemaExtractorContext) {\n const name = node.name.getText();\n const info = await context.getQuickInfo(node.name);\n const displaySig = info?.body?.displayString || '';\n const typeStr = parseTypeFromQuickInfo(info);\n const type = await context.resolveType(node, typeStr);\n return new VariableLikeSchema(context.getLocation(node), name, displaySig, type, false);\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,yBAAN,CAA6D;EAClEC,SAAS,CAACC,IAAD,EAAa;IACpB,OAAOA,IAAI,CAACC,IAAL,KAAcC,qBAAA,CAAGC,UAAH,CAAcC,cAAnC;EACD;;EAEmB,MAAdC,cAAc,CAACL,IAAD,EAAuB;IACzC,OAAO,CAAC,KAAIM,oCAAJ,EAAqBN,IAAI,CAACO,IAAL,CAAUC,OAAV,EAArB,EAA0CR,IAAI,CAACS,aAAL,GAAqBC,QAA/D,CAAD,CAAP;EACD;;EAEc,MAATC,SAAS,CAACX,IAAD,EAAuBY,OAAvB,EAAwD;IAAA;;IACrE,MAAML,IAAI,GAAGP,IAAI,CAACO,IAAL,CAAUC,OAAV,EAAb;IACA,MAAMK,IAAI,GAAG,MAAMD,OAAO,CAACE,YAAR,CAAqBd,IAAI,CAACO,IAA1B,CAAnB;IACA,MAAMQ,UAAU,GAAG,CAAAF,IAAI,SAAJ,IAAAA,IAAI,WAAJ,0BAAAA,IAAI,CAAEG,IAAN,0DAAYC,aAAZ,KAA6B,EAAhD;IACA,MAAMC,OAAO,GAAG,IAAAC,gDAAA,EAAuBN,IAAvB,CAAhB;IACA,MAAMO,IAAI,GAAG,MAAMR,OAAO,CAACS,WAAR,CAAoBrB,IAApB,EAA0BkB,OAA1B,CAAnB;IACA,OAAO,KAAII,uCAAJ,EAAuBV,OAAO,CAACW,WAAR,CAAoBvB,IAApB,CAAvB,EAAkDO,IAAlD,EAAwDQ,UAAxD,EAAoEK,IAApE,EAA0E,KAA1E,CAAP;EACD;;AAhBiE"}
1
+ {"version":3,"names":["BindingElementTransformer","predicate","node","kind","ts","SyntaxKind","BindingElement","getIdentifiers","ExportIdentifier","name","getText","getSourceFile","fileName","transform","context","info","getQuickInfo","displaySig","body","displayString","typeStr","parseTypeFromQuickInfo","type","resolveType","doc","jsDocToDocSchema","VariableLikeSchema","getLocation"],"sources":["binding-element.ts"],"sourcesContent":["import ts, { BindingElement, Node } from 'typescript';\nimport { VariableLikeSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\nimport { parseTypeFromQuickInfo } from './utils/parse-type-from-quick-info';\nimport { jsDocToDocSchema } from './utils/jsdoc-to-doc-schema';\n\n/**\n * for example:\n *\n * const objBindingElem = { elem1: 1, elem2: 2 };\n * const { elem1 } = objBindingElem;\n * export { elem1 };\n */\nexport class BindingElementTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.BindingElement;\n }\n\n async getIdentifiers(node: BindingElement) {\n return [new ExportIdentifier(node.name.getText(), node.getSourceFile().fileName)];\n }\n\n async transform(node: BindingElement, context: SchemaExtractorContext) {\n const name = node.name.getText();\n const info = await context.getQuickInfo(node.name);\n const displaySig = info?.body?.displayString || '';\n const typeStr = parseTypeFromQuickInfo(info);\n const type = await context.resolveType(node, typeStr);\n const doc = await jsDocToDocSchema(node, context);\n return new VariableLikeSchema(context.getLocation(node), name, displaySig, type, false, doc);\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EA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D;;AAjBiE"}
@@ -59,6 +59,16 @@ function _typeElementToSchema() {
59
59
  return data;
60
60
  }
61
61
 
62
+ function _jsdocToDocSchema() {
63
+ const data = require("./utils/jsdoc-to-doc-schema");
64
+
65
+ _jsdocToDocSchema = function () {
66
+ return data;
67
+ };
68
+
69
+ return data;
70
+ }
71
+
62
72
  class InterfaceDeclarationTransformer {
63
73
  predicate(node) {
64
74
  return node.kind === _typescript().SyntaxKind.InterfaceDeclaration;
@@ -70,7 +80,8 @@ class InterfaceDeclarationTransformer {
70
80
 
71
81
  async transform(interfaceDec, context) {
72
82
  const members = await (0, _pMapSeries().default)(interfaceDec.members, member => (0, _typeElementToSchema().typeElementToSchema)(member, context));
73
- return new (_semanticsEntities().InterfaceSchema)(context.getLocation(interfaceDec), interfaceDec.name.getText(), members);
83
+ const doc = await (0, _jsdocToDocSchema().jsDocToDocSchema)(interfaceDec, context);
84
+ return new (_semanticsEntities().InterfaceSchema)(context.getLocation(interfaceDec), interfaceDec.name.getText(), members, doc);
74
85
  }
75
86
 
76
87
  }
@@ -1 +1 @@
1
- {"version":3,"names":["InterfaceDeclarationTransformer","predicate","node","kind","SyntaxKind","InterfaceDeclaration","getIdentifiers","ExportIdentifier","name","getText","getSourceFile","fileName","transform","interfaceDec","context","members","pMapSeries","member","typeElementToSchema","InterfaceSchema","getLocation"],"sources":["interface-declaration.ts"],"sourcesContent":["import { Node, InterfaceDeclaration, SyntaxKind } from 'typescript';\nimport pMapSeries from 'p-map-series';\nimport { InterfaceSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\nimport { typeElementToSchema } from './utils/type-element-to-schema';\n\nexport class InterfaceDeclarationTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === SyntaxKind.InterfaceDeclaration;\n }\n\n async getIdentifiers(node: InterfaceDeclaration): Promise<ExportIdentifier[]> {\n return [new ExportIdentifier(node.name.getText(), node.getSourceFile().fileName)];\n }\n\n async transform(interfaceDec: InterfaceDeclaration, context: SchemaExtractorContext) {\n const members = await pMapSeries(interfaceDec.members, (member) => typeElementToSchema(member, context));\n return new InterfaceSchema(context.getLocation(interfaceDec), interfaceDec.name.getText(), members);\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAAMA,+BAAN,CAAmE;EACxEC,SAAS,CAACC,IAAD,EAAa;IACpB,OAAOA,IAAI,CAACC,IAAL,KAAcC,wBAAA,CAAWC,oBAAhC;EACD;;EAEmB,MAAdC,cAAc,CAACJ,IAAD,EAA0D;IAC5E,OAAO,CAAC,KAAIK,oCAAJ,EAAqBL,IAAI,CAACM,IAAL,CAAUC,OAAV,EAArB,EAA0CP,IAAI,CAACQ,aAAL,GAAqBC,QAA/D,CAAD,CAAP;EACD;;EAEc,MAATC,SAAS,CAACC,YAAD,EAAqCC,OAArC,EAAsE;IACnF,MAAMC,OAAO,GAAG,MAAM,IAAAC,qBAAA,EAAWH,YAAY,CAACE,OAAxB,EAAkCE,MAAD,IAAY,IAAAC,0CAAA,EAAoBD,MAApB,EAA4BH,OAA5B,CAA7C,CAAtB;IACA,OAAO,KAAIK,oCAAJ,EAAoBL,OAAO,CAACM,WAAR,CAAoBP,YAApB,CAApB,EAAuDA,YAAY,CAACL,IAAb,CAAkBC,OAAlB,EAAvD,EAAoFM,OAApF,CAAP;EACD;;AAZuE"}
1
+ {"version":3,"names":["InterfaceDeclarationTransformer","predicate","node","kind","SyntaxKind","InterfaceDeclaration","getIdentifiers","ExportIdentifier","name","getText","getSourceFile","fileName","transform","interfaceDec","context","members","pMapSeries","member","typeElementToSchema","doc","jsDocToDocSchema","InterfaceSchema","getLocation"],"sources":["interface-declaration.ts"],"sourcesContent":["import { Node, InterfaceDeclaration, SyntaxKind } from 'typescript';\nimport pMapSeries from 'p-map-series';\nimport { InterfaceSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\nimport { typeElementToSchema } from './utils/type-element-to-schema';\nimport { jsDocToDocSchema } from './utils/jsdoc-to-doc-schema';\n\nexport class InterfaceDeclarationTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === SyntaxKind.InterfaceDeclaration;\n }\n\n async getIdentifiers(node: InterfaceDeclaration): Promise<ExportIdentifier[]> {\n return [new ExportIdentifier(node.name.getText(), node.getSourceFile().fileName)];\n }\n\n async transform(interfaceDec: InterfaceDeclaration, context: SchemaExtractorContext) {\n const members = await pMapSeries(interfaceDec.members, (member) => typeElementToSchema(member, context));\n const doc = await jsDocToDocSchema(interfaceDec, context);\n return new InterfaceSchema(context.getLocation(interfaceDec), interfaceDec.name.getText(), members, doc);\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAAMA,+BAAN,CAAmE;EACxEC,SAAS,CAACC,IAAD,EAAa;IACpB,OAAOA,IAAI,CAACC,IAAL,KAAcC,wBAAA,CAAWC,oBAAhC;EACD;;EAEmB,MAAdC,cAAc,CAACJ,IAAD,EAA0D;IAC5E,OAAO,CAAC,KAAIK,oCAAJ,EAAqBL,IAAI,CAACM,IAAL,CAAUC,OAAV,EAArB,EAA0CP,IAAI,CAACQ,aAAL,GAAqBC,QAA/D,CAAD,CAAP;EACD;;EAEc,MAATC,SAAS,CAACC,YAAD,EAAqCC,OAArC,EAAsE;IACnF,MAAMC,OAAO,GAAG,MAAM,IAAAC,qBAAA,EAAWH,YAAY,CAACE,OAAxB,EAAkCE,MAAD,IAAY,IAAAC,0CAAA,EAAoBD,MAApB,EAA4BH,OAA5B,CAA7C,CAAtB;IACA,MAAMK,GAAG,GAAG,MAAM,IAAAC,oCAAA,EAAiBP,YAAjB,EAA+BC,OAA/B,CAAlB;IACA,OAAO,KAAIO,oCAAJ,EAAoBP,OAAO,CAACQ,WAAR,CAAoBT,YAApB,CAApB,EAAuDA,YAAY,CAACL,IAAb,CAAkBC,OAAlB,EAAvD,EAAoFM,OAApF,EAA6FI,GAA7F,CAAP;EACD;;AAbuE"}
@@ -49,6 +49,16 @@ function _typeNodeToSchema() {
49
49
  return data;
50
50
  }
51
51
 
52
+ function _jsdocToDocSchema() {
53
+ const data = require("./utils/jsdoc-to-doc-schema");
54
+
55
+ _jsdocToDocSchema = function () {
56
+ return data;
57
+ };
58
+
59
+ return data;
60
+ }
61
+
52
62
  class TypeAliasTransformer {
53
63
  predicate(node) {
54
64
  return node.kind === _typescript().default.SyntaxKind.TypeAliasDeclaration;
@@ -65,7 +75,8 @@ class TypeAliasTransformer {
65
75
  async transform(typeAlias, context) {
66
76
  const type = await (0, _typeNodeToSchema().typeNodeToSchema)(typeAlias.type, context);
67
77
  const displaySig = await context.getQuickInfoDisplayString(typeAlias.name);
68
- return new (_semanticsEntities().TypeSchema)(context.getLocation(typeAlias), this.getName(typeAlias), type, displaySig);
78
+ const doc = await (0, _jsdocToDocSchema().jsDocToDocSchema)(typeAlias, context);
79
+ return new (_semanticsEntities().TypeSchema)(context.getLocation(typeAlias), this.getName(typeAlias), type, displaySig, doc);
69
80
  }
70
81
 
71
82
  }
@@ -1 +1 @@
1
- {"version":3,"names":["TypeAliasTransformer","predicate","node","kind","ts","SyntaxKind","TypeAliasDeclaration","getIdentifiers","ExportIdentifier","name","getText","getSourceFile","fileName","getName","transform","typeAlias","context","type","typeNodeToSchema","displaySig","getQuickInfoDisplayString","TypeSchema","getLocation"],"sources":["type-alias.ts"],"sourcesContent":["import ts, { Node, TypeAliasDeclaration } from 'typescript';\nimport { TypeSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\nimport { typeNodeToSchema } from './utils/type-node-to-schema';\n\nexport class TypeAliasTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.TypeAliasDeclaration;\n }\n\n async getIdentifiers(node: TypeAliasDeclaration) {\n return [new ExportIdentifier(node.name.getText(), node.getSourceFile().fileName)];\n }\n\n private getName(node: TypeAliasDeclaration): string {\n return node.name.getText();\n }\n\n async transform(typeAlias: TypeAliasDeclaration, context: SchemaExtractorContext) {\n const type = await typeNodeToSchema(typeAlias.type, context);\n const displaySig = await context.getQuickInfoDisplayString(typeAlias.name);\n return new TypeSchema(context.getLocation(typeAlias), this.getName(typeAlias), type, displaySig);\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAAMA,oBAAN,CAAwD;EAC7DC,SAAS,CAACC,IAAD,EAAa;IACpB,OAAOA,IAAI,CAACC,IAAL,KAAcC,qBAAA,CAAGC,UAAH,CAAcC,oBAAnC;EACD;;EAEmB,MAAdC,cAAc,CAACL,IAAD,EAA6B;IAC/C,OAAO,CAAC,KAAIM,oCAAJ,EAAqBN,IAAI,CAACO,IAAL,CAAUC,OAAV,EAArB,EAA0CR,IAAI,CAACS,aAAL,GAAqBC,QAA/D,CAAD,CAAP;EACD;;EAEOC,OAAO,CAACX,IAAD,EAAqC;IAClD,OAAOA,IAAI,CAACO,IAAL,CAAUC,OAAV,EAAP;EACD;;EAEc,MAATI,SAAS,CAACC,SAAD,EAAkCC,OAAlC,EAAmE;IAChF,MAAMC,IAAI,GAAG,MAAM,IAAAC,oCAAA,EAAiBH,SAAS,CAACE,IAA3B,EAAiCD,OAAjC,CAAnB;IACA,MAAMG,UAAU,GAAG,MAAMH,OAAO,CAACI,yBAAR,CAAkCL,SAAS,CAACN,IAA5C,CAAzB;IACA,OAAO,KAAIY,+BAAJ,EAAeL,OAAO,CAACM,WAAR,CAAoBP,SAApB,CAAf,EAA+C,KAAKF,OAAL,CAAaE,SAAb,CAA/C,EAAwEE,IAAxE,EAA8EE,UAA9E,CAAP;EACD;;AAjB4D"}
1
+ {"version":3,"names":["TypeAliasTransformer","predicate","node","kind","ts","SyntaxKind","TypeAliasDeclaration","getIdentifiers","ExportIdentifier","name","getText","getSourceFile","fileName","getName","transform","typeAlias","context","type","typeNodeToSchema","displaySig","getQuickInfoDisplayString","doc","jsDocToDocSchema","TypeSchema","getLocation"],"sources":["type-alias.ts"],"sourcesContent":["import ts, { Node, TypeAliasDeclaration } from 'typescript';\nimport { TypeSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\nimport { typeNodeToSchema } from './utils/type-node-to-schema';\nimport { jsDocToDocSchema } from './utils/jsdoc-to-doc-schema';\n\nexport class TypeAliasTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.TypeAliasDeclaration;\n }\n\n async getIdentifiers(node: TypeAliasDeclaration) {\n return [new ExportIdentifier(node.name.getText(), node.getSourceFile().fileName)];\n }\n\n private getName(node: TypeAliasDeclaration): string {\n return node.name.getText();\n }\n\n async transform(typeAlias: TypeAliasDeclaration, context: SchemaExtractorContext) {\n const type = await typeNodeToSchema(typeAlias.type, context);\n const displaySig = await context.getQuickInfoDisplayString(typeAlias.name);\n const doc = await jsDocToDocSchema(typeAlias, context);\n return new TypeSchema(context.getLocation(typeAlias), this.getName(typeAlias), type, displaySig, doc);\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAAMA,oBAAN,CAAwD;EAC7DC,SAAS,CAACC,IAAD,EAAa;IACpB,OAAOA,IAAI,CAACC,IAAL,KAAcC,qBAAA,CAAGC,UAAH,CAAcC,oBAAnC;EACD;;EAEmB,MAAdC,cAAc,CAACL,IAAD,EAA6B;IAC/C,OAAO,CAAC,KAAIM,oCAAJ,EAAqBN,IAAI,CAACO,IAAL,CAAUC,OAAV,EAArB,EAA0CR,IAAI,CAACS,aAAL,GAAqBC,QAA/D,CAAD,CAAP;EACD;;EAEOC,OAAO,CAACX,IAAD,EAAqC;IAClD,OAAOA,IAAI,CAACO,IAAL,CAAUC,OAAV,EAAP;EACD;;EAEc,MAATI,SAAS,CAACC,SAAD,EAAkCC,OAAlC,EAAmE;IAChF,MAAMC,IAAI,GAAG,MAAM,IAAAC,oCAAA,EAAiBH,SAAS,CAACE,IAA3B,EAAiCD,OAAjC,CAAnB;IACA,MAAMG,UAAU,GAAG,MAAMH,OAAO,CAACI,yBAAR,CAAkCL,SAAS,CAACN,IAA5C,CAAzB;IACA,MAAMY,GAAG,GAAG,MAAM,IAAAC,oCAAA,EAAiBP,SAAjB,EAA4BC,OAA5B,CAAlB;IACA,OAAO,KAAIO,+BAAJ,EAAeP,OAAO,CAACQ,WAAR,CAAoBT,SAApB,CAAf,EAA+C,KAAKF,OAAL,CAAaE,SAAb,CAA/C,EAAwEE,IAAxE,EAA8EE,UAA9E,EAA0FE,GAA1F,CAAP;EACD;;AAlB4D"}
@@ -67,6 +67,16 @@ function _toFunctionLikeSchema() {
67
67
  return data;
68
68
  }
69
69
 
70
+ function _jsdocToDocSchema() {
71
+ const data = require("./jsdoc-to-doc-schema");
72
+
73
+ _jsdocToDocSchema = function () {
74
+ return data;
75
+ };
76
+
77
+ return data;
78
+ }
79
+
70
80
  async function classElementToSchema(node, context) {
71
81
  switch (node.kind) {
72
82
  case _typescript().SyntaxKind.Constructor:
@@ -113,7 +123,8 @@ async function propertyDeclaration(node, context) {
113
123
  const typeStr = (0, _parseTypeFromQuickInfo().parseTypeFromQuickInfo)(info);
114
124
  const type = await context.resolveType(node, typeStr);
115
125
  const isOptional = Boolean(node.questionToken);
116
- return new (_semanticsEntities().VariableLikeSchema)(context.getLocation(node), name, displaySig || '', type, isOptional);
126
+ const doc = await (0, _jsdocToDocSchema().jsDocToDocSchema)(node, context);
127
+ return new (_semanticsEntities().VariableLikeSchema)(context.getLocation(node), name, displaySig || '', type, isOptional, doc);
117
128
  }
118
129
 
119
130
  async function methodDeclaration(node, context) {
@@ -1 +1 @@
1
- {"version":3,"names":["classElementToSchema","node","context","kind","SyntaxKind","Constructor","constructor","PropertyDeclaration","propertyDeclaration","MethodDeclaration","methodDeclaration","GetAccessor","getAccessor","SetAccessor","setAccessor","IndexSignature","indexSignature","ClassStaticBlockDeclaration","SemicolonClassElement","Error","args","getParams","parameters","ConstructorSchema","getLocation","name","getText","info","getQuickInfo","displaySig","body","displayString","typeStr","parseTypeFromQuickInfo","type","resolveType","isOptional","Boolean","questionToken","VariableLikeSchema","toFunctionLikeSchema"],"sources":["class-element-to-schema.ts"],"sourcesContent":["import {\n ClassElement,\n ConstructorDeclaration,\n GetAccessorDeclaration,\n IndexSignatureDeclaration,\n MethodDeclaration,\n PropertyDeclaration,\n SetAccessorDeclaration,\n SyntaxKind,\n} from 'typescript';\nimport { ConstructorSchema, SchemaNode, VariableLikeSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaExtractorContext } from '../../schema-extractor-context';\nimport { getParams } from './get-params';\nimport { getAccessor, indexSignature, setAccessor } from './type-element-to-schema';\nimport { parseTypeFromQuickInfo } from './parse-type-from-quick-info';\nimport { toFunctionLikeSchema } from './to-function-like-schema';\n\nexport async function classElementToSchema(\n node: ClassElement,\n context: SchemaExtractorContext\n): Promise<SchemaNode | null> {\n switch (node.kind) {\n case SyntaxKind.Constructor:\n return constructor(node as ConstructorDeclaration, context);\n case SyntaxKind.PropertyDeclaration:\n return propertyDeclaration(node as PropertyDeclaration, context);\n case SyntaxKind.MethodDeclaration:\n return methodDeclaration(node as MethodDeclaration, context);\n case SyntaxKind.GetAccessor:\n return getAccessor(node as GetAccessorDeclaration, context);\n case SyntaxKind.SetAccessor:\n return setAccessor(node as SetAccessorDeclaration, context);\n case SyntaxKind.IndexSignature:\n return indexSignature(node as IndexSignatureDeclaration, context);\n case SyntaxKind.ClassStaticBlockDeclaration: // not sure what is it, but the name sounds like not something we need\n case SyntaxKind.SemicolonClassElement: // seems to be just a semicolon\n return null;\n default:\n // should never be here unless typescript added new class elements\n throw new Error(`unrecognized ClassElement type. got ${node.kind}`);\n }\n}\n\nasync function constructor(node: ConstructorDeclaration, context: SchemaExtractorContext) {\n const args = await getParams(node.parameters, context);\n return new ConstructorSchema(context.getLocation(node), args);\n}\n\nasync function propertyDeclaration(node: PropertyDeclaration, context: SchemaExtractorContext) {\n const name = node.name.getText();\n const info = await context.getQuickInfo(node.name);\n const displaySig = info?.body?.displayString;\n const typeStr = parseTypeFromQuickInfo(info);\n const type = await context.resolveType(node, typeStr);\n const isOptional = Boolean(node.questionToken);\n\n return new VariableLikeSchema(context.getLocation(node), name, displaySig || '', type, isOptional);\n}\n\nasync function methodDeclaration(node: MethodDeclaration, context: SchemaExtractorCont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ACxF,MAAMkB,IAAI,GAAG,MAAM,IAAAC,sBAAA,EAAUpB,IAAI,CAACqB,UAAf,EAA2BpB,OAA3B,CAAnB;EACA,OAAO,KAAIqB,sCAAJ,EAAsBrB,OAAO,CAACsB,WAAR,CAAoBvB,IAApB,CAAtB,EAAiDmB,IAAjD,CAAP;AACD;;AAED,eAAeZ,mBAAf,CAAmCP,IAAnC,EAA8DC,OAA9D,EAA+F;EAAA;;EAC7F,MAAMuB,IAAI,GAAGxB,IAAI,CAACwB,IAAL,CAAUC,OAAV,EAAb;EACA,MAAMC,IAAI,GAAG,MAAMzB,OAAO,CAAC0B,YAAR,CAAqB3B,IAAI,CAACwB,IAA1B,CAAnB;EACA,MAAMI,UAAU,GAAGF,IAAH,aAAGA,IAAH,qCAAGA,IAAI,CAAEG,IAAT,+CAAG,WAAYC,aAA/B;EACA,MAAMC,OAAO,GAAG,IAAAC,gDAAA,EAAuBN,IAAvB,CAAhB;EACA,MAAMO,IAAI,GAAG,MAAMhC,OAAO,CAACiC,WAAR,CAAoBlC,IAApB,EAA0B+B,OAA1B,CAAnB;EACA,MAAMI,UAAU,GAAGC,OAAO,CAACpC,IAAI,CAACqC,aAAN,CAA1B;EAEA,OAAO,KAAIC,uCAAJ,EAAuBrC,OAAO,CAACsB,WAAR,CAAoBvB,IAApB,CAAvB,EAAkDwB,IAAlD,EAAwDI,UAAU,IAAI,EAAtE,EAA0EK,IAA1E,EAAgFE,UAAhF,CAAP;AACD;;AAED,eAAe1B,iBAAf,CAAiCT,IAAjC,EAA0DC,OAA1D,EAA2F;EACzF,OAAO,IAAAsC,4CAAA,EAAqBvC,IAArB,EAA2BC,OAA3B,CAAP;AACD"}
1
+ {"version":3,"names":["classElementToSchema","node","context","kind","SyntaxKind","Constructor","constructor","PropertyDeclaration","propertyDeclaration","MethodDeclaration","methodDeclaration","GetAccessor","getAccessor","SetAccessor","setAccessor","IndexSignature","indexSignature","ClassStaticBlockDeclaration","SemicolonClassElement","Error","args","getParams","parameters","ConstructorSchema","getLocation","name","getText","info","getQuickInfo","displaySig","body","displayString","typeStr","parseTypeFromQuickInfo","type","resolveType","isOptional","Boolean","questionToken","doc","jsDocToDocSchema","VariableLikeSchema","toFunctionLikeSchema"],"sources":["class-element-to-schema.ts"],"sourcesContent":["import {\n ClassElement,\n ConstructorDeclaration,\n GetAccessorDeclaration,\n IndexSignatureDeclaration,\n MethodDeclaration,\n PropertyDeclaration,\n SetAccessorDeclaration,\n SyntaxKind,\n} from 'typescript';\nimport { ConstructorSchema, SchemaNode, VariableLikeSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaExtractorContext } from '../../schema-extractor-context';\nimport { getParams } from './get-params';\nimport { getAccessor, indexSignature, setAccessor } from './type-element-to-schema';\nimport { parseTypeFromQuickInfo } from './parse-type-from-quick-info';\nimport { toFunctionLikeSchema } from './to-function-like-schema';\nimport { jsDocToDocSchema } from './jsdoc-to-doc-schema';\n\nexport async function classElementToSchema(\n node: ClassElement,\n context: SchemaExtractorContext\n): Promise<SchemaNode | null> {\n switch (node.kind) {\n case SyntaxKind.Constructor:\n return constructor(node as ConstructorDeclaration, context);\n case SyntaxKind.PropertyDeclaration:\n return propertyDeclaration(node as PropertyDeclaration, context);\n case SyntaxKind.MethodDeclaration:\n return methodDeclaration(node as MethodDeclaration, context);\n case SyntaxKind.GetAccessor:\n return getAccessor(node as GetAccessorDeclaration, context);\n case SyntaxKind.SetAccessor:\n return setAccessor(node as SetAccessorDeclaration, context);\n case SyntaxKind.IndexSignature:\n return indexSignature(node as IndexSignatureDeclaration, context);\n case SyntaxKind.ClassStaticBlockDeclaration: // not sure what is it, but the name sounds like not something we need\n case SyntaxKind.SemicolonClassElement: // seems to be just a semicolon\n return null;\n default:\n // should never be here unless typescript added new class elements\n throw new Error(`unrecognized ClassElement type. got ${node.kind}`);\n }\n}\n\nasync function constructor(node: ConstructorDeclaration, context: SchemaExtractorContext) {\n const args = await getParams(node.parameters, context);\n return new ConstructorSchema(context.getLocation(node), args);\n}\n\nasync function propertyDeclaration(node: PropertyDeclaration, context: SchemaExtractorContext) {\n const name = node.name.getText();\n const info = await context.getQuickInfo(node.name);\n const displaySig = info?.body?.displayString;\n const typeStr = parseTypeFromQuickInfo(info);\n const type = await context.resolveType(node, typeStr);\n const isOptional = Boolean(node.questionToken);\n const doc = await jsDocToDocSchema(node, context);\n return new VariableLikeSchema(context.getLocation(node), name, displaySig || '', type, isOptional, doc);\n}\n\nasync function methodDeclaration(node: MethodDeclaration, context: SchemaExtractorContext) {\n return toFunctionLikeSchema(node, context);\n}\n"],"mappings":";;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAUA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,eAAeA,oBAAf,CACLC,IADK,EAELC,OAFK,EAGuB;EAC5B,QAAQD,IAAI,CAACE,IAAb;IACE,KAAKC,wBAAA,CAAWC,WAAhB;MACE,OAAOC,WAAW,CAACL,IAAD,EAAiCC,OAAjC,CAAlB;;IACF,KAAKE,wBAAA,CAAWG,mBAAhB;MACE,OAAOC,mBAAmB,CAACP,IAAD,EAA8BC,OAA9B,CAA1B;;IACF,KAAKE,wBAAA,CAAWK,iBAAhB;MACE,OAAOC,iBAAiB,CAACT,IAAD,EAA4BC,OAA5B,CAAxB;;IACF,KAAKE,wBAAA,CAAWO,WAAhB;MACE,OAAO,IAAAC,kCAAA,EAAYX,IAAZ,EAA4CC,OAA5C,CAAP;;IACF,KAAKE,wBAAA,CAAWS,WAAhB;MACE,OAAO,IAAAC,kCAAA,EAAYb,IAAZ,EAA4CC,OAA5C,CAAP;;IAC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AACsB,WAAR,CAAoBvB,IAApB,CAAvB,EAAkDwB,IAAlD,EAAwDI,UAAU,IAAI,EAAtE,EAA0EK,IAA1E,EAAgFE,UAAhF,EAA4FG,GAA5F,CAAP;AACD;;AAED,eAAe7B,iBAAf,CAAiCT,IAAjC,EAA0DC,OAA1D,EAA2F;EACzF,OAAO,IAAAwC,4CAAA,EAAqBzC,IAArB,EAA2BC,OAA3B,CAAP;AACD"}
@@ -70,6 +70,16 @@ function _getParams() {
70
70
  return data;
71
71
  }
72
72
 
73
+ function _jsdocToDocSchema() {
74
+ const data = require("./jsdoc-to-doc-schema");
75
+
76
+ _jsdocToDocSchema = function () {
77
+ return data;
78
+ };
79
+
80
+ return data;
81
+ }
82
+
73
83
  async function typeElementToSchema(node, context) {
74
84
  switch (node.kind) {
75
85
  case _typescript().SyntaxKind.MethodSignature:
@@ -107,7 +117,8 @@ async function propertySignature(node, context) {
107
117
  const typeStr = (0, _parseTypeFromQuickInfo().parseTypeFromQuickInfo)(info);
108
118
  const type = await context.resolveType(node, typeStr);
109
119
  const isOptional = Boolean(node.questionToken);
110
- return new (_semanticsEntities().VariableLikeSchema)(context.getLocation(node), name, displaySig, type, isOptional);
120
+ const doc = await (0, _jsdocToDocSchema().jsDocToDocSchema)(node, context);
121
+ return new (_semanticsEntities().VariableLikeSchema)(context.getLocation(node), name, displaySig, type, isOptional, doc);
111
122
  }
112
123
 
113
124
  async function indexSignature(node, context) {
@@ -1 +1 @@
1
- {"version":3,"names":["typeElementToSchema","node","context","kind","SyntaxKind","MethodSignature","toFunctionLikeSchema","ConstructSignature","CallSignature","callSignature","PropertySignature","propertySignature","IndexSignature","indexSignature","GetAccessor","getAccessor","SetAccessor","setAccessor","Error","name","getText","info","isComputedPropertyName","undefined","getQuickInfo","displaySig","body","displayString","typeStr","parseTypeFromQuickInfo","type","resolveType","isOptional","Boolean","questionToken","VariableLikeSchema","getLocation","params","getParams","parameters","typeNodeToSchema","IndexSignatureSchema","GetAccessorSchema","getQuickInfoDisplayString","SetAccessorSchema"],"sources":["type-element-to-schema.ts"],"sourcesContent":["import ts, {\n SyntaxKind,\n TypeElement,\n MethodSignature,\n isComputedPropertyName,\n IndexSignatureDeclaration,\n GetAccessorDeclaration,\n SetAccessorDeclaration,\n ConstructSignatureDeclaration,\n CallSignatureDeclaration,\n} from 'typescript';\nimport {\n GetAccessorSchema,\n IndexSignatureSchema,\n SchemaNode,\n SetAccessorSchema,\n VariableLikeSchema,\n} from '@teambit/semantics.entities.semantic-schema';\nimport { toFunctionLikeSchema } from './to-function-like-schema';\nimport { SchemaExtractorContext } from '../../schema-extractor-context';\nimport { parseTypeFromQuickInfo } from './parse-type-from-quick-info';\nimport { typeNodeToSchema } from './type-node-to-schema';\nimport { getParams } from './get-params';\n\nexport async function typeElementToSchema(node: TypeElement, context: SchemaExtractorContext): Promise<SchemaNode> {\n switch (node.kind) {\n case SyntaxKind.MethodSignature:\n return toFunctionLikeSchema(node as MethodSignature, context);\n case SyntaxKind.ConstructSignature:\n return toFunctionLikeSchema(node as ConstructSignatureDeclaration, context, 'new');\n case SyntaxKind.CallSignature:\n return callSignature(node as CallSignatureDeclaration, context);\n case SyntaxKind.PropertySignature:\n return propertySignature(node as ts.PropertySignature, context);\n case SyntaxKind.IndexSignature:\n return indexSignature(node as IndexSignatureDeclaration, context);\n case SyntaxKind.GetAccessor:\n return getAccessor(node as GetAccessorDeclaration, context);\n case SyntaxKind.SetAccessor:\n return setAccessor(node as SetAccessorDeclaration, context);\n default:\n throw new Error(`typeElementToSchema expect type-element node. got ${node.kind}`);\n }\n}\n\nasync function propertySignature(node: ts.PropertySignature, context: SchemaExtractorContext) {\n const name = node.name.getText();\n const info = isComputedPropertyName(node.name) ? undefined : await context.getQuickInfo(node.name);\n const displaySig = info?.body?.displayString || '';\n const typeStr = parseTypeFromQuickInfo(info);\n const type = await context.resolveType(node, typeStr);\n const isOptional = Boolean(node.questionToken);\n return new VariableLikeSchema(context.getLocation(node), name, displaySig, type, isOptional);\n}\n\nexport async function indexSignature(node: IndexSignatureDeclaration, context: SchemaExtractorContext) {\n const params = await getParams(node.parameters, context);\n const type = await typeNodeToSchema(node.type, context);\n return new IndexSignatureSchema(context.getLocation(node), params, type);\n}\n\nexport async function getAccessor(node: GetAccessorDeclaration, context: SchemaExtractorContext) {\n const info = await context.getQuickInfo(node.name);\n const displaySig = info?.body?.displayString || '';\n const typeStr = parseTypeFromQuickInfo(info);\n const type = await context.resolveType(node, typeStr);\n return new GetAccessorSchema(context.getLocation(node), node.name.getText(), type, displaySig);\n}\n\nexport async function setAccessor(node: SetAccessorDeclaration, context: SchemaExtractorContext) {\n const params = await getParams(node.parameters, context);\n const displaySig = await context.getQuickInfoDisplayString(node.name);\n return new SetAccessorSchema(context.getLocation(node), node.name.getText(), params[0], displaySig);\n}\n\nasync function callSignature(node: CallSignatureDeclaration, context: SchemaExtractorContext) {\n return toFunctionLikeSchema(node, context);\n}\n"],"mappings":";;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAWA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAOA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,eAAeA,mBAAf,CAAmCC,IAAnC,EAAsDC,OAAtD,EAA4G;EACjH,QAAQD,IAAI,CAACE,IAAb;IACE,KAAKC,wBAAA,CAAWC,eAAhB;MACE,OAAO,IAAAC,4CAAA,EAAqBL,IAArB,EAA8CC,OAA9C,CAAP;;IACF,KAAKE,wBAAA,CAAWG,kBAAhB;MACE,OAAO,IAAAD,4CAAA,EAAqBL,IAArB,EAA4DC,OAA5D,EAAqE,KAArE,CAAP;;IACF,KAAKE,wBAAA,CAAWI,aAAhB;MACE,OAAOC,aAAa,CAACR,IAAD,EAAm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AAI,CAACkB,IAAvC,CAAzB;EACA,OAAO,KAAIyB,sCAAJ,EAAsB1C,OAAO,CAACkC,WAAR,CAAoBnC,IAApB,CAAtB,EAAiDA,IAAI,CAACkB,IAAL,CAAUC,OAAV,EAAjD,EAAsEiB,MAAM,CAAC,CAAD,CAA5E,EAAiFZ,UAAjF,CAAP;AACD;;AAED,eAAehB,aAAf,CAA6BR,IAA7B,EAA6DC,OAA7D,EAA8F;EAC5F,OAAO,IAAAI,4CAAA,EAAqBL,IAArB,EAA2BC,OAA3B,CAAP;AACD"}
1
+ {"version":3,"names":["typeElementToSchema","node","context","kind","SyntaxKind","MethodSignature","toFunctionLikeSchema","ConstructSignature","CallSignature","callSignature","PropertySignature","propertySignature","IndexSignature","indexSignature","GetAccessor","getAccessor","SetAccessor","setAccessor","Error","name","getText","info","isComputedPropertyName","undefined","getQuickInfo","displaySig","body","displayString","typeStr","parseTypeFromQuickInfo","type","resolveType","isOptional","Boolean","questionToken","doc","jsDocToDocSchema","VariableLikeSchema","getLocation","params","getParams","parameters","typeNodeToSchema","IndexSignatureSchema","GetAccessorSchema","getQuickInfoDisplayString","SetAccessorSchema"],"sources":["type-element-to-schema.ts"],"sourcesContent":["import ts, {\n SyntaxKind,\n TypeElement,\n MethodSignature,\n isComputedPropertyName,\n IndexSignatureDeclaration,\n GetAccessorDeclaration,\n SetAccessorDeclaration,\n ConstructSignatureDeclaration,\n CallSignatureDeclaration,\n} from 'typescript';\nimport {\n GetAccessorSchema,\n IndexSignatureSchema,\n SchemaNode,\n SetAccessorSchema,\n VariableLikeSchema,\n} from '@teambit/semantics.entities.semantic-schema';\nimport { toFunctionLikeSchema } from './to-function-like-schema';\nimport { SchemaExtractorContext } from '../../schema-extractor-context';\nimport { parseTypeFromQuickInfo } from './parse-type-from-quick-info';\nimport { typeNodeToSchema } from './type-node-to-schema';\nimport { getParams } from './get-params';\nimport { jsDocToDocSchema } from './jsdoc-to-doc-schema';\n\nexport async function typeElementToSchema(node: TypeElement, context: SchemaExtractorContext): Promise<SchemaNode> {\n switch (node.kind) {\n case SyntaxKind.MethodSignature:\n return toFunctionLikeSchema(node as MethodSignature, context);\n case SyntaxKind.ConstructSignature:\n return toFunctionLikeSchema(node as ConstructSignatureDeclaration, context, 'new');\n case SyntaxKind.CallSignature:\n return callSignature(node as CallSignatureDeclaration, context);\n case SyntaxKind.PropertySignature:\n return propertySignature(node as ts.PropertySignature, context);\n case SyntaxKind.IndexSignature:\n return indexSignature(node as IndexSignatureDeclaration, context);\n case SyntaxKind.GetAccessor:\n return getAccessor(node as GetAccessorDeclaration, context);\n case SyntaxKind.SetAccessor:\n return setAccessor(node as SetAccessorDeclaration, context);\n default:\n throw new Error(`typeElementToSchema expect type-element node. got ${node.kind}`);\n }\n}\n\nasync function propertySignature(node: ts.PropertySignature, context: SchemaExtractorContext) {\n const name = node.name.getText();\n const info = isComputedPropertyName(node.name) ? undefined : await context.getQuickInfo(node.name);\n const displaySig = info?.body?.displayString || '';\n const typeStr = parseTypeFromQuickInfo(info);\n const type = await context.resolveType(node, typeStr);\n const isOptional = Boolean(node.questionToken);\n const doc = await jsDocToDocSchema(node, context);\n return new VariableLikeSchema(context.getLocation(node), name, displaySig, type, isOptional, doc);\n}\n\nexport async function indexSignature(node: IndexSignatureDeclaration, context: SchemaExtractorContext) {\n const params = await getParams(node.parameters, context);\n const type = await typeNodeToSchema(node.type, context);\n return new IndexSignatureSchema(context.getLocation(node), params, type);\n}\n\nexport async function getAccessor(node: GetAccessorDeclaration, context: SchemaExtractorContext) {\n const info = await context.getQuickInfo(node.name);\n const displaySig = info?.body?.displayString || '';\n const typeStr = parseTypeFromQuickInfo(info);\n const type = await context.resolveType(node, typeStr);\n return new GetAccessorSchema(context.getLocation(node), node.name.getText(), type, displaySig);\n}\n\nexport async function setAccessor(node: SetAccessorDeclaration, context: SchemaExtractorContext) {\n const params = await getParams(node.parameters, context);\n const displaySig = await context.getQuickInfoDisplayString(node.name);\n return new SetAccessorSchema(context.getLocation(node), node.name.getText(), params[0], displaySig);\n}\n\nasync function callSignature(node: CallSignatureDeclaration, context: SchemaExtractorContext) {\n return toFunctionLikeSchema(node, context);\n}\n"],"mappings":";;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAWA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAOA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,eAAeA,mBAAf,CAAmCC,IAAnC,EAAsDC,OAAtD,EAA4G;EACjH,QAAQD,IAAI,CAACE,IAAb;IACE,KAAKC,wBAAA,CAAWC,eAAhB;MACE,OAAO,IAAAC,4CAAA,EAAqBL,IAArB,EAA8CC,OAA9C,CAAP;;IACF,KAAKE,wBAAA,CAAWG,kBAAhB;MACE,OAAO,IAAAD,4CAAA,EAAqBL,IAArB,EAA4DC,OAA5D,EAAqE,KAArE,CAAP;;IACF,KAAKE,wBAAA,CAAWI,aAAhB;MACE,OAAOC,aAAa,CAACR,IAAD,EAAmCC,OAAnC,CAApB;;IACF,KAAKE,wBAAA,CAAWM,iBAAhB;MACE,OAAOC,iBAAiB,CAACV,IAAD,EAA+BC,OAA/B,CAAxB;;IACF,KAAKE,wBAAA,CAAWQ,cAAhB;MACE,OAAOC,cAAc,CAACZ,IAAD,EAAoCC,OAApC,CAArB;;IACF,KAAKE,wBAAA,CAAWU,WAAhB;MACE,OAAOC,WAAW,CAACd,IAAD,EAAiCC,OAAjC,CAAlB;;IACF,KAAKE,wBAAA,CAAWY,WAAhB;MACE,OAAOC,WAAW,CAAChB,IAAD,EAAiCC,OAAjC,CAAlB;;IACF;MACE,MAAM,IAAIgB,KAAJ,CAAW,qDAAoDjB,IAAI,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A3B,CAAP;AACD"}
@@ -127,11 +127,13 @@ async function typeNodeToSchema(node, context) {
127
127
  case _typescript().SyntaxKind.ThisType:
128
128
  return thisType(node, context);
129
129
 
130
+ case _typescript().SyntaxKind.ConditionalType:
131
+ return conditionalType(node, context);
132
+
130
133
  case _typescript().SyntaxKind.ConstructorType:
131
134
  case _typescript().SyntaxKind.NamedTupleMember:
132
135
  case _typescript().SyntaxKind.OptionalType:
133
136
  case _typescript().SyntaxKind.RestType:
134
- case _typescript().SyntaxKind.ConditionalType:
135
137
  case _typescript().SyntaxKind.InferType:
136
138
  case _typescript().SyntaxKind.MappedType:
137
139
  case _typescript().SyntaxKind.ImportType:
@@ -327,4 +329,12 @@ async function thisType(node, context) {
327
329
  return new (_semanticsEntities().ThisTypeSchema)(context.getLocation(node));
328
330
  }
329
331
 
332
+ async function conditionalType(node, context) {
333
+ const checkType = await typeNodeToSchema(node.checkType, context);
334
+ const extendsType = await typeNodeToSchema(node.extendsType, context);
335
+ const trueType = await typeNodeToSchema(node.trueType, context);
336
+ const falseType = await typeNodeToSchema(node.falseType, context);
337
+ return new (_semanticsEntities().ConditionalTypeSchema)(context.getLocation(node), checkType, extendsType, trueType, falseType);
338
+ }
339
+
330
340
  //# sourceMappingURL=type-node-to-schema.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["typeNodeToSchema","node","context","location","getLocation","isKeywordType","KeywordTypeSchema","getText","kind","SyntaxKind","IntersectionType","intersectionType","UnionType","unionType","TypeReference","typeReference","TypeLiteral","typeLiteral","LiteralType","LiteralTypeSchema","FunctionType","functionType","TypeQuery","typeQuery","ArrayType","arrayType","TypeOperator","typeOperator","TupleType","tupleType","ParenthesizedType","parenthesizedType","TypePredicate","typePredicate","IndexedAccessType","indexedAccessType","TemplateLiteralTypeSpan","templateLiteralTypeSpan","TemplateLiteralType","templateLiteralType","ThisType","thisType","ConstructorType","NamedTupleMember","OptionalType","RestType","ConditionalType","InferType","MappedType","ImportType","ExpressionWithTypeArguments","JSDocTypeExpression","JSDocAllType","JSDocUnknownType","JSDocNonNullableType","JSDocNullableType","JSDocOptionalType","JSDocFunctionType","JSDocVariadicType","JSDocNamepathType","JSDocSignature","JSDocTypeLiteral","Error","AnyKeyword","BigIntKeyword","BooleanKeyword","IntrinsicKeyword","NeverKeyword","NumberKeyword","ObjectKeyword","StringKeyword","SymbolKeyword","UndefinedKeyword","UnknownKeyword","VoidKeyword","types","pMapSeries","type","typeSchema","TypeIntersectionSchema","TypeUnionSchema","members","member","typeElementToSchema","TypeLiteralSchema","name","typeName","resolveType","typeArguments","TypeRefSchema","args","arg","typeArgs","params","getParams","parameters","returnType","modifiers","map","modifier","doc","jsDocToDocSchema","FunctionLikeSchema","displaySig","getQuickInfoDisplayString","exprName","TypeQuerySchema","elementType","TypeArraySchema","operatorName","getOperatorName","operator","TypeOperatorSchema","KeyOfKeyword","UniqueKeyword","ReadonlyKeyword","elements","elem","TupleTypeSchema","ParenthesizedTypeSchema","parameterName","isIdentifier","undefined","hasAssertsModifier","Boolean","assertsModifier","TypePredicateSchema","objectType","indexType","IndexedAccessSchema","templateSpans","span","head","text","TemplateLiteralTypeSchema","literal","TemplateLiteralTypeSpanSchema","ThisTypeSchema"],"sources":["type-node-to-schema.ts"],"sourcesContent":["import {\n TypeNode,\n SyntaxKind,\n KeywordTypeNode,\n FunctionTypeNode,\n TypeQueryNode,\n TypeReferenceNode,\n ArrayTypeNode,\n TypeOperatorNode,\n TupleTypeNode,\n IntersectionTypeNode,\n UnionTypeNode,\n TypeLiteralNode,\n ParenthesizedTypeNode,\n TypePredicateNode,\n isIdentifier,\n IndexedAccessTypeNode,\n TemplateLiteralTypeNode,\n TemplateLiteralTypeSpan,\n ThisTypeNode,\n} from 'typescript';\nimport {\n SchemaNode,\n TypeRefSchema,\n TypeIntersectionSchema,\n TypeUnionSchema,\n TypeLiteralSchema,\n TypeQuerySchema,\n LiteralTypeSchema,\n KeywordTypeSchema,\n TypeArraySchema,\n TypeOperatorSchema,\n TupleTypeSchema,\n FunctionLikeSchema,\n ParenthesizedTypeSchema,\n TypePredicateSchema,\n IndexedAccessSchema,\n TemplateLiteralTypeSpanSchema,\n TemplateLiteralTypeSchema,\n ThisTypeSchema,\n Modifier,\n} from '@teambit/semantics.entities.semantic-schema';\nimport pMapSeries from 'p-map-series';\nimport { SchemaExtractorContext } from '../../schema-extractor-context';\nimport { getParams } from './get-params';\nimport { typeElementToSchema } from './type-element-to-schema';\nimport { jsDocToDocSchema } from './jsdoc-to-doc-schema';\n\n// eslint-disable-next-line complexity\nexport async function typeNodeToSchema(node: TypeNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n const location = context.getLocation(node);\n if (isKeywordType(node)) {\n return new KeywordTypeSchema(location, node.getText());\n }\n switch (node.kind) {\n case SyntaxKind.IntersectionType:\n return intersectionType(node as IntersectionTypeNode, context);\n case SyntaxKind.UnionType:\n return unionType(node as UnionTypeNode, context);\n case SyntaxKind.TypeReference:\n return typeReference(node as TypeReferenceNode, context);\n case SyntaxKind.TypeLiteral:\n return typeLiteral(node as TypeLiteralNode, context);\n case SyntaxKind.LiteralType: // e.g. string/boolean\n return new LiteralTypeSchema(location, node.getText());\n case SyntaxKind.FunctionType:\n return functionType(node as FunctionTypeNode, context);\n case SyntaxKind.TypeQuery:\n return typeQuery(node as TypeQueryNode, context);\n case SyntaxKind.ArrayType:\n return arrayType(node as ArrayTypeNode, context);\n case SyntaxKind.TypeOperator:\n return typeOperator(node as TypeOperatorNode, context);\n case SyntaxKind.TupleType:\n return tupleType(node as TupleTypeNode, context);\n case SyntaxKind.ParenthesizedType:\n return parenthesizedType(node as ParenthesizedTypeNode, context);\n case SyntaxKind.TypePredicate:\n return typePredicate(node as TypePredicateNode, context);\n case SyntaxKind.IndexedAccessType:\n return indexedAccessType(node as IndexedAccessTypeNode, context);\n case SyntaxKind.TemplateLiteralTypeSpan:\n return templateLiteralTypeSpan(node as TemplateLiteralTypeSpan, context);\n case SyntaxKind.TemplateLiteralType:\n return templateLiteralType(node as TemplateLiteralTypeNode, context);\n case SyntaxKind.ThisType:\n return thisType(node as ThisTypeNode, context);\n case SyntaxKind.ConstructorType:\n case SyntaxKind.NamedTupleMember:\n case SyntaxKind.OptionalType:\n case SyntaxKind.RestType:\n case SyntaxKind.ConditionalType:\n case SyntaxKind.InferType:\n case SyntaxKind.MappedType:\n case SyntaxKind.ImportType:\n case SyntaxKind.ExpressionWithTypeArguments:\n case SyntaxKind.JSDocTypeExpression:\n case SyntaxKind.JSDocAllType:\n case SyntaxKind.JSDocUnknownType:\n case SyntaxKind.JSDocNonNullableType:\n case SyntaxKind.JSDocNullableType:\n case SyntaxKind.JSDocOptionalType:\n case SyntaxKind.JSDocFunctionType:\n case SyntaxKind.JSDocVariadicType:\n case SyntaxKind.JSDocNamepathType:\n case SyntaxKind.JSDocSignature:\n case SyntaxKind.JSDocTypeLiteral:\n throw new Error(`TypeNode ${node.kind} (probably ${SyntaxKind[node.kind]}) was not implemented yet.\ncontext: ${node.getText()}`);\n default:\n throw new Error(`Node ${node.kind} (probably ${SyntaxKind[node.kind]}) is not a TypeNode.\ncontext: ${node.getText()}`);\n }\n}\n\n/**\n * whether it's kind of `ts.KeywordTypeSyntaxKind`\n */\nfunction isKeywordType(node: TypeNode): node is KeywordTypeNode {\n switch (node.kind) {\n case SyntaxKind.AnyKeyword:\n case SyntaxKind.BigIntKeyword:\n case SyntaxKind.BooleanKeyword:\n case SyntaxKind.IntrinsicKeyword:\n case SyntaxKind.NeverKeyword:\n case SyntaxKind.NumberKeyword:\n case SyntaxKind.ObjectKeyword:\n case SyntaxKind.StringKeyword:\n case SyntaxKind.SymbolKeyword:\n case SyntaxKind.UndefinedKeyword:\n case SyntaxKind.UnknownKeyword:\n case SyntaxKind.VoidKeyword:\n return true;\n default:\n return false;\n }\n}\n\nasync function intersectionType(node: IntersectionTypeNode, context: SchemaExtractorContext) {\n const types = await pMapSeries(node.types, async (type) => {\n const typeSchema = await typeNodeToSchema(type, context);\n return typeSchema;\n });\n const location = context.getLocation(node);\n return new TypeIntersectionSchema(location, types);\n}\n\nasync function unionType(node: UnionTypeNode, context: SchemaExtractorContext) {\n const types = await pMapSeries(node.types, async (type) => {\n const typeSchema = await typeNodeToSchema(type, context);\n return typeSchema;\n });\n const location = context.getLocation(node);\n return new TypeUnionSchema(location, types);\n}\n\n/**\n * not to be confused with \"LiteralType\", which is string/boolean/null.\n * this \"TypeLiteral\" is an object with properties, such as: `{ a: string; b: number }`, similar to Interface.\n */\nasync function typeLiteral(node: TypeLiteralNode, context: SchemaExtractorContext) {\n const members = await pMapSeries(node.members, (member) => typeElementToSchema(member, context));\n const location = context.getLocation(node);\n return new TypeLiteralSchema(location, members);\n}\n\n/**\n * In the following example, `AriaButtonProps` is a type reference\n * ```ts\n * import type { AriaButtonProps } from '@react-types/button';\n * export type ButtonProps = AriaButtonProps & { a: string };\n * ```\n */\nasync function typeReference(node: TypeReferenceNode, context: SchemaExtractorContext) {\n const name = node.typeName.getText();\n const type = await context.resolveType(node, name, false);\n if (node.typeArguments && type instanceof TypeRefSchema) {\n const args = await pMapSeries(node.typeArguments, (arg) => typeNodeToSchema(arg, context));\n type.typeArgs = args;\n }\n return type;\n}\n\nasync function functionType(node: FunctionTypeNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n const name = node.name?.getText() || '';\n const params = await getParams(node.parameters, context);\n const returnType = await typeNodeToSchema(node.type, context);\n const location = context.getLocation(node);\n const modifiers = node.modifiers?.map((modifier) => modifier.getText()) || [];\n const doc = await jsDocToDocSchema(node, context);\n return new FunctionLikeSchema(location, name, params, returnType, '', modifiers as Modifier[], doc);\n}\n\n/**\n * e.g. `typeof Foo`\n */\nasync function typeQuery(node: TypeQueryNode, context: SchemaExtractorContext) {\n const displaySig = await context.getQuickInfoDisplayString(node.exprName);\n const type = await context.resolveType(node.exprName, node.exprName.getText(), false);\n const location = context.getLocation(node);\n return new TypeQuerySchema(location, type, displaySig);\n}\n\nasync function arrayType(node: ArrayTypeNode, context: SchemaExtractorContext) {\n const type = await typeNodeToSchema(node.elementType, context);\n const location = context.getLocation(node);\n return new TypeArraySchema(location, type);\n}\n\n/**\n * e.g. keyof typeof Foo\n */\nasync function typeOperator(node: TypeOperatorNode, context: SchemaExtractorContext) {\n const operatorName = getOperatorName(node.operator);\n const type = await typeNodeToSchema(node.type, context);\n return new TypeOperatorSchema(context.getLocation(node), operatorName, type);\n}\n\nfunction getOperatorName(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword) {\n switch (operator) {\n case SyntaxKind.KeyOfKeyword:\n return 'keyof';\n case SyntaxKind.UniqueKeyword:\n return 'unique';\n case SyntaxKind.ReadonlyKeyword:\n return 'readonly';\n default:\n throw new Error(`getOperatorName: unable to find operator name for ${operator}`);\n }\n}\n\nasync function tupleType(node: TupleTypeNode, context: SchemaExtractorContext) {\n const elements = await pMapSeries(node.elements, async (elem) => {\n const typeSchema = await typeNodeToSchema(elem, context);\n return typeSchema;\n });\n return new TupleTypeSchema(context.getLocation(node), elements);\n}\n\nasync function parenthesizedType(node: ParenthesizedTypeNode, context: SchemaExtractorContext) {\n const type = await typeNodeToSchema(node.type, context);\n return new ParenthesizedTypeSchema(context.getLocation(node), type);\n}\n\nasync function typePredicate(node: TypePredicateNode, context: SchemaExtractorContext) {\n const parameterName = isIdentifier(node.parameterName) ? node.parameterName.getText() : 'this';\n const type = node.type ? await typeNodeToSchema(node.type, context) : undefined;\n const hasAssertsModifier = Boolean(node.assertsModifier);\n return new TypePredicateSchema(context.getLocation(node), parameterName, type, hasAssertsModifier);\n}\n\nasync function indexedAccessType(node: IndexedAccessTypeNode, context: SchemaExtractorContext) {\n const objectType = await typeNodeToSchema(node.objectType, context);\n const indexType = await typeNodeToSchema(node.indexType, context);\n return new IndexedAccessSchema(context.getLocation(node), objectType, indexType);\n}\n\nasync function templateLiteralType(node: TemplateLiteralTypeNode, context: SchemaExtractorContext) {\n const templateSpans = await pMapSeries(node.templateSpans, (span) => templateLiteralTypeSpan(span, context));\n const head = node.head.text;\n return new TemplateLiteralTypeSchema(context.getLocation(node), head, templateSpans);\n}\n\nasync function templateLiteralTypeSpan(node: TemplateLiteralTypeSpan, context: SchemaExtractorContext) {\n const type = await typeNodeToSchema(node.type, context);\n const literal = node.literal.text;\n return new TemplateLiteralTypeSpanSchema(context.getLocation(node), literal, type);\n}\n\nasync function thisType(node: ThisTypeNode, context: SchemaExtractorContext) {\n return new ThisTypeSchema(context.getLocation(node));\n}\n"],"mappings":";;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAqBA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAqBA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;AACO,eAAeA,gBAAf,CAAgCC,IAAhC,EAAgDC,OAAhD,EAAsG;EAC3G,MAAMC,QAAQ,GAAGD,OAAO,CAACE,WAAR,CAAoBH,IAApB,CAAjB;;EACA,IAAII,aAAa,CAACJ,IAAD,CAAjB,EAAyB;IACvB,OAAO,KAAIK,sCAAJ,EAAsBH,QAAtB,EAAgCF,IAAI,CAACM,OAAL,EAAhC,CAAP;EACD;;EACD,QAAQN,IAAI,CAACO,IAAb;IACE,KAAKC,wBAAA,CAAWC,gBAAhB;MACE,OAAOC,gBAAgB,CAACV,IAAD,EAA+BC,OAA/B,CAAvB;;IACF,KAAKO,wBAAA,CAAWG,SAAhB;MACE,OAAOC,SAAS,CAACZ,IAAD,EAAwBC,OAAxB,CAAhB;;IACF,KAAKO,wBAAA,CAAWK,aAAhB;MACE,OAAOC,aAAa,CAACd,IAAD,EAA4BC,OAA5B,CAApB;;IACF,KAAKO,wBAAA,CAAWO,WAAhB;MACE,OAAOC,WAAW,CAAChB,IAAD,EAA0BC,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AJ,EAA8BpI,OAAO,CAACE,WAAR,CAAoBH,IAApB,CAA9B,EAAyDmI,IAAzD,EAA+DF,aAA/D,CAAP;AACD;;AAED,eAAe7F,uBAAf,CAAuCpC,IAAvC,EAAsEC,OAAtE,EAAuG;EACrG,MAAM2E,IAAI,GAAG,MAAM7E,gBAAgB,CAACC,IAAI,CAAC4E,IAAN,EAAY3E,OAAZ,CAAnC;EACA,MAAMqI,OAAO,GAAGtI,IAAI,CAACsI,OAAL,CAAaF,IAA7B;EACA,OAAO,KAAIG,kDAAJ,EAAkCtI,OAAO,CAACE,WAAR,CAAoBH,IAApB,CAAlC,EAA6DsI,OAA7D,EAAsE1D,IAAtE,CAAP;AACD;;AAED,eAAepC,QAAf,CAAwBxC,IAAxB,EAA4CC,OAA5C,EAA6E;EAC3E,OAAO,KAAIuI,mCAAJ,EAAmBvI,OAAO,CAACE,WAAR,CAAoBH,IAApB,CAAnB,CAAP;AACD"}
1
+ {"version":3,"names":["typeNodeToSchema","node","context","location","getLocation","isKeywordType","KeywordTypeSchema","getText","kind","SyntaxKind","IntersectionType","intersectionType","UnionType","unionType","TypeReference","typeReference","TypeLiteral","typeLiteral","LiteralType","LiteralTypeSchema","FunctionType","functionType","TypeQuery","typeQuery","ArrayType","arrayType","TypeOperator","typeOperator","TupleType","tupleType","ParenthesizedType","parenthesizedType","TypePredicate","typePredicate","IndexedAccessType","indexedAccessType","TemplateLiteralTypeSpan","templateLiteralTypeSpan","TemplateLiteralType","templateLiteralType","ThisType","thisType","ConditionalType","conditionalType","ConstructorType","NamedTupleMember","OptionalType","RestType","InferType","MappedType","ImportType","ExpressionWithTypeArguments","JSDocTypeExpression","JSDocAllType","JSDocUnknownType","JSDocNonNullableType","JSDocNullableType","JSDocOptionalType","JSDocFunctionType","JSDocVariadicType","JSDocNamepathType","JSDocSignature","JSDocTypeLiteral","Error","AnyKeyword","BigIntKeyword","BooleanKeyword","IntrinsicKeyword","NeverKeyword","NumberKeyword","ObjectKeyword","StringKeyword","SymbolKeyword","UndefinedKeyword","UnknownKeyword","VoidKeyword","types","pMapSeries","type","typeSchema","TypeIntersectionSchema","TypeUnionSchema","members","member","typeElementToSchema","TypeLiteralSchema","name","typeName","resolveType","typeArguments","TypeRefSchema","args","arg","typeArgs","params","getParams","parameters","returnType","modifiers","map","modifier","doc","jsDocToDocSchema","FunctionLikeSchema","displaySig","getQuickInfoDisplayString","exprName","TypeQuerySchema","elementType","TypeArraySchema","operatorName","getOperatorName","operator","TypeOperatorSchema","KeyOfKeyword","UniqueKeyword","ReadonlyKeyword","elements","elem","TupleTypeSchema","ParenthesizedTypeSchema","parameterName","isIdentifier","undefined","hasAssertsModifier","Boolean","assertsModifier","TypePredicateSchema","objectType","indexType","IndexedAccessSchema","templateSpans","span","head","text","TemplateLiteralTypeSchema","literal","TemplateLiteralTypeSpanSchema","ThisTypeSchema","checkType","extendsType","trueType","falseType","ConditionalTypeSchema"],"sources":["type-node-to-schema.ts"],"sourcesContent":["import {\n TypeNode,\n SyntaxKind,\n KeywordTypeNode,\n FunctionTypeNode,\n TypeQueryNode,\n TypeReferenceNode,\n ArrayTypeNode,\n TypeOperatorNode,\n TupleTypeNode,\n IntersectionTypeNode,\n UnionTypeNode,\n TypeLiteralNode,\n ParenthesizedTypeNode,\n TypePredicateNode,\n isIdentifier,\n IndexedAccessTypeNode,\n TemplateLiteralTypeNode,\n TemplateLiteralTypeSpan,\n ThisTypeNode,\n ConditionalTypeNode,\n} from 'typescript';\nimport {\n SchemaNode,\n TypeRefSchema,\n TypeIntersectionSchema,\n TypeUnionSchema,\n TypeLiteralSchema,\n TypeQuerySchema,\n LiteralTypeSchema,\n KeywordTypeSchema,\n TypeArraySchema,\n TypeOperatorSchema,\n TupleTypeSchema,\n FunctionLikeSchema,\n ParenthesizedTypeSchema,\n TypePredicateSchema,\n IndexedAccessSchema,\n TemplateLiteralTypeSpanSchema,\n TemplateLiteralTypeSchema,\n ThisTypeSchema,\n Modifier,\n ConditionalTypeSchema,\n} from '@teambit/semantics.entities.semantic-schema';\nimport pMapSeries from 'p-map-series';\nimport { SchemaExtractorContext } from '../../schema-extractor-context';\nimport { getParams } from './get-params';\nimport { typeElementToSchema } from './type-element-to-schema';\nimport { jsDocToDocSchema } from './jsdoc-to-doc-schema';\n\n// eslint-disable-next-line complexity\nexport async function typeNodeToSchema(node: TypeNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n const location = context.getLocation(node);\n if (isKeywordType(node)) {\n return new KeywordTypeSchema(location, node.getText());\n }\n switch (node.kind) {\n case SyntaxKind.IntersectionType:\n return intersectionType(node as IntersectionTypeNode, context);\n case SyntaxKind.UnionType:\n return unionType(node as UnionTypeNode, context);\n case SyntaxKind.TypeReference:\n return typeReference(node as TypeReferenceNode, context);\n case SyntaxKind.TypeLiteral:\n return typeLiteral(node as TypeLiteralNode, context);\n case SyntaxKind.LiteralType: // e.g. string/boolean\n return new LiteralTypeSchema(location, node.getText());\n case SyntaxKind.FunctionType:\n return functionType(node as FunctionTypeNode, context);\n case SyntaxKind.TypeQuery:\n return typeQuery(node as TypeQueryNode, context);\n case SyntaxKind.ArrayType:\n return arrayType(node as ArrayTypeNode, context);\n case SyntaxKind.TypeOperator:\n return typeOperator(node as TypeOperatorNode, context);\n case SyntaxKind.TupleType:\n return tupleType(node as TupleTypeNode, context);\n case SyntaxKind.ParenthesizedType:\n return parenthesizedType(node as ParenthesizedTypeNode, context);\n case SyntaxKind.TypePredicate:\n return typePredicate(node as TypePredicateNode, context);\n case SyntaxKind.IndexedAccessType:\n return indexedAccessType(node as IndexedAccessTypeNode, context);\n case SyntaxKind.TemplateLiteralTypeSpan:\n return templateLiteralTypeSpan(node as TemplateLiteralTypeSpan, context);\n case SyntaxKind.TemplateLiteralType:\n return templateLiteralType(node as TemplateLiteralTypeNode, context);\n case SyntaxKind.ThisType:\n return thisType(node as ThisTypeNode, context);\n case SyntaxKind.ConditionalType:\n return conditionalType(node as ConditionalTypeNode, context);\n case SyntaxKind.ConstructorType:\n case SyntaxKind.NamedTupleMember:\n case SyntaxKind.OptionalType:\n case SyntaxKind.RestType:\n case SyntaxKind.InferType:\n case SyntaxKind.MappedType:\n case SyntaxKind.ImportType:\n case SyntaxKind.ExpressionWithTypeArguments:\n case SyntaxKind.JSDocTypeExpression:\n case SyntaxKind.JSDocAllType:\n case SyntaxKind.JSDocUnknownType:\n case SyntaxKind.JSDocNonNullableType:\n case SyntaxKind.JSDocNullableType:\n case SyntaxKind.JSDocOptionalType:\n case SyntaxKind.JSDocFunctionType:\n case SyntaxKind.JSDocVariadicType:\n case SyntaxKind.JSDocNamepathType:\n case SyntaxKind.JSDocSignature:\n case SyntaxKind.JSDocTypeLiteral:\n throw new Error(`TypeNode ${node.kind} (probably ${SyntaxKind[node.kind]}) was not implemented yet.\ncontext: ${node.getText()}`);\n default:\n throw new Error(`Node ${node.kind} (probably ${SyntaxKind[node.kind]}) is not a TypeNode.\ncontext: ${node.getText()}`);\n }\n}\n\n/**\n * whether it's kind of `ts.KeywordTypeSyntaxKind`\n */\nfunction isKeywordType(node: TypeNode): node is KeywordTypeNode {\n switch (node.kind) {\n case SyntaxKind.AnyKeyword:\n case SyntaxKind.BigIntKeyword:\n case SyntaxKind.BooleanKeyword:\n case SyntaxKind.IntrinsicKeyword:\n case SyntaxKind.NeverKeyword:\n case SyntaxKind.NumberKeyword:\n case SyntaxKind.ObjectKeyword:\n case SyntaxKind.StringKeyword:\n case SyntaxKind.SymbolKeyword:\n case SyntaxKind.UndefinedKeyword:\n case SyntaxKind.UnknownKeyword:\n case SyntaxKind.VoidKeyword:\n return true;\n default:\n return false;\n }\n}\n\nasync function intersectionType(node: IntersectionTypeNode, context: SchemaExtractorContext) {\n const types = await pMapSeries(node.types, async (type) => {\n const typeSchema = await typeNodeToSchema(type, context);\n return typeSchema;\n });\n const location = context.getLocation(node);\n return new TypeIntersectionSchema(location, types);\n}\n\nasync function unionType(node: UnionTypeNode, context: SchemaExtractorContext) {\n const types = await pMapSeries(node.types, async (type) => {\n const typeSchema = await typeNodeToSchema(type, context);\n return typeSchema;\n });\n const location = context.getLocation(node);\n return new TypeUnionSchema(location, types);\n}\n\n/**\n * not to be confused with \"LiteralType\", which is string/boolean/null.\n * this \"TypeLiteral\" is an object with properties, such as: `{ a: string; b: number }`, similar to Interface.\n */\nasync function typeLiteral(node: TypeLiteralNode, context: SchemaExtractorContext) {\n const members = await pMapSeries(node.members, (member) => typeElementToSchema(member, context));\n const location = context.getLocation(node);\n return new TypeLiteralSchema(location, members);\n}\n\n/**\n * In the following example, `AriaButtonProps` is a type reference\n * ```ts\n * import type { AriaButtonProps } from '@react-types/button';\n * export type ButtonProps = AriaButtonProps & { a: string };\n * ```\n */\nasync function typeReference(node: TypeReferenceNode, context: SchemaExtractorContext) {\n const name = node.typeName.getText();\n const type = await context.resolveType(node, name, false);\n if (node.typeArguments && type instanceof TypeRefSchema) {\n const args = await pMapSeries(node.typeArguments, (arg) => typeNodeToSchema(arg, context));\n type.typeArgs = args;\n }\n return type;\n}\n\nasync function functionType(node: FunctionTypeNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n const name = node.name?.getText() || '';\n const params = await getParams(node.parameters, context);\n const returnType = await typeNodeToSchema(node.type, context);\n const location = context.getLocation(node);\n const modifiers = node.modifiers?.map((modifier) => modifier.getText()) || [];\n const doc = await jsDocToDocSchema(node, context);\n return new FunctionLikeSchema(location, name, params, returnType, '', modifiers as Modifier[], doc);\n}\n\n/**\n * e.g. `typeof Foo`\n */\nasync function typeQuery(node: TypeQueryNode, context: SchemaExtractorContext) {\n const displaySig = await context.getQuickInfoDisplayString(node.exprName);\n const type = await context.resolveType(node.exprName, node.exprName.getText(), false);\n const location = context.getLocation(node);\n return new TypeQuerySchema(location, type, displaySig);\n}\n\nasync function arrayType(node: ArrayTypeNode, context: SchemaExtractorContext) {\n const type = await typeNodeToSchema(node.elementType, context);\n const location = context.getLocation(node);\n return new TypeArraySchema(location, type);\n}\n\n/**\n * e.g. keyof typeof Foo\n */\nasync function typeOperator(node: TypeOperatorNode, context: SchemaExtractorContext) {\n const operatorName = getOperatorName(node.operator);\n const type = await typeNodeToSchema(node.type, context);\n return new TypeOperatorSchema(context.getLocation(node), operatorName, type);\n}\n\nfunction getOperatorName(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword) {\n switch (operator) {\n case SyntaxKind.KeyOfKeyword:\n return 'keyof';\n case SyntaxKind.UniqueKeyword:\n return 'unique';\n case SyntaxKind.ReadonlyKeyword:\n return 'readonly';\n default:\n throw new Error(`getOperatorName: unable to find operator name for ${operator}`);\n }\n}\n\nasync function tupleType(node: TupleTypeNode, context: SchemaExtractorContext) {\n const elements = await pMapSeries(node.elements, async (elem) => {\n const typeSchema = await typeNodeToSchema(elem, context);\n return typeSchema;\n });\n return new TupleTypeSchema(context.getLocation(node), elements);\n}\n\nasync function parenthesizedType(node: ParenthesizedTypeNode, context: SchemaExtractorContext) {\n const type = await typeNodeToSchema(node.type, context);\n return new ParenthesizedTypeSchema(context.getLocation(node), type);\n}\n\nasync function typePredicate(node: TypePredicateNode, context: SchemaExtractorContext) {\n const parameterName = isIdentifier(node.parameterName) ? node.parameterName.getText() : 'this';\n const type = node.type ? await typeNodeToSchema(node.type, context) : undefined;\n const hasAssertsModifier = Boolean(node.assertsModifier);\n return new TypePredicateSchema(context.getLocation(node), parameterName, type, hasAssertsModifier);\n}\n\nasync function indexedAccessType(node: IndexedAccessTypeNode, context: SchemaExtractorContext) {\n const objectType = await typeNodeToSchema(node.objectType, context);\n const indexType = await typeNodeToSchema(node.indexType, context);\n return new IndexedAccessSchema(context.getLocation(node), objectType, indexType);\n}\n\nasync function templateLiteralType(node: TemplateLiteralTypeNode, context: SchemaExtractorContext) {\n const templateSpans = await pMapSeries(node.templateSpans, (span) => templateLiteralTypeSpan(span, context));\n const head = node.head.text;\n return new TemplateLiteralTypeSchema(context.getLocation(node), head, templateSpans);\n}\n\nasync function templateLiteralTypeSpan(node: TemplateLiteralTypeSpan, context: SchemaExtractorContext) {\n const type = await typeNodeToSchema(node.type, context);\n const literal = node.literal.text;\n return new TemplateLiteralTypeSpanSchema(context.getLocation(node), literal, type);\n}\n\nasync function thisType(node: ThisTypeNode, context: SchemaExtractorContext) {\n return new ThisTypeSchema(context.getLocation(node));\n}\n\nasync function conditionalType(node: ConditionalTypeNode, context: SchemaExtractorContext) {\n const checkType = await typeNodeToSchema(node.checkType, context);\n const extendsType = await typeNodeToSchema(node.extendsType, context);\n const trueType = await typeNodeToSchema(node.trueType, context);\n const falseType = await typeNodeToSchema(node.falseType, context);\n return new ConditionalTypeSchema(context.getLocation(node), checkType, extendsType, trueType, falseType);\n}\n"],"mappings":";;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAsBA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAsBA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;AACO,eAAeA,gBAAf,CAAgCC,IAAhC,EAAgDC,OAAhD,EAAsG;EAC3G,MAAMC,QAAQ,GAAGD,OAAO,CAACE,WAAR,CAAoBH,IAApB,CAAjB;;EACA,IAAII,aAAa,CAACJ,IAAD,CAAjB,EAAyB;IACvB,OAAO,KAAIK,sCAAJ,EAAsBH,QAAtB,EAAgCF,IAAI,CAACM,OAAL,EAAhC,CAAP;EACD;;EACD,QAAQN,IAAI,CAACO,IAAb;IACE,KAAKC,wBAAA,CAAWC,gBAAhB;MACE,OAAOC,gBAAgB,CAACV,IAAD,EAA+BC,OAA/B,CAAvB;;IACF,KAAKO,wBAAA,CAAWG,SAAhB;MACE,OAAOC,SAAS,CAACZ,IAAD,EAAwBC,OAAxB,CAAhB;;IACF,KAAKO,wBAAA,CAAWK,aAAhB;MACE,OAAOC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E,WAAR,CAAoBH,IAApB,CAA1B,EAAqD0I,SAArD,EAAgEC,WAAhE,EAA6EC,QAA7E,EAAuFC,SAAvF,CAAP;AACD"}
@@ -89,6 +89,7 @@ class VariableDeclaration {
89
89
  const info = await context.getQuickInfo(varDec.name);
90
90
  const displaySig = (info === null || info === void 0 ? void 0 : (_info$body = info.body) === null || _info$body === void 0 ? void 0 : _info$body.displayString) || '';
91
91
  const location = context.getLocation(varDec);
92
+ const doc = await (0, _jsdocToDocSchema().jsDocToDocSchema)(varDec, context);
92
93
 
93
94
  if (((_varDec$initializer = varDec.initializer) === null || _varDec$initializer === void 0 ? void 0 : _varDec$initializer.kind) === _typescript().default.SyntaxKind.ArrowFunction) {
94
95
  var _varDec$modifiers;
@@ -97,13 +98,12 @@ class VariableDeclaration {
97
98
  const typeStr = (0, _parseTypeFromQuickInfo().parseReturnTypeFromQuickInfo)(info);
98
99
  const returnType = await context.resolveType(varDec, typeStr);
99
100
  const modifiers = ((_varDec$modifiers = varDec.modifiers) === null || _varDec$modifiers === void 0 ? void 0 : _varDec$modifiers.map(modifier => modifier.getText())) || [];
100
- const doc = await (0, _jsdocToDocSchema().jsDocToDocSchema)(varDec, context);
101
101
  return new (_semanticsEntities().FunctionLikeSchema)(location, name, args, returnType, displaySig, modifiers, doc);
102
102
  }
103
103
 
104
104
  const typeStr = (0, _parseTypeFromQuickInfo().parseTypeFromQuickInfo)(info);
105
105
  const type = await context.resolveType(varDec, typeStr);
106
- return new (_semanticsEntities().VariableLikeSchema)(location, name, displaySig, type, false);
106
+ return new (_semanticsEntities().VariableLikeSchema)(location, name, displaySig, type, false, doc);
107
107
  }
108
108
 
109
109
  }
@@ -1 +1 @@
1
- {"version":3,"names":["VariableDeclaration","predicate","node","kind","ts","SyntaxKind","getName","name","getText","getIdentifiers","ExportIdentifier","getSourceFile","fileName","transform","varDec","context","info","getQuickInfo","displaySig","body","displayString","location","getLocation","initializer","ArrowFunction","args","getParams","parameters","typeStr","parseReturnTypeFromQuickInfo","returnType","resolveType","modifiers","map","modifier","doc","jsDocToDocSchema","FunctionLikeSchema","parseTypeFromQuickInfo","type","VariableLikeSchema"],"sources":["variable-declaration.ts"],"sourcesContent":["import {\n SchemaNode,\n VariableLikeSchema,\n FunctionLikeSchema,\n Modifier,\n} from '@teambit/semantics.entities.semantic-schema';\nimport ts, { Node, VariableDeclaration as VariableDeclarationNode, ArrowFunction } from 'typescript';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\nimport { getParams } from './utils/get-params';\nimport { parseReturnTypeFromQuickInfo, parseTypeFromQuickInfo } from './utils/parse-type-from-quick-info';\nimport { jsDocToDocSchema } from './utils/jsdoc-to-doc-schema';\n\nexport class VariableDeclaration implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.VariableDeclaration;\n }\n\n getName(node: VariableDeclarationNode) {\n return node.name.getText();\n }\n\n async getIdentifiers(node: VariableDeclarationNode) {\n return [new ExportIdentifier(node.name.getText(), node.getSourceFile().fileName)];\n }\n\n async transform(varDec: VariableDeclarationNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n const name = this.getName(varDec);\n const info = await context.getQuickInfo(varDec.name);\n const displaySig = info?.body?.displayString || '';\n const location = context.getLocation(varDec);\n if (varDec.initializer?.kind === ts.SyntaxKind.ArrowFunction) {\n const args = await getParams((varDec.initializer as ArrowFunction).parameters, context);\n const typeStr = parseReturnTypeFromQuickInfo(info);\n const returnType = await context.resolveType(varDec, typeStr);\n const modifiers = varDec.modifiers?.map((modifier) => modifier.getText()) || [];\n const doc = await jsDocToDocSchema(varDec, context);\n return new FunctionLikeSchema(location, name, args, returnType, displaySig, modifiers as Modifier[], doc);\n }\n const typeStr = parseTypeFromQuickInfo(info);\n const type = await context.resolveType(varDec, typeStr);\n return new VariableLikeSchema(location, name, displaySig, type, false);\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;EAAA;;EAA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CAACS,WAAR,CAAsCI,UAAhD,EAA4DZ,OAA5D,CAAnB;MACA,MAAMa,OAAO,GAAG,IAAAC,sDAAA,EAA6Bb,IAA7B,CAAhB;MACA,MAAMc,UAAU,GAAG,MAAMf,OAAO,CAACgB,WAAR,CAAoBjB,MAApB,EAA4Bc,OAA5B,CAAzB;MACA,MAAMI,SAAS,GAAG,sBAAAlB,MAAM,CAACkB,SAAP,wEAAkBC,GAAlB,CAAuBC,QAAD,IAAcA,QAAQ,CAAC1B,OAAT,EAApC,MAA2D,EAA7E;MACA,MAAM2B,GAAG,GAAG,MAAM,IAAAC,oCAAA,EAAiBtB,MAAjB,EAAyBC,OAAzB,CAAlB;MACA,OAAO,KAAIsB,uCAAJ,EAAuBhB,QAAvB,EAAiCd,IAAjC,EAAuCkB,IAAvC,EAA6CK,UAA7C,EAAyDZ,UAAzD,EAAqEc,SAArE,EAA8FG,GAA9F,CAAP;IACD;;IACD,MAAMP,OAAO,GAAG,IAAAU,gDAAA,EAAuBtB,IAAvB,CAAhB;IACA,MAAMuB,IAAI,GAAG,MAAMxB,OAAO,CAACgB,WAAR,CAAoBjB,MAApB,EAA4Bc,OAA5B,CAAnB;IACA,OAAO,KAAIY,uCAAJ,EAAuBnB,QAAvB,EAAiCd,IAAjC,EAAuCW,UAAvC,EAAmDqB,IAAnD,EAAyD,KAAzD,CAAP;EACD;;AA7B2D"}
1
+ {"version":3,"names":["VariableDeclaration","predicate","node","kind","ts","SyntaxKind","getName","name","getText","getIdentifiers","ExportIdentifier","getSourceFile","fileName","transform","varDec","context","info","getQuickInfo","displaySig","body","displayString","location","getLocation","doc","jsDocToDocSchema","initializer","ArrowFunction","args","getParams","parameters","typeStr","parseReturnTypeFromQuickInfo","returnType","resolveType","modifiers","map","modifier","FunctionLikeSchema","parseTypeFromQuickInfo","type","VariableLikeSchema"],"sources":["variable-declaration.ts"],"sourcesContent":["import {\n SchemaNode,\n VariableLikeSchema,\n FunctionLikeSchema,\n Modifier,\n} from '@teambit/semantics.entities.semantic-schema';\nimport ts, { Node, VariableDeclaration as VariableDeclarationNode, ArrowFunction } from 'typescript';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\nimport { getParams } from './utils/get-params';\nimport { parseReturnTypeFromQuickInfo, parseTypeFromQuickInfo } from './utils/parse-type-from-quick-info';\nimport { jsDocToDocSchema } from './utils/jsdoc-to-doc-schema';\n\nexport class VariableDeclaration implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.VariableDeclaration;\n }\n\n getName(node: VariableDeclarationNode) {\n return node.name.getText();\n }\n\n async getIdentifiers(node: VariableDeclarationNode) {\n return [new ExportIdentifier(node.name.getText(), node.getSourceFile().fileName)];\n }\n\n async transform(varDec: VariableDeclarationNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n const name = this.getName(varDec);\n const info = await context.getQuickInfo(varDec.name);\n const displaySig = info?.body?.displayString || '';\n const location = context.getLocation(varDec);\n const doc = await jsDocToDocSchema(varDec, context);\n if (varDec.initializer?.kind === ts.SyntaxKind.ArrowFunction) {\n const args = await getParams((varDec.initializer as ArrowFunction).parameters, context);\n const typeStr = parseReturnTypeFromQuickInfo(info);\n const returnType = await context.resolveType(varDec, typeStr);\n const modifiers = varDec.modifiers?.map((modifier) => modifier.getText()) || [];\n return new FunctionLikeSchema(location, name, args, returnType, displaySig, modifiers as Modifier[], doc);\n }\n const typeStr = parseTypeFromQuickInfo(info);\n const type = await context.resolveType(varDec, typeStr);\n return new VariableLikeSchema(location, name, displaySig, type, false, doc);\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAMA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;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AA7B,CAAhB;MACA,MAAMgB,UAAU,GAAG,MAAMjB,OAAO,CAACkB,WAAR,CAAoBnB,MAApB,EAA4BgB,OAA5B,CAAzB;MACA,MAAMI,SAAS,GAAG,sBAAApB,MAAM,CAACoB,SAAP,wEAAkBC,GAAlB,CAAuBC,QAAD,IAAcA,QAAQ,CAAC5B,OAAT,EAApC,MAA2D,EAA7E;MACA,OAAO,KAAI6B,uCAAJ,EAAuBhB,QAAvB,EAAiCd,IAAjC,EAAuCoB,IAAvC,EAA6CK,UAA7C,EAAyDd,UAAzD,EAAqEgB,SAArE,EAA8FX,GAA9F,CAAP;IACD;;IACD,MAAMO,OAAO,GAAG,IAAAQ,gDAAA,EAAuBtB,IAAvB,CAAhB;IACA,MAAMuB,IAAI,GAAG,MAAMxB,OAAO,CAACkB,WAAR,CAAoBnB,MAApB,EAA4BgB,OAA5B,CAAnB;IACA,OAAO,KAAIU,uCAAJ,EAAuBnB,QAAvB,EAAiCd,IAAjC,EAAuCW,UAAvC,EAAmDqB,IAAnD,EAAyD,KAAzD,EAAgEhB,GAAhE,CAAP;EACD;;AA7B2D"}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/typescript",
3
- "version": "0.0.762",
3
+ "version": "0.0.765",
4
4
  "homepage": "https://bit.dev/teambit/typescript/typescript",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.typescript",
8
8
  "name": "typescript",
9
- "version": "0.0.762"
9
+ "version": "0.0.765"
10
10
  },
11
11
  "dependencies": {
12
12
  "lodash": "4.17.21",
@@ -18,21 +18,21 @@
18
18
  "@babel/runtime": "7.12.18",
19
19
  "core-js": "^3.0.0",
20
20
  "@teambit/harmony": "0.3.3",
21
- "@teambit/compiler": "0.0.762",
21
+ "@teambit/compiler": "0.0.765",
22
22
  "@teambit/typescript.modules.ts-config-mutator": "0.0.68",
23
- "@teambit/component": "0.0.762",
24
- "@teambit/dependency-resolver": "0.0.762",
25
- "@teambit/semantics.entities.semantic-schema": "0.0.21",
23
+ "@teambit/component": "0.0.765",
24
+ "@teambit/dependency-resolver": "0.0.765",
25
+ "@teambit/semantics.entities.semantic-schema": "0.0.22",
26
26
  "@teambit/ts-server": "0.0.32",
27
- "@teambit/aspect-loader": "0.0.762",
27
+ "@teambit/aspect-loader": "0.0.765",
28
28
  "@teambit/bit-error": "0.0.394",
29
- "@teambit/builder": "0.0.762",
30
- "@teambit/isolator": "0.0.762",
31
- "@teambit/logger": "0.0.596",
32
- "@teambit/schema": "0.0.762",
33
- "@teambit/workspace": "0.0.762",
34
- "@teambit/cli": "0.0.503",
35
- "@teambit/pkg": "0.0.762"
29
+ "@teambit/builder": "0.0.765",
30
+ "@teambit/isolator": "0.0.765",
31
+ "@teambit/logger": "0.0.599",
32
+ "@teambit/schema": "0.0.765",
33
+ "@teambit/workspace": "0.0.765",
34
+ "@teambit/cli": "0.0.506",
35
+ "@teambit/pkg": "0.0.765"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/lodash": "4.14.165",
@@ -48,7 +48,7 @@
48
48
  "@teambit/typescript.aspect-docs.typescript": "0.0.138"
49
49
  },
50
50
  "peerDependencies": {
51
- "@teambit/legacy": "1.0.283",
51
+ "@teambit/legacy": "1.0.286",
52
52
  "react-dom": "^16.8.0 || ^17.0.0",
53
53
  "react": "^16.8.0 || ^17.0.0"
54
54
  },
@@ -76,7 +76,7 @@
76
76
  "react": "-"
77
77
  },
78
78
  "peerDependencies": {
79
- "@teambit/legacy": "1.0.283",
79
+ "@teambit/legacy": "1.0.286",
80
80
  "react-dom": "^16.8.0 || ^17.0.0",
81
81
  "react": "^16.8.0 || ^17.0.0"
82
82
  }
@@ -1,2 +1,2 @@
1
- export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.typescript_typescript@0.0.762/dist/typescript.composition.js')]
2
- export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.typescript_typescript@0.0.762/dist/typescript.docs.mdx')]
1
+ export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.typescript_typescript@0.0.765/dist/typescript.composition.js')]
2
+ export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.typescript_typescript@0.0.765/dist/typescript.docs.mdx')]
@@ -4,6 +4,7 @@ import { SchemaTransformer } from '../schema-transformer';
4
4
  import { SchemaExtractorContext } from '../schema-extractor-context';
5
5
  import { ExportIdentifier } from '../export-identifier';
6
6
  import { parseTypeFromQuickInfo } from './utils/parse-type-from-quick-info';
7
+ import { jsDocToDocSchema } from './utils/jsdoc-to-doc-schema';
7
8
 
8
9
  /**
9
10
  * for example:
@@ -27,6 +28,7 @@ export class BindingElementTransformer implements SchemaTransformer {
27
28
  const displaySig = info?.body?.displayString || '';
28
29
  const typeStr = parseTypeFromQuickInfo(info);
29
30
  const type = await context.resolveType(node, typeStr);
30
- return new VariableLikeSchema(context.getLocation(node), name, displaySig, type, false);
31
+ const doc = await jsDocToDocSchema(node, context);
32
+ return new VariableLikeSchema(context.getLocation(node), name, displaySig, type, false, doc);
31
33
  }
32
34
  }
@@ -5,6 +5,7 @@ import { SchemaTransformer } from '../schema-transformer';
5
5
  import { SchemaExtractorContext } from '../schema-extractor-context';
6
6
  import { ExportIdentifier } from '../export-identifier';
7
7
  import { typeElementToSchema } from './utils/type-element-to-schema';
8
+ import { jsDocToDocSchema } from './utils/jsdoc-to-doc-schema';
8
9
 
9
10
  export class InterfaceDeclarationTransformer implements SchemaTransformer {
10
11
  predicate(node: Node) {
@@ -17,6 +18,7 @@ export class InterfaceDeclarationTransformer implements SchemaTransformer {
17
18
 
18
19
  async transform(interfaceDec: InterfaceDeclaration, context: SchemaExtractorContext) {
19
20
  const members = await pMapSeries(interfaceDec.members, (member) => typeElementToSchema(member, context));
20
- return new InterfaceSchema(context.getLocation(interfaceDec), interfaceDec.name.getText(), members);
21
+ const doc = await jsDocToDocSchema(interfaceDec, context);
22
+ return new InterfaceSchema(context.getLocation(interfaceDec), interfaceDec.name.getText(), members, doc);
21
23
  }
22
24
  }
@@ -4,6 +4,7 @@ import { SchemaTransformer } from '../schema-transformer';
4
4
  import { SchemaExtractorContext } from '../schema-extractor-context';
5
5
  import { ExportIdentifier } from '../export-identifier';
6
6
  import { typeNodeToSchema } from './utils/type-node-to-schema';
7
+ import { jsDocToDocSchema } from './utils/jsdoc-to-doc-schema';
7
8
 
8
9
  export class TypeAliasTransformer implements SchemaTransformer {
9
10
  predicate(node: Node) {
@@ -21,6 +22,7 @@ export class TypeAliasTransformer implements SchemaTransformer {
21
22
  async transform(typeAlias: TypeAliasDeclaration, context: SchemaExtractorContext) {
22
23
  const type = await typeNodeToSchema(typeAlias.type, context);
23
24
  const displaySig = await context.getQuickInfoDisplayString(typeAlias.name);
24
- return new TypeSchema(context.getLocation(typeAlias), this.getName(typeAlias), type, displaySig);
25
+ const doc = await jsDocToDocSchema(typeAlias, context);
26
+ return new TypeSchema(context.getLocation(typeAlias), this.getName(typeAlias), type, displaySig, doc);
25
27
  }
26
28
  }
@@ -14,6 +14,7 @@ import { getParams } from './get-params';
14
14
  import { getAccessor, indexSignature, setAccessor } from './type-element-to-schema';
15
15
  import { parseTypeFromQuickInfo } from './parse-type-from-quick-info';
16
16
  import { toFunctionLikeSchema } from './to-function-like-schema';
17
+ import { jsDocToDocSchema } from './jsdoc-to-doc-schema';
17
18
 
18
19
  export async function classElementToSchema(
19
20
  node: ClassElement,
@@ -53,8 +54,8 @@ async function propertyDeclaration(node: PropertyDeclaration, context: SchemaExt
53
54
  const typeStr = parseTypeFromQuickInfo(info);
54
55
  const type = await context.resolveType(node, typeStr);
55
56
  const isOptional = Boolean(node.questionToken);
56
-
57
- return new VariableLikeSchema(context.getLocation(node), name, displaySig || '', type, isOptional);
57
+ const doc = await jsDocToDocSchema(node, context);
58
+ return new VariableLikeSchema(context.getLocation(node), name, displaySig || '', type, isOptional, doc);
58
59
  }
59
60
 
60
61
  async function methodDeclaration(node: MethodDeclaration, context: SchemaExtractorContext) {
@@ -21,6 +21,7 @@ import { SchemaExtractorContext } from '../../schema-extractor-context';
21
21
  import { parseTypeFromQuickInfo } from './parse-type-from-quick-info';
22
22
  import { typeNodeToSchema } from './type-node-to-schema';
23
23
  import { getParams } from './get-params';
24
+ import { jsDocToDocSchema } from './jsdoc-to-doc-schema';
24
25
 
25
26
  export async function typeElementToSchema(node: TypeElement, context: SchemaExtractorContext): Promise<SchemaNode> {
26
27
  switch (node.kind) {
@@ -50,7 +51,8 @@ async function propertySignature(node: ts.PropertySignature, context: SchemaExtr
50
51
  const typeStr = parseTypeFromQuickInfo(info);
51
52
  const type = await context.resolveType(node, typeStr);
52
53
  const isOptional = Boolean(node.questionToken);
53
- return new VariableLikeSchema(context.getLocation(node), name, displaySig, type, isOptional);
54
+ const doc = await jsDocToDocSchema(node, context);
55
+ return new VariableLikeSchema(context.getLocation(node), name, displaySig, type, isOptional, doc);
54
56
  }
55
57
 
56
58
  export async function indexSignature(node: IndexSignatureDeclaration, context: SchemaExtractorContext) {
@@ -18,6 +18,7 @@ import {
18
18
  TemplateLiteralTypeNode,
19
19
  TemplateLiteralTypeSpan,
20
20
  ThisTypeNode,
21
+ ConditionalTypeNode,
21
22
  } from 'typescript';
22
23
  import {
23
24
  SchemaNode,
@@ -39,6 +40,7 @@ import {
39
40
  TemplateLiteralTypeSchema,
40
41
  ThisTypeSchema,
41
42
  Modifier,
43
+ ConditionalTypeSchema,
42
44
  } from '@teambit/semantics.entities.semantic-schema';
43
45
  import pMapSeries from 'p-map-series';
44
46
  import { SchemaExtractorContext } from '../../schema-extractor-context';
@@ -85,11 +87,12 @@ export async function typeNodeToSchema(node: TypeNode, context: SchemaExtractorC
85
87
  return templateLiteralType(node as TemplateLiteralTypeNode, context);
86
88
  case SyntaxKind.ThisType:
87
89
  return thisType(node as ThisTypeNode, context);
90
+ case SyntaxKind.ConditionalType:
91
+ return conditionalType(node as ConditionalTypeNode, context);
88
92
  case SyntaxKind.ConstructorType:
89
93
  case SyntaxKind.NamedTupleMember:
90
94
  case SyntaxKind.OptionalType:
91
95
  case SyntaxKind.RestType:
92
- case SyntaxKind.ConditionalType:
93
96
  case SyntaxKind.InferType:
94
97
  case SyntaxKind.MappedType:
95
98
  case SyntaxKind.ImportType:
@@ -270,3 +273,11 @@ async function templateLiteralTypeSpan(node: TemplateLiteralTypeSpan, context: S
270
273
  async function thisType(node: ThisTypeNode, context: SchemaExtractorContext) {
271
274
  return new ThisTypeSchema(context.getLocation(node));
272
275
  }
276
+
277
+ async function conditionalType(node: ConditionalTypeNode, context: SchemaExtractorContext) {
278
+ const checkType = await typeNodeToSchema(node.checkType, context);
279
+ const extendsType = await typeNodeToSchema(node.extendsType, context);
280
+ const trueType = await typeNodeToSchema(node.trueType, context);
281
+ const falseType = await typeNodeToSchema(node.falseType, context);
282
+ return new ConditionalTypeSchema(context.getLocation(node), checkType, extendsType, trueType, falseType);
283
+ }
@@ -30,16 +30,16 @@ export class VariableDeclaration implements SchemaTransformer {
30
30
  const info = await context.getQuickInfo(varDec.name);
31
31
  const displaySig = info?.body?.displayString || '';
32
32
  const location = context.getLocation(varDec);
33
+ const doc = await jsDocToDocSchema(varDec, context);
33
34
  if (varDec.initializer?.kind === ts.SyntaxKind.ArrowFunction) {
34
35
  const args = await getParams((varDec.initializer as ArrowFunction).parameters, context);
35
36
  const typeStr = parseReturnTypeFromQuickInfo(info);
36
37
  const returnType = await context.resolveType(varDec, typeStr);
37
38
  const modifiers = varDec.modifiers?.map((modifier) => modifier.getText()) || [];
38
- const doc = await jsDocToDocSchema(varDec, context);
39
39
  return new FunctionLikeSchema(location, name, args, returnType, displaySig, modifiers as Modifier[], doc);
40
40
  }
41
41
  const typeStr = parseTypeFromQuickInfo(info);
42
42
  const type = await context.resolveType(varDec, typeStr);
43
- return new VariableLikeSchema(location, name, displaySig, type, false);
43
+ return new VariableLikeSchema(location, name, displaySig, type, false, doc);
44
44
  }
45
45
  }