Skip to content

Commit 1837d0b

Browse files
committed
Fix incorrectly reported 2689 error
1 parent 3fc1f26 commit 1837d0b

File tree

5 files changed

+67
-2
lines changed

5 files changed

+67
-2
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3445,8 +3445,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
34453445
case SyntaxKind.PropertyAccessExpression:
34463446
return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined;
34473447
case SyntaxKind.ExpressionWithTypeArguments:
3448-
if (isEntityNameExpression((node as ExpressionWithTypeArguments).expression)) {
3449-
return (node as ExpressionWithTypeArguments).expression as EntityNameExpression;
3448+
if (isExpressionWithTypeArgumentsInClassExtendsClause(node) && isEntityNameExpression(node.expression)) {
3449+
return node.expression;
34503450
}
34513451
// falls through
34523452
default:
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
typeUsedAsValueError3.ts(6,14): error TS2693: 'foo' only refers to a type, but is being used as a value here.
2+
3+
4+
==== typeUsedAsValueError3.ts (1 errors) ====
5+
class baz<B> {}
6+
interface foo<A> {
7+
new (): typeof baz
8+
}
9+
10+
const bar = (foo<string>)<number>
11+
~~~
12+
!!! error TS2693: 'foo' only refers to a type, but is being used as a value here.
13+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//// [tests/cases/compiler/typeUsedAsValueError3.ts] ////
2+
3+
=== typeUsedAsValueError3.ts ===
4+
class baz<B> {}
5+
>baz : Symbol(baz, Decl(typeUsedAsValueError3.ts, 0, 0))
6+
>B : Symbol(B, Decl(typeUsedAsValueError3.ts, 0, 10))
7+
8+
interface foo<A> {
9+
>foo : Symbol(foo, Decl(typeUsedAsValueError3.ts, 0, 15))
10+
>A : Symbol(A, Decl(typeUsedAsValueError3.ts, 1, 14))
11+
12+
new (): typeof baz
13+
>baz : Symbol(baz, Decl(typeUsedAsValueError3.ts, 0, 0))
14+
}
15+
16+
const bar = (foo<string>)<number>
17+
>bar : Symbol(bar, Decl(typeUsedAsValueError3.ts, 5, 5))
18+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//// [tests/cases/compiler/typeUsedAsValueError3.ts] ////
2+
3+
=== typeUsedAsValueError3.ts ===
4+
class baz<B> {}
5+
>baz : baz<B>
6+
> : ^^^^^^
7+
8+
interface foo<A> {
9+
new (): typeof baz
10+
>baz : typeof baz
11+
> : ^^^^^^^^^^
12+
}
13+
14+
const bar = (foo<string>)<number>
15+
>bar : any
16+
> : ^^^
17+
>(foo<string>)<number> : any
18+
> : ^^^
19+
>(foo<string>) : any
20+
> : ^^^
21+
>foo<string> : any
22+
> : ^^^
23+
>foo : any
24+
> : ^^^
25+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// @strict: true
2+
// @noEmit: true
3+
4+
class baz<B> {}
5+
interface foo<A> {
6+
new (): typeof baz
7+
}
8+
9+
const bar = (foo<string>)<number>

0 commit comments

Comments
 (0)