@teambit/typescript 1.0.107 → 1.0.109

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 (68) hide show
  1. package/artifacts/__bit_junit.xml +49 -0
  2. package/artifacts/preview/teambit_typescript_typescript-preview.js +1 -0
  3. package/dist/cmds/write-tsconfig.cmd.d.ts +2 -2
  4. package/dist/compiler-options.d.ts +2 -2
  5. package/dist/extractor-options.d.ts +1 -1
  6. package/dist/identifier-list.d.ts +1 -1
  7. package/dist/identifier.d.ts +3 -3
  8. package/dist/{preview-1703590665075.js → preview-1703698405864.js} +2 -2
  9. package/dist/schema-extractor-context.d.ts +11 -11
  10. package/dist/schema-extractor-context.js +13 -17
  11. package/dist/schema-extractor-context.js.map +1 -1
  12. package/dist/schema-transformer.d.ts +2 -2
  13. package/dist/sourceFileTransformers/export.js +1 -2
  14. package/dist/sourceFileTransformers/export.js.map +1 -1
  15. package/dist/sourceFileTransformers/function.js +2 -3
  16. package/dist/sourceFileTransformers/function.js.map +1 -1
  17. package/dist/sourceFileTransformers/import.js +1 -2
  18. package/dist/sourceFileTransformers/import.js.map +1 -1
  19. package/dist/sourceFileTransformers/index.d.ts +1 -1
  20. package/dist/sourceFileTransformers/transform.js +1 -1
  21. package/dist/sourceFileTransformers/transform.js.map +1 -1
  22. package/dist/transformers/binding-element.js +1 -2
  23. package/dist/transformers/binding-element.js.map +1 -1
  24. package/dist/transformers/class-declaration.js +3 -6
  25. package/dist/transformers/class-declaration.js.map +1 -1
  26. package/dist/transformers/constructor.js +3 -4
  27. package/dist/transformers/constructor.js.map +1 -1
  28. package/dist/transformers/enum-declaration.js +1 -2
  29. package/dist/transformers/enum-declaration.js.map +1 -1
  30. package/dist/transformers/export-declaration.js +5 -7
  31. package/dist/transformers/export-declaration.js.map +1 -1
  32. package/dist/transformers/function-like.js +5 -8
  33. package/dist/transformers/function-like.js.map +1 -1
  34. package/dist/transformers/get-accessor.js +1 -2
  35. package/dist/transformers/get-accessor.js.map +1 -1
  36. package/dist/transformers/import-declaration.js +2 -3
  37. package/dist/transformers/import-declaration.js.map +1 -1
  38. package/dist/transformers/interface-declaration.js +1 -2
  39. package/dist/transformers/interface-declaration.js.map +1 -1
  40. package/dist/transformers/parameter.js +1 -2
  41. package/dist/transformers/parameter.js.map +1 -1
  42. package/dist/transformers/property-declaration.js +1 -2
  43. package/dist/transformers/property-declaration.js.map +1 -1
  44. package/dist/transformers/source-file-transformer.js +3 -5
  45. package/dist/transformers/source-file-transformer.js.map +1 -1
  46. package/dist/transformers/utils/jsdoc-to-doc-schema.js +2 -4
  47. package/dist/transformers/utils/jsdoc-to-doc-schema.js.map +1 -1
  48. package/dist/transformers/utils/parse-type-from-quick-info.js +1 -2
  49. package/dist/transformers/utils/parse-type-from-quick-info.js.map +1 -1
  50. package/dist/transformers/variable-declaration.js +8 -12
  51. package/dist/transformers/variable-declaration.js.map +1 -1
  52. package/dist/tsconfig-writer.d.ts +2 -2
  53. package/dist/tsconfig-writer.js +1 -4
  54. package/dist/tsconfig-writer.js.map +1 -1
  55. package/dist/typescript.composition.d.ts +2 -2
  56. package/dist/typescript.extractor.d.ts +3 -3
  57. package/dist/typescript.extractor.js +5 -7
  58. package/dist/typescript.extractor.js.map +1 -1
  59. package/dist/typescript.main.runtime.d.ts +7 -7
  60. package/dist/typescript.main.runtime.js +1 -2
  61. package/dist/typescript.main.runtime.js.map +1 -1
  62. package/dist/typescript.parser.js +7 -8
  63. package/dist/typescript.parser.js.map +1 -1
  64. package/dist/typescript.parser.spec.js +12 -15
  65. package/dist/typescript.parser.spec.js.map +1 -1
  66. package/package.json +27 -34
  67. package/tsconfig.json +16 -21
  68. package/types/asset.d.ts +15 -3
@@ -112,21 +112,20 @@ class TypeScriptParser {
112
112
  if (!exportStaticProperties.has(targetName)) exportStaticProperties.set(targetName, new Map());
113
113
  const existingProperties = exportStaticProperties.get(targetName);
114
114
  if (_typescript().default.isStringLiteral(statement.expression.right)) {
115
- existingProperties === null || existingProperties === void 0 || existingProperties.set(propertyName, statement.expression.right.text);
115
+ existingProperties?.set(propertyName, statement.expression.right.text);
116
116
  } else if (_typescript().default.isNumericLiteral(statement.expression.right)) {
117
- existingProperties === null || existingProperties === void 0 || existingProperties.set(propertyName, +statement.expression.right.text);
117
+ existingProperties?.set(propertyName, +statement.expression.right.text);
118
118
  } else if (statement.expression.right.kind === _typescript().default.SyntaxKind.UndefinedKeyword) {
119
- existingProperties === null || existingProperties === void 0 || existingProperties.set(propertyName, undefined);
119
+ existingProperties?.set(propertyName, undefined);
120
120
  } else if (statement.expression.right.kind === _typescript().default.SyntaxKind.NullKeyword) {
121
- existingProperties === null || existingProperties === void 0 || existingProperties.set(propertyName, null);
121
+ existingProperties?.set(propertyName, null);
122
122
  } else if (statement.expression.right.kind === _typescript().default.SyntaxKind.TrueKeyword) {
123
- existingProperties === null || existingProperties === void 0 || existingProperties.set(propertyName, true);
123
+ existingProperties?.set(propertyName, true);
124
124
  } else if (statement.expression.right.kind === _typescript().default.SyntaxKind.FalseKeyword) {
125
- existingProperties === null || existingProperties === void 0 || existingProperties.set(propertyName, false);
125
+ existingProperties?.set(propertyName, false);
126
126
  }
127
127
  } catch (err) {
128
- var _this$logger;
129
- (_this$logger = this.logger) === null || _this$logger === void 0 || _this$logger.error('failed parsing static properties', err);
128
+ this.logger?.error('failed parsing static properties', err);
130
129
  }
131
130
  });
132
131
  return exportStaticProperties;
