@teambit/typescript 0.0.735 → 0.0.738

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 (84) 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.js.map +1 -1
  6. package/dist/export-identifier.js.map +1 -1
  7. package/dist/export-list.js.map +1 -1
  8. package/dist/index.js.map +1 -1
  9. package/dist/schema-extractor-context.d.ts +2 -1
  10. package/dist/schema-extractor-context.js +15 -6
  11. package/dist/schema-extractor-context.js.map +1 -1
  12. package/dist/schema-transformer.js.map +1 -1
  13. package/dist/schema-transformer.plugin.js.map +1 -1
  14. package/dist/transformers/class-deceleration.js +2 -2
  15. package/dist/transformers/class-deceleration.js.map +1 -1
  16. package/dist/transformers/constructor.js +1 -1
  17. package/dist/transformers/constructor.js.map +1 -1
  18. package/dist/transformers/export-declaration.js +1 -1
  19. package/dist/transformers/export-declaration.js.map +1 -1
  20. package/dist/transformers/function-declaration.js.map +1 -1
  21. package/dist/transformers/index-signature.js +1 -1
  22. package/dist/transformers/index-signature.js.map +1 -1
  23. package/dist/transformers/index.js.map +1 -1
  24. package/dist/transformers/interface-declaration.js +1 -1
  25. package/dist/transformers/interface-declaration.js.map +1 -1
  26. package/dist/transformers/literal-type.d.ts +2 -1
  27. package/dist/transformers/literal-type.js +2 -2
  28. package/dist/transformers/literal-type.js.map +1 -1
  29. package/dist/transformers/method-declaration.js.map +1 -1
  30. package/dist/transformers/method-signature.js.map +1 -1
  31. package/dist/transformers/property-declaration.js +1 -1
  32. package/dist/transformers/property-declaration.js.map +1 -1
  33. package/dist/transformers/property-signature.js +1 -1
  34. package/dist/transformers/property-signature.js.map +1 -1
  35. package/dist/transformers/source-file-transformer.js +1 -1
  36. package/dist/transformers/source-file-transformer.js.map +1 -1
  37. package/dist/transformers/type-alias.js +1 -1
  38. package/dist/transformers/type-alias.js.map +1 -1
  39. package/dist/transformers/utils/get-params.js +6 -2
  40. package/dist/transformers/utils/get-params.js.map +1 -1
  41. package/dist/transformers/utils/parse-type-from-quick-info.js.map +1 -1
  42. package/dist/transformers/utils/to-function-schema.js +2 -2
  43. package/dist/transformers/utils/to-function-schema.js.map +1 -1
  44. package/dist/transformers/utils/type-node-to-schema.js +17 -10
  45. package/dist/transformers/utils/type-node-to-schema.js.map +1 -1
  46. package/dist/transformers/variable-declaration.js +3 -3
  47. package/dist/transformers/variable-declaration.js.map +1 -1
  48. package/dist/transformers/variable-statement.js +2 -3
  49. package/dist/transformers/variable-statement.js.map +1 -1
  50. package/dist/typescript.aspect.js.map +1 -1
  51. package/dist/typescript.compiler.js.map +1 -1
  52. package/dist/typescript.compiler.spec.js.map +1 -1
  53. package/dist/typescript.composition.js.map +1 -1
  54. package/dist/typescript.extractor.js +3 -3
  55. package/dist/typescript.extractor.js.map +1 -1
  56. package/dist/typescript.main.runtime.js.map +1 -1
  57. package/dist/typescript.parser.d.ts +2 -2
  58. package/dist/typescript.parser.js +4 -4
  59. package/dist/typescript.parser.js.map +1 -1
  60. package/dist/typescript.parser.spec.js.map +1 -1
  61. package/package-tar/teambit-typescript-0.0.738.tgz +0 -0
  62. package/package.json +11 -11
  63. package/{preview-1652808661748.js → preview-1653227849497.js} +2 -2
  64. package/transformers/class-deceleration.ts +2 -2
  65. package/transformers/constructor.ts +1 -1
  66. package/transformers/export-declaration.ts +1 -1
  67. package/transformers/index-signature.ts +1 -1
  68. package/transformers/interface-declaration.ts +1 -1
  69. package/transformers/literal-type.ts +3 -2
  70. package/transformers/property-declaration.ts +1 -1
  71. package/transformers/property-signature.ts +1 -1
  72. package/transformers/source-file-transformer.ts +1 -1
  73. package/transformers/type-alias.ts +1 -1
  74. package/transformers/utils/get-params.ts +5 -1
  75. package/transformers/utils/to-function-schema.ts +2 -2
  76. package/transformers/utils/type-node-to-schema.ts +16 -10
  77. package/transformers/variable-declaration.ts +3 -3
  78. package/transformers/variable-statement.ts +1 -2
  79. package/tsconfig.json +1 -1
  80. package/dist/transformers/export-declaration-type.d.ts +0 -0
  81. package/dist/transformers/export-declaration-type.js +0 -3
  82. package/dist/transformers/export-declaration-type.js.map +0 -1
  83. package/package-tar/teambit-typescript-0.0.735.tgz +0 -0
  84. package/transformers/export-declaration-type.ts +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["source-file-transformer.ts"],"names":["SourceFileTransformer","predicate","node","kind","ts","SyntaxKind","SourceFile","getIdentifiers","sourceFile","context","exports","listExports","exportNames","Promise","all","map","getExportedIdentifiers","exportIds","reduce","acc","current","item","find","exportName","id","push","transform","schemas","exportNode","computeSchema","Module","ast","statements","statement","ExportDeclaration","isExport","Boolean","modifiers","modifier","ExportKeyword"],"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;;AAKO,MAAMA,qBAAN,CAAyD;AAC9DC,EAAAA,SAAS,CAACC,IAAD,EAAa;AACpB,WAAOA,IAAI,CAACC,IAAL,KAAcC,sBAAGC,UAAH,CAAcC,UAAnC;AACD;;AAEmB,QAAdC,cAAc,CAACC,UAAD,EAAyBC,OAAzB,EAA0D;AAC5E,UAAMC,OAAO,GAAG,KAAKC,WAAL,CAAiBH,UAAjB,CAAhB;AAEA,UAAMI,WAAW,GAAG,MAAMC,OAAO,CAACC,GAAR,CACxBJ,OAAO,CAACK,GAAR,CAAab,IAAD,IAAgB;AAC1B,aAAOO,OAAO,CAACO,sBAAR,CAA+Bd,IAA/B,CAAP;AACD,KAFD,CADwB,CAA1B;AAMA,UAAMe,SAAS,GAAG,uBAAQL,WAAR,EAAqBM,MAArB,CAAgD,CAACC,GAAD,EAAMC,OAAN,KAAkB;AAClF,YAAMC,IAAI,GAAGF,GAAG,CAACG,IAAJ,CAAUC,UAAD,IAAgBA,UAAU,CAACC,EAAX,KAAkBJ,OAAO,CAACI,EAAnD,CAAb;AACA,UAAI,CAACH,IAAL,EAAWF,GAAG,CAACM,IAAJ,CAASL,OAAT;AACX,aAAOD,GAAP;AACD,KAJiB,EAIf,EAJe,CAAlB;AAMA,WAAOF,SAAP;AACD;;AAEc,QAATS,SAAS,CAACxB,IAAD,EAAmBO,OAAnB,EAAoD;AACjE,UAAMC,OAAO,GAAG,KAAKC,WAAL,CAAiBT,IAAjB,CAAhB;AACA,UAAMyB,OAAO,GAAG,MAAM,2BAAWjB,OAAX,EAAqBkB,UAAD,IAAgB;AACxD,aAAOnB,OAAO,CAACoB,aAAR,CAAsBD,UAAtB,CAAP;AACD,KAFqB,CAAtB;AAIA,WAAO,KAAIE,2BAAJ,EAAWH,OAAX,CAAP;AACD;AAED;AACF;AACA;;;AACUhB,EAAAA,WAAW,CAACoB,GAAD,EAA0B;AAC3C,WAAO,uBACLA,GAAG,CAACC,UAAJ,CAAejB,GAAf,CAAoBkB,SAAD,IAAe;AAAA;;AAChC,UAAIA,SAAS,CAAC9B,IAAV,KAAmBC,sBAAGC,UAAH,CAAc6B,iBAArC,EAAwD,OAAOD,SAAP;AACxD,YAAME,QAAQ,GAAGC,OAAO,yBACtBH,SAAS,CAACI,SADY,yDACtB,qBAAqBf,IAArB,CAA2BgB,QAAD,IAAc;AACtC,eAAOA,QAAQ,CAACnC,IAAT,KAAkBC,sBAAGC,UAAH,CAAckC,aAAvC;AACD,OAFD,CADsB,CAAxB,CAFgC,CAQhC;;AACA,UAAI,CAACJ,QAAL,EAAe;AACf,aAAOF,SAAP;AACD,KAXD,CADK,CAAP;AAcD;;AAlD6D","sourcesContent":["import ts, { Node, SourceFile } from 'typescript';\nimport { compact, flatten } from 'lodash';\nimport pMapSeries from 'p-map-series';\nimport { Module } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { ExportIdentifier } from '../export-identifier';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\n\nexport class SourceFileTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.SourceFile;\n }\n\n async getIdentifiers(sourceFile: SourceFile, context: SchemaExtractorContext) {\n const exports = this.listExports(sourceFile);\n\n const exportNames = await Promise.all(\n exports.map((node: Node) => {\n return context.getExportedIdentifiers(node);\n })\n );\n\n const exportIds = flatten(exportNames).reduce<ExportIdentifier[]>((acc, current) => {\n const item = acc.find((exportName) => exportName.id === current.id);\n if (!item) acc.push(current);\n return acc;\n }, []);\n\n return exportIds;\n }\n\n async transform(node: SourceFile, context: SchemaExtractorContext) {\n const exports = this.listExports(node);\n const schemas = await pMapSeries(exports, (exportNode) => {\n return context.computeSchema(exportNode);\n });\n\n return new Module(schemas);\n }\n\n /**\n * list all exports of a source file.\n */\n private listExports(ast: SourceFile): Node[] {\n return compact(\n ast.statements.map((statement) => {\n if (statement.kind === ts.SyntaxKind.ExportDeclaration) return statement;\n const isExport = Boolean(\n statement.modifiers?.find((modifier) => {\n return modifier.kind === ts.SyntaxKind.ExportKeyword;\n })\n );\n\n // eslint-disable-next-line consistent-return\n if (!isExport) return;\n return statement;\n })\n );\n }\n}\n"]}
