Skip to content

Commit a086a3c

Browse files
authored
fix(60563):@import * as namespace cannot be used with @implements (#60566)
1 parent 589f734 commit a086a3c

File tree

5 files changed

+76
-0
lines changed

5 files changed

+76
-0
lines changed

src/compiler/utilities.ts

+1
Original file line numberDiff line numberDiff line change
@@ -10467,6 +10467,7 @@ export function isValidBigIntString(s: string, roundTripOnly: boolean): boolean
1046710467
/** @internal */
1046810468
export function isValidTypeOnlyAliasUseSite(useSite: Node): boolean {
1046910469
return !!(useSite.flags & NodeFlags.Ambient)
10470+
|| isInJSDoc(useSite)
1047010471
|| isPartOfTypeQuery(useSite)
1047110472
|| isIdentifierInNonEmittingHeritageClause(useSite)
1047210473
|| isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/b.js(6,14): error TS2420: Class 'C' incorrectly implements interface 'I'.
2+
Property 'foo' is missing in type 'C' but required in type 'I'.
3+
4+
5+
==== /a.ts (0 errors) ====
6+
export interface I {
7+
foo(): void;
8+
}
9+
10+
==== /b.js (1 errors) ====
11+
/**
12+
* @import * as NS from './a'
13+
*/
14+
15+
/** @implements {NS.I} */
16+
export class C {}
17+
~
18+
!!! error TS2420: Class 'C' incorrectly implements interface 'I'.
19+
!!! error TS2420: Property 'foo' is missing in type 'C' but required in type 'I'.
20+
!!! related TS2728 /a.ts:2:5: 'foo' is declared here.
21+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//// [tests/cases/conformance/jsdoc/importTag23.ts] ////
2+
3+
=== /a.ts ===
4+
export interface I {
5+
>I : Symbol(I, Decl(a.ts, 0, 0))
6+
7+
foo(): void;
8+
>foo : Symbol(I.foo, Decl(a.ts, 0, 20))
9+
}
10+
11+
=== /b.js ===
12+
/**
13+
* @import * as NS from './a'
14+
*/
15+
16+
/** @implements {NS.I} */
17+
export class C {}
18+
>C : Symbol(C, Decl(b.js, 0, 0))
19+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//// [tests/cases/conformance/jsdoc/importTag23.ts] ////
2+
3+
=== /a.ts ===
4+
export interface I {
5+
foo(): void;
6+
>foo : () => void
7+
> : ^^^^^^
8+
}
9+
10+
=== /b.js ===
11+
/**
12+
* @import * as NS from './a'
13+
*/
14+
15+
/** @implements {NS.I} */
16+
export class C {}
17+
>C : C
18+
> : ^
19+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// @checkJs: true
2+
// @allowJs: true
3+
// @noEmit: true
4+
5+
// @filename: /a.ts
6+
export interface I {
7+
foo(): void;
8+
}
9+
10+
// @filename: /b.js
11+
/**
12+
* @import * as NS from './a'
13+
*/
14+
15+
/** @implements {NS.I} */
16+
export class C {}

0 commit comments

Comments
 (0)