@@ -1 +1 @@
1
- {"version":3,"names":["_semanticsEntities","data","require","_fsExtra","_typescript","_interopRequireDefault","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","TypeScriptParser","getExports","sourceFile","staticProperties","parseStaticProperties","exportModels","statements","forEach","statement","ts","isExportAssignment","isExportDeclaration","exportClause","isNamedExports","elements","element","name","escapedText","toString","push","Export","get","isNamespaceExport","modifiers","some","modifier","kind","SyntaxKind","ExportKeyword","isVariableStatement","child","declarationList","declarations","isIdentifier","isFunctionDeclaration","isClassDeclaration","withoutEmpty","filter","exportModel","undefined","parseModule","modulePath","content","ast","createSourceFile","readFileSync","ScriptTarget","Latest","moduleExports","exportStaticProperties","Map","isExpressionStatement","isBinaryExpression","expression","operatorToken","EqualsToken","isPropertyAccessExpression","left","targetName","text","propertyName","has","set","existingProperties","isStringLiteral","right","isNumericLiteral","UndefinedKeyword","NullKeyword","TrueKeyword","FalseKeyword","err","_this$logger","logger","error","constructor","exports"],"sources":["typescript.parser.ts"],"sourcesContent":["import { Parser } from '@teambit/schema';\nimport { Export, StaticProperties } from '@teambit/semantics.entities.semantic-schema';\nimport { Logger } from '@teambit/logger';\nimport { readFileSync } from 'fs-extra';\nimport ts from 'typescript';\n\nexport class TypeScriptParser implements Parser {\n public extension = /^.*\\.(js|jsx|ts|tsx)$/;\n\n getExports(sourceFile: ts.SourceFile): Export[] {\n const staticProperties = this.parseStaticProperties(sourceFile);\n const exportModels: Export[] = [];\n\n sourceFile.statements.forEach((statement) => {\n // export default\n if (ts.isExportAssignment(statement)) {\n // export default\n }\n\n // export declarations or re-exports\n if (ts.isExportDeclaration(statement)) {\n if (statement.exportClause) {\n if (ts.isNamedExports(statement.exportClause)) {\n statement.exportClause.elements.forEach((element) => {\n const name = element.name.escapedText.toString();\n if (name !== 'default') {\n exportModels.push(new Export(name, staticProperties.get(name)));\n }\n });\n }\n if (ts.isNamespaceExport(statement.exportClause)) {\n const name = statement.exportClause.name.escapedText.toString();\n exportModels.push(new Export(name, staticProperties.get(name)));\n }\n }\n }\n\n // export modifiers\n // - variable statement\n // - function statement\n // - class statement\n if (statement.modifiers) {\n statement.modifiers.some((modifier) => {\n if (modifier.kind === ts.SyntaxKind.ExportKeyword) {\n if (ts.isVariableStatement(statement)) {\n const child = statement.declarationList.declarations[0];\n if (ts.isIdentifier(child.name)) {\n const name = child.name.escapedText.toString();\n exportModels.push(new Export(name, staticProperties.get(name)));\n }\n } else if (ts.isFunctionDeclaration(statement)) {\n if (statement.name) {\n const name = statement.name.escapedText.toString();\n exportModels.push(new Export(name, staticProperties.get(name)));\n }\n } else if (ts.isClassDeclaration(statement)) {\n if (statement.name) {\n const name = statement.name.escapedText.toString();\n exportModels.push(new Export(name, staticProperties.get(name)));\n }\n }\n return true;\n }\n return false;\n });\n }\n });\n\n const withoutEmpty = exportModels.filter((exportModel) => exportModel !== undefined);\n // @ts-ignore\n return withoutEmpty;\n }\n\n parseModule(modulePath: string, content?: string) {\n const ast = ts.createSourceFile(modulePath, content || readFileSync(modulePath, 'utf8'), ts.ScriptTarget.Latest);\n\n const moduleExports = this.getExports(ast);\n return moduleExports;\n }\n\n parseStaticProperties(sourceFile: ts.SourceFile) {\n // TODO - should we also parse staticProperties inside classes / objects?\n\n const exportStaticProperties = new Map<string, StaticProperties>();\n\n sourceFile.statements.forEach((statement) => {\n try {\n if (!ts.isExpressionStatement(statement)) return;\n if (!ts.isBinaryExpression(statement.expression)) return;\n if (statement.expression.operatorToken.kind !== ts.SyntaxKind.EqualsToken) return;\n if (!ts.isPropertyAccessExpression(statement.expression.left)) return;\n if (!ts.isIdentifier(statement.expression.left.expression)) return;\n\n const targetName = statement.expression.left.expression.text;\n const propertyName = statement.expression.left.name.text;\n\n if (!exportStaticProperties.has(targetName)) exportStaticProperties.set(targetName, new Map());\n\n const existingProperties = exportStaticProperties.get(targetName);\n\n if (ts.isStringLiteral(statement.expression.right)) {\n existingProperties?.set(propertyName, statement.expression.right.text);\n } else if (ts.isNumericLiteral(statement.expression.right)) {\n existingProperties?.set(propertyName, +statement.expression.right.text);\n } else if (statement.expression.right.kind === ts.SyntaxKind.UndefinedKeyword) {\n existingProperties?.set(propertyName, undefined);\n } else if (statement.expression.right.kind === ts.SyntaxKind.NullKeyword) {\n existingProperties?.set(propertyName, null);\n } else if (statement.expression.right.kind === ts.SyntaxKind.TrueKeyword) {\n existingProperties?.set(propertyName, true);\n } else if (statement.expression.right.kind === ts.SyntaxKind.FalseKeyword) {\n existingProperties?.set(propertyName, false);\n }\n } catch (err) {\n this.logger?.error('failed parsing static properties', err);\n }\n });\n\n return exportStaticProperties;\n }\n\n constructor(private logger?: Logger | undefined) {}\n}\n"],"mappings":";;;;;;AACA,SAAAA,mBAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,kBAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,SAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,QAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,YAAA;EAAA,MAAAH,IAAA,GAAAI,sBAAA,CAAAH,OAAA;EAAAE,WAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA4B,SAAAI,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,gBAAAH,GAAA,EAAAI,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAJ,GAAA,IAAAO,MAAA,CAAAC,cAAA,CAAAR,GAAA,EAAAI,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAX,GAAA,CAAAI,GAAA,IAAAC,KAAA,WAAAL,GAAA;AAAA,SAAAM,eAAAM,CAAA,QAAAC,CAAA,GAAAC,YAAA,CAAAF,CAAA,uCAAAC,CAAA,GAAAA,CAAA,GAAAE,MAAA,CAAAF,CAAA;AAAA,SAAAC,aAAAF,CAAA,EAAAI,CAAA,2BAAAJ,CAAA,KAAAA,CAAA,SAAAA,CAAA,MAAAK,CAAA,GAAAL,CAAA,CAAAM,MAAA,CAAAC,WAAA,kBAAAF,CAAA,QAAAJ,CAAA,G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,YAAY,EAAE,IAAI,CAAC;QAC7C,CAAC,MAAM,IAAIpD,SAAS,CAAC6C,UAAU,CAACY,KAAK,CAACvC,IAAI,KAAKjB,qBAAE,CAACkB,UAAU,CAAC0C,WAAW,EAAE;UACxEN,kBAAkB,aAAlBA,kBAAkB,eAAlBA,kBAAkB,CAAED,GAAG,CAACF,YAAY,EAAE,IAAI,CAAC;QAC7C,CAAC,MAAM,IAAIpD,SAAS,CAAC6C,UAAU,CAACY,KAAK,CAACvC,IAAI,KAAKjB,qBAAE,CAACkB,UAAU,CAAC2C,YAAY,EAAE;UACzEP,kBAAkB,aAAlBA,kBAAkB,eAAlBA,kBAAkB,CAAED,GAAG,CAACF,YAAY,EAAE,KAAK,CAAC;QAC9C;MACF,CAAC,CAAC,OAAOW,GAAG,EAAE;QAAA,IAAAC,YAAA;QACZ,CAAAA,YAAA,OAAI,CAACC,MAAM,cAAAD,YAAA,eAAXA,YAAA,CAAaE,KAAK,CAAC,kCAAkC,EAAEH,GAAG,CAAC;MAC7D;IACF,CAAC,CAAC;IAEF,OAAOtB,sBAAsB;EAC/B;EAEA0B,WAAWA,CAASF,MAA2B,EAAE;IAAA,KAA7BA,MAA2B,GAA3BA,MAA2B;IAAA7F,eAAA,oBAlH5B,uBAAuB;EAkHQ;AACpD;AAACgG,OAAA,CAAA5E,gBAAA,GAAAA,gBAAA"}
1
+ {"version":3,"names":["_semanticsEntities","data","require","_fsExtra","_typescript","_interopRequireDefault","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","TypeScriptParser","getExports","sourceFile","staticProperties","parseStaticProperties","exportModels","statements","forEach","statement","ts","isExportAssignment","isExportDeclaration","exportClause","isNamedExports","elements","element","name","escapedText","toString","push","Export","get","isNamespaceExport","modifiers","some","modifier","kind","SyntaxKind","ExportKeyword","isVariableStatement","child","declarationList","declarations","isIdentifier","isFunctionDeclaration","isClassDeclaration","withoutEmpty","filter","exportModel","undefined","parseModule","modulePath","content","ast","createSourceFile","readFileSync","ScriptTarget","Latest","moduleExports","exportStaticProperties","Map","isExpressionStatement","isBinaryExpression","expression","operatorToken","EqualsToken","isPropertyAccessExpression","left","targetName","text","propertyName","has","set","existingProperties","isStringLiteral","right","isNumericLiteral","UndefinedKeyword","NullKeyword","TrueKeyword","FalseKeyword","err","logger","error","constructor","exports"],"sources":["typescript.parser.ts"],"sourcesContent":["import { Parser } from '@teambit/schema';\nimport { Export, StaticProperties } from '@teambit/semantics.entities.semantic-schema';\nimport { Logger } from '@teambit/logger';\nimport { readFileSync } from 'fs-extra';\nimport ts from 'typescript';\n\nexport class TypeScriptParser implements Parser {\n public extension = /^.*\\.(js|jsx|ts|tsx)$/;\n\n getExports(sourceFile: ts.SourceFile): Export[] {\n const staticProperties = this.parseStaticProperties(sourceFile);\n const exportModels: Export[] = [];\n\n sourceFile.statements.forEach((statement) => {\n // export default\n if (ts.isExportAssignment(statement)) {\n // export default\n }\n\n // export declarations or re-exports\n if (ts.isExportDeclaration(statement)) {\n if (statement.exportClause) {\n if (ts.isNamedExports(statement.exportClause)) {\n statement.exportClause.elements.forEach((element) => {\n const name = element.name.escapedText.toString();\n if (name !== 'default') {\n exportModels.push(new Export(name, staticProperties.get(name)));\n }\n });\n }\n if (ts.isNamespaceExport(statement.exportClause)) {\n const name = statement.exportClause.name.escapedText.toString();\n exportModels.push(new Export(name, staticProperties.get(name)));\n }\n }\n }\n\n // export modifiers\n // - variable statement\n // - function statement\n // - class statement\n if (statement.modifiers) {\n statement.modifiers.some((modifier) => {\n if (modifier.kind === ts.SyntaxKind.ExportKeyword) {\n if (ts.isVariableStatement(statement)) {\n const child = statement.declarationList.declarations[0];\n if (ts.isIdentifier(child.name)) {\n const name = child.name.escapedText.toString();\n exportModels.push(new Export(name, staticProperties.get(name)));\n }\n } else if (ts.isFunctionDeclaration(statement)) {\n if (statement.name) {\n const name = statement.name.escapedText.toString();\n exportModels.push(new Export(name, staticProperties.get(name)));\n }\n } else if (ts.isClassDeclaration(statement)) {\n if (statement.name) {\n const name = statement.name.escapedText.toString();\n exportModels.push(new Export(name, staticProperties.get(name)));\n }\n }\n return true;\n }\n return false;\n });\n }\n });\n\n const withoutEmpty = exportModels.filter((exportModel) => exportModel !== undefined);\n // @ts-ignore\n return withoutEmpty;\n }\n\n parseModule(modulePath: string, content?: string) {\n const ast = ts.createSourceFile(modulePath, content || readFileSync(modulePath, 'utf8'), ts.ScriptTarget.Latest);\n\n const moduleExports = this.getExports(ast);\n return moduleExports;\n }\n\n parseStaticProperties(sourceFile: ts.SourceFile) {\n // TODO - should we also parse staticProperties inside classes / objects?\n\n const exportStaticProperties = new Map<string, StaticProperties>();\n\n sourceFile.statements.forEach((statement) => {\n try {\n if (!ts.isExpressionStatement(statement)) return;\n if (!ts.isBinaryExpression(statement.expression)) return;\n if (statement.expression.operatorToken.kind !== ts.SyntaxKind.EqualsToken) return;\n if (!ts.isPropertyAccessExpression(statement.expression.left)) return;\n if (!ts.isIdentifier(statement.expression.left.expression)) return;\n\n const targetName = statement.expression.left.expression.text;\n const propertyName = statement.expression.left.name.text;\n\n if (!exportStaticProperties.has(targetName)) exportStaticProperties.set(targetName, new Map());\n\n const existingProperties = exportStaticProperties.get(targetName);\n\n if (ts.isStringLiteral(statement.expression.right)) {\n existingProperties?.set(propertyName, statement.expression.right.text);\n } else if (ts.isNumericLiteral(statement.expression.right)) {\n existingProperties?.set(propertyName, +statement.expression.right.text);\n } else if (statement.expression.right.kind === ts.SyntaxKind.UndefinedKeyword) {\n existingProperties?.set(propertyName, undefined);\n } else if (statement.expression.right.kind === ts.SyntaxKind.NullKeyword) {\n existingProperties?.set(propertyName, null);\n } else if (statement.expression.right.kind === ts.SyntaxKind.TrueKeyword) {\n existingProperties?.set(propertyName, true);\n } else if (statement.expression.right.kind === ts.SyntaxKind.FalseKeyword) {\n existingProperties?.set(propertyName, false);\n }\n } catch (err) {\n this.logger?.error('failed parsing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IAAI,CAAC;QAC7C,CAAC,MAAM,IAAIpD,SAAS,CAAC6C,UAAU,CAACY,KAAK,CAACvC,IAAI,KAAKjB,qBAAE,CAACkB,UAAU,CAAC2C,YAAY,EAAE;UACzEP,kBAAkB,EAAED,GAAG,CAACF,YAAY,EAAE,KAAK,CAAC;QAC9C;MACF,CAAC,CAAC,OAAOW,GAAG,EAAE;QACZ,IAAI,CAACC,MAAM,EAAEC,KAAK,CAAC,kCAAkC,EAAEF,GAAG,CAAC;MAC7D;IACF,CAAC,CAAC;IAEF,OAAOtB,sBAAsB;EAC/B;EAEAyB,WAAWA,CAASF,MAA2B,EAAE;IAAA,KAA7BA,MAA2B,GAA3BA,MAA2B;IAAA5F,eAAA,oBAlH5B,uBAAuB;EAkHQ;AACpD;AAAC+F,OAAA,CAAA3E,gBAAA,GAAAA,gBAAA"}
@@ -125,25 +125,22 @@ describe('TypescriptParser', () => {
125
125
  });
126
126
  describe('staticProperties', () => {
127
127
  it('should include staticProperties, when on arrowFunctions', () => {
128
- var _exportArrow$staticPr;
129
128
  const ast = _typescript().default.createSourceFile('example.tsx', exampleArrowFunction, _typescript().default.ScriptTarget.Latest);
130
129
  const exports = new (_typescript2().TypeScriptParser)().getExports(ast);
131
130
  const exportArrow = exports.find(x => x.identifier === 'arrow');
132
- (0, _chai().expect)(exportArrow === null || exportArrow === void 0 || (_exportArrow$staticPr = exportArrow.staticProperties) === null || _exportArrow$staticPr === void 0 ? void 0 : _exportArrow$staticPr.get('textProperty')).to.equal('propertyValue');
131
+ (0, _chai().expect)(exportArrow?.staticProperties?.get('textProperty')).to.equal('propertyValue');
133
132
  });
134
133
  it('should include staticProperties, when on regular functions', () => {
135
- var _exportClass$staticPr;
136
134
  const ast = _typescript().default.createSourceFile('example.tsx', exampleFunction, _typescript().default.ScriptTarget.Latest);
137
135
  const exports = new (_typescript2().TypeScriptParser)().getExports(ast);
138
136
  const exportClass = exports.find(x => x.identifier === 'func');
139
- (0, _chai().expect)(exportClass === null || exportClass === void 0 || (_exportClass$staticPr = exportClass.staticProperties) === null || _exportClass$staticPr === void 0 ? void 0 : _exportClass$staticPr.get('textProperty')).to.equal('propertyValue');
137
+ (0, _chai().expect)(exportClass?.staticProperties?.get('textProperty')).to.equal('propertyValue');
140
138
  });
141
139
  it('should include staticProperties, when on classes', () => {
142
- var _exportClass$staticPr2;
143
140
  const ast = _typescript().default.createSourceFile('example.tsx', exampleClass, _typescript().default.ScriptTarget.Latest);
144
141
  const exports = new (_typescript2().TypeScriptParser)().getExports(ast);
145
142
  const exportClass = exports.find(x => x.identifier === 'classy');
146
- (0, _chai().expect)(exportClass === null || exportClass === void 0 || (_exportClass$staticPr2 = exportClass.staticProperties) === null || _exportClass$staticPr2 === void 0 ? void 0 : _exportClass$staticPr2.get('textProperty')).to.equal('propertyValue');
143
+ (0, _chai().expect)(exportClass?.staticProperties?.get('textProperty')).to.equal('propertyValue');
147
144
  });
148
145
  });
149
146
  });
@@ -166,25 +163,25 @@ describe('TypescriptParser', () => {
166
163
  (0, _chai().expect)(staticProperties).to.exist;
167
164
  const exportHello = staticProperties.get('hello');
168
165
  (0, _chai().expect)(exportHello).to.exist;
169
- (0, _chai().expect)(exportHello === null || exportHello === void 0 ? void 0 : exportHello.get('text')).to.equal('is');
170
- (0, _chai().expect)(exportHello === null || exportHello === void 0 ? void 0 : exportHello.get('count')).to.equal(3);
171
- (0, _chai().expect)(exportHello === null || exportHello === void 0 ? void 0 : exportHello.get('nullish')).to.equal(null);
172
- (0, _chai().expect)(exportHello === null || exportHello === void 0 ? void 0 : exportHello.get('undef')).to.equal(undefined);
173
- (0, _chai().expect)(exportHello === null || exportHello === void 0 ? void 0 : exportHello.get('disable')).to.equal(false);
174
- (0, _chai().expect)(exportHello === null || exportHello === void 0 ? void 0 : exportHello.get('enable')).to.equal(true);
175
- (0, _chai().expect)(exportHello === null || exportHello === void 0 ? void 0 : exportHello.has('complextLiteral')).to.be.false;
166
+ (0, _chai().expect)(exportHello?.get('text')).to.equal('is');
167
+ (0, _chai().expect)(exportHello?.get('count')).to.equal(3);
168
+ (0, _chai().expect)(exportHello?.get('nullish')).to.equal(null);
169
+ (0, _chai().expect)(exportHello?.get('undef')).to.equal(undefined);
170
+ (0, _chai().expect)(exportHello?.get('disable')).to.equal(false);
171
+ (0, _chai().expect)(exportHello?.get('enable')).to.equal(true);
172
+ (0, _chai().expect)(exportHello?.has('complextLiteral')).to.be.false;
176
173
  });
177
174
  it('should skip non primitive values', () => {
178
175
  const ast = _typescript().default.createSourceFile('example.tsx', exampleFile, _typescript().default.ScriptTarget.Latest);
179
176
  const staticProperties = new (_typescript2().TypeScriptParser)().parseStaticProperties(ast);
180
177
  const exportHello = staticProperties.get('hello');
181
- (0, _chai().expect)(exportHello === null || exportHello === void 0 ? void 0 : exportHello.has('complextLiteral')).to.be.false;
178
+ (0, _chai().expect)(exportHello?.has('complextLiteral')).to.be.false;
182
179
  });
183
180
  it('should skip non assignment statements', () => {
184
181
  const ast = _typescript().default.createSourceFile('example.tsx', exampleFile, _typescript().default.ScriptTarget.Latest);
185
182
  const staticProperties = new (_typescript2().TypeScriptParser)().parseStaticProperties(ast);
186
183
  const exportHello = staticProperties.get('hello');
187
- (0, _chai().expect)(exportHello === null || exportHello === void 0 ? void 0 : exportHello.has('nonAssignedProperty')).to.be.false;
184
+ (0, _chai().expect)(exportHello?.has('nonAssignedProperty')).to.be.false;
188
185
  });
189
186
  });
190
187
  });
@@ -1 +1 @@
1
- {"version":3,"names":["_typescript","data","_interopRequireDefault","require","_chai","_typescript2","obj","__esModule","default","describe","exampleArrowFunction","exampleFunction","exampleClass","exampleStatement","exampleRenamedStatement","exampleReExport","exampleReExportDefault","exampleRenamedReExportAll","exampleExportDefault","it","ast","ts","createSourceFile","ScriptTarget","Latest","exports","TypeScriptParser","getExports","exportArrow","find","x","identifier","expect","to","exist","exportFunction","exportClass","exportVariable","exportFunction1","exportFunction2","not","length","equal","_exportArrow$staticPr","staticProperties","get","_exportClass$staticPr","_exportClass$staticPr2","exampleFile","parseStaticProperties","exportHello","undefined","has","be","false"],"sources":["typescript.parser.spec.ts"],"sourcesContent":["import ts from 'typescript';\nimport { expect } from 'chai';\n\nimport { TypeScriptParser } from './typescript.parser';\n\ndescribe('TypescriptParser', () => {\n describe('getExports', () => {\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export\n // https://www.typescriptlang.org/docs/handbook/modules.html#export\n\n const exampleArrowFunction = `\n export const arrow = () => { return 3; }\n arrow.textProperty = \"propertyValue\";\n `;\n\n const exampleFunction = `\n export function func() { return 3; }\n func.textProperty = \"propertyValue\";\n `;\n\n const exampleClass = `\n export class classy{ render() { return 3; } }\n classy.textProperty = \"propertyValue\";\n `;\n\n const exampleStatement = `\n function myFunction2 () { return 3; }\n const myVariable2 = 3;\n export { myFunction2, myVariable2 };\n `;\n\n const exampleRenamedStatement = `\n function myFunction2 () { return 3; }\n const myVariable2 = 3;\n export { myFunction2, myVariable2 as myVariable2Alias };\n `;\n\n const exampleReExport = `\n export { default as function1, function2 } from \"bar.js\";\n `;\n\n const exampleReExportDefault = `\n export { default, function2 } from \"bar.js\";\n `;\n\n const exampleRenamedReExportAll = `\n export * as ns from \"mod\";\n `;\n\n const exampleExportDefault = `\n const a: number = 1\n export default { a };\n `;\n\n it('should parse arrowFunctions', () => {\n const ast = ts.createSourceFile('example.tsx', exampleArrowFunction, ts.ScriptTarget.Latest);\n const exports = new TypeScriptParser().getExports(ast);\n\n const exportArrow = exports.find((x) => x.identifier === 'arrow');\n\n expect(exportArrow).to.exist;\n });\n\n it('should parse function exports', () => {\n const ast = ts.createSourceFile('example.tsx', exampleFunction, ts.ScriptTarget.Latest);\n const exports = new TypeScriptParser().getExports(ast);\n\n const exportFunction = exports.find((x) => x.identifier === 'func');\n\n expect(exportFunction).to.exist;\n });\n\n it('should parse classes', () => {\n const ast = ts.createSourceFile('example.tsx', exampleClass, ts.ScriptTarget.Latest);\n const exports = new TypeScriptParser().getExports(ast);\n\n const exportClass = exports.find((x) => x.identifier === 'classy');\n\n expect(exportClass).to.exist;\n });\n\n it('should parse declarations', () => {\n const ast = ts.createSourceFile('example.tsx', exampleStatement, ts.ScriptTarget.Latest);\n const exports = new TypeScriptParser().getExports(ast);\n\n const exportFunction = exports.find((x) => x.identifier === 'myFunction2');\n const exportVariable = exports.find((x) => x.identifier === 'myVariable2');\n\n expect(exportFunction).to.exist;\n expect(exportVariable).to.exist;\n });\n\n it('should parse renamed declarations', () => {\n const ast = ts.createSourceFile('example.tsx', exampleRenamedStatement, ts.ScriptTarget.Latest);\n const exports = new TypeScriptParser().getExports(ast);\n\n const exportFunction = exports.find((x) => x.identifier === 'myFunction2');\n const exportVariable = exports.find((x) => x.identifier === 'myVariable2Alias');\n\n expect(exportFunction).to.exist;\n expect(exportVariable).to.exist;\n });\n\n it('should parse re-exports', () => {\n const ast = ts.createSourceFile('example.tsx', exampleReExport, ts.ScriptTarget.Latest);\n const exports = new TypeScriptParser().getExports(ast);\n\n const exportFunction1 = exports.find((x) => x.identifier === 'function1');\n const exportFunction2 = exports.find((x) => x.identifier === 'function2');\n\n expect(exportFunction1).to.exist;\n expect(exportFunction2).to.exist;\n });\n\n it('should parse re-exports with default', () => {\n const ast = ts.createSourceFile('example.tsx', exampleReExportDefault, ts.ScriptTarget.Latest);\n const exports = new TypeScriptParser().getExports(ast);\n\n const exportFunction1 = exports.find((x) => x.identifier === 'default');\n const exportFunction2 = exports.find((x) => x.identifier === 'function2');\n\n expect(exportFunction1).not.to.exist;\n expect(exportFunction2).to.exist;\n });\n\n it('should parse renamed re-exports all', () => {\n const ast = ts.createSourceFile('example.tsx', exampleRenamedReExportAll, ts.ScriptTarget.Latest);\n const exports = new TypeScriptParser().getExports(ast);\n\n const exportFunction1 = exports.find((x) => x.identifier === 'ns');\n\n expect(exportFunction1).to.exist;\n });\n\n it('should parse default exports', () => {\n const ast = ts.createSourceFile('example.tsx', exampleExportDefault, ts.ScriptTarget.Latest);\n const exports = new TypeScriptParser().getExports(ast);\n\n expect(exports.length).to.equal(0);\n });\n\n describe('staticProperties', () => {\n it('should include staticProperties, when on arrowFunctions', () => {\n const ast = ts.createSourceFile('example.tsx', exampleArrowFunction, ts.ScriptTarget.Latest);\n const exports = new TypeScriptParser().getExports(ast);\n\n const exportArrow = exports.find((x) => x.identifier === 'arrow');\n\n expect(exportArrow?.staticProperties?.get('textProperty')).to.equal('propertyValue');\n });\n\n it('should include staticProperties, when on regular functions', () => {\n const ast = ts.createSourceFile('example.tsx', exampleFunction, ts.ScriptTarget.Latest);\n const exports = new TypeScriptParser().getExports(ast);\n\n const exportClass = exports.find((x) => x.identifier === 'func');\n\n expect(exportClass?.staticProperties?.get('textProperty')).to.equal('propertyValue');\n });\n\n it('should include staticProperties, when on classes', () => {\n const ast = ts.createSourceFile('example.tsx', exampleClass, ts.ScriptTarget.Latest);\n const exports = new TypeScriptParser().getExports(ast);\n\n const exportClass = exports.find((x) => x.identifier === 'classy');\n\n expect(exportClass?.staticProperties?.get('textProperty')).to.equal('propertyValue');\n });\n });\n });\n\n describe('collectStaticProperties', () => {\n const exampleFile = `\n export const hello = () => { return 3; }\n\n hello.text = \"is\";\n hello.count = 3;\n hello.nullish = null;\n hello.undef = undefined;\n hello.disable = false;\n hello.enable = true;\n hello.complextLiteral = \\`what \\${hello.text} it?\\`;\n hello.nonAssignedProperty += 'value';\n `;\n\n it('should parse all primitive values', () => {\n const ast = ts.createSourceFile('example.tsx', exampleFile, ts.ScriptTarget.Latest);\n const staticProperties = new TypeScriptParser().parseStaticProperties(ast);\n\n expect(staticProperties).to.exist;\n\n const exportHello = staticProperties.get('hello');\n expect(exportHello).to.exist;\n\n expect(exportHello?.get('text')).to.equal('is');\n expect(exportHello?.get('count')).to.equal(3);\n expect(exportHello?.get('nullish')).to.equal(null);\n expect(exportHello?.get('undef')).to.equal(undefined);\n expect(exportHello?.get('disable')).to.equal(false);\n expect(exportHello?.get('enable')).to.equal(true);\n\n expect(exportHello?.has('complextLiteral')).to.be.false;\n });\n\n it('should skip non primitive values', () => {\n const ast = ts.createSourceFile('example.tsx', exampleFile, ts.ScriptTarget.Latest);\n const staticProperties = new TypeScriptParser().parseStaticProperties(ast);\n const exportHello = staticProperties.get('hello');\n\n expect(exportHello?.has('complextLiteral')).to.be.false;\n });\n\n it('should skip non assignment statements', () => {\n const ast = ts.createSourceFile('example.tsx', exampleFile, ts.ScriptTarget.Latest);\n const staticProperties = new TypeScriptParser().parseStaticProperties(ast);\n const exportHello = staticProperties.get('hello');\n\n expect(exportHello?.has('nonAssignedProperty')).to.be.false;\n });\n });\n});\n"],"mappings":";;AAAA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,MAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,KAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,aAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,YAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAuD,SAAAC,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEvDG,QAAQ,CAAC,kBAAkB,EAAE,MAAM;EACjCA,QAAQ,CAAC,YAAY,EAAE,MAAM;IAC3B;IACA;;IAEA,MAAMC,oBAAoB,GAAI;AAClC;AACA;AACA,KAAK;IAED,MAAMC,eAAe,GAAI;AAC7B;AACA;AACA,KAAK;IAED,MAAMC,YAAY,GAAI;AAC1B;AACA;AACA,KAAK;IAED,MAAMC,gBAAgB,GAAI;AAC9B;AACA;AACA;AACA,KAAK;IAED,MAAMC,uBAAuB,GAAI;AACrC;AACA;AACA;AACA,KAAK;IAED,MAAMC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AgB,CAAC,aAAa,EAAE0B,WAAW,EAAE3B,qBAAE,CAACE,YAAY,CAACC,MAAM,CAAC;MACnF,MAAMoB,gBAAgB,GAAG,KAAIlB,+BAAgB,EAAC,CAAC,CAACuB,qBAAqB,CAAC7B,GAAG,CAAC;MAC1E,MAAM8B,WAAW,GAAGN,gBAAgB,CAACC,GAAG,CAAC,OAAO,CAAC;MAEjD,IAAAb,cAAM,EAACkB,WAAW,aAAXA,WAAW,uBAAXA,WAAW,CAAEE,GAAG,CAAC,qBAAqB,CAAC,CAAC,CAACnB,EAAE,CAACoB,EAAE,CAACC,KAAK;IAC7D,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC"}
1
+ {"version":3,"names":["_typescript","data","_interopRequireDefault","require","_chai","_typescript2","obj","__esModule","default","describe","exampleArrowFunction","exampleFunction","exampleClass","exampleStatement","exampleRenamedStatement","exampleReExport","exampleReExportDefault","exampleRenamedReExportAll","exampleExportDefault","it","ast","ts","createSourceFile","ScriptTarget","Latest","exports","TypeScriptParser","getExports","exportArrow","find","x","identifier","expect","to","exist","exportFunction","exportClass","exportVariable","exportFunction1","exportFunction2","not","length","equal","staticProperties","get","exampleFile","parseStaticProperties","exportHello","undefined","has","be","false"],"sources":["typescript.parser.spec.ts"],"sourcesContent":["import ts from 'typescript';\nimport { expect } from 'chai';\n\nimport { TypeScriptParser } from './typescript.parser';\n\ndescribe('TypescriptParser', () => {\n describe('getExports', () => {\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export\n // https://www.typescriptlang.org/docs/handbook/modules.html#export\n\n const exampleArrowFunction = `\n export const arrow = () => { return 3; }\n arrow.textProperty = \"propertyValue\";\n `;\n\n const exampleFunction = `\n export function func() { return 3; }\n func.textProperty = \"propertyValue\";\n `;\n\n const exampleClass = `\n export class classy{ render() { return 3; } }\n classy.textProperty = \"propertyValue\";\n `;\n\n const exampleStatement = `\n function myFunction2 () { return 3; }\n const myVariable2 = 3;\n export { myFunction2, myVariable2 };\n `;\n\n const exampleRenamedStatement = `\n function myFunction2 () { return 3; }\n const myVariable2 = 3;\n export { myFunction2, myVariable2 as myVariable2Alias };\n `;\n\n const exampleReExport = `\n export { default as function1, function2 } from \"bar.js\";\n `;\n\n const exampleReExportDefault = `\n export { default, function2 } from \"bar.js\";\n `;\n\n const exampleRenamedReExportAll = `\n export * as ns from \"mod\";\n `;\n\n const exampleExportDefault = `\n const a: number = 1\n export default { a };\n `;\n\n it('should parse arrowFunctions', () => {\n const ast = ts.createSourceFile('example.tsx', exampleArrowFunction, ts.ScriptTarget.Latest);\n const exports = new TypeScriptParser().getExports(ast);\n\n const exportArrow = exports.find((x) => x.identifier === 'arrow');\n\n expect(exportArrow).to.exist;\n });\n\n it('should parse function exports', () => {\n const ast = ts.createSourceFile('example.tsx', exampleFunction, ts.ScriptTarget.Latest);\n const exports = new TypeScriptParser().getExports(ast);\n\n const exportFunction = exports.find((x) => x.identifier === 'func');\n\n expect(exportFunction).to.exist;\n });\n\n it('should parse classes', () => {\n const ast = ts.createSourceFile('example.tsx', exampleClass, ts.ScriptTarget.Latest);\n const exports = new TypeScriptParser().getExports(ast);\n\n const exportClass = exports.find((x) => x.identifier === 'classy');\n\n expect(exportClass).to.exist;\n });\n\n it('should parse declarations', () => {\n const ast = ts.createSourceFile('example.tsx', exampleStatement, ts.ScriptTarget.Latest);\n const exports = new TypeScriptParser().getExports(ast);\n\n const exportFunction = exports.find((x) => x.identifier === 'myFunction2');\n const exportVariable = exports.find((x) => x.identifier === 'myVariable2');\n\n expect(exportFunction).to.exist;\n expect(exportVariable).to.exist;\n });\n\n it('should parse renamed declarations', () => {\n const ast = ts.createSourceFile('example.tsx', exampleRenamedStatement, ts.ScriptTarget.Latest);\n const exports = new TypeScriptParser().getExports(ast);\n\n const exportFunction = exports.find((x) => x.identifier === 'myFunction2');\n const exportVariable = exports.find((x) => x.identifier === 'myVariable2Alias');\n\n expect(exportFunction).to.exist;\n expect(exportVariable).to.exist;\n });\n\n it('should parse re-exports', () => {\n const ast = ts.createSourceFile('example.tsx', exampleReExport, ts.ScriptTarget.Latest);\n const exports = new TypeScriptParser().getExports(ast);\n\n const exportFunction1 = exports.find((x) => x.identifier === 'function1');\n const exportFunction2 = exports.find((x) => x.identifier === 'function2');\n\n expect(exportFunction1).to.exist;\n expect(exportFunction2).to.exist;\n });\n\n it('should parse re-exports with default', () => {\n const ast = ts.createSourceFile('example.tsx', exampleReExportDefault, ts.ScriptTarget.Latest);\n const exports = new TypeScriptParser().getExports(ast);\n\n const exportFunction1 = exports.find((x) => x.identifier === 'default');\n const exportFunction2 = exports.find((x) => x.identifier === 'function2');\n\n expect(exportFunction1).not.to.exist;\n expect(exportFunction2).to.exist;\n });\n\n it('should parse renamed re-exports all', () => {\n const ast = ts.createSourceFile('example.tsx', exampleRenamedReExportAll, ts.ScriptTarget.Latest);\n const exports = new TypeScriptParser().getExports(ast);\n\n const exportFunction1 = exports.find((x) => x.identifier === 'ns');\n\n expect(exportFunction1).to.exist;\n });\n\n it('should parse default exports', () => {\n const ast = ts.createSourceFile('example.tsx', exampleExportDefault, ts.ScriptTarget.Latest);\n const exports = new TypeScriptParser().getExports(ast);\n\n expect(exports.length).to.equal(0);\n });\n\n describe('staticProperties', () => {\n it('should include staticProperties, when on arrowFunctions', () => {\n const ast = ts.createSourceFile('example.tsx', exampleArrowFunction, ts.ScriptTarget.Latest);\n const exports = new TypeScriptParser().getExports(ast);\n\n const exportArrow = exports.find((x) => x.identifier === 'arrow');\n\n expect(exportArrow?.staticProperties?.get('textProperty')).to.equal('propertyValue');\n });\n\n it('should include staticProperties, when on regular functions', () => {\n const ast = ts.createSourceFile('example.tsx', exampleFunction, ts.ScriptTarget.Latest);\n const exports = new TypeScriptParser().getExports(ast);\n\n const exportClass = exports.find((x) => x.identifier === 'func');\n\n expect(exportClass?.staticProperties?.get('textProperty')).to.equal('propertyValue');\n });\n\n it('should include staticProperties, when on classes', () => {\n const ast = ts.createSourceFile('example.tsx', exampleClass, ts.ScriptTarget.Latest);\n const exports = new TypeScriptParser().getExports(ast);\n\n const exportClass = exports.find((x) => x.identifier === 'classy');\n\n expect(exportClass?.staticProperties?.get('textProperty')).to.equal('propertyValue');\n });\n });\n });\n\n describe('collectStaticProperties', () => {\n const exampleFile = `\n export const hello = () => { return 3; }\n\n hello.text = \"is\";\n hello.count = 3;\n hello.nullish = null;\n hello.undef = undefined;\n hello.disable = false;\n hello.enable = true;\n hello.complextLiteral = \\`what \\${hello.text} it?\\`;\n hello.nonAssignedProperty += 'value';\n `;\n\n it('should parse all primitive values', () => {\n const ast = ts.createSourceFile('example.tsx', exampleFile, ts.ScriptTarget.Latest);\n const staticProperties = new TypeScriptParser().parseStaticProperties(ast);\n\n expect(staticProperties).to.exist;\n\n const exportHello = staticProperties.get('hello');\n expect(exportHello).to.exist;\n\n expect(exportHello?.get('text')).to.equal('is');\n expect(exportHello?.get('count')).to.equal(3);\n expect(exportHello?.get('nullish')).to.equal(null);\n expect(exportHello?.get('undef')).to.equal(undefined);\n expect(exportHello?.get('disable')).to.equal(false);\n expect(exportHello?.get('enable')).to.equal(true);\n\n expect(exportHello?.has('complextLiteral')).to.be.false;\n });\n\n it('should skip non primitive values', () => {\n const ast = ts.createSourceFile('example.tsx', exampleFile, ts.ScriptTarget.Latest);\n const staticProperties = new TypeScriptParser().parseStaticProperties(ast);\n const exportHello = staticProperties.get('hello');\n\n expect(exportHello?.has('complextLiteral')).to.be.false;\n });\n\n it('should skip non assignment statements', () => {\n const ast = ts.createSourceFile('example.tsx', exampleFile, ts.ScriptTarget.Latest);\n const staticProperties = new TypeScriptParser().parseStaticProperties(ast);\n const exportHello = staticProperties.get('hello');\n\n expect(exportHello?.has('nonAssignedProperty')).to.be.false;\n });\n });\n});\n"],"mappings":";;AAAA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA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ACe,WAAW,EAAEE,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAChB,EAAE,CAACiB,EAAE,CAACC,KAAK;IACzD,CAAC,CAAC;IAEFhC,EAAE,CAAC,uCAAuC,EAAE,MAAM;MAChD,MAAMC,GAAG,GAAGC,qBAAE,CAACC,gBAAgB,CAAC,aAAa,EAAEuB,WAAW,EAAExB,qBAAE,CAACE,YAAY,CAACC,MAAM,CAAC;MACnF,MAAMmB,gBAAgB,GAAG,KAAIjB,+BAAgB,EAAC,CAAC,CAACoB,qBAAqB,CAAC1B,GAAG,CAAC;MAC1E,MAAM2B,WAAW,GAAGJ,gBAAgB,CAACC,GAAG,CAAC,OAAO,CAAC;MAEjD,IAAAZ,cAAM,EAACe,WAAW,EAAEE,GAAG,CAAC,qBAAqB,CAAC,CAAC,CAAChB,EAAE,CAACiB,EAAE,CAACC,KAAK;IAC7D,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/typescript",
3
- "version": "1.0.107",
3
+ "version": "1.0.109",
4
4
  "homepage": "https://bit.cloud/teambit/typescript/typescript",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.typescript",
8
8
  "name": "typescript",
9
- "version": "1.0.107"
9
+ "version": "1.0.109"
10
10
  },
