@teambit/typescript 0.0.736 → 0.0.739

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 (100) hide show
  1. package/dist/cmds/check-types.cmd.js.map +1 -1
  2. package/dist/cmds/init.cmd.js.map +1 -1
  3. package/dist/compiler-options.js.map +1 -1
  4. package/dist/exceptions/index.js.map +1 -1
  5. package/dist/exceptions/transformer-not-found.d.ts +2 -1
  6. package/dist/exceptions/transformer-not-found.js +3 -2
  7. package/dist/exceptions/transformer-not-found.js.map +1 -1
  8. package/dist/export-identifier.js.map +1 -1
  9. package/dist/export-list.js.map +1 -1
  10. package/dist/index.js.map +1 -1
  11. package/dist/schema-extractor-context.d.ts +6 -2
  12. package/dist/schema-extractor-context.js +35 -8
  13. package/dist/schema-extractor-context.js.map +1 -1
  14. package/dist/schema-transformer.js.map +1 -1
  15. package/dist/schema-transformer.plugin.js.map +1 -1
  16. package/dist/transformers/class-deceleration.js +11 -3
  17. package/dist/transformers/class-deceleration.js.map +1 -1
  18. package/dist/transformers/constructor.js +1 -1
  19. package/dist/transformers/constructor.js.map +1 -1
  20. package/dist/transformers/enum-declaration.d.ts +10 -0
  21. package/dist/transformers/enum-declaration.js +60 -0
  22. package/dist/transformers/enum-declaration.js.map +1 -0
  23. package/dist/transformers/export-declaration.js +1 -1
  24. package/dist/transformers/export-declaration.js.map +1 -1
  25. package/dist/transformers/function-declaration.js.map +1 -1
  26. package/dist/transformers/index-signature.js +1 -1
  27. package/dist/transformers/index-signature.js.map +1 -1
  28. package/dist/transformers/index.d.ts +1 -0
  29. package/dist/transformers/index.js +16 -0
  30. package/dist/transformers/index.js.map +1 -1
  31. package/dist/transformers/interface-declaration.js +1 -1
  32. package/dist/transformers/interface-declaration.js.map +1 -1
  33. package/dist/transformers/literal-type.d.ts +2 -1
  34. package/dist/transformers/literal-type.js +2 -2
  35. package/dist/transformers/literal-type.js.map +1 -1
  36. package/dist/transformers/method-declaration.js.map +1 -1
  37. package/dist/transformers/method-signature.js.map +1 -1
  38. package/dist/transformers/property-declaration.js +1 -1
  39. package/dist/transformers/property-declaration.js.map +1 -1
  40. package/dist/transformers/property-signature.js +1 -1
  41. package/dist/transformers/property-signature.js.map +1 -1
  42. package/dist/transformers/source-file-transformer.js +1 -1
  43. package/dist/transformers/source-file-transformer.js.map +1 -1
  44. package/dist/transformers/type-alias.js +1 -1
  45. package/dist/transformers/type-alias.js.map +1 -1
  46. package/dist/transformers/utils/get-params.js +54 -4
  47. package/dist/transformers/utils/get-params.js.map +1 -1
  48. package/dist/transformers/utils/parse-type-from-quick-info.d.ts +1 -0
  49. package/dist/transformers/utils/parse-type-from-quick-info.js +12 -3
  50. package/dist/transformers/utils/parse-type-from-quick-info.js.map +1 -1
  51. package/dist/transformers/utils/to-function-schema.js +2 -2
  52. package/dist/transformers/utils/to-function-schema.js.map +1 -1
  53. package/dist/transformers/utils/type-node-to-schema.js +51 -14
  54. package/dist/transformers/utils/type-node-to-schema.js.map +1 -1
  55. package/dist/transformers/variable-declaration.js +3 -3
  56. package/dist/transformers/variable-declaration.js.map +1 -1
  57. package/dist/transformers/variable-statement.js +2 -3
  58. package/dist/transformers/variable-statement.js.map +1 -1
  59. package/dist/typescript.aspect.js.map +1 -1
  60. package/dist/typescript.compiler.js.map +1 -1
  61. package/dist/typescript.compiler.spec.js.map +1 -1
  62. package/dist/typescript.composition.js.map +1 -1
  63. package/dist/typescript.extractor.d.ts +7 -1
  64. package/dist/typescript.extractor.js +33 -12
  65. package/dist/typescript.extractor.js.map +1 -1
  66. package/dist/typescript.main.runtime.d.ts +11 -2
  67. package/dist/typescript.main.runtime.js +17 -6
  68. package/dist/typescript.main.runtime.js.map +1 -1
  69. package/dist/typescript.parser.d.ts +2 -2
  70. package/dist/typescript.parser.js +4 -4
  71. package/dist/typescript.parser.js.map +1 -1
  72. package/dist/typescript.parser.spec.js.map +1 -1
  73. package/exceptions/transformer-not-found.ts +4 -2
  74. package/package-tar/teambit-typescript-0.0.739.tgz +0 -0
  75. package/package.json +12 -11
  76. package/{preview-1652844422371.js → preview-1653362849981.js} +2 -2
  77. package/transformers/class-deceleration.ts +6 -3
  78. package/transformers/constructor.ts +1 -1
  79. package/transformers/enum-declaration.ts +20 -0
  80. package/transformers/export-declaration.ts +1 -1
  81. package/transformers/index-signature.ts +1 -1
  82. package/transformers/index.ts +1 -0
  83. package/transformers/interface-declaration.ts +1 -1
  84. package/transformers/literal-type.ts +3 -2
  85. package/transformers/property-declaration.ts +1 -1
  86. package/transformers/property-signature.ts +1 -1
  87. package/transformers/source-file-transformer.ts +1 -1
  88. package/transformers/type-alias.ts +1 -1
  89. package/transformers/utils/get-params.ts +54 -6
  90. package/transformers/utils/parse-type-from-quick-info.ts +9 -1
  91. package/transformers/utils/to-function-schema.ts +2 -2
  92. package/transformers/utils/type-node-to-schema.ts +53 -14
  93. package/transformers/variable-declaration.ts +3 -3
  94. package/transformers/variable-statement.ts +1 -2
  95. package/tsconfig.json +1 -1
  96. package/dist/transformers/export-declaration-type.d.ts +0 -0
  97. package/dist/transformers/export-declaration-type.js +0 -3
  98. package/dist/transformers/export-declaration-type.js.map +0 -1
  99. package/package-tar/teambit-typescript-0.0.736.tgz +0 -0
  100. package/transformers/export-declaration-type.ts +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["check-types.cmd.ts"],"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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGO,MAAMA,aAAN,CAAuC;AAU5CC,EAAAA,WAAW,CAASC,UAAT,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AG,GAAI,4BAA2BD,GAAG,GAAG,IAAK,OAAnD;AACAP,IAAAA,QAAQ,CAACS,YAAT;;AACA,QAAIT,QAAQ,CAACU,eAAT,CAAyBf,MAA7B,EAAqC;AACnC,aAAO;AACLgB,QAAAA,IAAI,EAAErB,MAAM,GAAG,CAAH,GAAO,CADd;AAELsB,QAAAA,IAAI,EAAEC,iBAAMC,GAAN,CAAW,GAAEN,GAAI,qBAAoBR,QAAQ,CAACU,eAAT,CAAyBf,MAAO,SAArE;AAFD,OAAP;AAID;;AACD,WAAO;AACLgB,MAAAA,IAAI,EAAE,CADD;AAELC,MAAAA,IAAI,EAAEC,iBAAME,KAAN,CAAa,GAAEP,GAAI,yBAAnB;AAFD,KAAP;AAID;;AAnC2C","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"]}
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,2DAAb,CADQ,EAER,CAAC,EAAD,EAAK,QAAL,EAAe,wCAAf,CAFQ,CAK4F;EAAE;;EAE5F,MAANC,MAAM,CAAC,CAACC,WAAD,CAAD,EAA0B;IAAEC,GAAG,GAAG,KAAR;IAAeC,MAAM,GAAG;EAAxB,CAA1B,EAA8F;IACxG,IAAI,CAAC,KAAKL,SAAV,EAAqB,MAAM,KAAIM,8BAAJ,GAAN;IACrB,MAAMC,UAAU,GAAG,MAAM,KAAKP,SAAL,CAAeQ,wBAAf,CAAwCJ,GAAxC,EAA6CD,WAA7C,CAAzB;IACA,KAAKF,MAAL,CAAYQ,aAAZ,CAA2B,sBAAqBF,UAAU,CAACG,MAAO,aAAlE;IACA,MAAMC,KAAK,GAAG,KAAKZ,UAAL,CAAgBa,4BAAhB,CAA6CL,UAA7C,CAAd;IACA,MAAM,KAAKR,UAAL,CAAgBc,+BAAhB,CAAgD;MAAEC,eAAe,EAAE;IAAnB,CAAhD,EAA2EH,KAA3E,CAAN;IACA,MAAMI,QAAQ,GAAG,KAAKhB,UAAL,CAAgBiB,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;;AAnC2C"}
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
1
+ {"version":3,"names":[],"sources":["init.cmd.ts"],"sourcesContent":[""],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
1
+ {"version":3,"names":[],"sources":["compiler-options.ts"],"sourcesContent":["import type { CompilerOptions } from '@teambit/compiler';\n\nexport type TypeScriptCompilerOptions = {\n /**\n * tsconfig to use during compilation.\n */\n tsconfig: Record<string, any>;\n\n /**\n * path for .d.ts files to include during build.\n */\n types: string[];\n\n /**\n * Run the compiler for .js files. this will only affect whether to run the compiler on the files\n * or not. It won't change the tsconfig to support or not support js files.\n */\n compileJs?: boolean;\n\n /**\n * Run the compiler for .js files. this will only affect whether to run the compiler on the files\n * or not. It won't change the tsconfig to support or not support jsx files.\n */\n compileJsx?: boolean;\n} & Partial<CompilerOptions>;\n\nexport type TsCompilerOptionsWithoutTsConfig = Omit<TypeScriptCompilerOptions, 'tsconfig'>;\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA","sourcesContent":["export { TransformerNotFound } from './transformer-not-found';\n"]}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { TransformerNotFound } from './transformer-not-found';\n"],"mappings":";;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA"}
@@ -1,7 +1,8 @@
1
1
  import { Node } from 'typescript';
2
2
  import { Component } from '@teambit/component';
3
+ import { Location } from '@teambit/semantics.entities.semantic-schema';
3
4
  export declare class TransformerNotFound extends Error {
4
5
  readonly node: Node;
5
6
  readonly component: Component;
6
- constructor(node: Node, component: Component);
7
+ constructor(node: Node, component: Component, location: Location);
7
8
  }
@@ -18,9 +18,10 @@ function _typescript() {
18
18
  }
19
19
 
20
20
  class TransformerNotFound extends Error {
21
- constructor(node, component) {
21
+ constructor(node, component, location) {
22
22
  super(`typescript: could not find schema transformer for node of kind ${node.kind} (${_typescript().default.SyntaxKind[node.kind]}) in component ${component.id.toString()}.
23
- node text: ${node.getText()}`);
23
+ location: ${location.file}, line: ${location.line}, character: ${location.character}.
24
+ node-text: ${node.getText()}`);
24
25
  this.node = node;
25
26
  this.component = component;
26
27
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["transformer-not-found.ts"],"names":["TransformerNotFound","Error","constructor","node","component","kind","ts","SyntaxKind","id","toString","getText"],"mappings":";;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGO,MAAMA,mBAAN,SAAkCC,KAAlC,CAAwC;AAC7CC,EAAAA,WAAW,CAAUC,IAAV,EAA+BC,SAA/B,EAAqD;AAC9D,UACG,kEAAiED,IAAI,CAACE,IAAK,KAC1EC,sBAAGC,UAAH,CAAcJ,IAAI,CAACE,IAAnB,CACD,kBAAiBD,SAAS,CAACI,EAAV,CAAaC,QAAb,EAAwB;AAChD,aAAaN,IAAI,CAACO,OAAL,EAAe,EAJxB;AAD8D,SAA3CP,IAA2C,GAA3CA,IAA2C;AAAA,SAAtBC,SAAsB,GAAtBA,SAAsB;AAO/D;;AAR4C","sourcesContent":["import ts, { Node } from 'typescript';\nimport { Component } from '@teambit/component';\n\nexport class TransformerNotFound extends Error {\n constructor(readonly node: Node, readonly component: Component) {\n super(\n `typescript: could not find schema transformer for node of kind ${node.kind} (${\n ts.SyntaxKind[node.kind]\n }) in component ${component.id.toString()}.\nnode text: ${node.getText()}`\n );\n }\n}\n"]}
1
+ {"version":3,"names":["TransformerNotFound","Error","constructor","node","component","location","kind","ts","SyntaxKind","id","toString","file","line","character","getText"],"sources":["transformer-not-found.ts"],"sourcesContent":["import ts, { Node } from 'typescript';\nimport { Component } from '@teambit/component';\nimport { Location } from '@teambit/semantics.entities.semantic-schema';\n\nexport class TransformerNotFound extends Error {\n constructor(readonly node: Node, readonly component: Component, location: Location) {\n super(\n `typescript: could not find schema transformer for node of kind ${node.kind} (${\n ts.SyntaxKind[node.kind]\n }) in component ${component.id.toString()}.\nlocation: ${location.file}, line: ${location.line}, character: ${location.character}.\nnode-text: ${node.getText()}`\n );\n }\n}\n"],"mappings":";;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAIO,MAAMA,mBAAN,SAAkCC,KAAlC,CAAwC;EAC7CC,WAAW,CAAUC,IAAV,EAA+BC,SAA/B,EAAqDC,QAArD,EAAyE;IAClF,MACG,kEAAiEF,IAAI,CAACG,IAAK,KAC1EC,qBAAA,CAAGC,UAAH,CAAcL,IAAI,CAACG,IAAnB,CACD,kBAAiBF,SAAS,CAACK,EAAV,CAAaC,QAAb,EAAwB;AAChD,aAAaL,QAAQ,CAACM,IAAK,WAAUN,QAAQ,CAACO,IAAK,gBAAeP,QAAQ,CAACQ,SAAU;AACrF,aAAaV,IAAI,CAACW,OAAL,EAAe,EALxB;IADkF,KAA/DX,IAA+D,GAA/DA,IAA+D;IAAA,KAA1CC,SAA0C,GAA1CA,SAA0C;EAQnF;;AAT4C"}
@@ -1 +1 @@
1
- {"version":3,"sources":["export-identifier.ts"],"names":["ExportIdentifier","constructor","id","filePath"],"mappings":";;;;;;;AAAO,MAAMA,gBAAN,CAAuB;AAC5BC,EAAAA,WAAW,CAAUC,EAAV,EAA+BC,QAA/B,EAAiD;AAAA,SAAvCD,EAAuC,GAAvCA,EAAuC;AAAA,SAAlBC,QAAkB,GAAlBA,QAAkB;AAAE;;AADlC","sourcesContent":["export class ExportIdentifier {\n constructor(readonly id: string, readonly filePath: string) {}\n}\n"]}
1
+ {"version":3,"names":["ExportIdentifier","constructor","id","filePath"],"sources":["export-identifier.ts"],"sourcesContent":["export class ExportIdentifier {\n constructor(readonly id: string, readonly filePath: string) {}\n}\n"],"mappings":";;;;;;;AAAO,MAAMA,gBAAN,CAAuB;EAC5BC,WAAW,CAAUC,EAAV,EAA+BC,QAA/B,EAAiD;IAAA,KAAvCD,EAAuC,GAAvCA,EAAuC;IAAA,KAAlBC,QAAkB,GAAlBA,QAAkB;EAAE;;AADlC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["export-list.ts"],"names":["ExportList","constructor","exports","includes","id","Boolean","find","exportId"],"mappings":";;;;;;;AAEO,MAAMA,UAAN,CAAiB;AACtBC,EAAAA,WAAW,CAAUC,OAAV,EAAuC;AAAA,SAA7BA,OAA6B,GAA7BA,OAA6B;AAAE;;AAEpDC,EAAAA,QAAQ,CAACC,EAAD,EAAa;AACnB,WAAOC,OAAO,CAAC,KAAKH,OAAL,CAAaI,IAAb,CAAmBC,QAAD,IAAcA,QAAQ,CAACH,EAAT,KAAgBA,EAAhD,CAAD,CAAd;AACD;;AALqB","sourcesContent":["import { ExportIdentifier } from './export-identifier';\n\nexport class ExportList {\n constructor(readonly exports: ExportIdentifier[]) {}\n\n includes(id: string) {\n return Boolean(this.exports.find((exportId) => exportId.id === id));\n }\n}\n"]}
1
+ {"version":3,"names":["ExportList","constructor","exports","includes","id","Boolean","find","exportId"],"sources":["export-list.ts"],"sourcesContent":["import { ExportIdentifier } from './export-identifier';\n\nexport class ExportList {\n constructor(readonly exports: ExportIdentifier[]) {}\n\n includes(id: string) {\n return Boolean(this.exports.find((exportId) => exportId.id === id));\n }\n}\n"],"mappings":";;;;;;;AAEO,MAAMA,UAAN,CAAiB;EACtBC,WAAW,CAAUC,OAAV,EAAuC;IAAA,KAA7BA,OAA6B,GAA7BA,OAA6B;EAAE;;EAEpDC,QAAQ,CAACC,EAAD,EAAa;IACnB,OAAOC,OAAO,CAAC,KAAKH,OAAL,CAAaI,IAAb,CAAmBC,QAAD,IAAcA,QAAQ,CAACH,EAAT,KAAgBA,EAAhD,CAAD,CAAd;EACD;;AALqB"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA","sourcesContent":["export { TypescriptConfigMutator } from '@teambit/typescript.modules.ts-config-mutator';\nexport { TypescriptCompiler } from './typescript.compiler';\nexport type { TypescriptMain, TsConfigTransformer } from './typescript.main.runtime';\nexport type { TypeScriptCompilerOptions, TsCompilerOptionsWithoutTsConfig } from './compiler-options';\nexport { TypescriptAspect } from './typescript.aspect';\n"]}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { TypescriptConfigMutator } from '@teambit/typescript.modules.ts-config-mutator';\nexport { TypescriptCompiler } from './typescript.compiler';\nexport type { TypescriptMain, TsConfigTransformer } from './typescript.main.runtime';\nexport type { TypeScriptCompilerOptions, TsCompilerOptionsWithoutTsConfig } from './compiler-options';\nexport { TypescriptAspect } from './typescript.aspect';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA"}
@@ -3,18 +3,21 @@ import ts, { ExportDeclaration, Node, TypeNode } from 'typescript';
3
3
  import type { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';
4
4
  import { Component } from '@teambit/component';
5
5
  import { SchemaNode, Location } from '@teambit/semantics.entities.semantic-schema';
6
+ import { ComponentDependency } from '@teambit/dependency-resolver';
6
7
  import { TypeScriptExtractor } from './typescript.extractor';
7
8
  import { ExportList } from './export-list';
8
9
  export declare class SchemaExtractorContext {
9
10
  readonly tsserver: TsserverClient;
10
11
  readonly component: Component;
11
12
  readonly extractor: TypeScriptExtractor;
12
- constructor(tsserver: TsserverClient, component: Component, extractor: TypeScriptExtractor);
13
+ readonly componentDeps: ComponentDependency[];
14
+ constructor(tsserver: TsserverClient, component: Component, extractor: TypeScriptExtractor, componentDeps: ComponentDependency[]);
13
15
  computeSchema(node: Node): Promise<SchemaNode>;
14
16
  /**
15
17
  * returns the location of a node in a source file.
16
18
  */
17
- getLocation(node: Node, targetSourceFile?: ts.SourceFile): Location;
19
+ getLocation(node: Node, targetSourceFile?: ts.SourceFile, absolutePath?: boolean): Location;
20
+ getPathRelativeToComponent(filePath: string): string;
18
21
  /**
19
22
  * returns a signature for a node.
20
23
  */
@@ -69,4 +72,5 @@ export declare class SchemaExtractorContext {
69
72
  resolveType(node: Node & {
70
73
  type?: TypeNode;
71
74
  }, typeStr: string, isTypeStrFromQuickInfo?: boolean): Promise<SchemaNode>;
75
+ private getCompIdByPkgName;
72
76
  }
@@ -104,10 +104,11 @@ function _parseTypeFromQuickInfo() {
104
104
  }
105
105
 
106
106
  class SchemaExtractorContext {
107
- constructor(tsserver, component, extractor) {
107
+ constructor(tsserver, component, extractor, componentDeps) {
108
108
  this.tsserver = tsserver;
109
109
  this.component = component;
110
110
  this.extractor = extractor;
111
+ this.componentDeps = componentDeps;
111
112
  (0, _defineProperty2().default)(this, "_exports", undefined);
112
113
  }
113
114
 
@@ -119,17 +120,22 @@ class SchemaExtractorContext {
119
120
  */
120
121
 
121
122
 
122
- getLocation(node, targetSourceFile) {
123
+ getLocation(node, targetSourceFile, absolutePath = false) {
123
124
  const sourceFile = targetSourceFile || node.getSourceFile();
124
125
  const position = sourceFile.getLineAndCharacterOfPosition(node.getStart());
125
126
  const line = position.line + 1;
126
127
  const character = position.character + 1;
127
128
  return {
128
- file: sourceFile.fileName,
129
+ file: absolutePath ? sourceFile.fileName : this.getPathRelativeToComponent(sourceFile.fileName),
129
130
  line,
130
131
  character
131
132
  };
132
133
  }
134
+
135
+ getPathRelativeToComponent(filePath) {
136
+ const basePath = this.component.filesystem.files[0].base;
137
+ return (0, _path().relative)(basePath, filePath);
138
+ }
133
139
  /**
134
140
  * returns a signature for a node.
135
141
  */
@@ -346,7 +352,11 @@ class SchemaExtractorContext {
346
352
  async resolveType(node, typeStr, isTypeStrFromQuickInfo = true) {
347
353
  var _this$_exports;
348
354
 
349
- if ((_this$_exports = this._exports) !== null && _this$_exports !== void 0 && _this$_exports.includes(typeStr)) return new (_semanticsEntities().TypeRefSchema)(typeStr);
355
+ const location = this.getLocation(node);
356
+
357
+ if ((_this$_exports = this._exports) !== null && _this$_exports !== void 0 && _this$_exports.includes(typeStr)) {
358
+ return new (_semanticsEntities().TypeRefSchema)(location, typeStr);
359
+ }
350
360
 
351
361
  if (node.type && _typescript().default.isTypeNode(node.type)) {
352
362
  // if a node has "type" prop, it has the type data of the node. this normally happens when the code has the type
@@ -378,12 +388,12 @@ class SchemaExtractorContext {
378
388
 
379
389
  const unknownExactType = async () => {
380
390
  if (isTypeStrFromQuickInfo) {
381
- return new (_semanticsEntities().InferenceTypeSchema)(typeStr);
391
+ return new (_semanticsEntities().InferenceTypeSchema)(location, typeStr);
382
392
  }
383
393
 
384
394
  const info = await this.getQuickInfo(node);
385
395
  const type = (0, _parseTypeFromQuickInfo().parseTypeFromQuickInfo)(info);
386
- return new (_semanticsEntities().InferenceTypeSchema)(type);
396
+ return new (_semanticsEntities().InferenceTypeSchema)(location, type);
387
397
  };
388
398
 
389
399
  if (!definition) {
@@ -411,9 +421,26 @@ class SchemaExtractorContext {
411
421
  return schemaNode || unknownExactType();
412
422
  }
413
423
 
414
- const pkgName = this.parsePackageNameFromPath(definition.file); // TODO: find component id is exists, otherwise add the package name.
424
+ const compIdByPath = await this.extractor.getComponentIDByPath(definition.file);
425
+
426
+ if (compIdByPath) {
427
+ return new (_semanticsEntities().TypeRefSchema)(location, typeStr, compIdByPath);
428
+ }
429
+
430
+ const pkgName = this.parsePackageNameFromPath(definition.file);
431
+ const compIdByPkg = this.getCompIdByPkgName(pkgName);
432
+
433
+ if (compIdByPkg) {
434
+ return new (_semanticsEntities().TypeRefSchema)(location, typeStr, compIdByPkg);
435
+ }
436
+
437
+ return new (_semanticsEntities().TypeRefSchema)(location, typeStr, undefined, pkgName);
438
+ }
439
+
440
+ getCompIdByPkgName(pkgName) {
441
+ var _this$componentDeps$f;
415
442
 
416
- return new (_semanticsEntities().TypeRefSchema)(typeStr, undefined, pkgName);
443
+ return (_this$componentDeps$f = this.componentDeps.find(dep => dep.packageName === pkgName)) === null || _this$componentDeps$f === void 0 ? void 0 : _this$componentDeps$f.componentId;
417
444
  }
418
445
 
419
446
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["schema-extractor-context.ts"],"names":["SchemaExtractorContext","constructor","tsserver","component","extractor","undefined","computeSchema","node","getLocation","targetSourceFile","sourceFile","getSourceFile","position","getLineAndCharacterOfPosition","getStart","line","character","file","fileName","getSignature","getSignatureHelp","getPath","getPosition","offset","getPositionOfLineAndCharacter","getQuickInfo","getQuickInfoDisplayString","quickInfo","body","displayString","typeDefinition","getTypeDefinition","visitTypeDefinition","findFileInComponent","filePath","filesystem","files","find","path","includes","strings","map","format","endsWith","string","parsePackageNameFromPath","parts","split","length","lastPart","replace","sep","pkgParts","startsWith","pkgName","parseSourceFile","getSourceFileFromNode","def","getDefinition","firstDef","definition","startPosition","start","pos","nodeAtPos","visitDefinition","visit","parent","references","isExported","isFromComponent","getFileExports","exportDec","specifierPathStr","moduleSpecifier","getText","specifierPath","substring","absPath","computeExportedIdentifiers","setExports","exports","_exports","getExportedIdentifiers","jump","err","TransformerNotFound","resolveType","typeStr","isTypeStrFromQuickInfo","TypeRefSchema","type","ts","isTypeNode","getDef","headTypeDefinition","unknownExactType","InferenceTypeSchema","info","isDefInSameLocation","loc","schemaNode"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,sBAAN,CAA6B;AAClCC,EAAAA,WAAW,CACAC,QADA,EAEAC,SAFA,EAGAC,SAHA,EAIT;AAAA,SAHSF,QAGT,GAHSA,QAGT;AAAA,SAFSC,SAET,GAFSA,SAET;AAAA,SADSC,SACT,GADSA,SACT;AAAA,sDAkLiCC,SAlLjC;AAAE;;AAEJC,EAAAA,aAAa,CAACC,IAAD,EAAa;AACxB,WAAO,KAAKH,SAAL,CAAeE,aAAf,CAA6BC,IAA7B,EAAmC,IAAnC,CAAP;AACD;AAED;AACF;AACA;;;AACEC,EAAAA,WAAW,CAACD,IAAD,EAAaE,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KAAKzE,YAAL,CAAkBlB,IAAlB,CAAnB;AACA,YAAMoF,IAAI,GAAG,sDAAuBO,IAAvB,CAAb;AACA,aAAO,KAAID,wCAAJ,EAAwBN,IAAxB,CAAP;AACD,KAPD;;AAQA,QAAI,CAAC/B,UAAL,EAAiB;AACf,aAAOoC,gBAAgB,EAAvB;AACD,KApCoB,CAsCrB;;;AACA,UAAMG,mBAAmB,GAAG,MAAM;AAChC,UAAIvC,UAAU,CAAC3C,IAAX,KAAoBV,IAAI,CAACI,aAAL,GAAqBO,QAA7C,EAAuD;AACrD,eAAO,KAAP;AACD;;AACD,YAAMkF,GAAG,GAAG,KAAK5F,WAAL,CAAiBD,IAAjB,CAAZ;AACA,aAAO6F,GAAG,CAACrF,IAAJ,KAAa6C,UAAU,CAACE,KAAX,CAAiB/C,IAA9B,IAAsCqF,GAAG,CAACpF,SAAJ,KAAkB4C,UAAU,CAACE,KAAX,CAAiBvC,MAAhF;AACD,KAND;;AAQA,UAAMN,IAAI,GAAG,KAAKgB,mBAAL,CAAyB2B,UAAU,CAAC3C,IAApC,CAAb;;AACA,QAAIA,IAAJ,EAAU;AACR,UAAIkF,mBAAmB,EAAvB,EAA2B;AACzB,eAAOH,gBAAgB,EAAvB;AACD;;AACD,YAAMK,UAAU,GAAG,MAAM,KAAKjB,IAAL,CAAUnE,IAAV,EAAgB2C,UAAU,CAACE,KAA3B,CAAzB;AACA,aAAOuC,UAAU,IAAIL,gBAAgB,EAArC;AACD;;AACD,UAAM1C,OAAO,GAAG,KAAKT,wBAAL,CAA8Be,UAAU,CAAC3C,IAAzC,CAAhB,CAvDqB,CAwDrB;;AACA,WAAO,KAAIyE,kCAAJ,EAAkBF,OAAlB,EAA2BnF,SAA3B,EAAsCiD,OAAtC,CAAP;AACD;;AA7RiC","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 { resolve, sep } from 'path';\nimport { Component } from '@teambit/component';\nimport { TypeRefSchema, SchemaNode, InferenceTypeSchema, Location } from '@teambit/semantics.entities.semantic-schema';\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 ) {}\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): 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\n return {\n file: sourceFile.fileName,\n line,\n character,\n };\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 /**\n * create a reference to a type from a component.\n * think if we don't need this because of type ref\n */\n // createRef() {\n // return {};\n // }\n\n getQuickInfo(node: Node) {\n return this.tsserver.getQuickInfo(this.getPath(node), this.getLocation(node));\n }\n\n async getQuickInfoDisplayString(node: Node): Promise<string> {\n const quickInfo = await this.tsserver.getQuickInfo(this.getPath(node), this.getLocation(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 private getSourceFile(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 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 sourceFile = this.getSourceFile(firstDef.file);\n\n return sourceFile;\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.getSourceFile(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.getSourceFile(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 if (this._exports?.includes(typeStr)) return new TypeRefSchema(typeStr);\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(typeStr);\n }\n const info = await this.getQuickInfo(node);\n const type = parseTypeFromQuickInfo(info);\n return new InferenceTypeSchema(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 const pkgName = this.parsePackageNameFromPath(definition.file);\n // TODO: find component id is exists, otherwise add the package name.\n return new TypeRefSchema(typeStr, undefined, pkgName);\n }\n}\n"]}
1
+ {"version":3,"names":["SchemaExtractorContext","constructor","tsserver","component","extractor","componentDeps","undefined","computeSchema","node","getLocation","targetSourceFile","absolutePath","sourceFile","getSourceFile","position","getLineAndCharacterOfPosition","getStart","line","character","file","fileName","getPathRelativeToComponent","filePath","basePath","filesystem","files","base","relative","getSignature","getSignatureHelp","getPath","getPosition","offset","getPositionOfLineAndCharacter","getQuickInfo","getQuickInfoDisplayString","quickInfo","body","displayString","typeDefinition","getTypeDefinition","visitTypeDefinition","findFileInComponent","find","path","includes","strings","map","format","endsWith","string","parsePackageNameFromPath","parts","split","length","lastPart","replace","sep","pkgParts","startsWith","pkgName","parseSourceFile","getSourceFileFromNode","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","err","TransformerNotFound","resolveType","typeStr","isTypeStrFromQuickInfo","location","TypeRefSchema","type","ts","isTypeNode","typeNodeToSchema","getDef","headTypeDefinition","unknownExactType","InferenceTypeSchema","info","parseTypeFromQuickInfo","isDefInSameLocation","loc","schemaNode","compIdByPath","getComponentIDByPath","compIdByPkg","getCompIdByPkgName","dep","packageName","componentId"],"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 { 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\n return {\n file: absolutePath ? sourceFile.fileName : this.getPathRelativeToComponent(sourceFile.fileName),\n line,\n character,\n };\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 /**\n * create a reference to a type from a component.\n * think if we don't need this because of type ref\n */\n // createRef() {\n // return {};\n // }\n\n getQuickInfo(node: Node) {\n return this.tsserver.getQuickInfo(this.getPath(node), this.getLocation(node));\n }\n\n async getQuickInfoDisplayString(node: Node): Promise<string> {\n const quickInfo = await this.tsserver.getQuickInfo(this.getPath(node), this.getLocation(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 private getSourceFile(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 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 sourceFile = this.getSourceFile(firstDef.file);\n\n return sourceFile;\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.getSourceFile(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.getSourceFile(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);\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 const compIdByPath = await this.extractor.getComponentIDByPath(definition.file);\n if (compIdByPath) {\n return new TypeRefSchema(location, typeStr, compIdByPath);\n }\n const pkgName = this.parsePackageNameFromPath(definition.file);\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 private getCompIdByPkgName(pkgName: string): ComponentID | undefined {\n return this.componentDeps.find((dep) => dep.packageName === pkgName)?.componentId;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;A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WAAJ,EAAiB;MACf,OAAO,KAAIhB,kCAAJ,EAAkBD,QAAlB,EAA4BF,OAA5B,EAAqCmB,WAArC,CAAP;IACD;;IACD,OAAO,KAAIhB,kCAAJ,EAAkBD,QAAlB,EAA4BF,OAA5B,EAAqC3F,SAArC,EAAgDsD,OAAhD,CAAP;EACD;;EAEOyD,kBAAkB,CAACzD,OAAD,EAA2C;IAAA;;IACnE,gCAAO,KAAKvD,aAAL,CAAmBsC,IAAnB,CAAyB2E,GAAD,IAASA,GAAG,CAACC,WAAJ,KAAoB3D,OAArD,CAAP,0DAAO,sBAA+D4D,WAAtE;EACD;;AAjTiC"}
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
1
+ {"version":3,"names":[],"sources":["schema-transformer.ts"],"sourcesContent":["import { Node } from 'typescript';\nimport { SchemaNode } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaExtractorContext } from './schema-extractor-context';\nimport { ExportIdentifier } from './export-identifier';\n\nexport type SchemaTransformer = {\n /**\n * determine whether to apply schema on given node.\n */\n predicate(node: Node): boolean;\n\n getIdentifiers(node: Node, context: SchemaExtractorContext): Promise<ExportIdentifier[]>;\n\n /**\n * transform the node into JSONSchema.\n */\n transform(node: Node, context: SchemaExtractorContext): Promise<SchemaNode>;\n};\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"sources":["schema-transformer.plugin.ts"],"names":["SchemaTransformerPlugin","constructor","schemaTransformerSlot","register","object"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAGO,MAAMA,uBAAN,CAA0D;AAC/DC,EAAAA,WAAW,CAASC,qBAAT,EAAuD;AAAA,SAA9CA,qBAA8C,GAA9CA,qBAA8C;AAAA,qDAExD,sBAFwD;AAAA,sDAIvD,CAAC,MAAD,CAJuD;AAAE;;AAMtD,QAARC,QAAQ,CAACC,MAAD,EAAc;AAC1B,WAAO,KAAKF,qBAAL,CAA2BC,QAA3B,CAAoC,CAACC,MAAD,CAApC,CAAP;AACD;;AAT8D","sourcesContent":["import { PluginDefinition } from '@teambit/aspect-loader';\nimport { SchemaTransformerSlot } from './typescript.main.runtime';\n\nexport class SchemaTransformerPlugin implements PluginDefinition {\n constructor(private schemaTransformerSlot: SchemaTransformerSlot) {}\n\n pattern = '*.schema-extractor.*';\n\n runtimes = ['main'];\n\n async register(object: any) {\n return this.schemaTransformerSlot.register([object]);\n }\n}\n"]}
1
+ {"version":3,"names":["SchemaTransformerPlugin","constructor","schemaTransformerSlot","register","object"],"sources":["schema-transformer.plugin.ts"],"sourcesContent":["import { PluginDefinition } from '@teambit/aspect-loader';\nimport { SchemaTransformerSlot } from './typescript.main.runtime';\n\nexport class SchemaTransformerPlugin implements PluginDefinition {\n constructor(private schemaTransformerSlot: SchemaTransformerSlot) {}\n\n pattern = '*.schema-extractor.*';\n\n runtimes = ['main'];\n\n async register(object: any) {\n return this.schemaTransformerSlot.register([object]);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAGO,MAAMA,uBAAN,CAA0D;EAC/DC,WAAW,CAASC,qBAAT,EAAuD;IAAA,KAA9CA,qBAA8C,GAA9CA,qBAA8C;IAAA,iDAExD,sBAFwD;IAAA,kDAIvD,CAAC,MAAD,CAJuD;EAAE;;EAMtD,MAARC,QAAQ,CAACC,MAAD,EAAc;IAC1B,OAAO,KAAKF,qBAAL,CAA2BC,QAA3B,CAAoC,CAACC,MAAD,CAApC,CAAP;EACD;;AAT8D"}
@@ -40,7 +40,7 @@ function _semanticsEntities() {
40
40
  }
41
41
 
42
42
  function _typescript() {
43
- const data = _interopRequireDefault(require("typescript"));
43
+ const data = _interopRequireWildcard(require("typescript"));
44
44
 
45
45
  _typescript = function () {
46
46
  return data;
@@ -79,6 +79,10 @@ function _getParams() {
79
79
  return data;
80
80
  }
81
81
 
82
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
83
+
84
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
85
+
82
86
  class ClassDecelerationTransformer {
83
87
  predicate(node) {
84
88
  return node.kind === _typescript().default.SyntaxKind.ClassDeclaration;
@@ -106,6 +110,10 @@ class ClassDecelerationTransformer {
106
110
  return null;
107
111
  }
108
112
 
113
+ if ((0, _typescript().isSemicolonClassElement)(member)) {
114
+ return null;
115
+ }
116
+
109
117
  switch (member.kind) {
110
118
  case _typescript().default.SyntaxKind.GetAccessor:
111
119
  {
@@ -116,7 +124,7 @@ class ClassDecelerationTransformer {
116
124
  const displaySig = (info === null || info === void 0 ? void 0 : (_info$body = info.body) === null || _info$body === void 0 ? void 0 : _info$body.displayString) || '';
117
125
  const typeStr = (0, _parseTypeFromQuickInfo().parseTypeFromQuickInfo)(info);
118
126
  const type = await context.resolveType(getter, typeStr);
119
- return new (_semanticsEntities().GetAccessorSchema)(getter.name.getText(), type, displaySig);
127
+ return new (_semanticsEntities().GetAccessorSchema)(context.getLocation(getter), getter.name.getText(), type, displaySig);
120
128
  }
121
129
 
122
130
  case _typescript().default.SyntaxKind.SetAccessor:
@@ -124,7 +132,7 @@ class ClassDecelerationTransformer {
124
132
  const setter = member;
125
133
  const params = await (0, _getParams().getParams)(setter.parameters, context);
126
134
  const displaySig = await context.getQuickInfoDisplayString(setter.name);
127
- return new (_semanticsEntities().SetAccessorSchema)(setter.name.getText(), params[0], displaySig);
135
+ return new (_semanticsEntities().SetAccessorSchema)(context.getLocation(setter), setter.name.getText(), params[0], displaySig);
128
136
  }
129
137
 
130
138
  default:
@@ -1 +1 @@
1
- {"version":3,"sources":["class-deceleration.ts"],"names":["ClassDecelerationTransformer","predicate","node","kind","ts","SyntaxKind","ClassDeclaration","getName","name","getText","getIdentifiers","ExportIdentifier","getSourceFile","fileName","transform","context","className","members","member","isPrivate","modifiers","some","modifier","PrivateKeyword","GetAccessor","getter","info","getQuickInfo","displaySig","body","displayString","typeStr","type","resolveType","GetAccessorSchema","SetAccessor","setter","params","parameters","getQuickInfoDisplayString","SetAccessorSchema","computeSchema","ClassSchema","getLocation"],"mappings":";;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,4BAAN,CAAgE;AACrEC,EAAAA,SAAS,CAACC,IAAD,EAAa;AACpB,WAAOA,IAAI,CAACC,IAAL,KAAcC,sBAAGC,UAAH,CAAcC,gBAAnC;AACD,GAHoE,CAKrE;;;AACQC,EAAAA,OAAO,CAACL,IAAD,EAAyB;AAAA;;AACtC,WAAO,eAAAA,IAAI,CAACM,IAAL,0DAAWC,OAAX,OAAwB,SAA/B;AACD;;AAEmB,QAAdC,cAAc,CAACR,IAAD,EAAyB;AAC3C,WAAO,CAAC,KAAIS,oCAAJ,EAAqB,KAAKJ,OAAL,CAAaL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A6BvB,OAA7B,CAArB;AACA,kBAAMa,UAAU,GAAG,MAAMb,OAAO,CAACwB,yBAAR,CAAkCH,MAAM,CAAC5B,IAAzC,CAAzB;AACA,mBAAO,KAAIgC,sCAAJ,EAAsBJ,MAAM,CAAC5B,IAAP,CAAYC,OAAZ,EAAtB,EAA6C4B,MAAM,CAAC,CAAD,CAAnD,EAAwDT,UAAxD,CAAP;AACD;;AACD;AACE,iBAAOb,OAAO,CAAC0B,aAAR,CAAsBvB,MAAtB,CAAP;AAhBJ;AAkBD,KAvBqB,CAAtB;AAwBA,WAAO,KAAIwB,gCAAJ,EAAgB1B,SAAhB,EAA2B,uBAAQC,OAAR,CAA3B,EAA6CF,OAAO,CAAC4B,WAAR,CAAoBzC,IAApB,CAA7C,CAAP;AACD;;AAzCoE","sourcesContent":["import pMapSeries from 'p-map-series';\nimport { compact } from 'lodash';\nimport { ClassSchema, GetAccessorSchema, SetAccessorSchema } from '@teambit/semantics.entities.semantic-schema';\nimport ts, { Node, ClassDeclaration } from 'typescript';\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 { getParams } from './utils/get-params';\n\nexport class ClassDecelerationTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.ClassDeclaration;\n }\n\n // @todo: in case of `export default class` the class has no name.\n private getName(node: ClassDeclaration) {\n return node.name?.getText() || 'default';\n }\n\n async getIdentifiers(node: ClassDeclaration) {\n return [new ExportIdentifier(this.getName(node), node.getSourceFile().fileName)];\n }\n\n async transform(node: ClassDeclaration, context: SchemaExtractorContext) {\n const className = this.getName(node);\n const members = await pMapSeries(node.members, async (member) => {\n const isPrivate = member.modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.PrivateKeyword);\n if (isPrivate) {\n return null;\n }\n switch (member.kind) {\n case ts.SyntaxKind.GetAccessor: {\n const getter = member as ts.GetAccessorDeclaration;\n const info = await context.getQuickInfo(getter.name);\n const displaySig = info?.body?.displayString || '';\n const typeStr = parseTypeFromQuickInfo(info);\n const type = await context.resolveType(getter, typeStr);\n return new GetAccessorSchema(getter.name.getText(), type, displaySig);\n }\n case ts.SyntaxKind.SetAccessor: {\n const setter = member as ts.SetAccessorDeclaration;\n const params = await getParams(setter.parameters, context);\n const displaySig = await context.getQuickInfoDisplayString(setter.name);\n return new SetAccessorSchema(setter.name.getText(), params[0], displaySig);\n }\n default:\n return context.computeSchema(member);\n }\n });\n return new ClassSchema(className, compact(members), context.getLocation(node));\n }\n}\n"]}
1
+ {"version":3,"names":["ClassDecelerationTransformer","predicate","node","kind","ts","SyntaxKind","ClassDeclaration","getName","name","getText","getIdentifiers","ExportIdentifier","getSourceFile","fileName","transform","context","className","members","pMapSeries","member","isPrivate","modifiers","some","modifier","PrivateKeyword","isSemicolonClassElement","GetAccessor","getter","info","getQuickInfo","displaySig","body","displayString","typeStr","parseTypeFromQuickInfo","type","resolveType","GetAccessorSchema","getLocation","SetAccessor","setter","params","getParams","parameters","getQuickInfoDisplayString","SetAccessorSchema","computeSchema","ClassSchema","compact"],"sources":["class-deceleration.ts"],"sourcesContent":["import pMapSeries from 'p-map-series';\nimport { compact } from 'lodash';\nimport { ClassSchema, GetAccessorSchema, SetAccessorSchema } from '@teambit/semantics.entities.semantic-schema';\nimport ts, { Node, ClassDeclaration, isSemicolonClassElement } from 'typescript';\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 { getParams } from './utils/get-params';\n\nexport class ClassDecelerationTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.ClassDeclaration;\n }\n\n // @todo: in case of `export default class` the class has no name.\n private getName(node: ClassDeclaration) {\n return node.name?.getText() || 'default';\n }\n\n async getIdentifiers(node: ClassDeclaration) {\n return [new ExportIdentifier(this.getName(node), node.getSourceFile().fileName)];\n }\n\n async transform(node: ClassDeclaration, context: SchemaExtractorContext) {\n const className = this.getName(node);\n const members = await pMapSeries(node.members, async (member) => {\n const isPrivate = member.modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.PrivateKeyword);\n if (isPrivate) {\n return null;\n }\n if (isSemicolonClassElement(member)) {\n return null;\n }\n switch (member.kind) {\n case ts.SyntaxKind.GetAccessor: {\n const getter = member as ts.GetAccessorDeclaration;\n const info = await context.getQuickInfo(getter.name);\n const displaySig = info?.body?.displayString || '';\n const typeStr = parseTypeFromQuickInfo(info);\n const type = await context.resolveType(getter, typeStr);\n return new GetAccessorSchema(context.getLocation(getter), getter.name.getText(), type, displaySig);\n }\n case ts.SyntaxKind.SetAccessor: {\n const setter = member as ts.SetAccessorDeclaration;\n const params = await getParams(setter.parameters, context);\n const displaySig = await context.getQuickInfoDisplayString(setter.name);\n return new SetAccessorSchema(context.getLocation(setter), setter.name.getText(), params[0], displaySig);\n }\n default:\n return context.computeSchema(member);\n }\n });\n return new ClassSchema(className, compact(members), context.getLocation(node));\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;;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,4BAAN,CAAgE;EACrEC,SAAS,CAACC,IAAD,EAAa;IACpB,OAAOA,IAAI,CAACC,IAAL,KAAcC,qBAAA,CAAGC,UAAH,CAAcC,gBAAnC;EACD,CAHoE,CAKrE;;;EACQC,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AACqB,WAAR,CAAoBT,MAApB,EAA4BM,OAA5B,CAAnB;YACA,OAAO,KAAII,sCAAJ,EAAsBtB,OAAO,CAACuB,WAAR,CAAoBX,MAApB,CAAtB,EAAmDA,MAAM,CAACnB,IAAP,CAAYC,OAAZ,EAAnD,EAA0E0B,IAA1E,EAAgFL,UAAhF,CAAP;UACD;;QACD,KAAK1B,qBAAA,CAAGC,UAAH,CAAckC,WAAnB;UAAgC;YAC9B,MAAMC,MAAM,GAAGrB,MAAf;YACA,MAAMsB,MAAM,GAAG,MAAM,IAAAC,sBAAA,EAAUF,MAAM,CAACG,UAAjB,EAA6B5B,OAA7B,CAArB;YACA,MAAMe,UAAU,GAAG,MAAMf,OAAO,CAAC6B,yBAAR,CAAkCJ,MAAM,CAAChC,IAAzC,CAAzB;YACA,OAAO,KAAIqC,sCAAJ,EAAsB9B,OAAO,CAACuB,WAAR,CAAoBE,MAApB,CAAtB,EAAmDA,MAAM,CAAChC,IAAP,CAAYC,OAAZ,EAAnD,EAA0EgC,MAAM,CAAC,CAAD,CAAhF,EAAqFX,UAArF,CAAP;UACD;;QACD;UACE,OAAOf,OAAO,CAAC+B,aAAR,CAAsB3B,MAAtB,CAAP;MAhBJ;IAkBD,CA1BqB,CAAtB;IA2BA,OAAO,KAAI4B,gCAAJ,EAAgB/B,SAAhB,EAA2B,IAAAgC,iBAAA,EAAQ/B,OAAR,CAA3B,EAA6CF,OAAO,CAACuB,WAAR,CAAoBpC,IAApB,CAA7C,CAAP;EACD;;AA5CoE"}
@@ -60,7 +60,7 @@ class Constructor {
60
60
 
61
61
  async transform(constructorDec, context) {
62
62
  const args = await (0, _getParams().getParams)(constructorDec.parameters, context);
63
- return new (_semanticsEntities().ConstructorSchema)(args);
63
+ return new (_semanticsEntities().ConstructorSchema)(context.getLocation(constructorDec), args);
64
64
  }
65
65
 
66
66
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["constructor.ts"],"names":["Constructor","predicate","node","kind","ts","SyntaxKind","getIdentifiers","ExportIdentifier","getSourceFile","fileName","transform","constructorDec","context","args","parameters","ConstructorSchema"],"mappings":";;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,WAAN,CAA+C;AACpDC,EAAAA,SAAS,CAACC,IAAD,EAAa;AACpB,WAAOA,IAAI,CAACC,IAAL,KAAcC,sBAAGC,UAAH,CAAcL,WAAnC;AACD;;AAEmB,QAAdM,cAAc,CAACJ,IAAD,EAA+B;AACjD,WAAO,CAAC,KAAIK,oCAAJ,EAAqB,aAArB,EAAoCL,IAAI,CAACM,aAAL,GAAqBC,QAAzD,CAAD,CAAP;AACD;;AAEc,QAATC,SAAS,CAACC,cAAD,EAAyCC,OAAzC,EAA+F;AAC5G,UAAMC,IAAI,GAAG,MAAM,4BAAUF,cAAc,CAACG,UAAzB,EAAqCF,OAArC,CAAnB;AAEA,WAAO,KAAIG,sCAAJ,EAAsBF,IAAtB,CAAP;AACD;;AAbmD","sourcesContent":["import { SchemaNode, ConstructorSchema } from '@teambit/semantics.entities.semantic-schema';\nimport ts, { Node, ConstructorDeclaration } from 'typescript';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { ExportIdentifier } from '../export-identifier';\nimport { getParams } from './utils/get-params';\n\nexport class Constructor implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.Constructor;\n }\n\n async getIdentifiers(node: ConstructorDeclaration) {\n return [new ExportIdentifier('constructor', node.getSourceFile().fileName)];\n }\n\n async transform(constructorDec: ConstructorDeclaration, context: SchemaExtractorContext): Promise<SchemaNode> {\n const args = await getParams(constructorDec.parameters, context);\n\n return new ConstructorSchema(args);\n }\n}\n"]}
1
+ {"version":3,"names":["Constructor","predicate","node","kind","ts","SyntaxKind","getIdentifiers","ExportIdentifier","getSourceFile","fileName","transform","constructorDec","context","args","getParams","parameters","ConstructorSchema","getLocation"],"sources":["constructor.ts"],"sourcesContent":["import { SchemaNode, ConstructorSchema } from '@teambit/semantics.entities.semantic-schema';\nimport ts, { Node, ConstructorDeclaration } from 'typescript';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { ExportIdentifier } from '../export-identifier';\nimport { getParams } from './utils/get-params';\n\nexport class Constructor implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.Constructor;\n }\n\n async getIdentifiers(node: ConstructorDeclaration) {\n return [new ExportIdentifier('constructor', node.getSourceFile().fileName)];\n }\n\n async transform(constructorDec: ConstructorDeclaration, context: SchemaExtractorContext): Promise<SchemaNode> {\n const args = await getParams(constructorDec.parameters, context);\n\n return new ConstructorSchema(context.getLocation(constructorDec), args);\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,WAAN,CAA+C;EACpDC,SAAS,CAACC,IAAD,EAAa;IACpB,OAAOA,IAAI,CAACC,IAAL,KAAcC,qBAAA,CAAGC,UAAH,CAAcL,WAAnC;EACD;;EAEmB,MAAdM,cAAc,CAACJ,IAAD,EAA+B;IACjD,OAAO,CAAC,KAAIK,oCAAJ,EAAqB,aAArB,EAAoCL,IAAI,CAACM,aAAL,GAAqBC,QAAzD,CAAD,CAAP;EACD;;EAEc,MAATC,SAAS,CAACC,cAAD,EAAyCC,OAAzC,EAA+F;IAC5G,MAAMC,IAAI,GAAG,MAAM,IAAAC,sBAAA,EAAUH,cAAc,CAACI,UAAzB,EAAqCH,OAArC,CAAnB;IAEA,OAAO,KAAII,sCAAJ,EAAsBJ,OAAO,CAACK,WAAR,CAAoBN,cAApB,CAAtB,EAA2DE,IAA3D,CAAP;EACD;;AAbmD"}
@@ -0,0 +1,10 @@
1
+ import { Node, EnumDeclaration } from 'typescript';
2
+ import { EnumSchema } from '@teambit/semantics.entities.semantic-schema';
3
+ import { SchemaTransformer } from '../schema-transformer';
4
+ import { SchemaExtractorContext } from '../schema-extractor-context';
5
+ import { ExportIdentifier } from '../export-identifier';
6
+ export declare class EnumDeclarationTransformer implements SchemaTransformer {
7
+ predicate(node: Node): boolean;
8
+ getIdentifiers(node: EnumDeclaration): Promise<ExportIdentifier[]>;
9
+ transform(enumDec: EnumDeclaration, context: SchemaExtractorContext): Promise<EnumSchema>;
10
+ }
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ require("core-js/modules/es.promise.js");
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports.EnumDeclarationTransformer = void 0;
11
+
12
+ function _typescript() {
13
+ const data = _interopRequireDefault(require("typescript"));
14
+
15
+ _typescript = function () {
16
+ return data;
17
+ };
18
+
19
+ return data;
20
+ }
21
+
22
+ function _semanticsEntities() {
23
+ const data = require("@teambit/semantics.entities.semantic-schema");
24
+
25
+ _semanticsEntities = function () {
26
+ return data;
27
+ };
28
+
29
+ return data;
30
+ }
31
+
32
+ function _exportIdentifier() {
33
+ const data = require("../export-identifier");
34
+
35
+ _exportIdentifier = function () {
36
+ return data;
37
+ };
38
+
39
+ return data;
40
+ }
41
+
42
+ class EnumDeclarationTransformer {
43
+ predicate(node) {
44
+ return node.kind === _typescript().default.SyntaxKind.EnumDeclaration;
45
+ }
46
+
47
+ async getIdentifiers(node) {
48
+ return [new (_exportIdentifier().ExportIdentifier)(node.name.getText(), node.getSourceFile().fileName)];
49
+ }
50
+
51
+ async transform(enumDec, context) {
52
+ const members = enumDec.members.map(member => member.name.getText());
53
+ return new (_semanticsEntities().EnumSchema)(context.getLocation(enumDec), enumDec.name.getText(), members);
54
+ }
55
+
56
+ }
57
+
58
+ exports.EnumDeclarationTransformer = EnumDeclarationTransformer;
59
+
60
+ //# sourceMappingURL=enum-declaration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["EnumDeclarationTransformer","predicate","node","kind","ts","SyntaxKind","EnumDeclaration","getIdentifiers","ExportIdentifier","name","getText","getSourceFile","fileName","transform","enumDec","context","members","map","member","EnumSchema","getLocation"],"sources":["enum-declaration.ts"],"sourcesContent":["import ts, { Node, EnumDeclaration } from 'typescript';\nimport { EnumSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\n\nexport class EnumDeclarationTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.EnumDeclaration;\n }\n\n async getIdentifiers(node: EnumDeclaration): Promise<ExportIdentifier[]> {\n return [new ExportIdentifier(node.name.getText(), node.getSourceFile().fileName)];\n }\n\n async transform(enumDec: EnumDeclaration, context: SchemaExtractorContext) {\n const members = enumDec.members.map((member) => member.name.getText());\n return new EnumSchema(context.getLocation(enumDec), enumDec.name.getText(), members);\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;;AAEO,MAAMA,0BAAN,CAA8D;EACnEC,SAAS,CAACC,IAAD,EAAa;IACpB,OAAOA,IAAI,CAACC,IAAL,KAAcC,qBAAA,CAAGC,UAAH,CAAcC,eAAnC;EACD;;EAEmB,MAAdC,cAAc,CAACL,IAAD,EAAqD;IACvE,OAAO,CAAC,KAAIM,oCAAJ,EAAqBN,IAAI,CAACO,IAAL,CAAUC,OAAV,EAArB,EAA0CR,IAAI,CAACS,aAAL,GAAqBC,QAA/D,CAAD,CAAP;EACD;;EAEc,MAATC,SAAS,CAACC,OAAD,EAA2BC,OAA3B,EAA4D;IACzE,MAAMC,OAAO,GAAGF,OAAO,CAACE,OAAR,CAAgBC,GAAhB,CAAqBC,MAAD,IAAYA,MAAM,CAACT,IAAP,CAAYC,OAAZ,EAAhC,CAAhB;IACA,OAAO,KAAIS,+BAAJ,EAAeJ,OAAO,CAACK,WAAR,CAAoBN,OAApB,CAAf,EAA6CA,OAAO,CAACL,IAAR,CAAaC,OAAb,EAA7C,EAAqEM,OAArE,CAAP;EACD;;AAZkE"}
@@ -88,7 +88,7 @@ class ExportDeclaration {
88
88
  const schemas = await Promise.all(exportClause.elements.map(async element => {
89
89
  return context.visitDefinition(element.name);
90
90
  }));
91
- return new (_semanticsEntities().Module)((0, _lodash().compact)(schemas));
91
+ return new (_semanticsEntities().Module)(context.getLocation(node), (0, _lodash().compact)(schemas));
92
92
  } // e.g. `export * as Composition from './button';
93
93
 
94
94
 
@@ -1 +1 @@
1
- {"version":3,"sources":["export-declaration.ts"],"names":["ExportDeclaration","predicate","node","kind","SyntaxKind","getIdentifiers","exportDec","context","exportClause","ts","NamedExports","elements","map","elm","ExportIdentifier","name","getText","getSourceFile","fileName","NamespaceExport","moduleSpecifier","getFileExports","transform","schemas","Promise","all","element","visitDefinition","Module","namespace","sourceFile","getSourceFileFromNode","Error","result","computeSchema","specifier"],"mappings":";;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AASA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;;;AAEO,MAAMA,iBAAN,CAAqD;AAC1DC,EAAAA,SAAS,CAACC,IAAD,EAAa;AACpB,WAAOA,IAAI,CAACC,IAAL,KAA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J,CAAU,0BAAV,CAAN;AACD;;AAnEyD","sourcesContent":["import { SchemaNode, Module } from '@teambit/semantics.entities.semantic-schema';\nimport { compact } from 'lodash';\nimport ts, {\n Node,\n SyntaxKind,\n ExportDeclaration as ExportDeclarationNode,\n NamedExports,\n NamespaceExport,\n} from 'typescript';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { ExportIdentifier } from '../export-identifier';\n\nexport class ExportDeclaration implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === SyntaxKind.ExportDeclaration;\n }\n\n async getIdentifiers(exportDec: ExportDeclarationNode, context: SchemaExtractorContext) {\n if (exportDec.exportClause?.kind === ts.SyntaxKind.NamedExports) {\n exportDec.exportClause as NamedExports;\n return exportDec.exportClause.elements.map((elm) => {\n return new ExportIdentifier(elm.name.getText(), elm.getSourceFile().fileName);\n });\n }\n\n if (exportDec.exportClause?.kind === ts.SyntaxKind.NamespaceExport) {\n return [new ExportIdentifier(exportDec.exportClause.name.getText(), exportDec.getSourceFile().fileName)];\n }\n\n if (exportDec.moduleSpecifier) {\n return context.getFileExports(exportDec);\n }\n\n return [];\n }\n\n async transform(node: Node, context: SchemaExtractorContext): Promise<SchemaNode> {\n const exportDec = node as ExportDeclarationNode;\n const exportClause = exportDec.exportClause;\n // e.g. `export { button1, button2 } as Composition from './button';\n if (exportClause?.kind === SyntaxKind.NamedExports) {\n exportClause as NamedExports;\n const schemas = await Promise.all(\n exportClause.elements.map(async (element) => {\n return context.visitDefinition(element.name);\n })\n );\n\n return new Module(compact(schemas));\n }\n // e.g. `export * as Composition from './button';\n if (exportClause?.kind === SyntaxKind.NamespaceExport) {\n exportClause as NamespaceExport;\n const namespace = exportClause.name.getText();\n const sourceFile = await context.getSourceFileFromNode(exportClause.name);\n if (!sourceFile) {\n throw new Error(`unable to find the source-file for \"${namespace}\"`);\n }\n const result = await context.computeSchema(sourceFile);\n if (!(result instanceof Module)) {\n throw new Error(`expect result to be instance of Module`);\n }\n result.namespace = namespace;\n return result;\n }\n // it's export-all, e.g. `export * from './button'`;\n if (!exportClause) {\n const specifier = exportDec.moduleSpecifier;\n if (!specifier) {\n throw new Error(`fatal: no specifier`);\n }\n const sourceFile = await context.getSourceFileFromNode(specifier);\n if (!sourceFile) {\n throw new Error(`unable to find the source-file`);\n }\n return context.computeSchema(sourceFile);\n }\n\n throw new Error('unrecognized export type');\n }\n}\n"]}
1
+ {"version":3,"names":["ExportDeclaration","predicate","node","kind","SyntaxKind","getIdentifiers","exportDec","context","exportClause","ts","NamedExports","elements","map","elm","ExportIdentifier","name","getText","getSourceFile","fileName","NamespaceExport","moduleSpecifier","getFileExports","transform","schemas","Promise","all","element","visitDefinition","Module","getLocation","compact","namespace","sourceFile","getSourceFileFromNode","Error","result","computeSchema","specifier"],"sources":["export-declaration.ts"],"sourcesContent":["import { SchemaNode, Module } from '@teambit/semantics.entities.semantic-schema';\nimport { compact } from 'lodash';\nimport ts, {\n Node,\n SyntaxKind,\n ExportDeclaration as ExportDeclarationNode,\n NamedExports,\n NamespaceExport,\n} from 'typescript';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { ExportIdentifier } from '../export-identifier';\n\nexport class ExportDeclaration implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === SyntaxKind.ExportDeclaration;\n }\n\n async getIdentifiers(exportDec: ExportDeclarationNode, context: SchemaExtractorContext) {\n if (exportDec.exportClause?.kind === ts.SyntaxKind.NamedExports) {\n exportDec.exportClause as NamedExports;\n return exportDec.exportClause.elements.map((elm) => {\n return new ExportIdentifier(elm.name.getText(), elm.getSourceFile().fileName);\n });\n }\n\n if (exportDec.exportClause?.kind === ts.SyntaxKind.NamespaceExport) {\n return [new ExportIdentifier(exportDec.exportClause.name.getText(), exportDec.getSourceFile().fileName)];\n }\n\n if (exportDec.moduleSpecifier) {\n return context.getFileExports(exportDec);\n }\n\n return [];\n }\n\n async transform(node: Node, context: SchemaExtractorContext): Promise<SchemaNode> {\n const exportDec = node as ExportDeclarationNode;\n const exportClause = exportDec.exportClause;\n // e.g. `export { button1, button2 } as Composition from './button';\n if (exportClause?.kind === SyntaxKind.NamedExports) {\n exportClause as NamedExports;\n const schemas = await Promise.all(\n exportClause.elements.map(async (element) => {\n return context.visitDefinition(element.name);\n })\n );\n\n return new Module(context.getLocation(node), compact(schemas));\n }\n // e.g. `export * as Composition from './button';\n if (exportClause?.kind === SyntaxKind.NamespaceExport) {\n exportClause as NamespaceExport;\n const namespace = exportClause.name.getText();\n const sourceFile = await context.getSourceFileFromNode(exportClause.name);\n if (!sourceFile) {\n throw new Error(`unable to find the source-file for \"${namespace}\"`);\n }\n const result = await context.computeSchema(sourceFile);\n if (!(result instanceof Module)) {\n throw new Error(`expect result to be instance of Module`);\n }\n result.namespace = namespace;\n return result;\n }\n // it's export-all, e.g. `export * from './button'`;\n if (!exportClause) {\n const specifier = exportDec.moduleSpecifier;\n if (!specifier) {\n throw new Error(`fatal: no specifier`);\n }\n const sourceFile = await context.getSourceFileFromNode(specifier);\n if (!sourceFile) {\n throw new Error(`unable to find the source-file`);\n }\n return context.computeSchema(sourceFile);\n }\n\n throw new Error('unrecognized export type');\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;;AASA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;;;;;AAEO,MAAMA,iBAAN,CAAqD;EAC1DC,SAAS,CAACC,IAAD,EAAa;IACpB,OAAOA,IAAI,CAACC,IAAL,KAAcC,wBAAA,CAAWJ,iBAAhC;EACD;;EAEmB,MAAdK,cAAc,CAACC,SAAD,EAAmCC,OAAnC,EAAoE;IAAA;;IACtF,IAAI,0BAAAD,SAAS,CAACE,YAAV,gFAAwBL,IAAxB,MAAiCM,qBAA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unctionDeclaration","predicate","node","kind","ts","SyntaxKind","getIdentifiers","funcDec","ExportIdentifier","getName","getSourceFile","fileName","name","getText","transform","context"],"mappings":";;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,mBAAN,CAAuD;AAC5DC,EAAAA,SAAS,CAACC,IAAD,EAAa;AACpB,WAAOA,IAAI,CAACC,IAAL,KAAcC,sBAAGC,UAAH,CAAcL,mBAAnC;AACD,GAH2D,CAK5D;;;AACoB,QAAdM,cAAc,CAACC,OAAD,EAAmC;AACrD,WAAO,CAAC,KAAIC,oCAAJ,EAAqB,KAAKC,OAAL,CAAaF,OAAb,CAArB,EAA4CA,OAAO,CAACG,aAAR,GAAwBC,QAApE,CAAD,CAAP;AACD;;AAEOF,EAAAA,OAAO,CAACF,OAAD,EAAmC;AAAA;;AAChD,WAAO,kBAAAA,OAAO,CAACK,IAAR,gEAAcC,OAAd,OAA2B,EAAlC;AACD;;AAEc,QAATC,SAAS,CAACP,OAAD,EAAmCQ,OAAnC,EAAyF;AACtG,WAAO,8CAAqBR,OAArB,EAA8BQ,OAA9B,CAAP;AACD;;AAhB2D","sourcesContent":["import { SchemaNode } from '@teambit/semantics.entities.semantic-schema';\nimport ts, { Node, FunctionDeclaration as FunctionDeclarationNode } from 'typescript';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { ExportIdentifier } from '../export-identifier';\nimport { toFunctionLikeSchema } from './utils/to-function-schema';\n\nexport class FunctionDeclaration implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.FunctionDeclaration;\n }\n\n // need to check for anonymous functions assigned for vars, const and let.\n async getIdentifiers(funcDec: FunctionDeclarationNode) {\n return [new ExportIdentifier(this.getName(funcDec), funcDec.getSourceFile().fileName)];\n }\n\n private getName(funcDec: FunctionDeclarationNode) {\n return funcDec.name?.getText() || '';\n }\n\n async transform(funcDec: FunctionDeclarationNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n return toFunctionLikeSchema(funcDec, context);\n }\n}\n"]}
1
+ {"version":3,"names":["FunctionDeclaration","predicate","node","kind","ts","SyntaxKind","getIdentifiers","funcDec","ExportIdentifier","getName","getSourceFile","fileName","name","getText","transform","context","toFunctionLikeSchema"],"sources":["function-declaration.ts"],"sourcesContent":["import { SchemaNode } from '@teambit/semantics.entities.semantic-schema';\nimport ts, { Node, FunctionDeclaration as FunctionDeclarationNode } from 'typescript';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { ExportIdentifier } from '../export-identifier';\nimport { toFunctionLikeSchema } from './utils/to-function-schema';\n\nexport class FunctionDeclaration implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.FunctionDeclaration;\n }\n\n // need to check for anonymous functions assigned for vars, const and let.\n async getIdentifiers(funcDec: FunctionDeclarationNode) {\n return [new ExportIdentifier(this.getName(funcDec), funcDec.getSourceFile().fileName)];\n }\n\n private getName(funcDec: FunctionDeclarationNode) {\n return funcDec.name?.getText() || '';\n }\n\n async transform(funcDec: FunctionDeclarationNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n return toFunctionLikeSchema(funcDec, context);\n }\n}\n"],"mappings":";;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAAMA,mBAAN,CAAuD;EAC5DC,SAAS,CAACC,IAAD,EAAa;IACpB,OAAOA,IAAI,CAACC,IAAL,KAAcC,qBAAA,CAAGC,UAAH,CAAcL,mBAAnC;EACD,CAH2D,CAK5D;;;EACoB,MAAdM,cAAc,CAACC,OAAD,EAAmC;IACrD,OAAO,CAAC,KAAIC,oCAAJ,EAAqB,KAAKC,OAAL,CAAaF,OAAb,CAArB,EAA4CA,OAAO,CAACG,aAAR,GAAwBC,QAApE,CAAD,CAAP;EACD;;EAEOF,OAAO,CAACF,OAAD,EAAmC;IAAA;;IAChD,OAAO,kBAAAA,OAAO,CAACK,IAAR,gEAAcC,OAAd,OAA2B,EAAlC;EACD;;EAEc,MAATC,SAAS,CAACP,OAAD,EAAmCQ,OAAnC,EAAyF;IACtG,OAAO,IAAAC,wCAAA,EAAqBT,OAArB,EAA8BQ,OAA9B,CAAP;EACD;;AAhB2D"}
@@ -61,7 +61,7 @@ class IndexSignature {
61
61
  async transform(indexSig, context) {
62
62
  const params = await (0, _getParams().getParams)(indexSig.parameters, context);
63
63
  const type = await (0, _typeNodeToSchema().typeNodeToSchema)(indexSig.type, context);
64
- return new (_semanticsEntities().IndexSignatureSchema)(params, type);
64
+ return new (_semanticsEntities().IndexSignatureSchema)(context.getLocation(indexSig), params, type);
65
65
  }
66
66
 
67
67
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["index-signature.ts"],"names":["IndexSignature","predicate","node","kind","ts","SyntaxKind","getIdentifiers","transform","indexSig","context","params","parameters","type","IndexSignatureSchema"],"mappings":";;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,cAAN,CAAkD;AACvDC,EAAAA,SAAS,CAACC,IAAD,EAAa;AACpB,WAAOA,IAAI,CAACC,IAAL,KAAcC,sBAAGC,UAAH,CAAcL,cAAnC;AACD;;AAEmB,QAAdM,cAAc,GAAG;AACrB,WAAO,EAAP;AACD;;AAEc,QAATC,SAAS,CAACC,QAAD,EAAsCC,OAAtC,EAA4F;AACzG,UAAMC,MAAM,GAAG,MAAM,4BAAUF,QAAQ,CAACG,UAAnB,EAA+BF,OAA/B,CAArB;AACA,UAAMG,IAAI,GAAG,MAAM,0CAAiBJ,QAAQ,CAACI,IAA1B,EAAgCH,OAAhC,CAAnB;AACA,WAAO,KAAII,yCAAJ,EAAyBH,MAAzB,EAAiCE,IAAjC,CAAP;AACD;;AAbsD","sourcesContent":["import { SchemaNode, IndexSignatureSchema } from '@teambit/semantics.entities.semantic-schema';\nimport ts, { Node, IndexSignatureDeclaration } from 'typescript';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { getParams } from './utils/get-params';\nimport { typeNodeToSchema } from './utils/type-node-to-schema';\n\nexport class IndexSignature implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.IndexSignature;\n }\n\n async getIdentifiers() {\n return [];\n }\n\n async transform(indexSig: IndexSignatureDeclaration, context: SchemaExtractorContext): Promise<SchemaNode> {\n const params = await getParams(indexSig.parameters, context);\n const type = await typeNodeToSchema(indexSig.type, context);\n return new IndexSignatureSchema(params, type);\n }\n}\n"]}
1
+ {"version":3,"names":["IndexSignature","predicate","node","kind","ts","SyntaxKind","getIdentifiers","transform","indexSig","context","params","getParams","parameters","type","typeNodeToSchema","IndexSignatureSchema","getLocation"],"sources":["index-signature.ts"],"sourcesContent":["import { SchemaNode, IndexSignatureSchema } from '@teambit/semantics.entities.semantic-schema';\nimport ts, { Node, IndexSignatureDeclaration } from 'typescript';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { getParams } from './utils/get-params';\nimport { typeNodeToSchema } from './utils/type-node-to-schema';\n\nexport class IndexSignature implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.IndexSignature;\n }\n\n async getIdentifiers() {\n return [];\n }\n\n async transform(indexSig: IndexSignatureDeclaration, context: SchemaExtractorContext): Promise<SchemaNode> {\n const params = await getParams(indexSig.parameters, context);\n const type = await typeNodeToSchema(indexSig.type, context);\n return new IndexSignatureSchema(context.getLocation(indexSig), params, type);\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,cAAN,CAAkD;EACvDC,SAAS,CAACC,IAAD,EAAa;IACpB,OAAOA,IAAI,CAACC,IAAL,KAAcC,qBAAA,CAAGC,UAAH,CAAcL,cAAnC;EACD;;EAEmB,MAAdM,cAAc,GAAG;IACrB,OAAO,EAAP;EACD;;EAEc,MAATC,SAAS,CAACC,QAAD,EAAsCC,OAAtC,EAA4F;IACzG,MAAMC,MAAM,GAAG,MAAM,IAAAC,sBAAA,EAAUH,QAAQ,CAACI,UAAnB,EAA+BH,OAA/B,CAArB;IACA,MAAMI,IAAI,GAAG,MAAM,IAAAC,oCAAA,EAAiBN,QAAQ,CAACK,IAA1B,EAAgCJ,OAAhC,CAAnB;IACA,OAAO,KAAIM,yCAAJ,EAAyBN,OAAO,CAACO,WAAR,CAAoBR,QAApB,CAAzB,EAAwDE,MAAxD,EAAgEG,IAAhE,CAAP;EACD;;AAbsD"}