1
+ {"version":3,"names":["SourceFileTransformer","predicate","node","kind","ts","SyntaxKind","SourceFile","getIdentifiers","sourceFile","context","exports","listExports","exportNames","Promise","all","map","getExportedIdentifiers","exportIds","flatten","reduce","acc","current","item","find","exportName","id","push","transform","schemas","pMapSeries","exportNode","computeSchema","Module","getLocation","ast","compact","statements","statement","ExportDeclaration","isExport","Boolean","modifiers","modifier","ExportKeyword"],"sources":["source-file-transformer.ts"],"sourcesContent":["import ts, { Node, SourceFile } from 'typescript';\nimport { compact, flatten } from 'lodash';\nimport pMapSeries from 'p-map-series';\nimport { Module } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { ExportIdentifier } from '../export-identifier';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\n\nexport class SourceFileTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.SourceFile;\n }\n\n async getIdentifiers(sourceFile: SourceFile, context: SchemaExtractorContext) {\n const exports = this.listExports(sourceFile);\n\n const exportNames = await Promise.all(\n exports.map((node: Node) => {\n return context.getExportedIdentifiers(node);\n })\n );\n\n const exportIds = flatten(exportNames).reduce<ExportIdentifier[]>((acc, current) => {\n const item = acc.find((exportName) => exportName.id === current.id);\n if (!item) acc.push(current);\n return acc;\n }, []);\n\n return exportIds;\n }\n\n async transform(node: SourceFile, context: SchemaExtractorContext) {\n const exports = this.listExports(node);\n const schemas = await pMapSeries(exports, (exportNode) => {\n return context.computeSchema(exportNode);\n });\n\n return new Module(context.getLocation(node), schemas);\n }\n\n /**\n * list all exports of a source file.\n */\n private listExports(ast: SourceFile): Node[] {\n return compact(\n ast.statements.map((statement) => {\n if (statement.kind === ts.SyntaxKind.ExportDeclaration) return statement;\n const isExport = Boolean(\n statement.modifiers?.find((modifier) => {\n return modifier.kind === ts.SyntaxKind.ExportKeyword;\n })\n );\n\n // eslint-disable-next-line consistent-return\n if (!isExport) return;\n return statement;\n })\n );\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;;AAKO,MAAMA,qBAAN,CAAyD;EAC9DC,SAAS,CAACC,IAAD,EAAa;IACpB,OAAOA,IAAI,CAACC,IAAL,KAAcC,qBAAA,CAAGC,UAAH,CAAcC,UAAnC;EACD;;EAEmB,MAAdC,cAAc,CAACC,UAAD,EAAyBC,OAAzB,EAA0D;IAC5E,MAAMC,OAAO,GAA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BACtBH,SAAS,CAACI,SADY,yDACtB,qBAAqBlB,IAArB,CAA2BmB,QAAD,IAAc;QACtC,OAAOA,QAAQ,CAACvC,IAAT,KAAkBC,qBAAA,CAAGC,UAAH,CAAcsC,aAAvC;MACD,CAFD,CADsB,CAAxB,CAFgC,CAQhC;;MACA,IAAI,CAACJ,QAAL,EAAe;MACf,OAAOF,SAAP;IACD,CAXD,CADK,CAAP;EAcD;;AAlD6D"}
@@ -68,7 +68,7 @@ class TypeAliasTransformer {
68
68
  const type = await (0, _typeNodeToSchema().typeNodeToSchema)(typeAlias.type, context);
69
69
  const info = await context.getQuickInfo(typeAlias.name);
70
70
  const displaySig = info === null || info === void 0 ? void 0 : (_info$body = info.body) === null || _info$body === void 0 ? void 0 : _info$body.displayString;
71
- return new (_semanticsEntities().TypeSchema)(this.getName(typeAlias), type, displaySig);
71
+ return new (_semanticsEntities().TypeSchema)(context.getLocation(typeAlias), this.getName(typeAlias), type, displaySig || '');
72
72
  }
73
73
 
74
74
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["type-alias.ts"],"names":["TypeAliasTransformer","predicate","node","kind","ts","SyntaxKind","TypeAliasDeclaration","getIdentifiers","ExportIdentifier","name","getText","getSourceFile","fileName","getName","transform","typeAlias","context","type","info","getQuickInfo","displaySig","body","displayString","TypeSchema"],"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,oBAAN,CAAwD;AAC7DC,EAAAA,SAAS,CAACC,IAAD,EAAa;AACpB,WAAOA,IAAI,CAACC,IAAL,KAAcC,sBAAGC,UAAH,CAAcC,oBAAnC;AACD;;AAEmB,QAAdC,cAAc,CAACL,IAAD,EAA6B;AAC/C,WAAO,CAAC,KAAIM,oCAAJ,EAAqBN,IAAI,CAACO,IAAL,CAAUC,OAAV,EAArB,EAA0CR,IAAI,CAACS,aAAL,GAAqBC,QAA/D,CAAD,CAAP;AACD;;AAEOC,EAAAA,OAAO,CAACX,IAAD,EAAqC;AAClD,WAAOA,IAAI,CAACO,IAAL,CAAUC,OAAV,EAAP;AACD;;AAEc,QAATI,SAAS,CAACC,SAAD,EAAkCC,OAAlC,EAAmE;AAAA;;AAChF,UAAMC,IAAI,GAAG,MAAM,0CAAiBF,SAAS,CAACE,IAA3B,EAAiCD,OAAjC,CAAnB;AACA,UAAME,IAAI,GAAG,MAAMF,OAAO,CAACG,YAAR,CAAqBJ,SAAS,CAACN,IAA/B,CAAnB;AACA,UAAMW,UAAU,GAAGF,IAAH,aAAGA,IAAH,qCAAGA,IAAI,CAAEG,IAAT,+CAAG,WAAYC,aAA/B;AACA,WAAO,KAAIC,+BAAJ,EAAe,KAAKV,OAAL,CAAaE,SAAb,CAAf,EAAwCE,IAAxC,EAA8CG,UAA9C,CAAP;AACD;;AAlB4D","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 info = await context.getQuickInfo(typeAlias.name);\n const displaySig = info?.body?.displayString;\n return new TypeSchema(this.getName(typeAlias), type, displaySig as string);\n }\n}\n"]}
1
+ {"version":3,"names":["TypeAliasTransformer","predicate","node","kind","ts","SyntaxKind","TypeAliasDeclaration","getIdentifiers","ExportIdentifier","name","getText","getSourceFile","fileName","getName","transform","typeAlias","context","type","typeNodeToSchema","info","getQuickInfo","displaySig","body","displayString","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 info = await context.getQuickInfo(typeAlias.name);\n const displaySig = info?.body?.displayString;\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;IAAA;;IAChF,MAAMC,IAAI,GAAG,MAAM,IAAAC,oCAAA,EAAiBH,SAAS,CAACE,IAA3B,EAAiCD,OAAjC,CAAnB;IACA,MAAMG,IAAI,GAAG,MAAMH,OAAO,CAACI,YAAR,CAAqBL,SAAS,CAACN,IAA/B,CAAnB;IACA,MAAMY,UAAU,GAAGF,IAAH,aAAGA,IAAH,qCAAGA,IAAI,CAAEG,IAAT,+CAAG,WAAYC,aAA/B;IACA,OAAO,KAAIC,+BAAJ,EAAeR,OAAO,CAACS,WAAR,CAAoBV,SAApB,CAAf,EAA+C,KAAKF,OAAL,CAAaE,SAAb,CAA/C,EAAwEE,IAAxE,EAA8EI,UAAU,IAAI,EAA5F,CAAP;EACD;;AAlB4D"}
@@ -51,9 +51,13 @@ function _typeNodeToSchema() {
51
51
 
52
52
  async function getParams(parameterNodes, context) {
53
53
  return (0, _pMapSeries().default)(parameterNodes, async param => {
54
- return new (_semanticsEntities().ParameterSchema)(param.name.getText(), await getParamType(param, context), param.initializer ? param.initializer.getText() : undefined);
54
+ return new (_semanticsEntities().ParameterSchema)(context.getLocation(param), param.name.getText(), await getParamType(param, context), param.initializer ? param.initializer.getText() : undefined);
55
55
  });
56
56
  }
57
+ /**
58
+ * @todo: probably not needed. just call context.resolveType instead.
59
+ */
60
+
57
61
 
58
62
  async function getParamType(param, context) {
59
63
  if (param.type) {
@@ -63,7 +67,7 @@ async function getParamType(param, context) {
63
67
 
64
68
  const info = await context.getQuickInfo(param.name);
65
69
  const parsed = (0, _parseTypeFromQuickInfo().parseTypeFromQuickInfo)(info);
66
- return new (_semanticsEntities().TypeRefSchema)(parsed || 'any');
70
+ return new (_semanticsEntities().TypeRefSchema)(context.getLocation(param), parsed || 'any');
67
71
  }
68
72
 
69
73
  //# sourceMappingURL=get-params.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["get-params.ts"],"names":["getParams","parameterNodes","context","param","ParameterSchema","name","getText","getParamType","initializer","undefined","type","info","getQuickInfo","parsed","TypeRefSchema"],"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,eAAeA,SAAf,CACLC,cADK,EAELC,OAFK,EAGuB;AAC5B,SAAO,2BAAWD,cAAX,EAA2B,MAAOE,KAAP,IAAiB;AACjD,WAAO,KAAIC,oCAAJ,EACLD,KAAK,CAACE,IAAN,CAAWC,OAAX,EADK,EAEL,MAAMC,YAAY,CAACJ,KAAD,EAAQD,OAAR,CAFb,EAGLC,KAAK,CAACK,WAAN,GAAoBL,KAAK,CAACK,WAAN,CAAkBF,OAAlB,EAApB,GAAkDG,SAH7C,CAAP;AAKD,GANM,CAAP;AAOD;;AAED,eAAeF,YAAf,CAA4BJ,KAA5B,EAAyDD,OAAzD,EAA+G;AAC7G,MAAIC,KAAK,CAACO,IAAV,EAAgB;AACd,UAAMA,IAAI,GAAGP,KAAK,CAACO,IAAnB;AACA,WAAO,0CAAiBA,IAAjB,EAAuBR,OAAvB,CAAP;AACD;;AACD,QAAMS,IAAI,GAAG,MAAMT,OAAO,CAACU,YAAR,CAAqBT,KAAK,CAACE,IAA3B,CAAnB;AACA,QAAMQ,MAAM,GAAG,sDAAuBF,IAAvB,CAAf;AACA,SAAO,KAAIG,kCAAJ,EAAkBD,MAAM,IAAI,KAA5B,CAAP;AACD","sourcesContent":["import { ParameterSchema, SchemaNode, TypeRefSchema } from '@teambit/semantics.entities.semantic-schema';\nimport pMapSeries from 'p-map-series';\nimport { ParameterDeclaration, NodeArray } from 'typescript';\nimport { SchemaExtractorContext } from '../../schema-extractor-context';\nimport { parseTypeFromQuickInfo } from './parse-type-from-quick-info';\nimport { typeNodeToSchema } from './type-node-to-schema';\n\nexport async function getParams(\n parameterNodes: NodeArray<ParameterDeclaration>,\n context: SchemaExtractorContext\n): Promise<ParameterSchema[]> {\n return pMapSeries(parameterNodes, async (param) => {\n return new ParameterSchema(\n param.name.getText(),\n await getParamType(param, context),\n param.initializer ? param.initializer.getText() : undefined\n );\n });\n}\n\nasync function getParamType(param: ParameterDeclaration, context: SchemaExtractorContext): Promise<SchemaNode> {\n if (param.type) {\n const type = param.type;\n return typeNodeToSchema(type, context);\n }\n const info = await context.getQuickInfo(param.name);\n const parsed = parseTypeFromQuickInfo(info);\n return new TypeRefSchema(parsed || 'any');\n}\n"]}
1
+ {"version":3,"names":["getParams","parameterNodes","context","pMapSeries","param","ParameterSchema","getLocation","name","getText","getParamType","initializer","undefined","type","typeNodeToSchema","info","getQuickInfo","parsed","parseTypeFromQuickInfo","TypeRefSchema"],"sources":["get-params.ts"],"sourcesContent":["import { ParameterSchema, SchemaNode, TypeRefSchema } from '@teambit/semantics.entities.semantic-schema';\nimport pMapSeries from 'p-map-series';\nimport { ParameterDeclaration, NodeArray } from 'typescript';\nimport { SchemaExtractorContext } from '../../schema-extractor-context';\nimport { parseTypeFromQuickInfo } from './parse-type-from-quick-info';\nimport { typeNodeToSchema } from './type-node-to-schema';\n\nexport async function getParams(\n parameterNodes: NodeArray<ParameterDeclaration>,\n context: SchemaExtractorContext\n): Promise<ParameterSchema[]> {\n return pMapSeries(parameterNodes, async (param) => {\n return new ParameterSchema(\n context.getLocation(param),\n param.name.getText(),\n await getParamType(param, context),\n param.initializer ? param.initializer.getText() : undefined\n );\n });\n}\n\n/**\n * @todo: probably not needed. just call context.resolveType instead.\n */\nasync function getParamType(param: ParameterDeclaration, context: SchemaExtractorContext): Promise<SchemaNode> {\n if (param.type) {\n const type = param.type;\n return typeNodeToSchema(type, context);\n }\n const info = await context.getQuickInfo(param.name);\n const parsed = parseTypeFromQuickInfo(info);\n return new TypeRefSchema(context.getLocation(param), parsed || 'any');\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,eAAeA,SAAf,CACLC,cADK,EAELC,OAFK,EAGuB;EAC5B,OAAO,IAAAC,qBAAA,EAAWF,cAAX,EAA2B,MAAOG,KAAP,IAAiB;IACjD,OAAO,KAAIC,oCAAJ,EACLH,OAAO,CAACI,WAAR,CAAoBF,KAApB,CADK,EAELA,KAAK,CAACG,IAAN,CAAWC,OAAX,EAFK,EAGL,MAAMC,YAAY,CAACL,KAAD,EAAQF,OAAR,CAHb,EAILE,KAAK,CAACM,WAAN,GAAoBN,KAAK,CAACM,WAAN,CAAkBF,OAAlB,EAApB,GAAkDG,SAJ7C,CAAP;EAMD,CAPM,CAAP;AAQD;AAED;AACA;AACA;;;AACA,eAAeF,YAAf,CAA4BL,KAA5B,EAAyDF,OAAzD,EAA+G;EAC7G,IAAIE,KAAK,CAACQ,IAAV,EAAgB;IACd,MAAMA,IAAI,GAAGR,KAAK,CAACQ,IAAnB;IACA,OAAO,IAAAC,oCAAA,EAAiBD,IAAjB,EAAuBV,OAAvB,CAAP;EACD;;EACD,MAAMY,IAAI,GAAG,MAAMZ,OAAO,CAACa,YAAR,CAAqBX,KAAK,CAACG,IAA3B,CAAnB;EACA,MAAMS,MAAM,GAAG,IAAAC,gDAAA,EAAuBH,IAAvB,CAAf;EACA,OAAO,KAAII,kCAAJ,EAAkBhB,OAAO,CAACI,WAAR,CAAoBF,KAApB,CAAlB,EAA8CY,MAAM,IAAI,KAAxD,CAAP;AACD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["parse-type-from-quick-info.ts"],"names":["parseTypeFromQuickInfo","quickInfo","body","displayString","splitByColon","split","kind","tail","join","trim","length","Error","firstLine","splitBySpace","typeName","splitByEqual","parseReturnTypeFromQuickInfo","typeStr","array"],"mappings":";;;;;;;;;;;;;;AAAA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,sBAAT,CAAgCC,SAAhC,EAA2F;AAAA;;AAChG,MAAI,EAACA,SAAD,aAACA,SAAD,kCAACA,SAAS,CAAEC,IAAZ,4CAAC,gBAAiBC,aAAlB,CAAJ,EAAqC,OAAO,EAAP;AACrC,QAAMA,aAAa,GAAGF,SAAS,CAACC,IAAV,CAAeC,aAArC;AACA,QAAMC,YAAY,GAAGD,aAAa,CAACE,KAAd,CAAoB,GAApB,CAArB;;AACA,UAAQJ,SAAS,CAACC,IAAV,CAAeI,IAAvB;AACE,SAAK,OAAL;AACA,SAAK,UAAL;AACA,SAAK,KAAL;AACA,SAAK,KAAL;AAAY;AACV,cAAM,GAAG,GAAGC,IAAN,IAAcH,YAApB;AACA,eAAOG,IAAI,CAACC,IAAL,CAAU,GAAV,EAAeC,IAAf,EAAP;AACD;;AACD,SAAK,QAAL;AACA,SAAK,UAAL;AAAiB;AACf,cAAMJ,KAAK,GAAGF,aAAa,CAACE,KAAd,CAAoB,KAApB,CAAd;;AACA,YAAIA,KAAK,CAACK,MAAN,KAAiB,CAArB,EAAwB;AACtB,gBAAM,IAAIC,KAAJ,CAAW,uDAAsDR,aAAc,EAA/E,CAAN;AACD;;AACD,eAAOE,KAAK,CAAC,CAAD,CAAL,CAASI,IAAT,EAAP;AACD;;AACD,SAAK,OAAL;AAAc;AACZ;AACA;AACA;AACA;AACA;AACA,cAAMG,SAAS,GAAGT,aAAa,CAACE,KAAd,CAAoB,IAApB,EAA0B,CAA1B,CAAlB;AACA,cAAMQ,YAAY,GAAGD,SAAS,CAACH,IAAV,GAAiBJ,KAAjB,CAAuB,GAAvB,CAArB,CAPY,CAQZ;;AACA,cAAM,IAAKS,QAAL,IAAiBD,YAAvB;AACA,eAAOC,QAAP;AACD;;AACD,SAAK,MAAL;AAAa;AACX;AACA,cAAMC,YAAY,GAAGZ,aAAa,CAACE,KAAd,CAAoB,GAApB,CAArB;AACA,cAAM,GAAG,GAAGE,IAAN,IAAcQ,YAApB;AACA,eAAOR,IAAI,CAACC,IAAL,CAAU,GAAV,EAAeC,IAAf,EAAP;AACD;;AACD;AACE,aAAOL,YAAY,CAACA,YAAY,CAACM,MAAb,GAAsB,CAAvB,CAAZ,CAAsCD,IAAtC,EAAP;AAnCJ;AAqCD;;AAEM,SAASO,4BAAT,CAAsCf,SAAtC,EAAiG;AACtG,MAAI,CAACA,SAAL,EAAgB,OAAO,EAAP;AAChB,QAAMgB,OAAO,GAAGjB,sBAAsB,CAACC,SAAD,CAAtC;AACA,QAAMiB,KAAK,GAAGD,OAAO,CAACZ,KAAR,CAAc,IAAd,CAAd;AACA,SAAOa,KAAK,CAACA,KAAK,CAACR,MAAN,GAAe,CAAhB,CAAL,CAAwBD,IAAxB,EAAP;AACD","sourcesContent":["// eslint-disable-next-line import/no-unresolved\nimport protocol from 'typescript/lib/protocol';\n\n/**\n * try to parse the type from the quickinfo.\n * this is an error-prone process, we do our best here.\n *\n * an example of a function with many \":\"\n * `export function getObj(a: string, func: (b: number) => {}) { return { a: 1, b: 2 } };`\n * which produce the following quickinfo:\n * ```ts\n * function getObj(a: string, func: (b: number) => {}): {\n * a: number;\n * b: number;\n * }\n * ```\n *\n * some examples of quickinfo:\n *\n * function ts.signatureToDisplayParts(typechecker: TypeChecker, signature: Signature, enclosingDeclaration?: Node | undefined, flags?: TypeFormatFlags): SymbolDisplayPart[]\n *\n * const enum ts.TypeFormatFlags\n *\n * (method) ts.TypeChecker.writeSignature(signature: Signature, enclosingDeclaration?: Node | undefined, flags?: TypeFormatFlags | undefined, kind?: SignatureKind | undefined, writer?: EmitTextWriter | undefined): string\n *\n * const obj: {\n * a: number;\n * b: number;\n * }\n *\n * function getObj(a: string): {\n * a: number;\n * b: number;\n * }\n */\nexport function parseTypeFromQuickInfo(quickInfo: protocol.QuickInfoResponse | undefined): string {\n if (!quickInfo?.body?.displayString) return '';\n const displayString = quickInfo.body.displayString;\n const splitByColon = displayString.split(':');\n switch (quickInfo.body.kind) {\n case 'const':\n case 'property':\n case 'let':\n case 'var': {\n const [, ...tail] = splitByColon;\n return tail.join(':').trim();\n }\n case 'method':\n case 'function': {\n const split = displayString.split('): ');\n if (split.length !== 2) {\n throw new Error(`quickinfo of a function below was not implemented.\\n${displayString}`);\n }\n return split[1].trim();\n }\n case 'alias': {\n // e.g. (alias) class BuilderService\\nimport BuilderService\n // e.g. '(alias) type Serializable = {\\n' +\n // ' toString(): string;\\n' +\n // '}\\n' +\n // 'import Serializable'\n const firstLine = displayString.split('\\n')[0];\n const splitBySpace = firstLine.trim().split(' ');\n // first two are alias keyword and alias type\n const [, , typeName] = splitBySpace;\n return typeName;\n }\n case 'type': {\n // e.g. `type TaskSlot = SlotRegistry<BuildTask[]>`\n const splitByEqual = displayString.split('=');\n const [, ...tail] = splitByEqual;\n return tail.join('=').trim();\n }\n default:\n return splitByColon[splitByColon.length - 1].trim();\n }\n}\n\nexport function parseReturnTypeFromQuickInfo(quickInfo: protocol.QuickInfoResponse | undefined): string {\n if (!quickInfo) return '';\n const typeStr = parseTypeFromQuickInfo(quickInfo);\n const array = typeStr.split('=>');\n return array[array.length - 1].trim();\n}\n"]}
1
+ {"version":3,"names":["parseTypeFromQuickInfo","quickInfo","body","displayString","splitByColon","split","kind","tail","join","trim","length","Error","firstLine","splitBySpace","typeName","splitByEqual","parseReturnTypeFromQuickInfo","typeStr","array"],"sources":["parse-type-from-quick-info.ts"],"sourcesContent":["// eslint-disable-next-line import/no-unresolved\nimport protocol from 'typescript/lib/protocol';\n\n/**\n * try to parse the type from the quickinfo.\n * this is an error-prone process, we do our best here.\n *\n * an example of a function with many \":\"\n * `export function getObj(a: string, func: (b: number) => {}) { return { a: 1, b: 2 } };`\n * which produce the following quickinfo:\n * ```ts\n * function getObj(a: string, func: (b: number) => {}): {\n * a: number;\n * b: number;\n * }\n * ```\n *\n * some examples of quickinfo:\n *\n * function ts.signatureToDisplayParts(typechecker: TypeChecker, signature: Signature, enclosingDeclaration?: Node | undefined, flags?: TypeFormatFlags): SymbolDisplayPart[]\n *\n * const enum ts.TypeFormatFlags\n *\n * (method) ts.TypeChecker.writeSignature(signature: Signature, enclosingDeclaration?: Node | undefined, flags?: TypeFormatFlags | undefined, kind?: SignatureKind | undefined, writer?: EmitTextWriter | undefined): string\n *\n * const obj: {\n * a: number;\n * b: number;\n * }\n *\n * function getObj(a: string): {\n * a: number;\n * b: number;\n * }\n */\nexport function parseTypeFromQuickInfo(quickInfo: protocol.QuickInfoResponse | undefined): string {\n if (!quickInfo?.body?.displayString) return '';\n const displayString = quickInfo.body.displayString;\n const splitByColon = displayString.split(':');\n switch (quickInfo.body.kind) {\n case 'const':\n case 'property':\n case 'let':\n case 'var': {\n const [, ...tail] = splitByColon;\n return tail.join(':').trim();\n }\n case 'method':\n case 'function': {\n const split = displayString.split('): ');\n if (split.length !== 2) {\n throw new Error(`quickinfo of a function below was not implemented.\\n${displayString}`);\n }\n return split[1].trim();\n }\n case 'alias': {\n // e.g. (alias) class BuilderService\\nimport BuilderService\n // e.g. '(alias) type Serializable = {\\n' +\n // ' toString(): string;\\n' +\n // '}\\n' +\n // 'import Serializable'\n const firstLine = displayString.split('\\n')[0];\n const splitBySpace = firstLine.trim().split(' ');\n // first two are alias keyword and alias type\n const [, , typeName] = splitBySpace;\n return typeName;\n }\n case 'type': {\n // e.g. `type TaskSlot = SlotRegistry<BuildTask[]>`\n const splitByEqual = displayString.split('=');\n const [, ...tail] = splitByEqual;\n return tail.join('=').trim();\n }\n default:\n return splitByColon[splitByColon.length - 1].trim();\n }\n}\n\nexport function parseReturnTypeFromQuickInfo(quickInfo: protocol.QuickInfoResponse | undefined): string {\n if (!quickInfo) return '';\n const typeStr = parseTypeFromQuickInfo(quickInfo);\n const array = typeStr.split('=>');\n return array[array.length - 1].trim();\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,sBAAT,CAAgCC,SAAhC,EAA2F;EAAA;;EAChG,IAAI,EAACA,SAAD,aAACA,SAAD,kCAACA,SAAS,CAAEC,IAAZ,4CAAC,gBAAiBC,aAAlB,CAAJ,EAAqC,OAAO,EAAP;EACrC,MAAMA,aAAa,GAAGF,SAAS,CAACC,IAAV,CAAeC,aAArC;EACA,MAAMC,YAAY,GAAGD,aAAa,CAACE,KAAd,CAAoB,GAApB,CAArB;;EACA,QAAQJ,SAAS,CAACC,IAAV,CAAeI,IAAvB;IACE,KAAK,OAAL;IACA,KAAK,UAAL;IACA,KAAK,KAAL;IACA,KAAK,KAAL;MAAY;QACV,MAAM,GAAG,GAAGC,IAAN,IAAcH,YAApB;QACA,OAAOG,IAAI,CAACC,IAAL,CAAU,GAAV,EAAeC,IAAf,EAAP;MACD;;IACD,KAAK,QAAL;IACA,KAAK,UAAL;MAAiB;QACf,MAAMJ,KAAK,GAAGF,aAAa,CAACE,KAAd,CAAoB,KAApB,CAAd;;QACA,IAAIA,KAAK,CAACK,MAAN,KAAiB,CAArB,EAAwB;UACtB,MAAM,IAAIC,KAAJ,CAAW,uDAAsDR,aAAc,EAA/E,CAAN;QACD;;QACD,OAAOE,KAAK,CAAC,CAAD,CAAL,CAASI,IAAT,EAAP;MACD;;IACD,KAAK,OAAL;MAAc;QACZ;QACA;QACA;QACA;QACA;QACA,MAAMG,SAAS,GAAGT,aAAa,CAACE,KAAd,CAAoB,IAApB,EAA0B,CAA1B,CAAlB;QACA,MAAMQ,YAAY,GAAGD,SAAS,CAACH,IAAV,GAAiBJ,KAAjB,CAAuB,GAAvB,CAArB,CAPY,CAQZ;;QACA,MAAM,IAAKS,QAAL,IAAiBD,YAAvB;QACA,OAAOC,QAAP;MACD;;IACD,KAAK,MAAL;MAAa;QACX;QACA,MAAMC,YAAY,GAAGZ,aAAa,CAACE,KAAd,CAAoB,GAApB,CAArB;QACA,MAAM,GAAG,GAAGE,IAAN,IAAcQ,YAApB;QACA,OAAOR,IAAI,CAACC,IAAL,CAAU,GAAV,EAAeC,IAAf,EAAP;MACD;;IACD;MACE,OAAOL,YAAY,CAACA,YAAY,CAACM,MAAb,GAAsB,CAAvB,CAAZ,CAAsCD,IAAtC,EAAP;EAnCJ;AAqCD;;AAEM,SAASO,4BAAT,CAAsCf,SAAtC,EAAiG;EACtG,IAAI,CAACA,SAAL,EAAgB,OAAO,EAAP;EAChB,MAAMgB,OAAO,GAAGjB,sBAAsB,CAACC,SAAD,CAAtC;EACA,MAAMiB,KAAK,GAAGD,OAAO,CAACZ,KAAR,CAAc,IAAd,CAAd;EACA,OAAOa,KAAK,CAACA,KAAK,CAACR,MAAN,GAAe,CAAhB,CAAL,CAAwBD,IAAxB,EAAP;AACD"}
@@ -44,12 +44,12 @@ async function toFunctionLikeSchema(node, context) {
44
44
 
45
45
  const info = await context.getQuickInfo(node.name);
46
46
  const returnTypeStr = (0, _parseTypeFromQuickInfo().parseTypeFromQuickInfo)(info);
47
- const displaySig = info === null || info === void 0 ? void 0 : (_info$body = info.body) === null || _info$body === void 0 ? void 0 : _info$body.displayString;
47
+ const displaySig = (info === null || info === void 0 ? void 0 : (_info$body = info.body) === null || _info$body === void 0 ? void 0 : _info$body.displayString) || '';
48
48
  const args = await (0, _getParams().getParams)(node.parameters, context);
49
49
  const returnType = await context.resolveType(node, returnTypeStr);
50
50
  const modifiers = ((_node$modifiers = node.modifiers) === null || _node$modifiers === void 0 ? void 0 : _node$modifiers.map(modifier => modifier.getText())) || [];
51
51
  const location = context.getLocation(node);
52
- return new (_semanticsEntities().FunctionLikeSchema)(name, args, returnType, displaySig || '', location, modifiers);
52
+ return new (_semanticsEntities().FunctionLikeSchema)(location, name, args, returnType, displaySig, modifiers);
53
53
  }
54
54
 
55
55
  //# sourceMappingURL=to-function-schema.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["to-function-schema.ts"],"names":["toFunctionLikeSchema","node","context","name","getText","info","getQuickInfo","returnTypeStr","displaySig","body","displayString","args","parameters","returnType","resolveType","modifiers","map","modifier","location","getLocation","FunctionLikeSchema"],"mappings":";;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,eAAeA,oBAAf,CAAoCC,IAApC,EAAgEC,OAAhE,EAAiG;AAAA;;AACtG,QAAMC,IAAI,GAAG,eAAAF,IAAI,CAACE,IAAL,0DAAWC,OAAX,OAAwB,EAArC,CADsG,CAEtG;;AACA,QAAMC,IAAI,GAAG,MAAMH,OAAO,CAACI,YAAR,CAAqBL,IAAI,CAACE,IAA1B,CAAnB;AACA,QAAMI,aAAa,GAAG,sDAAuBF,IAAvB,CAAtB;AACA,QAAMG,UAAU,GAAGH,IAAH,aAAGA,IAAH,qCAAGA,IAAI,CAAEI,IAAT,+CAAG,WAAYC,aAA/B;AACA,QAAMC,IAAI,GAAG,MAAM,4BAAUV,IAAI,CAACW,UAAf,EAA2BV,OAA3B,CAAnB;AACA,QAAMW,UAAU,GAAG,MAAMX,OAAO,CAACY,WAAR,CAAoBb,IAApB,EAA0BM,aAA1B,CAAzB;AACA,QAAMQ,SAAS,GAAG,oBAAAd,IAAI,CAACc,SAAL,oEAAgBC,GAAhB,CAAqBC,QAAD,IAAcA,QAAQ,CAACb,OAAT,EAAlC,MAAyD,EAA3E;AACA,QAAMc,QAAQ,GAAGhB,OAAO,CAACiB,WAAR,CAAoBlB,IAApB,CAAjB;AAEA,SAAO,KAAImB,uCAAJ,EAAuBjB,IAAvB,EAA6BQ,IAA7B,EAAmCE,UAAnC,EAA+CL,UAAU,IAAI,EAA7D,EAAiEU,QAAjE,EAA2EH,SAA3E,CAAP;AACD","sourcesContent":["import { SignatureDeclaration } from 'typescript';\nimport { FunctionLikeSchema, Modifier } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaExtractorContext } from '../../schema-extractor-context';\nimport { getParams } from './get-params';\nimport { parseTypeFromQuickInfo } from './parse-type-from-quick-info';\n\nexport async function toFunctionLikeSchema(node: SignatureDeclaration, context: SchemaExtractorContext) {\n const name = node.name?.getText() || '';\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const info = await context.getQuickInfo(node.name!);\n const returnTypeStr = parseTypeFromQuickInfo(info);\n const displaySig = info?.body?.displayString;\n const args = await getParams(node.parameters, context);\n const returnType = await context.resolveType(node, returnTypeStr);\n const modifiers = node.modifiers?.map((modifier) => modifier.getText()) || [];\n const location = context.getLocation(node);\n\n return new FunctionLikeSchema(name, args, returnType, displaySig || '', location, modifiers as Modifier[]);\n}\n"]}
1
+ {"version":3,"names":["toFunctionLikeSchema","node","context","name","getText","info","getQuickInfo","returnTypeStr","parseTypeFromQuickInfo","displaySig","body","displayString","args","getParams","parameters","returnType","resolveType","modifiers","map","modifier","location","getLocation","FunctionLikeSchema"],"sources":["to-function-schema.ts"],"sourcesContent":["import { SignatureDeclaration } from 'typescript';\nimport { FunctionLikeSchema, Modifier } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaExtractorContext } from '../../schema-extractor-context';\nimport { getParams } from './get-params';\nimport { parseTypeFromQuickInfo } from './parse-type-from-quick-info';\n\nexport async function toFunctionLikeSchema(node: SignatureDeclaration, context: SchemaExtractorContext) {\n const name = node.name?.getText() || '';\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const info = await context.getQuickInfo(node.name!);\n const returnTypeStr = parseTypeFromQuickInfo(info);\n const displaySig = info?.body?.displayString || '';\n const args = await getParams(node.parameters, context);\n const returnType = await context.resolveType(node, returnTypeStr);\n const modifiers = node.modifiers?.map((modifier) => modifier.getText()) || [];\n const location = context.getLocation(node);\n\n return new FunctionLikeSchema(location, name, args, returnType, displaySig, modifiers as Modifier[]);\n}\n"],"mappings":";;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,eAAeA,oBAAf,CAAoCC,IAApC,EAAgEC,OAAhE,EAAiG;EAAA;;EACtG,MAAMC,IAAI,GAAG,eAAAF,IAAI,CAACE,IAAL,0DAAWC,OAAX,OAAwB,EAArC,CADsG,CAEtG;;EACA,MAAMC,IAAI,GAAG,MAAMH,OAAO,CAACI,YAAR,CAAqBL,IAAI,CAACE,IAA1B,CAAnB;EACA,MAAMI,aAAa,GAAG,IAAAC,gDAAA,EAAuBH,IAAvB,CAAtB;EACA,MAAMI,UAAU,GAAG,CAAAJ,IAAI,SAAJ,IAAAA,IAAI,WAAJ,0BAAAA,IAAI,CAAEK,IAAN,0DAAYC,aAAZ,KAA6B,EAAhD;EACA,MAAMC,IAAI,GAAG,MAAM,IAAAC,sBAAA,EAAUZ,IAAI,CAACa,UAAf,EAA2BZ,OAA3B,CAAnB;EACA,MAAMa,UAAU,GAAG,MAAMb,OAAO,CAACc,WAAR,CAAoBf,IAApB,EAA0BM,aAA1B,CAAzB;EACA,MAAMU,SAAS,GAAG,oBAAAhB,IAAI,CAACgB,SAAL,oEAAgBC,GAAhB,CAAqBC,QAAD,IAAcA,QAAQ,CAACf,OAAT,EAAlC,MAAyD,EAA3E;EACA,MAAMgB,QAAQ,GAAGlB,OAAO,CAACmB,WAAR,CAAoBpB,IAApB,CAAjB;EAEA,OAAO,KAAIqB,uCAAJ,EAAuBF,QAAvB,EAAiCjB,IAAjC,EAAuCS,IAAvC,EAA6CG,UAA7C,EAAyDN,UAAzD,EAAqEQ,SAArE,CAAP;AACD"}
@@ -51,8 +51,10 @@ function _getParams() {
51
51
 
52
52
  // eslint-disable-next-line complexity
53
53
  async function typeNodeToSchema(node, context) {
54
+ const location = context.getLocation(node);
55
+
54
56
  if (isKeywordType(node)) {
55
- return new (_semanticsEntities().KeywordTypeSchema)(node.getText());
57
+ return new (_semanticsEntities().KeywordTypeSchema)(location, node.getText());
56
58
  }
57
59
 
58
60
  switch (node.kind) {
@@ -70,7 +72,7 @@ async function typeNodeToSchema(node, context) {
70
72
 
71
73
  case _typescript().SyntaxKind.LiteralType:
72
74
  // e.g. string/boolean
73
- return new (_semanticsEntities().LiteralTypeSchema)(node.getText());
75
+ return new (_semanticsEntities().LiteralTypeSchema)(location, node.getText());
74
76
 
75
77
  case _typescript().SyntaxKind.FunctionType:
76
78
  return functionType(node, context);
@@ -152,7 +154,8 @@ async function intersectionType(node, context) {
152
154
  const typeSchema = await typeNodeToSchema(type, context);
153
155
  return typeSchema;
154
156
  });
155
- return new (_semanticsEntities().TypeIntersectionSchema)(types);
157
+ const location = context.getLocation(node);
158
+ return new (_semanticsEntities().TypeIntersectionSchema)(location, types);
156
159
  }
157
160
 
158
161
  async function unionType(node, context) {
@@ -160,7 +163,8 @@ async function unionType(node, context) {
160
163
  const typeSchema = await typeNodeToSchema(type, context);
161
164
  return typeSchema;
162
165
  });
163
- return new (_semanticsEntities().TypeUnionSchema)(types);
166
+ const location = context.getLocation(node);
167
+ return new (_semanticsEntities().TypeUnionSchema)(location, types);
164
168
  }
165
169
  /**
166
170
  * not to be confused with "LiteralType", which is string/boolean/null.
@@ -173,7 +177,8 @@ async function typeLiteral(node, context) {
173
177
  const typeSchema = await context.computeSchema(member);
174
178
  return typeSchema;
175
179
  });
176
- return new (_semanticsEntities().TypeLiteralSchema)(members);
180
+ const location = context.getLocation(node);
181
+ return new (_semanticsEntities().TypeLiteralSchema)(location, members);
177
182
  }
178
183
  /**
179
184
  * In the following example, `AriaButtonProps` is a type reference
@@ -197,7 +202,7 @@ async function functionType(node, context) {
197
202
  const params = await (0, _getParams().getParams)(node.parameters, context);
198
203
  const returnType = await typeNodeToSchema(node.type, context);
199
204
  const location = context.getLocation(node);
200
- return new (_semanticsEntities().FunctionLikeSchema)(name, params, returnType, '', location);
205
+ return new (_semanticsEntities().FunctionLikeSchema)(location, name, params, returnType, '');
201
206
  }
202
207
  /**
203
208
  * e.g. `typeof Foo`
@@ -207,12 +212,14 @@ async function functionType(node, context) {
207
212
  async function typeQuery(node, context) {
208
213
  const displaySig = await context.getQuickInfoDisplayString(node.exprName);
209
214
  const type = await context.resolveType(node.exprName, node.exprName.getText(), false);
210
- return new (_semanticsEntities().TypeQuerySchema)(type, displaySig);
215
+ const location = context.getLocation(node);
216
+ return new (_semanticsEntities().TypeQuerySchema)(location, type, displaySig);
211
217
  }
212
218
 
213
219
  async function arrayType(node, context) {
214
220
  const type = await typeNodeToSchema(node.elementType, context);
215
- return new (_semanticsEntities().TypeArraySchema)(type);
221
+ const location = context.getLocation(node);
222
+ return new (_semanticsEntities().TypeArraySchema)(location, type);
216
223
  }
217
224
  /**
218
225
  * e.g. keyof typeof Foo
@@ -222,7 +229,7 @@ async function arrayType(node, context) {
222
229
  async function typeOperator(node, context) {
223
230
  const operatorName = getOperatorName(node.operator);
224
231
  const type = await typeNodeToSchema(node.type, context);
225
- return new (_semanticsEntities().TypeOperatorSchema)(operatorName, type);
232
+ return new (_semanticsEntities().TypeOperatorSchema)(context.getLocation(node), operatorName, type);
226
233
  }
227
234
 
228
235
  function getOperatorName(operator) {
@@ -246,7 +253,7 @@ async function tupleType(node, context) {
246
253
  const typeSchema = await typeNodeToSchema(elem, context);
247
254
  return typeSchema;
248
255
  });
249
- return new (_semanticsEntities().TupleTypeSchema)(elements);
256
+ return new (_semanticsEntities().TupleTypeSchema)(context.getLocation(node), elements);
250
257
  }
251
258
 
252
259
  //# sourceMappingURL=type-node-to-schema.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["type-node-to-schema.ts"],"names":["typeNodeToSchema","node","context","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","TypePredicate","ConstructorType","NamedTupleMember","OptionalType","RestType","ConditionalType","InferType","ParenthesizedType","ThisType","IndexedAccessType","MappedType","TemplateLiteralType","TemplateLiteralTypeSpan","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","type","typeSchema","TypeIntersectionSchema","TypeUnionSchema","members","member","computeSchema","TypeLiteralSchema","name","typeName","resolveType","params","parameters","returnType","location","getLocation","FunctionLikeSchema","displaySig","getQuickInfoDisplayString","exprName","TypeQuerySchema","elementType","TypeArraySchema","operatorName","getOperatorName","operator","TypeOperatorSchema","KeyOfKeyword","UniqueKeyword","ReadonlyKeyword","elements","elem","TupleTypeSchema"],"mappings":";;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAcA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAaA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAC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CAACwF,WAAN,EAAmBvF,OAAnB,CAAnC;AACA,SAAO,KAAIwF,oCAAJ,EAAoBtB,IAApB,CAAP;AACD;AAED;AACA;AACA;;;AACA,eAAe3C,YAAf,CAA4BxB,IAA5B,EAAoDC,OAApD,EAAqF;AACnF,QAAMyF,YAAY,GAAGC,eAAe,CAAC3F,IAAI,CAAC4F,QAAN,CAApC;AACA,QAAMzB,IAAI,GAAG,MAAMpE,gBAAgB,CAACC,IAAI,CAACmE,IAAN,EAAYlE,OAAZ,CAAnC;AACA,SAAO,KAAI4F,uCAAJ,EAAuBH,YAAvB,EAAqCvB,IAArC,CAAP;AACD;;AAED,SAASwB,eAAT,CAAyBC,QAAzB,EAAoH;AAClH,UAAQA,QAAR;AACE,SAAKtF,yBAAWwF,YAAhB;AACE,aAAO,OAAP;;AACF,SAAKxF,yBAAWyF,aAAhB;AACE,aAAO,QAAP;;AACF,SAAKzF,yBAAW0F,eAAhB;AACE,aAAO,UAAP;;AACF;AACE,YAAM,IAAI3C,KAAJ,CAAW,qDAAoDuC,QAAS,EAAxE,CAAN;AARJ;AAUD;;AAED,eAAelE,SAAf,CAAyB1B,IAAzB,EAA8CC,OAA9C,EAA+E;AAC7E,QAAMgG,QAAQ,GAAG,MAAM,2BAAWjG,IAAI,CAACiG,QAAhB,EAA0B,MAAOC,IAAP,IAAgB;AAC/D,UAAM9B,UAAU,GAAG,MAAMrE,gBAAgB,CAACmG,IAAD,EAAOjG,OAAP,CAAzC;AACA,WAAOmE,UAAP;AACD,GAHsB,CAAvB;AAIA,SAAO,KAAI+B,oCAAJ,EAAoBF,QAApB,CAAP;AACD","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} from 'typescript';\nimport {\n SchemaNode,\n TypeIntersectionSchema,\n TypeUnionSchema,\n TypeLiteralSchema,\n TypeQuerySchema,\n LiteralTypeSchema,\n KeywordTypeSchema,\n TypeArraySchema,\n TypeOperatorSchema,\n TupleTypeSchema,\n FunctionLikeSchema,\n} from '@teambit/semantics.entities.semantic-schema';\nimport pMapSeries from 'p-map-series';\nimport { SchemaExtractorContext } from '../../schema-extractor-context';\nimport { getParams } from './get-params';\n\n// eslint-disable-next-line complexity\nexport async function typeNodeToSchema(node: TypeNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n if (isKeywordType(node)) {\n return new KeywordTypeSchema(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(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.TypePredicate:\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.ParenthesizedType:\n case SyntaxKind.ThisType:\n case SyntaxKind.IndexedAccessType:\n case SyntaxKind.MappedType:\n case SyntaxKind.TemplateLiteralType:\n case SyntaxKind.TemplateLiteralTypeSpan:\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 \"${SyntaxKind[node.kind]}\" was not implemented yet.\ncontext: ${node.getText()}`);\n default:\n throw new Error(`Node \"${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 return new TypeIntersectionSchema(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 return new TypeUnionSchema(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, async (member) => {\n const typeSchema = await context.computeSchema(member);\n return typeSchema;\n });\n return new TypeLiteralSchema(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 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 return new FunctionLikeSchema(name, params, returnType, '', location);\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 return new TypeQuerySchema(type, displaySig);\n}\n\nasync function arrayType(node: ArrayTypeNode, context: SchemaExtractorContext) {\n const type = await typeNodeToSchema(node.elementType, context);\n return new TypeArraySchema(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(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(elements);\n}\n"]}
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","TypePredicate","ConstructorType","NamedTupleMember","OptionalType","RestType","ConditionalType","InferType","ParenthesizedType","ThisType","IndexedAccessType","MappedType","TemplateLiteralType","TemplateLiteralTypeSpan","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","computeSchema","TypeLiteralSchema","name","typeName","resolveType","params","getParams","parameters","returnType","FunctionLikeSchema","displaySig","getQuickInfoDisplayString","exprName","TypeQuerySchema","elementType","TypeArraySchema","operatorName","getOperatorName","operator","TypeOperatorSchema","KeyOfKeyword","UniqueKeyword","ReadonlyKeyword","elements","elem","TupleTypeSchema"],"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} from 'typescript';\nimport {\n SchemaNode,\n TypeIntersectionSchema,\n TypeUnionSchema,\n TypeLiteralSchema,\n TypeQuerySchema,\n LiteralTypeSchema,\n KeywordTypeSchema,\n TypeArraySchema,\n TypeOperatorSchema,\n TupleTypeSchema,\n FunctionLikeSchema,\n} from '@teambit/semantics.entities.semantic-schema';\nimport pMapSeries from 'p-map-series';\nimport { SchemaExtractorContext } from '../../schema-extractor-context';\nimport { getParams } from './get-params';\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.TypePredicate:\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.ParenthesizedType:\n case SyntaxKind.ThisType:\n case SyntaxKind.IndexedAccessType:\n case SyntaxKind.MappedType:\n case SyntaxKind.TemplateLiteralType:\n case SyntaxKind.TemplateLiteralTypeSpan:\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 \"${SyntaxKind[node.kind]}\" was not implemented yet.\ncontext: ${node.getText()}`);\n default:\n throw new Error(`Node \"${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, async (member) => {\n const typeSchema = await context.computeSchema(member);\n return typeSchema;\n });\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 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 return new FunctionLikeSchema(location, name, params, returnType, '');\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"],"mappings":";;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAcA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAaA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;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,OAA1B,CAAlB;;IACF,KAAKO,wBAAA,CAAWS,WAAhB;MAA6B;MAC3B,OAAO,KAAIC,sCAAJ,EAAsBhB,QAAtB,EAAgCF,IAAI,CAACM,OAAL,EAAhC,CAAP;;IACF,KAAKE,wBAAA,CAAWW,YAAhB;MACE,OAAOC,YAAY,CAACpB,IAAD,EAA2BC,OAA3B,CAA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context.getQuickInfo(varDec.name);
80
80
  const displaySig = (info === null || info === void 0 ? void 0 : (_info$body = info.body) === null || _info$body === void 0 ? void 0 : _info$body.displayString) || '';
81
+ const location = context.getLocation(varDec);
81
82
 
82
83
  if (((_varDec$initializer = varDec.initializer) === null || _varDec$initializer === void 0 ? void 0 : _varDec$initializer.kind) === _typescript().default.SyntaxKind.ArrowFunction) {
83
84
  const args = await (0, _getParams().getParams)(varDec.initializer.parameters, context);
84
85
  const typeStr = (0, _parseTypeFromQuickInfo().parseReturnTypeFromQuickInfo)(info);
85
86
  const returnType = await context.resolveType(varDec, typeStr);
86
- const location = context.getLocation(varDec);
87
- return new (_semanticsEntities().FunctionLikeSchema)(name, args, returnType, displaySig, location);
87
+ return new (_semanticsEntities().FunctionLikeSchema)(location, name, args, returnType, displaySig);
88
88
  }
89
89
 
90
90
  const typeStr = (0, _parseTypeFromQuickInfo().parseTypeFromQuickInfo)(info);
91
91
  const type = await context.resolveType(varDec, typeStr);
92
- return new (_semanticsEntities().VariableSchema)(name, displaySig, type);
92
+ return new (_semanticsEntities().VariableSchema)(location, name, displaySig, type);
93
93
  }
94
94
 
95
95
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["variable-declaration.ts"],"names":["VariableDeclaration","predicate","node","kind","ts","SyntaxKind","getName","name","getText","getIdentifiers","ExportIdentifier","getSourceFile","fileName","transform","varDec","context","info","getQuickInfo","displaySig","body","displayString","initializer","ArrowFunction","args","parameters","typeStr","returnType","resolveType","location","getLocation","FunctionLikeSchema","type","VariableSchema"],"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;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,mBAAN,CAAuD;AAC5DC,E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AAMH,OAAO,GAAG,sDAAuBT,IAAvB,CAAhB;AACA,UAAMe,IAAI,GAAG,MAAMhB,OAAO,CAACY,WAAR,CAAoBb,MAApB,EAA4BW,OAA5B,CAAnB;AACA,WAAO,KAAIO,mCAAJ,EAAmBzB,IAAnB,EAAyBW,UAAzB,EAAqCa,IAArC,CAAP;AACD;;AA3B2D","sourcesContent":["import { SchemaNode, VariableSchema, FunctionLikeSchema } 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';\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 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 location = context.getLocation(varDec);\n return new FunctionLikeSchema(name, args, returnType, displaySig, location);\n }\n const typeStr = parseTypeFromQuickInfo(info);\n const type = await context.resolveType(varDec, typeStr);\n return new VariableSchema(name, displaySig, type);\n }\n}\n"]}
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","FunctionLikeSchema","parseTypeFromQuickInfo","type","VariableSchema"],"sources":["variable-declaration.ts"],"sourcesContent":["import { SchemaNode, VariableSchema, FunctionLikeSchema } 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';\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 return new FunctionLikeSchema(location, name, args, returnType, displaySig);\n }\n const typeStr = parseTypeFromQuickInfo(info);\n const type = await context.resolveType(varDec, typeStr);\n return new VariableSchema(location, name, displaySig, type);\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;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OAAO,CAACgB,WAAR,CAAoBjB,MAApB,EAA4Bc,OAA5B,CAAzB;MACA,OAAO,KAAII,uCAAJ,EAAuBX,QAAvB,EAAiCd,IAAjC,EAAuCkB,IAAvC,EAA6CK,UAA7C,EAAyDZ,UAAzD,CAAP;IACD;;IACD,MAAMU,OAAO,GAAG,IAAAK,gDAAA,EAAuBjB,IAAvB,CAAhB;IACA,MAAMkB,IAAI,GAAG,MAAMnB,OAAO,CAACgB,WAAR,CAAoBjB,MAApB,EAA4Bc,OAA5B,CAAnB;IACA,OAAO,KAAIO,mCAAJ,EAAmBd,QAAnB,EAA6Bd,IAA7B,EAAmCW,UAAnC,EAA+CgB,IAA/C,CAAP;EACD;;AA3B2D"}
@@ -79,9 +79,8 @@ class VariableStatementTransformer {
79
79
  // this will get the schema from variable-declaration
80
80
  const schema = await context.visitDefinition(dec.name);
81
81
  return schema;
82
- }); // @todo: find a better way to return an array of SchemaNode. this is not really a module
83
-
84
- return new (_semanticsEntities().Module)((0, _lodash().compact)(schemas));
82
+ });
83
+ return new (_semanticsEntities().Module)(context.getLocation(node), (0, _lodash().compact)(schemas));
85
84
  }
86
85
 
87
86
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["variable-statement.ts"],"names":["VariableStatementTransformer","predicate","node","kind","ts","SyntaxKind","VariableStatement","getIdentifiers","declarationList","declarations","map","dec","ExportIdentifier","name","getText","getSourceFile","fileName","transform","context","schemas","schema","visitDefinition","Module"],"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;;AAEA;AACA;AACA;AACA;AACO,MAAMA,4BAAN,CAAgE;AACrEC,EAAAA,SAAS,CAACC,IAAD,EAAa;AACpB,WAAOA,IAAI,CAACC,IAAL,KAAcC,sBAAGC,UAAH,CAAcC,iBAAnC;AACD;;AAEmB,QAAdC,cAAc,CAACL,IAAD,EAA0B;AAC5C,WAAOA,IAAI,CAACM,eAAL,CAAqBC,YAArB,CAAkCC,GAAlC,CAAuCC,GAAD,IAAS;AACpD,aAAO,KAAIC,oCAAJ,EAAqBD,GAAG,CAACE,IAAJ,CAASC,OAAT,EAArB,EAAyCH,GAAG,CAACI,aAAJ,GAAoBC,QAA7D,CAAP;AACD,KAFM,CAAP;AAGD;;AAEc,QAATC,SAAS,CAACf,IAAD,EAA0BgB,OAA1B,EAAgF;AAC7F,UAAMC,OAAO,GAAG,MAAM,2BAAWjB,IAAI,CAACM,eAAL,CAAqBC,YAAhC,EAA8C,MAAOE,GAAP,IAAe;AACjF;AACA,YAAMS,MAAM,GAAG,MAAMF,OAAO,CAACG,eAAR,CAAwBV,GAAG,CAACE,IAA5B,CAArB;AACA,aAAOO,MAAP;AACD,KAJqB,CAAtB,CAD6F,CAM7F;;AACA,WAAO,KAAIE,2BAAJ,EAAW,uBAAQH,OAAR,CAAX,CAAP;AACD;;AAnBoE","sourcesContent":["import { SchemaNode, Module } from '@teambit/semantics.entities.semantic-schema';\nimport { compact } from 'lodash';\nimport pMapSeries from 'p-map-series';\nimport ts, { Node, VariableStatement } from 'typescript';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\n\n/**\n * variable statement is a collection of variable declarations.\n * e.g. `export const a = 1, b = () => {}, c = {};`\n */\nexport class VariableStatementTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.VariableStatement;\n }\n\n async getIdentifiers(node: VariableStatement) {\n return node.declarationList.declarations.map((dec) => {\n return new ExportIdentifier(dec.name.getText(), dec.getSourceFile().fileName);\n });\n }\n\n async transform(node: VariableStatement, context: SchemaExtractorContext): Promise<SchemaNode> {\n const schemas = await pMapSeries(node.declarationList.declarations, async (dec) => {\n // this will get the schema from variable-declaration\n const schema = await context.visitDefinition(dec.name);\n return schema;\n });\n // @todo: find a better way to return an array of SchemaNode. this is not really a module\n return new Module(compact(schemas));\n }\n}\n"]}
1
+ {"version":3,"names":["VariableStatementTransformer","predicate","node","kind","ts","SyntaxKind","VariableStatement","getIdentifiers","declarationList","declarations","map","dec","ExportIdentifier","name","getText","getSourceFile","fileName","transform","context","schemas","pMapSeries","schema","visitDefinition","Module","getLocation","compact"],"sources":["variable-statement.ts"],"sourcesContent":["import { SchemaNode, Module } from '@teambit/semantics.entities.semantic-schema';\nimport { compact } from 'lodash';\nimport pMapSeries from 'p-map-series';\nimport ts, { Node, VariableStatement } from 'typescript';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\n\n/**\n * variable statement is a collection of variable declarations.\n * e.g. `export const a = 1, b = () => {}, c = {};`\n */\nexport class VariableStatementTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.VariableStatement;\n }\n\n async getIdentifiers(node: VariableStatement) {\n return node.declarationList.declarations.map((dec) => {\n return new ExportIdentifier(dec.name.getText(), dec.getSourceFile().fileName);\n });\n }\n\n async transform(node: VariableStatement, context: SchemaExtractorContext): Promise<SchemaNode> {\n const schemas = await pMapSeries(node.declarationList.declarations, async (dec) => {\n // this will get the schema from variable-declaration\n const schema = await context.visitDefinition(dec.name);\n return schema;\n });\n return new Module(context.getLocation(node), compact(schemas));\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;;AAEA;AACA;AACA;AACA;AACO,MAAMA,4BAAN,CAAgE;EACrEC,SAAS,CAACC,IAAD,EAAa;IACpB,OAAOA,IAAI,CAACC,IAAL,KAAcC,qBAAA,CAAGC,UAAH,CAAcC,iBAAnC;EACD;;EAEmB,MAAdC,cAAc,CAACL,IAAD,EAA0B;IAC5C,OAAOA,IAAI,CAACM,eAAL,CAAqBC,YAArB,CAAkCC,GAAlC,CAAuCC,GAAD,IAAS;MACpD,OAAO,KAAIC,oCAAJ,EAAqBD,GAAG,CAACE,IAAJ,CAASC,OAAT,EAArB,EAAyCH,GAAG,CAACI,aAAJ,GAAoBC,QAA7D,CAAP;IACD,CAFM,CAAP;EAGD;;EAEc,MAATC,SAAS,CAACf,IAAD,EAA0BgB,OAA1B,EAAgF;IAC7F,MAAMC,OAAO,GAAG,MAAM,IAAAC,qBAAA,EAAWlB,IAAI,CAACM,eAAL,CAAqBC,YAAhC,EAA8C,MAAOE,GAAP,IAAe;MACjF;MACA,MAAMU,MAAM,GAAG,MAAMH,OAAO,CAACI,eAAR,CAAwBX,GAAG,CAACE,IAA5B,CAArB;MACA,OAAOQ,MAAP;IACD,CAJqB,CAAtB;IAKA,OAAO,KAAIE,2BAAJ,EAAWL,OAAO,CAACM,WAAR,CAAoBtB,IAApB,CAAX,EAAsC,IAAAuB,iBAAA,EAAQN,OAAR,CAAtC,CAAP;EACD;;AAlBoE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["typescript.aspect.ts"],"names":["TypescriptAspect","Aspect","create","id"],"mappings":";;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,gBAAgB,GAAGC,kBAAOC,MAAP,CAAc;AAC5CC,EAAAA,EAAE,EAAE;AADwC,CAAd,CAAzB","sourcesContent":["import { Aspect } from '@teambit/harmony';\n\nexport const TypescriptAspect = Aspect.create({\n id: 'teambit.typescript/typescript',\n});\n"]}
1
+ {"version":3,"names":["TypescriptAspect","Aspect","create","id"],"sources":["typescript.aspect.ts"],"sourcesContent":["import { Aspect } from '@teambit/harmony';\n\nexport const TypescriptAspect = Aspect.create({\n id: 'teambit.typescript/typescript',\n});\n"],"mappings":";;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAAMA,gBAAgB,GAAGC,iBAAA,CAAOC,MAAP,CAAc;EAC5CC,EAAE,EAAE;AADwC,CAAd,CAAzB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["typescript.compiler.ts"],"names":["TypescriptCompiler","constructor","id","logger","options","tsModule","distDir","distGlobPatterns","shouldCopyNonSupportedFiles","artifactName","tsconfig","compilerOptions","outDir","displayConfig","stringifyTsconfig","getDistDir","transpileFile","fileContent","isFileSupported","filePath","compilerOptionsFromTsconfig","convertCompilerOptionsFromJson","errors","length","formattedErrors","formatDiagnosticsWithColorAndContext","getFormatDiagnosticsHost","Error","sourceRoot","componentDir","rootDir","result","transpileModule","fileName","reportDiagnostics","diagnostics","formatHost","error","outputPath","replaceFileExtToJs","outputFiles","outputText","sourceMapText","push","preBuild","context","capsules","capsuleNetwork","seedersCapsules","capsuleDirs","map","capsule","path","writeTsConfig","writeTypes","writeNpmIgnore","build","componentsResults","runTscBuild","artifacts","getArtifactDefinition","postBuild","Promise","all","packageJson","PackageJsonFile","loadFromCapsuleSync","packageJsonObject","types","write","generatedBy","name","globPatterns","getDistPathBySrcPath","srcPath","fileWithJSExtIfNeeded","join","isJsAndCompile","compileJs","endsWith","isJsxAndCompile","compileJsx","network","capsulesRootDir","getCapsulesToCompile","getAllCapsuleDirs","getCanonicalFileName","p","getCurrentDirectory","getNewLine","sys","newLine","currentComponentResult","reportDiagnostic","diagnostic","errorStr","process","stdout","isTTY","formatDiagnostic","file","BitError","consoleFailure","component","reportSolutionBuilderStatus","diag","msg","messageText","debug","errorCounter","errorCount","info","host","createSolutionBuilderHost","undefined","writeProjectReferencesTsConfig","solutionBuilder","createSolutionBuilder","verbose","nextProject","longProcessLogger","createLongProcessLogger","getNextInvalidatedProject","capsulePath","project","replace","currentComponentId","getIdByPathInCapsule","logProgress","toString","getCapsule","startTime","Date","now","done","endTime","end","dirs","typePath","contents","fs","readFile","filename","basename","dir","pathExists","outputFile","NPM_IGNORE_FILE","npmIgnorePath","npmIgnoreEntriesStr","appendFile","projects","files","references","tsconfigStr","writeFile","JSON","stringify","fileExtension","extname","RegExp","version"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;;;AAGO,MAAMA,kBAAN,CAA6C;AAKlDC,EAAAA,WAAW,CACAC,EADA,EAEDC,MAFC,EAGDC,OAHC,EAIDC,QAJC,EAKT;AAAA;;AAAA,SAJSH,EAIT,GAJSA,EAIT;AAAA,SAHQC,MAGR,GAHQA,MAGR;AAAA,SAFQC,OAER,GAFQA,OAER;AAAA,SADQC,QACR,GADQA,QACR;AAAA;AAAA;AAAA;AAAA;AAAA,yDAYY,YAZZ;AAAA,2DAac,KAbd;AACA,SAAKC,OAAL,GAAeF,OAAO,CAACE,OAAR,IAAmB,MAAlC;AACA,SAAKC,gBAAL,GAAwBH,OAAO,CAACG,gBAAR,IAA4B,CAAE,GAAE,KAAKD,OAAQ,KAAjB,EAAwB,IAAG,KAAKA,OAAQ,uBAAxC,CAApD;AACA,SAAKE,2BAAL,GACE,OAAOJ,OAAO,CAACI,2BAAf,KAA+C,SAA/C,GAA2DJ,OAAO,CAACI,2BAAnE,GAAiG,IADnG;AAEA,SAAKC,YAAL,GAAoBL,OAAO,CAACK,YAAR,IAAwB,MAA5C;AACA,0BAAKL,OAAL,EAAaM,QAAb,mBAAaA,QAAb,GAA0B,EAA1B;AACA,kCAAKN,OAAL,CAAaM,QAAb,EAAsBC,eAAtB,2BAAsBA,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,eAAnB,CAAb,EAAkD4H,WAAlD,CAAN;AACD;;AAE0B,QAAbrG,aAAa,CAACoF,IAAD,EAAiB;AAC1C,UAAMiB,WAAW,GAAG,KAAK5I,iBAAL,CAAuB,KAAKV,OAAL,CAAaM,QAApC,CAApB;AACA,UAAMoD,OAAO,CAACC,GAAR,CAAY0E,IAAI,CAACvF,GAAL,CAAU8F,GAAD,IAASJ,mBAAGe,SAAH,CAAavG,gBAAKwB,IAAL,CAAUoE,GAAV,EAAe,eAAf,CAAb,EAA8CU,WAA9C,CAAlB,CAAZ,CAAN;AACD;;AAEO5I,EAAAA,iBAAiB,CAACJ,QAAD,EAAW;AAClC,WAAOkJ,IAAI,CAACC,SAAL,CAAenJ,QAAf,EAAyBwG,SAAzB,EAAoC,CAApC,CAAP;AACD;;AAEO3E,EAAAA,kBAAkB,CAACpB,QAAD,EAA2B;AACnD,QAAI,CAAC,KAAKD,eAAL,CAAqBC,QAArB,CAAL,EAAqC,OAAOA,QAAP;;AACrC,UAAM2I,aAAa,GAAG1G,gBAAK2G,OAAL,CAAa5I,QAAb,CAAtB;;AACA,WAAOA,QAAQ,CAAC0G,OAAT,CAAiB,IAAImC,MAAJ,CAAY,GAAEF,aAAc,GAA5B,CAAjB,EAAkD,KAAlD,CAAP,CAHmD,CAGc;AAClE;;AAEDG,EAAAA,OAAO,GAAG;AACR,WAAO,KAAK5J,QAAL,CAAc4J,OAArB;AACD;;AAhSiD","sourcesContent":["import { BuildContext, BuiltTaskResult, ComponentResult } from '@teambit/builder';\nimport { Compiler, TranspileFileParams, TranspileFileOutput } from '@teambit/compiler';\nimport { Network } from '@teambit/isolator';\nimport { Logger } from '@teambit/logger';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport ts from 'typescript';\nimport { BitError } from '@teambit/bit-error';\nimport PackageJsonFile from '@teambit/legacy/dist/consumer/component/package-json-file';\nimport { TypeScriptCompilerOptions } from './compiler-options';\n\nexport class TypescriptCompiler implements Compiler {\n distDir: string;\n distGlobPatterns: string[];\n shouldCopyNonSupportedFiles: boolean;\n artifactName: string;\n constructor(\n readonly id: string,\n private logger: Logger,\n private options: TypeScriptCompilerOptions,\n private tsModule: typeof ts\n ) {\n this.distDir = options.distDir || 'dist';\n this.distGlobPatterns = options.distGlobPatterns || [`${this.distDir}/**`, `!${this.distDir}/tsconfig.tsbuildinfo`];\n this.shouldCopyNonSupportedFiles =\n typeof options.shouldCopyNonSupportedFiles === 'boolean' ? options.shouldCopyNonSupportedFiles : true;\n this.artifactName = options.artifactName || 'dist';\n this.options.tsconfig ||= {};\n this.options.tsconfig.compilerOptions ||= {};\n // mutate the outDir, otherwise, on capsules, the dists might be written to a different directory and make confusion\n this.options.tsconfig.compilerOptions.outDir = this.distDir;\n }\n\n displayName = 'TypeScript';\n deleteDistDir = false;\n\n displayConfig() {\n return this.stringifyTsconfig(this.options.tsconfig);\n }\n\n getDistDir() {\n return this.distDir;\n }\n\n /**\n * compile one file on the workspace\n */\n transpileFile(fileContent: string, options: TranspileFileParams): TranspileFileOutput {\n if (!this.isFileSupported(options.filePath)) {\n return null; // file is not supported\n }\n const compilerOptionsFromTsconfig = this.tsModule.convertCompilerOptionsFromJson(\n this.options.tsconfig.compilerOptions,\n '.'\n );\n if (compilerOptionsFromTsconfig.errors.length) {\n // :TODO @david replace to a more concrete error type and put in 'exceptions' directory here.\n const formattedErrors = this.tsModule.formatDiagnosticsWithColorAndContext(\n compilerOptionsFromTsconfig.errors,\n this.getFormatDiagnosticsHost()\n );\n throw new Error(`failed parsing the tsconfig.json.\\n${formattedErrors}`);\n }\n\n const compilerOptions = compilerOptionsFromTsconfig.options;\n compilerOptions.sourceRoot = options.componentDir;\n compilerOptions.rootDir = '.';\n const result = this.tsModule.transpileModule(fileContent, {\n compilerOptions,\n fileName: options.filePath,\n reportDiagnostics: true,\n });\n\n if (result.diagnostics && result.diagnostics.length) {\n const formatHost = this.getFormatDiagnosticsHost();\n const error = this.tsModule.formatDiagnosticsWithColorAndContext(result.diagnostics, formatHost);\n\n // :TODO @david please replace to a more concrete error type and put in 'exceptions' directory here.\n throw new Error(error);\n }\n\n const outputPath = this.replaceFileExtToJs(options.filePath);\n const outputFiles = [{ outputText: result.outputText, outputPath }];\n if (result.sourceMapText) {\n outputFiles.push({\n outputText: result.sourceMapText,\n outputPath: `${outputPath}.map`,\n });\n }\n return outputFiles;\n }\n\n async preBuild(context: BuildContext) {\n const capsules = context.capsuleNetwork.seedersCapsules;\n const capsuleDirs = capsules.map((capsule) => capsule.path);\n await this.writeTsConfig(capsuleDirs);\n await this.writeTypes(capsuleDirs);\n await this.writeNpmIgnore(capsuleDirs);\n }\n\n /**\n * compile multiple components on the capsules\n */\n async build(context: BuildContext): Promise<BuiltTaskResult> {\n const componentsResults = await this.runTscBuild(context.capsuleNetwork);\n\n return {\n artifacts: this.getArtifactDefinition(),\n componentsResults,\n };\n }\n\n async postBuild(context: BuildContext) {\n await Promise.all(\n context.capsuleNetwork.seedersCapsules.map(async (capsule) => {\n const packageJson = PackageJsonFile.loadFromCapsuleSync(capsule.path);\n // the types['index.ts'] is needed only during the build to avoid errors when tsc finds the\n // same type once in the d.ts and once in the ts file.\n if (packageJson.packageJsonObject.types) {\n delete packageJson.packageJsonObject.types;\n await packageJson.write();\n }\n })\n );\n }\n\n getArtifactDefinition() {\n return [\n {\n generatedBy: this.id,\n name: this.artifactName,\n globPatterns: this.distGlobPatterns,\n },\n ];\n }\n\n /**\n * given a source file, return its parallel in the dists. e.g. index.ts => dist/index.js\n */\n getDistPathBySrcPath(srcPath: string) {\n const fileWithJSExtIfNeeded = this.replaceFileExtToJs(srcPath);\n return path.join(this.distDir, fileWithJSExtIfNeeded);\n }\n\n /**\n * whether typescript is able to compile the given path\n */\n isFileSupported(filePath: string): boolean {\n const isJsAndCompile = !!this.options.compileJs && filePath.endsWith('.js');\n const isJsxAndCompile = !!this.options.compileJsx && filePath.endsWith('.jsx');\n return (\n (filePath.endsWith('.ts') || filePath.endsWith('.tsx') || isJsAndCompile || isJsxAndCompile) &&\n !filePath.endsWith('.d.ts')\n );\n }\n\n /**\n * we have two options here:\n * 1. pass all capsules-dir at the second parameter of createSolutionBuilder and then no\n * need to write the main tsconfig.json with all the references.\n * 2. write main tsconfig.json and pass the capsules root-dir.\n * we went with option #2 because it'll be easier for users to go to the capsule-root and run\n * `tsc --build` to debug issues.\n */\n private async runTscBuild(network: Network): Promise<ComponentResult[]> {\n const rootDir = network.capsulesRootDir;\n const capsules = await network.getCapsulesToCompile();\n if (!capsules.length) {\n return [];\n }\n const capsuleDirs = capsules.getAllCapsuleDirs();\n const formatHost = {\n getCanonicalFileName: (p) => p,\n getCurrentDirectory: () => '', // it helps to get the files with absolute paths\n getNewLine: () => this.tsModule.sys.newLine,\n };\n const componentsResults: ComponentResult[] = [];\n let currentComponentResult: Partial<ComponentResult> = { errors: [] };\n const reportDiagnostic = (diagnostic: ts.Diagnostic) => {\n const errorStr = process.stdout.isTTY\n ? this.tsModule.formatDiagnosticsWithColorAndContext([diagnostic], formatHost)\n : this.tsModule.formatDiagnostic(diagnostic, formatHost);\n if (!diagnostic.file) {\n // the error is general and not related to a specific file. e.g. tsconfig is missing.\n throw new BitError(errorStr);\n }\n this.logger.consoleFailure(errorStr);\n if (!currentComponentResult.component || !currentComponentResult.errors) {\n throw new Error(`currentComponentResult is not defined yet for ${diagnostic.file}`);\n }\n currentComponentResult.errors.push(errorStr);\n };\n // this only works when `verbose` is `true` in the `ts.createSolutionBuilder` function.\n const reportSolutionBuilderStatus = (diag: ts.Diagnostic) => {\n const msg = diag.messageText as string;\n this.logger.debug(msg);\n };\n const errorCounter = (errorCount: number) => {\n this.logger.info(`total error found: ${errorCount}`);\n };\n const host = this.tsModule.createSolutionBuilderHost(\n undefined,\n undefined,\n reportDiagnostic,\n reportSolutionBuilderStatus,\n errorCounter\n );\n await this.writeProjectReferencesTsConfig(rootDir, capsuleDirs);\n const solutionBuilder = this.tsModule.createSolutionBuilder(host, [rootDir], { verbose: true });\n let nextProject;\n const longProcessLogger = this.logger.createLongProcessLogger('compile typescript components', capsules.length);\n // eslint-disable-next-line no-cond-assign\n while ((nextProject = solutionBuilder.getNextInvalidatedProject())) {\n // regex to make sure it will work correctly for both linux and windows\n // it replaces both /tsconfig.json and \\tsocnfig.json\n const capsulePath = nextProject.project.replace(/[/\\\\]tsconfig.json/, '');\n const currentComponentId = capsules.getIdByPathInCapsule(capsulePath);\n if (!currentComponentId) throw new Error(`unable to find component for ${capsulePath}`);\n longProcessLogger.logProgress(currentComponentId.toString());\n const capsule = capsules.getCapsule(currentComponentId);\n if (!capsule) throw new Error(`unable to find capsule for ${currentComponentId.toString()}`);\n currentComponentResult.component = capsule.component;\n currentComponentResult.startTime = Date.now();\n nextProject.done();\n currentComponentResult.endTime = Date.now();\n componentsResults.push({ ...currentComponentResult } as ComponentResult);\n currentComponentResult = { errors: [] };\n }\n longProcessLogger.end();\n\n return componentsResults;\n }\n\n private getFormatDiagnosticsHost(): ts.FormatDiagnosticsHost {\n return {\n getCanonicalFileName: (p) => p,\n getCurrentDirectory: this.tsModule.sys.getCurrentDirectory,\n getNewLine: () => this.tsModule.sys.newLine,\n };\n }\n\n private async writeTypes(dirs: string[]) {\n await Promise.all(\n this.options.types.map(async (typePath) => {\n const contents = await fs.readFile(typePath, 'utf8');\n const filename = path.basename(typePath);\n\n await Promise.all(\n dirs.map(async (dir) => {\n const filePath = path.join(dir, 'types', filename);\n if (!(await fs.pathExists(filePath))) {\n await fs.outputFile(filePath, contents);\n }\n })\n );\n })\n );\n }\n\n /**\n * when using project-references, typescript adds a file \"tsconfig.tsbuildinfo\" which is not\n * needed for the package.\n */\n private async writeNpmIgnore(dirs: string[]) {\n const NPM_IGNORE_FILE = '.npmignore';\n await Promise.all(\n dirs.map(async (dir) => {\n const npmIgnorePath = path.join(dir, NPM_IGNORE_FILE);\n const npmIgnoreEntriesStr = `\\n${this.distDir}/tsconfig.tsbuildinfo\\n`;\n await fs.appendFile(npmIgnorePath, npmIgnoreEntriesStr);\n })\n );\n }\n\n private async writeProjectReferencesTsConfig(rootDir: string, projects: string[]) {\n const files = [];\n const references = projects.map((project) => ({ path: project }));\n const tsconfig = { files, references };\n const tsconfigStr = this.stringifyTsconfig(tsconfig);\n await fs.writeFile(path.join(rootDir, 'tsconfig.json'), tsconfigStr);\n }\n\n private async writeTsConfig(dirs: string[]) {\n const tsconfigStr = this.stringifyTsconfig(this.options.tsconfig);\n await Promise.all(dirs.map((dir) => fs.writeFile(path.join(dir, 'tsconfig.json'), tsconfigStr)));\n }\n\n private stringifyTsconfig(tsconfig) {\n return JSON.stringify(tsconfig, undefined, 2);\n }\n\n private replaceFileExtToJs(filePath: string): string {\n if (!this.isFileSupported(filePath)) return filePath;\n const fileExtension = path.extname(filePath);\n return filePath.replace(new RegExp(`${fileExtension}$`), '.js'); // makes sure it's the last occurrence\n }\n\n version() {\n return this.tsModule.version;\n }\n}\n"]}
1
+ {"version":3,"names":["TypescriptCompiler","constructor","id","logger","options","tsModule","distDir","distGlobPatterns","shouldCopyNonSupportedFiles","artifactName","tsconfig","compilerOptions","outDir","displayConfig","stringifyTsconfig","getDistDir","transpileFile","fileContent","isFileSupported","filePath","compilerOptionsFromTsconfig","convertCompilerOptionsFromJson","errors","length","formattedErrors","formatDiagnosticsWithColorAndContext","getFormatDiagnosticsHost","Error","sourceRoot","componentDir","rootDir","result","transpileModule","fileName","reportDiagnostics","diagnostics","formatHost","error","outputPath","replaceFileExtToJs","outputFiles","outputText","sourceMapText","push","preBuild","context","capsules","capsuleNetwork","seedersCapsules","capsuleDirs","map","capsule","path","writeTsConfig","writeTypes","writeNpmIgnore","build","componentsResults","runTscBuild","artifacts","getArtifactDefinition","postBuild","Promise","all","packageJson","PackageJsonFile","loadFromCapsuleSync","packageJsonObject","types","write","generatedBy","name","globPatterns","getDistPathBySrcPath","srcPath","fileWithJSExtIfNeeded","join","isJsAndCompile","compileJs","endsWith","isJsxAndCompile","compileJsx","network","capsulesRootDir","getCapsulesToCompile","getAllCapsuleDirs","getCanonicalFileName","p","getCurrentDirectory","getNewLine","sys","newLine","currentComponentResult","reportDiagnostic","diagnostic","errorStr","process","stdout","isTTY","formatDiagnostic","file","BitError","consoleFailure","component","reportSolutionBuilderStatus","diag","msg","messageText","debug","errorCounter","errorCount","info","host","createSolutionBuilderHost","undefined","writeProjectReferencesTsConfig","solutionBuilder","createSolutionBuilder","verbose","nextProject","longProcessLogger","createLongProcessLogger","getNextInvalidatedProject","capsulePath","project","replace","currentComponentId","getIdByPathInCapsule","logProgress","toString","getCapsule","startTime","Date","now","done","endTime","end","dirs","typePath","contents","fs","readFile","filename","basename","dir","pathExists","outputFile","NPM_IGNORE_FILE","npmIgnorePath","npmIgnoreEntriesStr","appendFile","projects","files","references","tsconfigStr","writeFile","JSON","stringify","fileExtension","extname","RegExp","version"],"sources":["typescript.compiler.ts"],"sourcesContent":["import { BuildContext, BuiltTaskResult, ComponentResult } from '@teambit/builder';\nimport { Compiler, TranspileFileParams, TranspileFileOutput } from '@teambit/compiler';\nimport { Network } from '@teambit/isolator';\nimport { Logger } from '@teambit/logger';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport ts from 'typescript';\nimport { BitError } from '@teambit/bit-error';\nimport PackageJsonFile from '@teambit/legacy/dist/consumer/component/package-json-file';\nimport { TypeScriptCompilerOptions } from './compiler-options';\n\nexport class TypescriptCompiler implements Compiler {\n distDir: string;\n distGlobPatterns: string[];\n shouldCopyNonSupportedFiles: boolean;\n artifactName: string;\n constructor(\n readonly id: string,\n private logger: Logger,\n private options: TypeScriptCompilerOptions,\n private tsModule: typeof ts\n ) {\n this.distDir = options.distDir || 'dist';\n this.distGlobPatterns = options.distGlobPatterns || [`${this.distDir}/**`, `!${this.distDir}/tsconfig.tsbuildinfo`];\n this.shouldCopyNonSupportedFiles =\n typeof options.shouldCopyNonSupportedFiles === 'boolean' ? options.shouldCopyNonSupportedFiles : true;\n this.artifactName = options.artifactName || 'dist';\n this.options.tsconfig ||= {};\n this.options.tsconfig.compilerOptions ||= {};\n // mutate the outDir, otherwise, on capsules, the dists might be written to a different directory and make confusion\n this.options.tsconfig.compilerOptions.outDir = this.distDir;\n }\n\n displayName = 'TypeScript';\n deleteDistDir = false;\n\n displayConfig() {\n return this.stringifyTsconfig(this.options.tsconfig);\n }\n\n getDistDir() {\n return this.distDir;\n }\n\n /**\n * compile one file on the workspace\n */\n transpileFile(fileContent: string, options: TranspileFileParams): TranspileFileOutput {\n if (!this.isFileSupported(options.filePath)) {\n return null; // file is not supported\n }\n const compilerOptionsFromTsconfig = this.tsModule.convertCompilerOptionsFromJson(\n this.options.tsconfig.compilerOptions,\n '.'\n );\n if (compilerOptionsFromTsconfig.errors.length) {\n // :TODO @david replace to a more concrete error type and put in 'exceptions' directory here.\n const formattedErrors = this.tsModule.formatDiagnosticsWithColorAndContext(\n compilerOptionsFromTsconfig.errors,\n this.getFormatDiagnosticsHost()\n );\n throw new Error(`failed parsing the tsconfig.json.\\n${formattedErrors}`);\n }\n\n const compilerOptions = compilerOptionsFromTsconfig.options;\n compilerOptions.sourceRoot = options.componentDir;\n compilerOptions.rootDir = '.';\n const result = this.tsModule.transpileModule(fileContent, {\n compilerOptions,\n fileName: options.filePath,\n reportDiagnostics: true,\n });\n\n if (result.diagnostics && result.diagnostics.length) {\n const formatHost = this.getFormatDiagnosticsHost();\n const error = this.tsModule.formatDiagnosticsWithColorAndContext(result.diagnostics, formatHost);\n\n // :TODO @david please replace to a more concrete error type and put in 'exceptions' directory here.\n throw new Error(error);\n }\n\n const outputPath = this.replaceFileExtToJs(options.filePath);\n const outputFiles = [{ outputText: result.outputText, outputPath }];\n if (result.sourceMapText) {\n outputFiles.push({\n outputText: result.sourceMapText,\n outputPath: `${outputPath}.map`,\n });\n }\n return outputFiles;\n }\n\n async preBuild(context: BuildContext) {\n const capsules = context.capsuleNetwork.seedersCapsules;\n const capsuleDirs = capsules.map((capsule) => capsule.path);\n await this.writeTsConfig(capsuleDirs);\n await this.writeTypes(capsuleDirs);\n await this.writeNpmIgnore(capsuleDirs);\n }\n\n /**\n * compile multiple components on the capsules\n */\n async build(context: BuildContext): Promise<BuiltTaskResult> {\n const componentsResults = await this.runTscBuild(context.capsuleNetwork);\n\n return {\n artifacts: this.getArtifactDefinition(),\n componentsResults,\n };\n }\n\n async postBuild(context: BuildContext) {\n await Promise.all(\n context.capsuleNetwork.seedersCapsules.map(async (capsule) => {\n const packageJson = PackageJsonFile.loadFromCapsuleSync(capsule.path);\n // the types['index.ts'] is needed only during the build to avoid errors when tsc finds the\n // same type once in the d.ts and once in the ts file.\n if (packageJson.packageJsonObject.types) {\n delete packageJson.packageJsonObject.types;\n await packageJson.write();\n }\n })\n );\n }\n\n getArtifactDefinition() {\n return [\n {\n generatedBy: this.id,\n name: this.artifactName,\n globPatterns: this.distGlobPatterns,\n },\n ];\n }\n\n /**\n * given a source file, return its parallel in the dists. e.g. index.ts => dist/index.js\n */\n getDistPathBySrcPath(srcPath: string) {\n const fileWithJSExtIfNeeded = this.replaceFileExtToJs(srcPath);\n return path.join(this.distDir, fileWithJSExtIfNeeded);\n }\n\n /**\n * whether typescript is able to compile the given path\n */\n isFileSupported(filePath: string): boolean {\n const isJsAndCompile = !!this.options.compileJs && filePath.endsWith('.js');\n const isJsxAndCompile = !!this.options.compileJsx && filePath.endsWith('.jsx');\n return (\n (filePath.endsWith('.ts') || filePath.endsWith('.tsx') || isJsAndCompile || isJsxAndCompile) &&\n !filePath.endsWith('.d.ts')\n );\n }\n\n /**\n * we have two options here:\n * 1. pass all capsules-dir at the second parameter of createSolutionBuilder and then no\n * need to write the main tsconfig.json with all the references.\n * 2. write main tsconfig.json and pass the capsules root-dir.\n * we went with option #2 because it'll be easier for users to go to the capsule-root and run\n * `tsc --build` to debug issues.\n */\n private async runTscBuild(network: Network): Promise<ComponentResult[]> {\n const rootDir = network.capsulesRootDir;\n const capsules = await network.getCapsulesToCompile();\n if (!capsules.length) {\n return [];\n }\n const capsuleDirs = capsules.getAllCapsuleDirs();\n const formatHost = {\n getCanonicalFileName: (p) => p,\n getCurrentDirectory: () => '', // it helps to get the files with absolute paths\n getNewLine: () => this.tsModule.sys.newLine,\n };\n const componentsResults: ComponentResult[] = [];\n let currentComponentResult: Partial<ComponentResult> = { errors: [] };\n const reportDiagnostic = (diagnostic: ts.Diagnostic) => {\n const errorStr = process.stdout.isTTY\n ? this.tsModule.formatDiagnosticsWithColorAndContext([diagnostic], formatHost)\n : this.tsModule.formatDiagnostic(diagnostic, formatHost);\n if (!diagnostic.file) {\n // the error is general and not related to a specific file. e.g. tsconfig is missing.\n throw new BitError(errorStr);\n }\n this.logger.consoleFailure(errorStr);\n if (!currentComponentResult.component || !currentComponentResult.errors) {\n throw new Error(`currentComponentResult is not defined yet for ${diagnostic.file}`);\n }\n currentComponentResult.errors.push(errorStr);\n };\n // this only works when `verbose` is `true` in the `ts.createSolutionBuilder` function.\n const reportSolutionBuilderStatus = (diag: ts.Diagnostic) => {\n const msg = diag.messageText as string;\n this.logger.debug(msg);\n };\n const errorCounter = (errorCount: number) => {\n this.logger.info(`total error found: ${errorCount}`);\n };\n const host = this.tsModule.createSolutionBuilderHost(\n undefined,\n undefined,\n reportDiagnostic,\n reportSolutionBuilderStatus,\n errorCounter\n );\n await this.writeProjectReferencesTsConfig(rootDir, capsuleDirs);\n const solutionBuilder = this.tsModule.createSolutionBuilder(host, [rootDir], { verbose: true });\n let nextProject;\n const longProcessLogger = this.logger.createLongProcessLogger('compile typescript components', capsules.length);\n // eslint-disable-next-line no-cond-assign\n while ((nextProject = solutionBuilder.getNextInvalidatedProject())) {\n // regex to make sure it will work correctly for both linux and windows\n // it replaces both /tsconfig.json and \\tsocnfig.json\n const capsulePath = nextProject.project.replace(/[/\\\\]tsconfig.json/, '');\n const currentComponentId = capsules.getIdByPathInCapsule(capsulePath);\n if (!currentComponentId) throw new Error(`unable to find component for ${capsulePath}`);\n longProcessLogger.logProgress(currentComponentId.toString());\n const capsule = capsules.getCapsule(currentComponentId);\n if (!capsule) throw new Error(`unable to find capsule for ${currentComponentId.toString()}`);\n currentComponentResult.component = capsule.component;\n currentComponentResult.startTime = Date.now();\n nextProject.done();\n currentComponentResult.endTime = Date.now();\n componentsResults.push({ ...currentComponentResult } as ComponentResult);\n currentComponentResult = { errors: [] };\n }\n longProcessLogger.end();\n\n return componentsResults;\n }\n\n private getFormatDiagnosticsHost(): ts.FormatDiagnosticsHost {\n return {\n getCanonicalFileName: (p) => p,\n getCurrentDirectory: this.tsModule.sys.getCurrentDirectory,\n getNewLine: () => this.tsModule.sys.newLine,\n };\n }\n\n private async writeTypes(dirs: string[]) {\n await Promise.all(\n this.options.types.map(async (typePath) => {\n const contents = await fs.readFile(typePath, 'utf8');\n const filename = path.basename(typePath);\n\n await Promise.all(\n dirs.map(async (dir) => {\n const filePath = path.join(dir, 'types', filename);\n if (!(await fs.pathExists(filePath))) {\n await fs.outputFile(filePath, contents);\n }\n })\n );\n })\n );\n }\n\n /**\n * when using project-references, typescript adds a file \"tsconfig.tsbuildinfo\" which is not\n * needed for the package.\n */\n private async writeNpmIgnore(dirs: string[]) {\n const NPM_IGNORE_FILE = '.npmignore';\n await Promise.all(\n dirs.map(async (dir) => {\n const npmIgnorePath = path.join(dir, NPM_IGNORE_FILE);\n const npmIgnoreEntriesStr = `\\n${this.distDir}/tsconfig.tsbuildinfo\\n`;\n await fs.appendFile(npmIgnorePath, npmIgnoreEntriesStr);\n })\n );\n }\n\n private async writeProjectReferencesTsConfig(rootDir: string, projects: string[]) {\n const files = [];\n const references = projects.map((project) => ({ path: project }));\n const tsconfig = { files, references };\n const tsconfigStr = this.stringifyTsconfig(tsconfig);\n await fs.writeFile(path.join(rootDir, 'tsconfig.json'), tsconfigStr);\n }\n\n private async writeTsConfig(dirs: string[]) {\n const tsconfigStr = this.stringifyTsconfig(this.options.tsconfig);\n await Promise.all(dirs.map((dir) => fs.writeFile(path.join(dir, 'tsconfig.json'), tsconfigStr)));\n }\n\n private stringifyTsconfig(tsconfig) {\n return JSON.stringify(tsconfig, undefined, 2);\n }\n\n private replaceFileExtToJs(filePath: string): string {\n if (!this.isFileSupported(filePath)) return filePath;\n const fileExtension = path.extname(filePath);\n return filePath.replace(new RegExp(`${fileExtension}$`), '.js'); // makes sure it's the last occurrence\n }\n\n version() {\n return this.tsModule.version;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;;;;;AAGO,MAAMA,kBAAN,CAA6C;EAKlDC,WAAW,CACAC,EADA,EAEDC,MAFC,EAGDC,OAHC,EAIDC,QAJC,EAKT;IAAA;;IAAA,KAJSH,EAIT,GAJSA,EAIT;IAAA,KAHQC,MAGR,GAHQA,MAGR;IAAA,KAFQC,OAER,GAFQA,OAER;IAAA,KADQC,QACR,GADQA,QACR;IAAA;IAAA;IAAA;IAAA;IAAA,qDAYY,YAZZ;IAAA,uDAac,KAbd;IACA,KAAKC,OAAL,GAAeF,OAAO,CAACE,OAAR,IAAmB,MAAlC;IACA,KAAKC,gBAAL,GAAwBH,OAAO,CAACG,gBAAR,IAA4B,CAAE,GAAE,KAAKD,OAAQ,KAAjB,EAAwB,IAAG,KAAKA,OAAQ,uBAAxC,CAApD;IACA,KAAKE,2BAAL,GACE,OAAOJ,OAAO,CAACI,2BAAf,KAA+C,SAA/C,GAA2DJ,OAAO,CAACI,2BAAnE,GAAiG,IADnG;IAEA,KAAKC,YAAL,GAAoBL,OAAO,CAACK,YAAR,IAAwB,MAA5C;IACA,sBAAKL,OAAL,EAAaM,QAAb,mBAAaA,QAAb,GAA0B,EAA1B;IACA,8BAAKN,OAAL,CAAaM,QAAb,EAAsBC,eAAtB,2BAAsBA,eAAtB,GAA0C,EAA1C,EAPA,CAQA;;IACA,KAAKP,OAAL,CAAaM,QAAb,CAAsBC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AAb,EAA8CU,WAA9C,CAAlB,CAAZ,CAAN;EACD;;EAEO5I,iBAAiB,CAACJ,QAAD,EAAW;IAClC,OAAOkJ,IAAI,CAACC,SAAL,CAAenJ,QAAf,EAAyBwG,SAAzB,EAAoC,CAApC,CAAP;EACD;;EAEO3E,kBAAkB,CAACpB,QAAD,EAA2B;IACnD,IAAI,CAAC,KAAKD,eAAL,CAAqBC,QAArB,CAAL,EAAqC,OAAOA,QAAP;;IACrC,MAAM2I,aAAa,GAAG1G,eAAA,CAAK2G,OAAL,CAAa5I,QAAb,CAAtB;;IACA,OAAOA,QAAQ,CAAC0G,OAAT,CAAiB,IAAImC,MAAJ,CAAY,GAAEF,aAAc,GAA5B,CAAjB,EAAkD,KAAlD,CAAP,CAHmD,CAGc;EAClE;;EAEDG,OAAO,GAAG;IACR,OAAO,KAAK5J,QAAL,CAAc4J,OAArB;EACD;;AAhSiD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["typescript.compiler.spec.ts"],"names":["defaultOpts","tsconfig","types","describe","it","tsCompiler","getTsCompiler","getDistPathBySrcPath","to","equal","path","join","isFileSupported","be","true","false","compileJsx","compileJs","opts","finalOpts","Object","assign","TypescriptCompiler","TypescriptAspect","id","Logger","ts"],"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;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;;;AAGA,MAAMA,WAAW,GAAG;AAClBC,EAAAA,QAAQ,EAAE,EADQ;AAElBC,EAAAA,KAAK,EAAE;AAFW,CAApB;AAKAC,QAAQ,CAAC,oBAAD,EAAuB,MAAM;AACnCA,EAAAA,QAAQ,CAAC,sBA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AAC3E,QAAMmB,SAAS,GAAGC,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBrB,WAAlB,EAA+BkB,IAA/B,CAAlB;AACA,SAAO,KAAII,iCAAJ,EAAuBC,gCAAiBC,EAAxC,EAA4C,KAAIC,gBAAJ,EAAW,MAAX,CAA5C,EAAgEN,SAAhE,EAA2EO,qBAA3E,CAAP;AACD","sourcesContent":["import { Logger } from '@teambit/logger';\nimport ts from 'typescript';\nimport { expect } from 'chai';\nimport path from 'path';\nimport { TypescriptAspect } from './typescript.aspect';\n\nimport { TypescriptCompiler } from './typescript.compiler';\nimport type { TsCompilerOptionsWithoutTsConfig } from './compiler-options';\n\nconst defaultOpts = {\n tsconfig: {},\n types: [],\n};\n\ndescribe('TypescriptCompiler', () => {\n describe('getDistPathBySrcPath', () => {\n it('should replace the extension with .js and prepend the dist dir', () => {\n const tsCompiler = getTsCompiler();\n expect(tsCompiler.getDistPathBySrcPath('index.ts')).to.equal(path.join('dist', 'index.js'));\n expect(tsCompiler.getDistPathBySrcPath('index.tsx')).to.equal(path.join('dist', 'index.js'));\n });\n it('should not replace the extension if the file is not supported', () => {\n const tsCompiler = getTsCompiler();\n expect(tsCompiler.getDistPathBySrcPath('style.css')).to.equal(path.join('dist', 'style.css'));\n expect(tsCompiler.getDistPathBySrcPath('index.d.ts')).to.equal(path.join('dist', 'index.d.ts'));\n });\n });\n describe('isFileSupported', () => {\n it('should support .ts files', () => {\n const tsCompiler = getTsCompiler();\n expect(tsCompiler.isFileSupported('index.ts')).to.be.true;\n });\n it('should support .tsx files', () => {\n const tsCompiler = getTsCompiler();\n expect(tsCompiler.isFileSupported('index.tsx')).to.be.true;\n });\n it('should not support .jsx files by default', () => {\n const tsCompiler = getTsCompiler();\n expect(tsCompiler.isFileSupported('index.jsx')).to.be.false;\n });\n it('should not support .js files by default', () => {\n const tsCompiler = getTsCompiler();\n expect(tsCompiler.isFileSupported('index.js')).to.be.false;\n });\n it('should support .jsx files when passing compileJsx', () => {\n const tsCompiler = getTsCompiler({ compileJsx: true, ...defaultOpts });\n expect(tsCompiler.isFileSupported('index.jsx')).to.be.true;\n });\n it('should support .js files when passing compileJs', () => {\n const tsCompiler = getTsCompiler({ compileJs: true, ...defaultOpts });\n expect(tsCompiler.isFileSupported('index.js')).to.be.true;\n });\n it('should not support .d.ts files', () => {\n const tsCompiler = getTsCompiler();\n expect(tsCompiler.isFileSupported('index.d.ts')).to.be.false;\n });\n });\n});\n\nfunction getTsCompiler(opts: TsCompilerOptionsWithoutTsConfig = defaultOpts) {\n const finalOpts = Object.assign({}, defaultOpts, opts);\n return new TypescriptCompiler(TypescriptAspect.id, new Logger('test'), finalOpts, ts);\n}\n"]}
1
+ {"version":3,"names":["defaultOpts","tsconfig","types","describe","it","tsCompiler","getTsCompiler","expect","getDistPathBySrcPath","to","equal","path","join","isFileSupported","be","true","false","compileJsx","compileJs","opts","finalOpts","Object","assign","TypescriptCompiler","TypescriptAspect","id","Logger","ts"],"sources":["typescript.compiler.spec.ts"],"sourcesContent":["import { Logger } from '@teambit/logger';\nimport ts from 'typescript';\nimport { expect } from 'chai';\nimport path from 'path';\nimport { TypescriptAspect } from './typescript.aspect';\n\nimport { TypescriptCompiler } from './typescript.compiler';\nimport type { TsCompilerOptionsWithoutTsConfig } from './compiler-options';\n\nconst defaultOpts = {\n tsconfig: {},\n types: [],\n};\n\ndescribe('TypescriptCompiler', () => {\n describe('getDistPathBySrcPath', () => {\n it('should replace the extension with .js and prepend the dist dir', () => {\n const tsCompiler = getTsCompiler();\n expect(tsCompiler.getDistPathBySrcPath('index.ts')).to.equal(path.join('dist', 'index.js'));\n expect(tsCompiler.getDistPathBySrcPath('index.tsx')).to.equal(path.join('dist', 'index.js'));\n });\n it('should not replace the extension if the file is not supported', () => {\n const tsCompiler = getTsCompiler();\n expect(tsCompiler.getDistPathBySrcPath('style.css')).to.equal(path.join('dist', 'style.css'));\n expect(tsCompiler.getDistPathBySrcPath('index.d.ts')).to.equal(path.join('dist', 'index.d.ts'));\n });\n });\n describe('isFileSupported', () => {\n it('should support .ts files', () => {\n const tsCompiler = getTsCompiler();\n expect(tsCompiler.isFileSupported('index.ts')).to.be.true;\n });\n it('should support .tsx files', () => {\n const tsCompiler = getTsCompiler();\n expect(tsCompiler.isFileSupported('index.tsx')).to.be.true;\n });\n it('should not support .jsx files by default', () => {\n const tsCompiler = getTsCompiler();\n expect(tsCompiler.isFileSupported('index.jsx')).to.be.false;\n });\n it('should not support .js files by default', () => {\n const tsCompiler = getTsCompiler();\n expect(tsCompiler.isFileSupported('index.js')).to.be.false;\n });\n it('should support .jsx files when passing compileJsx', () => {\n const tsCompiler = getTsCompiler({ compileJsx: true, ...defaultOpts });\n expect(tsCompiler.isFileSupported('index.jsx')).to.be.true;\n });\n it('should support .js files when passing compileJs', () => {\n const tsCompiler = getTsCompiler({ compileJs: true, ...defaultOpts });\n expect(tsCompiler.isFileSupported('index.js')).to.be.true;\n });\n it('should not support .d.ts files', () => {\n const tsCompiler = getTsCompiler();\n expect(tsCompiler.isFileSupported('index.d.ts')).to.be.false;\n });\n });\n});\n\nfunction getTsCompiler(opts: TsCompilerOptionsWithoutTsConfig = defaultOpts) {\n const finalOpts = Object.assign({}, defaultOpts, opts);\n return new TypescriptCompiler(TypescriptAspect.id, new Logger('test'), finalOpts, ts);\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;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;;;;;AAGA,MAAMA,WAAW,GAAG;EAClBC,QAAQ,EAAE,EADQ;EAElBC,KAAK,EAAE;AAFW,CAApB;AAKAC,QAAQ,CAAC,oBAAD,EAAuB,M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HC,CAAF;EAID,CA7BO,CAAR;AA8BD,CA3CO,CAAR;;AA6CA,SAASV,aAAT,CAAuBa,IAAsC,GAAGnB,WAAhE,EAA6E;EAC3E,MAAMoB,SAAS,GAAGC,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBtB,WAAlB,EAA+BmB,IAA/B,CAAlB;EACA,OAAO,KAAII,iCAAJ,EAAuBC,+BAAA,CAAiBC,EAAxC,EAA4C,KAAIC,gBAAJ,EAAW,MAAX,CAA5C,EAAgEN,SAAhE,EAA2EO,qBAA3E,CAAP;AACD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["typescript.composition.tsx"],"names":["Logo","height","display","justifyContent","width"],"mappings":";;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,IAAI,GAAG,mBAClB;AAAK,EAAA,KAAK,EAAE;AAAEC,IAAAA,MAAM,EAAE,MAAV;AAAkBC,IAAAA,OAAO,EAAE,MAA3B;AAAmCC,IAAAA,cAAc,EAAE;AAAnD;AAAZ,gBACE;AAAK,EAAA,KAAK,EAAE;AAAEC,IAAAA,KAAK,EAAE;AAAT,GAAZ;AAA2B,EAAA,GAAG,EAAC;AAA/B,EADF,CADK","sourcesContent":["import React from 'react';\n\nexport const Logo = () => (\n <div style={{ height: '100%', display: 'flex', justifyContent: 'center' }}>\n <img style={{ width: 70 }} src=\"https://static.bit.dev/brands/logo-typescript.svg\" />\n </div>\n);\n"]}
1
+ {"version":3,"names":["Logo","height","display","justifyContent","width"],"sources":["typescript.composition.tsx"],"sourcesContent":["import React from 'react';\n\nexport const Logo = () => (\n <div style={{ height: '100%', display: 'flex', justifyContent: 'center' }}>\n <img style={{ width: 70 }} src=\"https://static.bit.dev/brands/logo-typescript.svg\" />\n </div>\n);\n"],"mappings":";;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAAMA,IAAI,GAAG,mBAClB;EAAK,KAAK,EAAE;IAAEC,MAAM,EAAE,MAAV;IAAkBC,OAAO,EAAE,MAA3B;IAAmCC,cAAc,EAAE;EAAnD;AAAZ,gBACE;EAAK,KAAK,EAAE;IAAEC,KAAK,EAAE;EAAT,CAAZ;EAA2B,GAAG,EAAC;AAA/B,EADF,CADK"}
@@ -107,9 +107,9 @@ class TypeScriptExtractor {
107
107
  context.setExports(new (_exportList().ExportList)(exportNames));
108
108
  const moduleSchema = await this.computeSchema(mainAst, context);
109
109
  moduleSchema.flatExportsRecursively();
110
- const apiScheme = moduleSchema; // return APISchema.from({ });
111
-
112
- return new (_semanticsEntities().APISchema)(apiScheme);
110
+ const apiScheme = moduleSchema;
111
+ const location = context.getLocation(mainAst);
112
+ return new (_semanticsEntities().APISchema)(location, apiScheme);
113
113
  }
114
114
 
115
115
  async computeExportedIdentifiers(node, context) {