11
11
  "dependencies": {
12
12
  "lodash": "4.17.21",
@@ -17,46 +17,42 @@
17
17
  "fs-extra": "10.0.0",
18
18
  "yesno": "0.4.0",
19
19
  "get-tsconfig": "4.2.0",
20
- "core-js": "^3.0.0",
21
- "@babel/runtime": "7.20.0",
22
20
  "@teambit/semantics.entities.semantic-schema": "0.0.59",
23
21
  "@teambit/harmony": "0.4.6",
24
22
  "@teambit/bit-error": "0.0.404",
25
- "@teambit/compiler": "1.0.107",
23
+ "@teambit/compiler": "1.0.109",
26
24
  "@teambit/typescript.modules.ts-config-mutator": "0.0.80",
27
- "@teambit/builder": "1.0.107",
28
- "@teambit/isolator": "1.0.107",
29
- "@teambit/component": "1.0.107",
30
- "@teambit/dependency-resolver": "1.0.107",
31
- "@teambit/formatter": "1.0.107",
32
- "@teambit/ts-server": "0.0.52",
33
- "@teambit/aspect-loader": "1.0.107",
34
- "@teambit/envs": "1.0.107",
35
- "@teambit/logger": "0.0.932",
36
- "@teambit/workspace": "1.0.107",
37
- "@teambit/schema": "1.0.107",
38
- "@teambit/scope": "1.0.107",
39
- "@teambit/cli": "0.0.839",
40
- "@teambit/pkg": "1.0.107",
41
- "@teambit/watcher": "1.0.107"
25
+ "@teambit/builder": "1.0.109",
26
+ "@teambit/isolator": "1.0.109",
27
+ "@teambit/component": "1.0.109",
28
+ "@teambit/dependency-resolver": "1.0.109",
29
+ "@teambit/formatter": "1.0.109",
30
+ "@teambit/ts-server": "0.0.53",
31
+ "@teambit/aspect-loader": "1.0.109",
32
+ "@teambit/envs": "1.0.109",
33
+ "@teambit/logger": "0.0.934",
34
+ "@teambit/workspace": "1.0.109",
35
+ "@teambit/schema": "1.0.109",
36
+ "@teambit/scope": "1.0.109",
37
+ "@teambit/cli": "0.0.841",
38
+ "@teambit/pkg": "1.0.109",
39
+ "@teambit/watcher": "1.0.109"
42
40
  },
