Content-Length: 1854 | pFad | http://github.com/typescript-eslint/typescript-eslint/pull/11380.diff
thub.com diff --git a/packages/type-utils/src/typeOrValueSpecifiers/typeDeclaredInPackageDeclarationFile.ts b/packages/type-utils/src/typeOrValueSpecifiers/typeDeclaredInPackageDeclarationFile.ts index cb0b303bafac..e0da69700a83 100644 --- a/packages/type-utils/src/typeOrValueSpecifiers/typeDeclaredInPackageDeclarationFile.ts +++ b/packages/type-utils/src/typeOrValueSpecifiers/typeDeclaredInPackageDeclarationFile.ts @@ -5,14 +5,17 @@ function findParentModuleDeclaration( ): ts.ModuleDeclaration | undefined { switch (node.kind) { case ts.SyntaxKind.ModuleDeclaration: + // "namespace x {...}" should be ignored here + if (node.flags & ts.NodeFlags.Namespace) { + break; + } return ts.isStringLiteral((node as ts.ModuleDeclaration).name) ? (node as ts.ModuleDeclaration) : undefined; case ts.SyntaxKind.SourceFile: return undefined; - default: - return findParentModuleDeclaration(node.parent); } + return findParentModuleDeclaration(node.parent); } function typeDeclaredInDeclareModule( diff --git a/packages/type-utils/tests/TypeOrValueSpecifier.test.ts b/packages/type-utils/tests/TypeOrValueSpecifier.test.ts index 8aee949efb37..86806ad1dae2 100644 --- a/packages/type-utils/tests/TypeOrValueSpecifier.test.ts +++ b/packages/type-utils/tests/TypeOrValueSpecifier.test.ts @@ -405,6 +405,14 @@ describe('TypeOrValueSpecifier', () => { package: 'node:test', }, ], + [ + 'import { fail } from "node:assert"; type Test = typeof fail;', + { + from: 'package', + name: 'fail', + package: 'assert', + }, + ], ] as const satisfies [string, TypeOrValueSpecifier][])( 'matches a matching package specifier: %s\n\t%s', ([code, typeOrValueSpecifier], { expect }) => {Fetched URL: http://github.com/typescript-eslint/typescript-eslint/pull/11380.diff
Alternative Proxies: