Skip to content

Commit 34a18af

Browse files
committed
Make it compile-able with latest typescript version (again)
See microsoft/TypeScript#57207
1 parent 74181e8 commit 34a18af

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/bundle-generator.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -481,11 +481,13 @@ export function generateDtsBundle(entries: readonly EntryPointConfig[], options:
481481
const exportElementSymbol = getImportExportReferencedSymbol(exportElement, typeChecker);
482482

483483
const namespaceImportFromImportableModule = getDeclarationsForSymbol(exportElementSymbol).find((importDecl: ts.Declaration): importDecl is ts.NamespaceImport => {
484-
return ts.isNamespaceImport(importDecl) && isReferencedModuleImportable(importDecl.parent.parent);
484+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
485+
return ts.isNamespaceImport(importDecl) && isReferencedModuleImportable(importDecl.parent.parent as ts.ImportDeclaration);
485486
});
486487

487488
if (namespaceImportFromImportableModule !== undefined) {
488-
const importModuleSpecifier = getImportModuleName(namespaceImportFromImportableModule.parent.parent);
489+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
490+
const importModuleSpecifier = getImportModuleName(namespaceImportFromImportableModule.parent.parent as ts.ImportDeclaration);
489491
if (importModuleSpecifier === null) {
490492
throw new Error(`Cannot get import module name from '${namespaceImportFromImportableModule.parent.parent.getText()}'`);
491493
}
@@ -987,7 +989,8 @@ export function generateDtsBundle(entries: readonly EntryPointConfig[], options:
987989
const exportElementSymbol = getImportExportReferencedSymbol(decl, typeChecker);
988990
const namespaceImport = getDeclarationsForSymbol(exportElementSymbol).find(ts.isNamespaceImport);
989991
if (namespaceImport !== undefined) {
990-
handleNamespacedImportOrExport(namespaceImport.parent.parent, namespaceExports, symbol);
992+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
993+
handleNamespacedImportOrExport(namespaceImport.parent.parent as ts.ImportDeclaration, namespaceExports, symbol);
991994
}
992995

993996
return;
@@ -1028,7 +1031,8 @@ export function generateDtsBundle(entries: readonly EntryPointConfig[], options:
10281031
// i.e. `import * as NS from './local-module'`
10291032
const result = getDeclarationsForSymbol(getImportExportReferencedSymbol(decl, typeChecker)).some((importDecl: ts.Declaration) => {
10301033
if (ts.isNamespaceImport(importDecl)) {
1031-
return !isReferencedModuleImportable(importDecl.parent.parent);
1034+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
1035+
return !isReferencedModuleImportable(importDecl.parent.parent as ts.ImportDeclaration);
10321036
}
10331037

10341038
if (ts.isImportSpecifier(importDecl)) {

src/helpers/typescript.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ export function getExportsForSourceFile(typeChecker: ts.TypeChecker, sourceFileS
205205
// most likely this export is part of the symbol merging situation
206206
// where one of the declarations is the imported value but the other is declared locally
207207
// in this case we need to add an extra export to the exports list to make sure that it is marked as "exported"
208-
const referencedModule = resolveReferencedModule(importSpecifierDeclaration.parent.parent.parent, typeChecker);
208+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
209+
const referencedModule = resolveReferencedModule(importSpecifierDeclaration.parent.parent.parent as ts.ImportDeclaration, typeChecker);
209210
if (referencedModule !== null) {
210211
const referencedModuleSymbol = getNodeSymbol(referencedModule, typeChecker);
211212
if (referencedModuleSymbol !== null) {

0 commit comments

Comments
 (0)