43
41
  "devDependencies": {
44
42
  "@types/lodash": "4.14.165",
45
43
  "@types/fs-extra": "9.0.7",
46
44
  "@types/chai": "4.2.15",
47
45
  "chai": "4.3.0",
48
- "@types/react": "^17.0.8",
49
46
  "@types/mocha": "9.1.0",
50
- "@types/node": "12.20.4",
51
- "@types/react-dom": "^17.0.5",
52
- "@types/jest": "^26.0.0",
53
- "@types/testing-library__jest-dom": "5.9.5",
47
+ "@types/jest": "^29.2.2",
48
+ "@types/testing-library__jest-dom": "^5.9.5",
49
+ "@teambit/harmony.envs.core-aspect-env": "0.0.14",
54
50
  "@teambit/typescript.aspect-docs.typescript": "0.0.165"
55
51
  },
56
52
  "peerDependencies": {
57
- "@teambit/legacy": "1.0.624",
58
- "react": "^16.8.0 || ^17.0.0",
59
- "react-dom": "^16.8.0 || ^17.0.0"
53
+ "react": "^17.0.0 || ^18.0.0",
54
+ "@types/react": "^18.2.12",
55
+ "@teambit/legacy": "1.0.624"
60
56
  },
61
57
  "license": "Apache-2.0",
