-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disallow expression with type parameters as left side of property acc…
…ess (#49464)
- Loading branch information
1 parent
ad6d086
commit 569cdf1
Showing
22 changed files
with
433 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
tests/cases/compiler/genericCallWithoutArgs.ts(4,2): error TS1477: An instantiation expression cannot be followed by a property access. | ||
tests/cases/compiler/genericCallWithoutArgs.ts(4,18): error TS1003: Identifier expected. | ||
|
||
|
||
==== tests/cases/compiler/genericCallWithoutArgs.ts (1 errors) ==== | ||
==== tests/cases/compiler/genericCallWithoutArgs.ts (2 errors) ==== | ||
function f<X, Y>(x: X, y: Y) { | ||
} | ||
|
||
f<number,string>. | ||
~~~~~~~~~~~~~~~ | ||
!!! error TS1477: An instantiation expression cannot be followed by a property access. | ||
|
||
!!! error TS1003: Identifier expected. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...s/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
tests/cases/compiler/optionalChainWithInstantiationExpression1.ts(12,5): error TS1477: An instantiation expression cannot be followed by a property access. | ||
|
||
|
||
==== tests/cases/compiler/optionalChainWithInstantiationExpression1.ts (1 errors) ==== | ||
declare namespace A { | ||
export class b<T> { | ||
static d: number; | ||
constructor(x: T); | ||
} | ||
} | ||
|
||
type c = unknown; | ||
|
||
declare const a: typeof A | undefined; | ||
|
||
a?.b<c>.d; | ||
~~~ | ||
!!! error TS1477: An instantiation expression cannot be followed by a property access. | ||
|
||
a?.b.d | ||
|
20 changes: 20 additions & 0 deletions
20
tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//// [optionalChainWithInstantiationExpression1.ts] | ||
declare namespace A { | ||
export class b<T> { | ||
static d: number; | ||
constructor(x: T); | ||
} | ||
} | ||
|
||
type c = unknown; | ||
|
||
declare const a: typeof A | undefined; | ||
|
||
a?.b<c>.d; | ||
|
||
a?.b.d | ||
|
||
|
||
//// [optionalChainWithInstantiationExpression1.js] | ||
(a === null || a === void 0 ? void 0 : a.b).d; | ||
a === null || a === void 0 ? void 0 : a.b.d; |
39 changes: 39 additions & 0 deletions
39
tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
=== tests/cases/compiler/optionalChainWithInstantiationExpression1.ts === | ||
declare namespace A { | ||
>A : Symbol(A, Decl(optionalChainWithInstantiationExpression1.ts, 0, 0)) | ||
|
||
export class b<T> { | ||
>b : Symbol(b, Decl(optionalChainWithInstantiationExpression1.ts, 0, 21)) | ||
>T : Symbol(T, Decl(optionalChainWithInstantiationExpression1.ts, 1, 19)) | ||
|
||
static d: number; | ||
>d : Symbol(b.d, Decl(optionalChainWithInstantiationExpression1.ts, 1, 23)) | ||
|
||
constructor(x: T); | ||
>x : Symbol(x, Decl(optionalChainWithInstantiationExpression1.ts, 3, 20)) | ||
>T : Symbol(T, Decl(optionalChainWithInstantiationExpression1.ts, 1, 19)) | ||
} | ||
} | ||
|
||
type c = unknown; | ||
>c : Symbol(c, Decl(optionalChainWithInstantiationExpression1.ts, 5, 1)) | ||
|
||
declare const a: typeof A | undefined; | ||
>a : Symbol(a, Decl(optionalChainWithInstantiationExpression1.ts, 9, 13)) | ||
>A : Symbol(A, Decl(optionalChainWithInstantiationExpression1.ts, 0, 0)) | ||
|
||
a?.b<c>.d; | ||
>a?.b<c>.d : Symbol(A.b.d, Decl(optionalChainWithInstantiationExpression1.ts, 1, 23)) | ||
>a?.b : Symbol(A.b, Decl(optionalChainWithInstantiationExpression1.ts, 0, 21)) | ||
>a : Symbol(a, Decl(optionalChainWithInstantiationExpression1.ts, 9, 13)) | ||
>b : Symbol(A.b, Decl(optionalChainWithInstantiationExpression1.ts, 0, 21)) | ||
>c : Symbol(c, Decl(optionalChainWithInstantiationExpression1.ts, 5, 1)) | ||
>d : Symbol(A.b.d, Decl(optionalChainWithInstantiationExpression1.ts, 1, 23)) | ||
|
||
a?.b.d | ||
>a?.b.d : Symbol(A.b.d, Decl(optionalChainWithInstantiationExpression1.ts, 1, 23)) | ||
>a?.b : Symbol(A.b, Decl(optionalChainWithInstantiationExpression1.ts, 0, 21)) | ||
>a : Symbol(a, Decl(optionalChainWithInstantiationExpression1.ts, 9, 13)) | ||
>b : Symbol(A.b, Decl(optionalChainWithInstantiationExpression1.ts, 0, 21)) | ||
>d : Symbol(A.b.d, Decl(optionalChainWithInstantiationExpression1.ts, 1, 23)) | ||
|
37 changes: 37 additions & 0 deletions
37
tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
=== tests/cases/compiler/optionalChainWithInstantiationExpression1.ts === | ||
declare namespace A { | ||
>A : typeof A | ||
|
||
export class b<T> { | ||
>b : b<T> | ||
|
||
static d: number; | ||
>d : number | ||
|
||
constructor(x: T); | ||
>x : T | ||
} | ||
} | ||
|
||
type c = unknown; | ||
>c : unknown | ||
|
||
declare const a: typeof A | undefined; | ||
>a : typeof A | ||
>A : typeof A | ||
|
||
a?.b<c>.d; | ||
>a?.b<c>.d : number | ||
>a?.b<c> : { new (x: unknown): A.b<unknown>; prototype: A.b<any>; d: number; } | ||
>a?.b : typeof A.b | ||
>a : typeof A | ||
>b : typeof A.b | ||
>d : number | ||
|
||
a?.b.d | ||
>a?.b.d : number | ||
>a?.b : typeof A.b | ||
>a : typeof A | ||
>b : typeof A.b | ||
>d : number | ||
|
21 changes: 21 additions & 0 deletions
21
...s/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
tests/cases/compiler/optionalChainWithInstantiationExpression1.ts(12,5): error TS1477: An instantiation expression cannot be followed by a property access. | ||
|
||
|
||
==== tests/cases/compiler/optionalChainWithInstantiationExpression1.ts (1 errors) ==== | ||
declare namespace A { | ||
export class b<T> { | ||
static d: number; | ||
constructor(x: T); | ||
} | ||
} | ||
|
||
type c = unknown; | ||
|
||
declare const a: typeof A | undefined; | ||
|
||
a?.b<c>.d; | ||
~~~ | ||
!!! error TS1477: An instantiation expression cannot be followed by a property access. | ||
|
||
a?.b.d | ||
|
20 changes: 20 additions & 0 deletions
20
tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//// [optionalChainWithInstantiationExpression1.ts] | ||
declare namespace A { | ||
export class b<T> { | ||
static d: number; | ||
constructor(x: T); | ||
} | ||
} | ||
|
||
type c = unknown; | ||
|
||
declare const a: typeof A | undefined; | ||
|
||
a?.b<c>.d; | ||
|
||
a?.b.d | ||
|
||
|
||
//// [optionalChainWithInstantiationExpression1.js] | ||
a?.b.d; | ||
a?.b.d; |
39 changes: 39 additions & 0 deletions
39
tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
=== tests/cases/compiler/optionalChainWithInstantiationExpression1.ts === | ||
declare namespace A { | ||
>A : Symbol(A, Decl(optionalChainWithInstantiationExpression1.ts, 0, 0)) | ||
|
||
export class b<T> { | ||
>b : Symbol(b, Decl(optionalChainWithInstantiationExpression1.ts, 0, 21)) | ||
>T : Symbol(T, Decl(optionalChainWithInstantiationExpression1.ts, 1, 19)) | ||
|
||
static d: number; | ||
>d : Symbol(b.d, Decl(optionalChainWithInstantiationExpression1.ts, 1, 23)) | ||
|
||
constructor(x: T); | ||
>x : Symbol(x, Decl(optionalChainWithInstantiationExpression1.ts, 3, 20)) | ||
>T : Symbol(T, Decl(optionalChainWithInstantiationExpression1.ts, 1, 19)) | ||
} | ||
} | ||
|
||
type c = unknown; | ||
>c : Symbol(c, Decl(optionalChainWithInstantiationExpression1.ts, 5, 1)) | ||
|
||
declare const a: typeof A | undefined; | ||
>a : Symbol(a, Decl(optionalChainWithInstantiationExpression1.ts, 9, 13)) | ||
>A : Symbol(A, Decl(optionalChainWithInstantiationExpression1.ts, 0, 0)) | ||
|
||
a?.b<c>.d; | ||
>a?.b<c>.d : Symbol(A.b.d, Decl(optionalChainWithInstantiationExpression1.ts, 1, 23)) | ||
>a?.b : Symbol(A.b, Decl(optionalChainWithInstantiationExpression1.ts, 0, 21)) | ||
>a : Symbol(a, Decl(optionalChainWithInstantiationExpression1.ts, 9, 13)) | ||
>b : Symbol(A.b, Decl(optionalChainWithInstantiationExpression1.ts, 0, 21)) | ||
>c : Symbol(c, Decl(optionalChainWithInstantiationExpression1.ts, 5, 1)) | ||
>d : Symbol(A.b.d, Decl(optionalChainWithInstantiationExpression1.ts, 1, 23)) | ||
|
||
a?.b.d | ||
>a?.b.d : Symbol(A.b.d, Decl(optionalChainWithInstantiationExpression1.ts, 1, 23)) | ||
>a?.b : Symbol(A.b, Decl(optionalChainWithInstantiationExpression1.ts, 0, 21)) | ||
>a : Symbol(a, Decl(optionalChainWithInstantiationExpression1.ts, 9, 13)) | ||
>b : Symbol(A.b, Decl(optionalChainWithInstantiationExpression1.ts, 0, 21)) | ||
>d : Symbol(A.b.d, Decl(optionalChainWithInstantiationExpression1.ts, 1, 23)) | ||
|
37 changes: 37 additions & 0 deletions
37
tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
=== tests/cases/compiler/optionalChainWithInstantiationExpression1.ts === | ||
declare namespace A { | ||
>A : typeof A | ||
|
||
export class b<T> { | ||
>b : b<T> | ||
|
||
static d: number; | ||
>d : number | ||
|
||
constructor(x: T); | ||
>x : T | ||
} | ||
} | ||
|
||
type c = unknown; | ||
>c : unknown | ||
|
||
declare const a: typeof A | undefined; | ||
>a : typeof A | ||
>A : typeof A | ||
|
||
a?.b<c>.d; | ||
>a?.b<c>.d : number | ||
>a?.b<c> : { new (x: unknown): A.b<unknown>; prototype: A.b<any>; d: number; } | ||
>a?.b : typeof A.b | ||
>a : typeof A | ||
>b : typeof A.b | ||
>d : number | ||
|
||
a?.b.d | ||
>a?.b.d : number | ||
>a?.b : typeof A.b | ||
>a : typeof A | ||
>b : typeof A.b | ||
>d : number | ||
|
19 changes: 19 additions & 0 deletions
19
tests/baselines/reference/optionalChainWithInstantiationExpression2(target=es2019).js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//// [optionalChainWithInstantiationExpression2.ts] | ||
declare interface A { | ||
c: number; | ||
<T>(): T; | ||
} | ||
|
||
type b = 'b type'; | ||
|
||
declare const a: A | undefined; | ||
|
||
a?.<b>(); | ||
|
||
a<b>?.(); | ||
|
||
|
||
//// [optionalChainWithInstantiationExpression2.js] | ||
var _a; | ||
a === null || a === void 0 ? void 0 : a(); | ||
(_a = (a)) === null || _a === void 0 ? void 0 : _a(); |
27 changes: 27 additions & 0 deletions
27
tests/baselines/reference/optionalChainWithInstantiationExpression2(target=es2019).symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
=== tests/cases/compiler/optionalChainWithInstantiationExpression2.ts === | ||
declare interface A { | ||
>A : Symbol(A, Decl(optionalChainWithInstantiationExpression2.ts, 0, 0)) | ||
|
||
c: number; | ||
>c : Symbol(A.c, Decl(optionalChainWithInstantiationExpression2.ts, 0, 21)) | ||
|
||
<T>(): T; | ||
>T : Symbol(T, Decl(optionalChainWithInstantiationExpression2.ts, 2, 5)) | ||
>T : Symbol(T, Decl(optionalChainWithInstantiationExpression2.ts, 2, 5)) | ||
} | ||
|
||
type b = 'b type'; | ||
>b : Symbol(b, Decl(optionalChainWithInstantiationExpression2.ts, 3, 1)) | ||
|
||
declare const a: A | undefined; | ||
>a : Symbol(a, Decl(optionalChainWithInstantiationExpression2.ts, 7, 13)) | ||
>A : Symbol(A, Decl(optionalChainWithInstantiationExpression2.ts, 0, 0)) | ||
|
||
a?.<b>(); | ||
>a : Symbol(a, Decl(optionalChainWithInstantiationExpression2.ts, 7, 13)) | ||
>b : Symbol(b, Decl(optionalChainWithInstantiationExpression2.ts, 3, 1)) | ||
|
||
a<b>?.(); | ||
>a : Symbol(a, Decl(optionalChainWithInstantiationExpression2.ts, 7, 13)) | ||
>b : Symbol(b, Decl(optionalChainWithInstantiationExpression2.ts, 3, 1)) | ||
|
23 changes: 23 additions & 0 deletions
23
tests/baselines/reference/optionalChainWithInstantiationExpression2(target=es2019).types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
=== tests/cases/compiler/optionalChainWithInstantiationExpression2.ts === | ||
declare interface A { | ||
c: number; | ||
>c : number | ||
|
||
<T>(): T; | ||
} | ||
|
||
type b = 'b type'; | ||
>b : "b type" | ||
|
||
declare const a: A | undefined; | ||
>a : A | ||
|
||
a?.<b>(); | ||
>a?.<b>() : "b type" | ||
>a : A | ||
|
||
a<b>?.(); | ||
>a<b>?.() : "b type" | ||
>a<b> : { (): "b type"; c: number; } | ||
>a : A | ||
|
Oops, something went wrong.