Skip to content

Commit

Permalink
Another attempt to fix the compilation for versions before type-only …
Browse files Browse the repository at this point in the history
…imports/exports

Maintaining very old versions is hard...
  • Loading branch information
timocov committed Apr 2, 2022
1 parent 1d18c1a commit 1ab4b2d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/bundle-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ function addImport(statement: ts.DeclarationStatement, params: UpdateParams, imp
}

interface ImportSpecifierInternal extends ts.ImportSpecifier {
// fallback to support TS versions without type-only imports/exports
isTypeOnly: boolean;
}

Expand All @@ -635,9 +636,9 @@ function addImport(statement: ts.DeclarationStatement, params: UpdateParams, imp
// import { El1, El2 } from 'module';
importClause.namedBindings.elements
.filter(params.areDeclarationSame.bind(params, statement))
.forEach((specifier: ImportSpecifierInternal) => {
.forEach((specifier: ts.ImportSpecifier) => {
let importName = specifier.getText();
if (specifier.isTypeOnly) {
if ((specifier as ImportSpecifierInternal).isTypeOnly) {
// let's fallback all the imports to ones without "type" specifier
importName = importName.replace(/^(\s*type\s+)/g, '');
}
Expand Down

0 comments on commit 1ab4b2d

Please sign in to comment.