62
58
  "optionalDependencies": {},
@@ -70,7 +66,7 @@
70
66
  },
71
67
  "private": false,
72
68
  "engines": {
73
- "node": ">=12.22.0"
69
+ "node": ">=16.0.0"
74
70
  },
75
71
  "repository": {
76
72
  "type": "git",
@@ -79,12 +75,9 @@
79
75
  "keywords": [
80
76
  "bit",
81
77
  "bit-aspect",
78
+ "bit-core-aspect",
82
79
  "components",
83
80
  "collaboration",
84
- "web",
85
- "react",
86
- "react-components",
87
- "angular",
88
- "angular-components"
81
+ "web"
89
82
  ]
90
83
  }
package/tsconfig.json CHANGED
@@ -1,38 +1,33 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "lib": [
4
- "es2019",
5
- "DOM",
6
- "ES6",
7
- "DOM.Iterable",
8
- "ScriptHost"
4
+ "esnext",
5
+ "dom",
6
+ "dom.Iterable"
9
7
  ],
10
- "target": "es2015",
11
- "module": "CommonJS",
12
- "jsx": "react",
13
- "allowJs": true,
14
- "composite": true,
8
+ "target": "es2020",
9
+ "module": "es2020",
10
+ "jsx": "react-jsx",
15
11
  "declaration": true,
16
12
  "sourceMap": true,
17
- "skipLibCheck": true,
18
13
  "experimentalDecorators": true,
19
- "outDir": "dist",
14
+ "skipLibCheck": true,
20
15
  "moduleResolution": "node",
21
16
  "esModuleInterop": true,
22
- "rootDir": ".",
23
17
  "resolveJsonModule": true,
24
- "emitDeclarationOnly": true,
25
- "emitDecoratorMetadata": true,
26
- "allowSyntheticDefaultImports": true,
27
- "strictPropertyInitialization": false,
28
- "strict": true,
29
- "noImplicitAny": false,
30
- "preserveConstEnums": true
18
+ "allowJs": true,
19
+ "outDir": "dist",
20
+ "emitDeclarationOnly": true
31
21
  },
32
22
  "exclude": [
23
+ "artifacts",
24
+ "public",
33
25
  "dist",
26
+ "node_modules",
27
+ "package.json",
34
28
  "esm.mjs",
35
- "package.json"
29
+ "**/*.cjs",
30
+ "./dist"
36
31
  ],
37
32
  "include": [
38
33
  "**/*",
package/types/asset.d.ts CHANGED
@@ -5,12 +5,12 @@ declare module '*.png' {
5
5
  declare module '*.svg' {
6
6
  import type { FunctionComponent, SVGProps } from 'react';
7
7
 
8
- export const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement> & { title?: string }>;
8
+ export const ReactComponent: FunctionComponent<
9
+ SVGProps<SVGSVGElement> & { title?: string }
10
+ >;
9
11
  const src: string;
10
12
  export default src;
11
13
  }
12
-
13
- // @TODO Gilad
14
14
  declare module '*.jpg' {
15
15
  const value: any;
16
16
  export = value;
@@ -27,3 +27,15 @@ declare module '*.bmp' {
27
27
  const value: any;
28
28
  export = value;
29
29
  }
30
+ declare module '*.otf' {
31
+ const value: any;
32
+ export = value;
33
+ }
34
+ declare module '*.woff' {
35
+ const value: any;
36
+ export = value;
37
+ }
38
+ declare module '*.woff2' {
39
+ const value: any;
40
+ export = value;
41
+ }