From 61cd8e35a719ef1e679f67c8e1579a37b79690fe Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 1 Jun 2022 12:07:01 -0700 Subject: [PATCH 1/7] Add test case --- ...hInstantiationExpression(target=es2019).js | 20 ++++++++++ ...antiationExpression(target=es2019).symbols | 39 +++++++++++++++++++ ...stantiationExpression(target=es2019).types | 36 +++++++++++++++++ ...hInstantiationExpression(target=es2020).js | 20 ++++++++++ ...antiationExpression(target=es2020).symbols | 39 +++++++++++++++++++ ...stantiationExpression(target=es2020).types | 36 +++++++++++++++++ ...ptionalChainWithInstantiationExpression.ts | 16 ++++++++ 7 files changed, 206 insertions(+) create mode 100644 tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2019).js create mode 100644 tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2019).symbols create mode 100644 tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2019).types create mode 100644 tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2020).js create mode 100644 tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2020).symbols create mode 100644 tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2020).types create mode 100644 tests/cases/compiler/optionalChainWithInstantiationExpression.ts diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2019).js b/tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2019).js new file mode 100644 index 0000000000000..523c415eed4e0 --- /dev/null +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2019).js @@ -0,0 +1,20 @@ +//// [optionalChainWithInstantiationExpression.ts] +declare namespace A { + export class b { + static d: number; + constructor(x: T); + } +} + +type c = unknown; + +declare const a: typeof A | undefined; + +a?.b.d; + +a?.b.d + + +//// [optionalChainWithInstantiationExpression.js] +(a === null || a === void 0 ? void 0 : a.b).d; +a === null || a === void 0 ? void 0 : a.b.d; diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2019).symbols b/tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2019).symbols new file mode 100644 index 0000000000000..2e7626bbe87d1 --- /dev/null +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2019).symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/optionalChainWithInstantiationExpression.ts === +declare namespace A { +>A : Symbol(A, Decl(optionalChainWithInstantiationExpression.ts, 0, 0)) + + export class b { +>b : Symbol(b, Decl(optionalChainWithInstantiationExpression.ts, 0, 21)) +>T : Symbol(T, Decl(optionalChainWithInstantiationExpression.ts, 1, 19)) + + static d: number; +>d : Symbol(b.d, Decl(optionalChainWithInstantiationExpression.ts, 1, 23)) + + constructor(x: T); +>x : Symbol(x, Decl(optionalChainWithInstantiationExpression.ts, 3, 20)) +>T : Symbol(T, Decl(optionalChainWithInstantiationExpression.ts, 1, 19)) + } +} + +type c = unknown; +>c : Symbol(c, Decl(optionalChainWithInstantiationExpression.ts, 5, 1)) + +declare const a: typeof A | undefined; +>a : Symbol(a, Decl(optionalChainWithInstantiationExpression.ts, 9, 13)) +>A : Symbol(A, Decl(optionalChainWithInstantiationExpression.ts, 0, 0)) + +a?.b.d; +>a?.b.d : Symbol(A.b.d, Decl(optionalChainWithInstantiationExpression.ts, 1, 23)) +>a?.b : Symbol(A.b, Decl(optionalChainWithInstantiationExpression.ts, 0, 21)) +>a : Symbol(a, Decl(optionalChainWithInstantiationExpression.ts, 9, 13)) +>b : Symbol(A.b, Decl(optionalChainWithInstantiationExpression.ts, 0, 21)) +>c : Symbol(c, Decl(optionalChainWithInstantiationExpression.ts, 5, 1)) +>d : Symbol(A.b.d, Decl(optionalChainWithInstantiationExpression.ts, 1, 23)) + +a?.b.d +>a?.b.d : Symbol(A.b.d, Decl(optionalChainWithInstantiationExpression.ts, 1, 23)) +>a?.b : Symbol(A.b, Decl(optionalChainWithInstantiationExpression.ts, 0, 21)) +>a : Symbol(a, Decl(optionalChainWithInstantiationExpression.ts, 9, 13)) +>b : Symbol(A.b, Decl(optionalChainWithInstantiationExpression.ts, 0, 21)) +>d : Symbol(A.b.d, Decl(optionalChainWithInstantiationExpression.ts, 1, 23)) + diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2019).types b/tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2019).types new file mode 100644 index 0000000000000..be07e95bb2a99 --- /dev/null +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2019).types @@ -0,0 +1,36 @@ +=== tests/cases/compiler/optionalChainWithInstantiationExpression.ts === +declare namespace A { +>A : typeof A + + export class b { +>b : b + + 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.d; +>a?.b.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 + diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2020).js b/tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2020).js new file mode 100644 index 0000000000000..533a8e24c11c5 --- /dev/null +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2020).js @@ -0,0 +1,20 @@ +//// [optionalChainWithInstantiationExpression.ts] +declare namespace A { + export class b { + static d: number; + constructor(x: T); + } +} + +type c = unknown; + +declare const a: typeof A | undefined; + +a?.b.d; + +a?.b.d + + +//// [optionalChainWithInstantiationExpression.js] +a?.b.d; +a?.b.d; diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2020).symbols b/tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2020).symbols new file mode 100644 index 0000000000000..2e7626bbe87d1 --- /dev/null +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2020).symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/optionalChainWithInstantiationExpression.ts === +declare namespace A { +>A : Symbol(A, Decl(optionalChainWithInstantiationExpression.ts, 0, 0)) + + export class b { +>b : Symbol(b, Decl(optionalChainWithInstantiationExpression.ts, 0, 21)) +>T : Symbol(T, Decl(optionalChainWithInstantiationExpression.ts, 1, 19)) + + static d: number; +>d : Symbol(b.d, Decl(optionalChainWithInstantiationExpression.ts, 1, 23)) + + constructor(x: T); +>x : Symbol(x, Decl(optionalChainWithInstantiationExpression.ts, 3, 20)) +>T : Symbol(T, Decl(optionalChainWithInstantiationExpression.ts, 1, 19)) + } +} + +type c = unknown; +>c : Symbol(c, Decl(optionalChainWithInstantiationExpression.ts, 5, 1)) + +declare const a: typeof A | undefined; +>a : Symbol(a, Decl(optionalChainWithInstantiationExpression.ts, 9, 13)) +>A : Symbol(A, Decl(optionalChainWithInstantiationExpression.ts, 0, 0)) + +a?.b.d; +>a?.b.d : Symbol(A.b.d, Decl(optionalChainWithInstantiationExpression.ts, 1, 23)) +>a?.b : Symbol(A.b, Decl(optionalChainWithInstantiationExpression.ts, 0, 21)) +>a : Symbol(a, Decl(optionalChainWithInstantiationExpression.ts, 9, 13)) +>b : Symbol(A.b, Decl(optionalChainWithInstantiationExpression.ts, 0, 21)) +>c : Symbol(c, Decl(optionalChainWithInstantiationExpression.ts, 5, 1)) +>d : Symbol(A.b.d, Decl(optionalChainWithInstantiationExpression.ts, 1, 23)) + +a?.b.d +>a?.b.d : Symbol(A.b.d, Decl(optionalChainWithInstantiationExpression.ts, 1, 23)) +>a?.b : Symbol(A.b, Decl(optionalChainWithInstantiationExpression.ts, 0, 21)) +>a : Symbol(a, Decl(optionalChainWithInstantiationExpression.ts, 9, 13)) +>b : Symbol(A.b, Decl(optionalChainWithInstantiationExpression.ts, 0, 21)) +>d : Symbol(A.b.d, Decl(optionalChainWithInstantiationExpression.ts, 1, 23)) + diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2020).types b/tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2020).types new file mode 100644 index 0000000000000..be07e95bb2a99 --- /dev/null +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2020).types @@ -0,0 +1,36 @@ +=== tests/cases/compiler/optionalChainWithInstantiationExpression.ts === +declare namespace A { +>A : typeof A + + export class b { +>b : b + + 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.d; +>a?.b.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 + diff --git a/tests/cases/compiler/optionalChainWithInstantiationExpression.ts b/tests/cases/compiler/optionalChainWithInstantiationExpression.ts new file mode 100644 index 0000000000000..6bc4c947195ad --- /dev/null +++ b/tests/cases/compiler/optionalChainWithInstantiationExpression.ts @@ -0,0 +1,16 @@ +// @target: es2019,es2020 + +declare namespace A { + export class b { + static d: number; + constructor(x: T); + } +} + +type c = unknown; + +declare const a: typeof A | undefined; + +a?.b.d; + +a?.b.d From 52bb8f3a035e1500a9a18c5f292fd21b4f471245 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 9 Jun 2022 15:05:58 -0700 Subject: [PATCH 2/7] Add extra test --- ...antiationExpression(target=es2019).symbols | 39 ------------------- ...antiationExpression(target=es2020).symbols | 39 ------------------- ...nstantiationExpression1(target=es2019).js} | 4 +- ...ntiationExpression1(target=es2019).symbols | 39 +++++++++++++++++++ ...antiationExpression1(target=es2019).types} | 3 +- ...nstantiationExpression1(target=es2020).js} | 4 +- ...ntiationExpression1(target=es2020).symbols | 39 +++++++++++++++++++ ...antiationExpression1(target=es2020).types} | 3 +- ...InstantiationExpression2(target=es2019).js | 19 +++++++++ ...ntiationExpression2(target=es2019).symbols | 27 +++++++++++++ ...tantiationExpression2(target=es2019).types | 23 +++++++++++ ...InstantiationExpression2(target=es2020).js | 18 +++++++++ ...ntiationExpression2(target=es2020).symbols | 27 +++++++++++++ ...tantiationExpression2(target=es2020).types | 23 +++++++++++ ...ionalChainWithInstantiationExpression1.ts} | 0 ...tionalChainWithInstantiationExpression2.ts | 14 +++++++ 16 files changed, 237 insertions(+), 84 deletions(-) delete mode 100644 tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2019).symbols delete mode 100644 tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2020).symbols rename tests/baselines/reference/{optionalChainWithInstantiationExpression(target=es2019).js => optionalChainWithInstantiationExpression1(target=es2019).js} (71%) create mode 100644 tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).symbols rename tests/baselines/reference/{optionalChainWithInstantiationExpression(target=es2020).types => optionalChainWithInstantiationExpression1(target=es2019).types} (79%) rename tests/baselines/reference/{optionalChainWithInstantiationExpression(target=es2020).js => optionalChainWithInstantiationExpression1(target=es2020).js} (64%) create mode 100644 tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).symbols rename tests/baselines/reference/{optionalChainWithInstantiationExpression(target=es2019).types => optionalChainWithInstantiationExpression1(target=es2020).types} (79%) create mode 100644 tests/baselines/reference/optionalChainWithInstantiationExpression2(target=es2019).js create mode 100644 tests/baselines/reference/optionalChainWithInstantiationExpression2(target=es2019).symbols create mode 100644 tests/baselines/reference/optionalChainWithInstantiationExpression2(target=es2019).types create mode 100644 tests/baselines/reference/optionalChainWithInstantiationExpression2(target=es2020).js create mode 100644 tests/baselines/reference/optionalChainWithInstantiationExpression2(target=es2020).symbols create mode 100644 tests/baselines/reference/optionalChainWithInstantiationExpression2(target=es2020).types rename tests/cases/compiler/{optionalChainWithInstantiationExpression.ts => optionalChainWithInstantiationExpression1.ts} (100%) create mode 100644 tests/cases/compiler/optionalChainWithInstantiationExpression2.ts diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2019).symbols b/tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2019).symbols deleted file mode 100644 index 2e7626bbe87d1..0000000000000 --- a/tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2019).symbols +++ /dev/null @@ -1,39 +0,0 @@ -=== tests/cases/compiler/optionalChainWithInstantiationExpression.ts === -declare namespace A { ->A : Symbol(A, Decl(optionalChainWithInstantiationExpression.ts, 0, 0)) - - export class b { ->b : Symbol(b, Decl(optionalChainWithInstantiationExpression.ts, 0, 21)) ->T : Symbol(T, Decl(optionalChainWithInstantiationExpression.ts, 1, 19)) - - static d: number; ->d : Symbol(b.d, Decl(optionalChainWithInstantiationExpression.ts, 1, 23)) - - constructor(x: T); ->x : Symbol(x, Decl(optionalChainWithInstantiationExpression.ts, 3, 20)) ->T : Symbol(T, Decl(optionalChainWithInstantiationExpression.ts, 1, 19)) - } -} - -type c = unknown; ->c : Symbol(c, Decl(optionalChainWithInstantiationExpression.ts, 5, 1)) - -declare const a: typeof A | undefined; ->a : Symbol(a, Decl(optionalChainWithInstantiationExpression.ts, 9, 13)) ->A : Symbol(A, Decl(optionalChainWithInstantiationExpression.ts, 0, 0)) - -a?.b.d; ->a?.b.d : Symbol(A.b.d, Decl(optionalChainWithInstantiationExpression.ts, 1, 23)) ->a?.b : Symbol(A.b, Decl(optionalChainWithInstantiationExpression.ts, 0, 21)) ->a : Symbol(a, Decl(optionalChainWithInstantiationExpression.ts, 9, 13)) ->b : Symbol(A.b, Decl(optionalChainWithInstantiationExpression.ts, 0, 21)) ->c : Symbol(c, Decl(optionalChainWithInstantiationExpression.ts, 5, 1)) ->d : Symbol(A.b.d, Decl(optionalChainWithInstantiationExpression.ts, 1, 23)) - -a?.b.d ->a?.b.d : Symbol(A.b.d, Decl(optionalChainWithInstantiationExpression.ts, 1, 23)) ->a?.b : Symbol(A.b, Decl(optionalChainWithInstantiationExpression.ts, 0, 21)) ->a : Symbol(a, Decl(optionalChainWithInstantiationExpression.ts, 9, 13)) ->b : Symbol(A.b, Decl(optionalChainWithInstantiationExpression.ts, 0, 21)) ->d : Symbol(A.b.d, Decl(optionalChainWithInstantiationExpression.ts, 1, 23)) - diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2020).symbols b/tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2020).symbols deleted file mode 100644 index 2e7626bbe87d1..0000000000000 --- a/tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2020).symbols +++ /dev/null @@ -1,39 +0,0 @@ -=== tests/cases/compiler/optionalChainWithInstantiationExpression.ts === -declare namespace A { ->A : Symbol(A, Decl(optionalChainWithInstantiationExpression.ts, 0, 0)) - - export class b { ->b : Symbol(b, Decl(optionalChainWithInstantiationExpression.ts, 0, 21)) ->T : Symbol(T, Decl(optionalChainWithInstantiationExpression.ts, 1, 19)) - - static d: number; ->d : Symbol(b.d, Decl(optionalChainWithInstantiationExpression.ts, 1, 23)) - - constructor(x: T); ->x : Symbol(x, Decl(optionalChainWithInstantiationExpression.ts, 3, 20)) ->T : Symbol(T, Decl(optionalChainWithInstantiationExpression.ts, 1, 19)) - } -} - -type c = unknown; ->c : Symbol(c, Decl(optionalChainWithInstantiationExpression.ts, 5, 1)) - -declare const a: typeof A | undefined; ->a : Symbol(a, Decl(optionalChainWithInstantiationExpression.ts, 9, 13)) ->A : Symbol(A, Decl(optionalChainWithInstantiationExpression.ts, 0, 0)) - -a?.b.d; ->a?.b.d : Symbol(A.b.d, Decl(optionalChainWithInstantiationExpression.ts, 1, 23)) ->a?.b : Symbol(A.b, Decl(optionalChainWithInstantiationExpression.ts, 0, 21)) ->a : Symbol(a, Decl(optionalChainWithInstantiationExpression.ts, 9, 13)) ->b : Symbol(A.b, Decl(optionalChainWithInstantiationExpression.ts, 0, 21)) ->c : Symbol(c, Decl(optionalChainWithInstantiationExpression.ts, 5, 1)) ->d : Symbol(A.b.d, Decl(optionalChainWithInstantiationExpression.ts, 1, 23)) - -a?.b.d ->a?.b.d : Symbol(A.b.d, Decl(optionalChainWithInstantiationExpression.ts, 1, 23)) ->a?.b : Symbol(A.b, Decl(optionalChainWithInstantiationExpression.ts, 0, 21)) ->a : Symbol(a, Decl(optionalChainWithInstantiationExpression.ts, 9, 13)) ->b : Symbol(A.b, Decl(optionalChainWithInstantiationExpression.ts, 0, 21)) ->d : Symbol(A.b.d, Decl(optionalChainWithInstantiationExpression.ts, 1, 23)) - diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2019).js b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).js similarity index 71% rename from tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2019).js rename to tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).js index 523c415eed4e0..593e340b04559 100644 --- a/tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2019).js +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).js @@ -1,4 +1,4 @@ -//// [optionalChainWithInstantiationExpression.ts] +//// [optionalChainWithInstantiationExpression1.ts] declare namespace A { export class b { static d: number; @@ -15,6 +15,6 @@ a?.b.d; a?.b.d -//// [optionalChainWithInstantiationExpression.js] +//// [optionalChainWithInstantiationExpression1.js] (a === null || a === void 0 ? void 0 : a.b).d; a === null || a === void 0 ? void 0 : a.b.d; diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).symbols b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).symbols new file mode 100644 index 0000000000000..160950e459108 --- /dev/null +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/optionalChainWithInstantiationExpression1.ts === +declare namespace A { +>A : Symbol(A, Decl(optionalChainWithInstantiationExpression1.ts, 0, 0)) + + export class b { +>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.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)) +>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)) + diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2020).types b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).types similarity index 79% rename from tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2020).types rename to tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).types index be07e95bb2a99..11e0ab6572ae9 100644 --- a/tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2020).types +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/optionalChainWithInstantiationExpression.ts === +=== tests/cases/compiler/optionalChainWithInstantiationExpression1.ts === declare namespace A { >A : typeof A @@ -22,6 +22,7 @@ declare const a: typeof A | undefined; a?.b.d; >a?.b.d : number +>a?.b : { new (x: unknown): A.b; prototype: A.b; d: number; } >a?.b : typeof A.b >a : typeof A >b : typeof A.b diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2020).js b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).js similarity index 64% rename from tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2020).js rename to tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).js index 533a8e24c11c5..86f3e9f520934 100644 --- a/tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2020).js +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).js @@ -1,4 +1,4 @@ -//// [optionalChainWithInstantiationExpression.ts] +//// [optionalChainWithInstantiationExpression1.ts] declare namespace A { export class b { static d: number; @@ -15,6 +15,6 @@ a?.b.d; a?.b.d -//// [optionalChainWithInstantiationExpression.js] +//// [optionalChainWithInstantiationExpression1.js] a?.b.d; a?.b.d; diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).symbols b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).symbols new file mode 100644 index 0000000000000..160950e459108 --- /dev/null +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/optionalChainWithInstantiationExpression1.ts === +declare namespace A { +>A : Symbol(A, Decl(optionalChainWithInstantiationExpression1.ts, 0, 0)) + + export class b { +>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.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)) +>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)) + diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2019).types b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).types similarity index 79% rename from tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2019).types rename to tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).types index be07e95bb2a99..11e0ab6572ae9 100644 --- a/tests/baselines/reference/optionalChainWithInstantiationExpression(target=es2019).types +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/optionalChainWithInstantiationExpression.ts === +=== tests/cases/compiler/optionalChainWithInstantiationExpression1.ts === declare namespace A { >A : typeof A @@ -22,6 +22,7 @@ declare const a: typeof A | undefined; a?.b.d; >a?.b.d : number +>a?.b : { new (x: unknown): A.b; prototype: A.b; d: number; } >a?.b : typeof A.b >a : typeof A >b : typeof A.b diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression2(target=es2019).js b/tests/baselines/reference/optionalChainWithInstantiationExpression2(target=es2019).js new file mode 100644 index 0000000000000..e5c499eb06325 --- /dev/null +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression2(target=es2019).js @@ -0,0 +1,19 @@ +//// [optionalChainWithInstantiationExpression2.ts] +declare interface A { + c: number; + (): T; +} + +type b = 'b type'; + +declare const a: A | undefined; + +a?.(); + +a?.(); + + +//// [optionalChainWithInstantiationExpression2.js] +var _a; +a === null || a === void 0 ? void 0 : a(); +(_a = (a)) === null || _a === void 0 ? void 0 : _a(); diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression2(target=es2019).symbols b/tests/baselines/reference/optionalChainWithInstantiationExpression2(target=es2019).symbols new file mode 100644 index 0000000000000..9da7857d2d3c3 --- /dev/null +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression2(target=es2019).symbols @@ -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 : 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?.(); +>a : Symbol(a, Decl(optionalChainWithInstantiationExpression2.ts, 7, 13)) +>b : Symbol(b, Decl(optionalChainWithInstantiationExpression2.ts, 3, 1)) + +a?.(); +>a : Symbol(a, Decl(optionalChainWithInstantiationExpression2.ts, 7, 13)) +>b : Symbol(b, Decl(optionalChainWithInstantiationExpression2.ts, 3, 1)) + diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression2(target=es2019).types b/tests/baselines/reference/optionalChainWithInstantiationExpression2(target=es2019).types new file mode 100644 index 0000000000000..67fc79bb5df18 --- /dev/null +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression2(target=es2019).types @@ -0,0 +1,23 @@ +=== tests/cases/compiler/optionalChainWithInstantiationExpression2.ts === +declare interface A { + c: number; +>c : number + + (): T; +} + +type b = 'b type'; +>b : "b type" + +declare const a: A | undefined; +>a : A + +a?.(); +>a?.() : "b type" +>a : A + +a?.(); +>a?.() : "b type" +>a : { (): "b type"; c: number; } +>a : A + diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression2(target=es2020).js b/tests/baselines/reference/optionalChainWithInstantiationExpression2(target=es2020).js new file mode 100644 index 0000000000000..9cca16c431b87 --- /dev/null +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression2(target=es2020).js @@ -0,0 +1,18 @@ +//// [optionalChainWithInstantiationExpression2.ts] +declare interface A { + c: number; + (): T; +} + +type b = 'b type'; + +declare const a: A | undefined; + +a?.(); + +a?.(); + + +//// [optionalChainWithInstantiationExpression2.js] +a?.(); +a?.(); diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression2(target=es2020).symbols b/tests/baselines/reference/optionalChainWithInstantiationExpression2(target=es2020).symbols new file mode 100644 index 0000000000000..9da7857d2d3c3 --- /dev/null +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression2(target=es2020).symbols @@ -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 : 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?.(); +>a : Symbol(a, Decl(optionalChainWithInstantiationExpression2.ts, 7, 13)) +>b : Symbol(b, Decl(optionalChainWithInstantiationExpression2.ts, 3, 1)) + +a?.(); +>a : Symbol(a, Decl(optionalChainWithInstantiationExpression2.ts, 7, 13)) +>b : Symbol(b, Decl(optionalChainWithInstantiationExpression2.ts, 3, 1)) + diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression2(target=es2020).types b/tests/baselines/reference/optionalChainWithInstantiationExpression2(target=es2020).types new file mode 100644 index 0000000000000..67fc79bb5df18 --- /dev/null +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression2(target=es2020).types @@ -0,0 +1,23 @@ +=== tests/cases/compiler/optionalChainWithInstantiationExpression2.ts === +declare interface A { + c: number; +>c : number + + (): T; +} + +type b = 'b type'; +>b : "b type" + +declare const a: A | undefined; +>a : A + +a?.(); +>a?.() : "b type" +>a : A + +a?.(); +>a?.() : "b type" +>a : { (): "b type"; c: number; } +>a : A + diff --git a/tests/cases/compiler/optionalChainWithInstantiationExpression.ts b/tests/cases/compiler/optionalChainWithInstantiationExpression1.ts similarity index 100% rename from tests/cases/compiler/optionalChainWithInstantiationExpression.ts rename to tests/cases/compiler/optionalChainWithInstantiationExpression1.ts diff --git a/tests/cases/compiler/optionalChainWithInstantiationExpression2.ts b/tests/cases/compiler/optionalChainWithInstantiationExpression2.ts new file mode 100644 index 0000000000000..6f719e434b6d1 --- /dev/null +++ b/tests/cases/compiler/optionalChainWithInstantiationExpression2.ts @@ -0,0 +1,14 @@ +// @target: es2019,es2020 + +declare interface A { + c: number; + (): T; +} + +type b = 'b type'; + +declare const a: A | undefined; + +a?.(); + +a?.(); From fc428dc3681f203760b22e47009df4a082411b3e Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 9 Jun 2022 16:33:29 -0700 Subject: [PATCH 3/7] Return early from parsing property access expression after type parameters --- src/compiler/parser.ts | 4 +++ .../genericCallWithoutArgs.errors.txt | 10 ------- .../reference/genericCallWithoutArgs.js | 2 +- .../reference/genericCallWithoutArgs.types | 2 -- .../instantiationExpressionErrors.errors.txt | 26 ++++++++++++++++++- .../instantiationExpressionErrors.js | 15 ++++++++--- .../instantiationExpressionErrors.symbols | 6 ++--- .../instantiationExpressionErrors.types | 13 +++++----- ...ationExpression1(target=es2019).errors.txt | 24 +++++++++++++++++ ...InstantiationExpression1(target=es2019).js | 3 ++- ...ntiationExpression1(target=es2019).symbols | 2 -- ...tantiationExpression1(target=es2019).types | 3 +-- ...ationExpression1(target=es2020).errors.txt | 24 +++++++++++++++++ ...InstantiationExpression1(target=es2020).js | 3 ++- ...ntiationExpression1(target=es2020).symbols | 2 -- ...tantiationExpression1(target=es2020).types | 3 +-- .../parserMemberAccessExpression1.errors.txt | 14 +++++++++- .../parserMemberAccessExpression1.js | 6 +++-- .../parserMemberAccessExpression1.types | 6 ++--- ...erMemberAccessOffOfGenericType1.errors.txt | 13 ++++++++-- .../parserMemberAccessOffOfGenericType1.js | 3 ++- ...arserMemberAccessOffOfGenericType1.symbols | 1 + .../parserMemberAccessOffOfGenericType1.types | 4 +-- 23 files changed, 138 insertions(+), 51 deletions(-) delete mode 100644 tests/baselines/reference/genericCallWithoutArgs.errors.txt create mode 100644 tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).errors.txt create mode 100644 tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).errors.txt diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index b44b86e971a7a..000c60b6fa335 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -5605,6 +5605,10 @@ namespace ts { } if (isPropertyAccess) { + // TODO: issue a better error? + if (expression.kind === SyntaxKind.ExpressionWithTypeArguments) { + return expression as MemberExpression; + } expression = parsePropertyAccessExpressionRest(pos, expression, questionDotToken); continue; } diff --git a/tests/baselines/reference/genericCallWithoutArgs.errors.txt b/tests/baselines/reference/genericCallWithoutArgs.errors.txt deleted file mode 100644 index 75a2d51a1da3e..0000000000000 --- a/tests/baselines/reference/genericCallWithoutArgs.errors.txt +++ /dev/null @@ -1,10 +0,0 @@ -tests/cases/compiler/genericCallWithoutArgs.ts(4,18): error TS1003: Identifier expected. - - -==== tests/cases/compiler/genericCallWithoutArgs.ts (1 errors) ==== - function f(x: X, y: Y) { - } - - f. - -!!! error TS1003: Identifier expected. \ No newline at end of file diff --git a/tests/baselines/reference/genericCallWithoutArgs.js b/tests/baselines/reference/genericCallWithoutArgs.js index aab48f5e047c6..0e4d8446f999c 100644 --- a/tests/baselines/reference/genericCallWithoutArgs.js +++ b/tests/baselines/reference/genericCallWithoutArgs.js @@ -7,4 +7,4 @@ f. //// [genericCallWithoutArgs.js] function f(x, y) { } -f.; +f; diff --git a/tests/baselines/reference/genericCallWithoutArgs.types b/tests/baselines/reference/genericCallWithoutArgs.types index 6d4969a83ee7e..b11961d0dfc95 100644 --- a/tests/baselines/reference/genericCallWithoutArgs.types +++ b/tests/baselines/reference/genericCallWithoutArgs.types @@ -6,8 +6,6 @@ function f(x: X, y: Y) { } f. ->f. : any >f : (x: number, y: string) => void >f : (x: X, y: Y) => void -> : any diff --git a/tests/baselines/reference/instantiationExpressionErrors.errors.txt b/tests/baselines/reference/instantiationExpressionErrors.errors.txt index 5b60983d594dc..fb552b6635b15 100644 --- a/tests/baselines/reference/instantiationExpressionErrors.errors.txt +++ b/tests/baselines/reference/instantiationExpressionErrors.errors.txt @@ -1,3 +1,11 @@ +tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(7,22): error TS1005: ',' expected. +tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(7,22): error TS2451: Cannot redeclare block-scoped variable 'g'. +tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(7,22): error TS7005: Variable 'g' implicitly has an 'any' type. +tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(8,22): error TS1005: ',' expected. +tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(8,22): error TS2451: Cannot redeclare block-scoped variable 'g'. +tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(8,22): error TS7005: Variable 'g' implicitly has an 'any' type. +tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(8,23): error TS1005: ',' expected. +tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(8,31): error TS1109: Expression expected. tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(13,12): error TS2365: Operator '>' cannot be applied to types 'boolean' and 'string[]'. tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(13,14): error TS2693: 'number' only refers to a type, but is being used as a value here. tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(18,12): error TS2365: Operator '>' cannot be applied to types 'boolean' and 'number'. @@ -10,7 +18,7 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpr tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(35,12): error TS2365: Operator '<' cannot be applied to types '{ (): T; g(): U; }' and 'boolean'. -==== tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts (10 errors) ==== +==== tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts (18 errors) ==== declare let f: { (): T, g(): U }; // Type arguments in member expressions @@ -18,7 +26,23 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpr const a1 = f; // { (): number; g(): U; } const a2 = f.g; // () => number const a3 = f.g; // () => U + ~ +!!! error TS1005: ',' expected. + ~ +!!! error TS2451: Cannot redeclare block-scoped variable 'g'. + ~ +!!! error TS7005: Variable 'g' implicitly has an 'any' type. const a4 = f.g; // () => number + ~ +!!! error TS1005: ',' expected. + ~ +!!! error TS2451: Cannot redeclare block-scoped variable 'g'. + ~ +!!! error TS7005: Variable 'g' implicitly has an 'any' type. + ~ +!!! error TS1005: ',' expected. + ~ +!!! error TS1109: Expression expected. const a5 = f['g']; // () => number // `[` is an expression starter and cannot immediately follow a type argument list diff --git a/tests/baselines/reference/instantiationExpressionErrors.js b/tests/baselines/reference/instantiationExpressionErrors.js index 9f6b17f13787a..9beb00ea35479 100644 --- a/tests/baselines/reference/instantiationExpressionErrors.js +++ b/tests/baselines/reference/instantiationExpressionErrors.js @@ -53,8 +53,9 @@ var _a, _b; // Type arguments in member expressions var a1 = (f); // { (): number; g(): U; } var a2 = (f.g); // () => number -var a3 = f.g; // () => U -var a4 = (f.g); // () => number +var a3 = (f), g; // () => U +var a4 = (f), g; +; // () => number var a5 = (f['g']); // () => number // `[` is an expression starter and cannot immediately follow a type argument list var a6 = f < number > ['g']; // Error @@ -90,8 +91,14 @@ declare const a1: { g(): U; }; declare const a2: () => number; -declare const a3: () => U; -declare const a4: () => number; +declare const a3: { + (): number; + g(): U; +}, g: any; +declare const a4: { + (): number; + g(): U; +}, g: any; declare const a5: () => number; declare const a6: boolean; declare const a7: () => U; diff --git a/tests/baselines/reference/instantiationExpressionErrors.symbols b/tests/baselines/reference/instantiationExpressionErrors.symbols index dc1e6d5d64b3c..be0d6298c8d30 100644 --- a/tests/baselines/reference/instantiationExpressionErrors.symbols +++ b/tests/baselines/reference/instantiationExpressionErrors.symbols @@ -21,15 +21,13 @@ const a2 = f.g; // () => number const a3 = f.g; // () => U >a3 : Symbol(a3, Decl(instantiationExpressionErrors.ts, 6, 5)) ->f.g : Symbol(g, Decl(instantiationExpressionErrors.ts, 0, 26)) >f : Symbol(f, Decl(instantiationExpressionErrors.ts, 0, 11)) ->g : Symbol(g, Decl(instantiationExpressionErrors.ts, 0, 26)) +>g : Symbol(g, Decl(instantiationExpressionErrors.ts, 6, 21)) const a4 = f.g; // () => number >a4 : Symbol(a4, Decl(instantiationExpressionErrors.ts, 7, 5)) ->f.g : Symbol(g, Decl(instantiationExpressionErrors.ts, 0, 26)) >f : Symbol(f, Decl(instantiationExpressionErrors.ts, 0, 11)) ->g : Symbol(g, Decl(instantiationExpressionErrors.ts, 0, 26)) +>g : Symbol(g, Decl(instantiationExpressionErrors.ts, 7, 21)) const a5 = f['g']; // () => number >a5 : Symbol(a5, Decl(instantiationExpressionErrors.ts, 8, 5)) diff --git a/tests/baselines/reference/instantiationExpressionErrors.types b/tests/baselines/reference/instantiationExpressionErrors.types index c2de6b5720ec1..6d15d2d416559 100644 --- a/tests/baselines/reference/instantiationExpressionErrors.types +++ b/tests/baselines/reference/instantiationExpressionErrors.types @@ -18,19 +18,18 @@ const a2 = f.g; // () => number >g : () => U const a3 = f.g; // () => U ->a3 : () => U ->f.g : () => U +>a3 : { (): number; g(): U; } >f : { (): number; g(): U; } >f : { (): T; g(): U; } ->g : () => U +>g : any const a4 = f.g; // () => number ->a4 : () => number ->f.g : () => number ->f.g : () => U +>a4 : { (): number; g(): U; } >f : { (): number; g(): U; } >f : { (): T; g(): U; } ->g : () => U +>g : any +> : number +> : any const a5 = f['g']; // () => number >a5 : () => number diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).errors.txt b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).errors.txt new file mode 100644 index 0000000000000..7b2c4620a8987 --- /dev/null +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).errors.txt @@ -0,0 +1,24 @@ +tests/cases/compiler/optionalChainWithInstantiationExpression1.ts(12,9): error TS1005: ';' expected. +tests/cases/compiler/optionalChainWithInstantiationExpression1.ts(12,9): error TS2304: Cannot find name 'd'. + + +==== tests/cases/compiler/optionalChainWithInstantiationExpression1.ts (2 errors) ==== + declare namespace A { + export class b { + static d: number; + constructor(x: T); + } + } + + type c = unknown; + + declare const a: typeof A | undefined; + + a?.b.d; + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS2304: Cannot find name 'd'. + + a?.b.d + \ No newline at end of file diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).js b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).js index 593e340b04559..8ca2d1325f55c 100644 --- a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).js +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).js @@ -16,5 +16,6 @@ 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; a === null || a === void 0 ? void 0 : a.b.d; diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).symbols b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).symbols index 160950e459108..1c803256ec3ee 100644 --- a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).symbols +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).symbols @@ -23,12 +23,10 @@ declare const a: typeof A | undefined; >A : Symbol(A, Decl(optionalChainWithInstantiationExpression1.ts, 0, 0)) 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)) >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)) diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).types b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).types index 11e0ab6572ae9..806e8123ca2c7 100644 --- a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).types +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).types @@ -21,12 +21,11 @@ declare const a: typeof A | undefined; >A : typeof A a?.b.d; ->a?.b.d : number >a?.b : { new (x: unknown): A.b; prototype: A.b; d: number; } >a?.b : typeof A.b >a : typeof A >b : typeof A.b ->d : number +>d : any a?.b.d >a?.b.d : number diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).errors.txt b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).errors.txt new file mode 100644 index 0000000000000..7b2c4620a8987 --- /dev/null +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).errors.txt @@ -0,0 +1,24 @@ +tests/cases/compiler/optionalChainWithInstantiationExpression1.ts(12,9): error TS1005: ';' expected. +tests/cases/compiler/optionalChainWithInstantiationExpression1.ts(12,9): error TS2304: Cannot find name 'd'. + + +==== tests/cases/compiler/optionalChainWithInstantiationExpression1.ts (2 errors) ==== + declare namespace A { + export class b { + static d: number; + constructor(x: T); + } + } + + type c = unknown; + + declare const a: typeof A | undefined; + + a?.b.d; + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS2304: Cannot find name 'd'. + + a?.b.d + \ No newline at end of file diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).js b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).js index 86f3e9f520934..9c54fda5f15ca 100644 --- a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).js +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).js @@ -16,5 +16,6 @@ a?.b.d //// [optionalChainWithInstantiationExpression1.js] -a?.b.d; +a?.b; +d; a?.b.d; diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).symbols b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).symbols index 160950e459108..1c803256ec3ee 100644 --- a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).symbols +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).symbols @@ -23,12 +23,10 @@ declare const a: typeof A | undefined; >A : Symbol(A, Decl(optionalChainWithInstantiationExpression1.ts, 0, 0)) 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)) >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)) diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).types b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).types index 11e0ab6572ae9..806e8123ca2c7 100644 --- a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).types +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).types @@ -21,12 +21,11 @@ declare const a: typeof A | undefined; >A : typeof A a?.b.d; ->a?.b.d : number >a?.b : { new (x: unknown): A.b; prototype: A.b; d: number; } >a?.b : typeof A.b >a : typeof A >b : typeof A.b ->d : number +>d : any a?.b.d >a?.b.d : number diff --git a/tests/baselines/reference/parserMemberAccessExpression1.errors.txt b/tests/baselines/reference/parserMemberAccessExpression1.errors.txt index f791d4dc1caec..dff099daa1052 100644 --- a/tests/baselines/reference/parserMemberAccessExpression1.errors.txt +++ b/tests/baselines/reference/parserMemberAccessExpression1.errors.txt @@ -3,11 +3,15 @@ tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(2,1): error TS2304: Cannot find name 'Foo'. tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(2,9): error TS2304: Cannot find name 'T'. tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(3,1): error TS2304: Cannot find name 'Foo'. +tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(3,8): error TS1005: ';' expected. +tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(3,8): error TS2304: Cannot find name 'Bar'. tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(4,1): error TS2304: Cannot find name 'Foo'. +tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(4,8): error TS1005: ';' expected. +tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(4,8): error TS2304: Cannot find name 'Bar'. tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(4,12): error TS2304: Cannot find name 'T'. -==== tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts (7 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts (11 errors) ==== Foo(); ~~~ !!! error TS2304: Cannot find name 'Foo'. @@ -21,9 +25,17 @@ tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression Foo.Bar(); ~~~ !!! error TS2304: Cannot find name 'Foo'. + ~~~ +!!! error TS1005: ';' expected. + ~~~ +!!! error TS2304: Cannot find name 'Bar'. Foo.Bar(); ~~~ !!! error TS2304: Cannot find name 'Foo'. + ~~~ +!!! error TS1005: ';' expected. + ~~~ +!!! error TS2304: Cannot find name 'Bar'. ~ !!! error TS2304: Cannot find name 'T'. \ No newline at end of file diff --git a/tests/baselines/reference/parserMemberAccessExpression1.js b/tests/baselines/reference/parserMemberAccessExpression1.js index 1b3df778063b2..63ad3a4c7e879 100644 --- a/tests/baselines/reference/parserMemberAccessExpression1.js +++ b/tests/baselines/reference/parserMemberAccessExpression1.js @@ -8,5 +8,7 @@ Foo.Bar(); //// [parserMemberAccessExpression1.js] Foo(); Foo.Bar(); -Foo.Bar(); -Foo.Bar(); +Foo; +Bar(); +Foo; +Bar(); diff --git a/tests/baselines/reference/parserMemberAccessExpression1.types b/tests/baselines/reference/parserMemberAccessExpression1.types index 395f91b2450f3..6c60687c5c0f3 100644 --- a/tests/baselines/reference/parserMemberAccessExpression1.types +++ b/tests/baselines/reference/parserMemberAccessExpression1.types @@ -10,16 +10,14 @@ Foo.Bar(); >Bar : any Foo.Bar(); ->Foo.Bar() : any ->Foo.Bar : any >Foo : any >Foo : any +>Bar() : any >Bar : any Foo.Bar(); ->Foo.Bar() : any ->Foo.Bar : any >Foo : any >Foo : any +>Bar() : any >Bar : any diff --git a/tests/baselines/reference/parserMemberAccessOffOfGenericType1.errors.txt b/tests/baselines/reference/parserMemberAccessOffOfGenericType1.errors.txt index d0ffa095c3ee7..e5c340e72ac7d 100644 --- a/tests/baselines/reference/parserMemberAccessOffOfGenericType1.errors.txt +++ b/tests/baselines/reference/parserMemberAccessOffOfGenericType1.errors.txt @@ -1,7 +1,16 @@ tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessOffOfGenericType1.ts(1,9): error TS2304: Cannot find name 'List'. +tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessOffOfGenericType1.ts(1,22): error TS1005: ',' expected. +tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessOffOfGenericType1.ts(1,31): error TS1005: ',' expected. +tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessOffOfGenericType1.ts(1,32): error TS1109: Expression expected. -==== tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessOffOfGenericType1.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessOffOfGenericType1.ts (4 errors) ==== var v = List.makeChild(); ~~~~ -!!! error TS2304: Cannot find name 'List'. \ No newline at end of file +!!! error TS2304: Cannot find name 'List'. + ~~~~~~~~~ +!!! error TS1005: ',' expected. + ~ +!!! error TS1005: ',' expected. + ~ +!!! error TS1109: Expression expected. \ No newline at end of file diff --git a/tests/baselines/reference/parserMemberAccessOffOfGenericType1.js b/tests/baselines/reference/parserMemberAccessOffOfGenericType1.js index d73594d4a6d3e..eb0a0b94a0594 100644 --- a/tests/baselines/reference/parserMemberAccessOffOfGenericType1.js +++ b/tests/baselines/reference/parserMemberAccessOffOfGenericType1.js @@ -2,4 +2,5 @@ var v = List.makeChild(); //// [parserMemberAccessOffOfGenericType1.js] -var v = List.makeChild(); +var v = (List), makeChild; +(); diff --git a/tests/baselines/reference/parserMemberAccessOffOfGenericType1.symbols b/tests/baselines/reference/parserMemberAccessOffOfGenericType1.symbols index ab2eff6445126..5813f78e326af 100644 --- a/tests/baselines/reference/parserMemberAccessOffOfGenericType1.symbols +++ b/tests/baselines/reference/parserMemberAccessOffOfGenericType1.symbols @@ -1,4 +1,5 @@ === tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessOffOfGenericType1.ts === var v = List.makeChild(); >v : Symbol(v, Decl(parserMemberAccessOffOfGenericType1.ts, 0, 3)) +>makeChild : Symbol(makeChild, Decl(parserMemberAccessOffOfGenericType1.ts, 0, 21)) diff --git a/tests/baselines/reference/parserMemberAccessOffOfGenericType1.types b/tests/baselines/reference/parserMemberAccessOffOfGenericType1.types index b89005fb0ca62..9a37bc4669af3 100644 --- a/tests/baselines/reference/parserMemberAccessOffOfGenericType1.types +++ b/tests/baselines/reference/parserMemberAccessOffOfGenericType1.types @@ -1,9 +1,9 @@ === tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessOffOfGenericType1.ts === var v = List.makeChild(); >v : any ->List.makeChild() : any ->List.makeChild : any >List : any >List : any >makeChild : any +>() : any +> : any From 728c9b4c61a26762f9e5edd730bc7c497ed772ae Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 22 Jun 2022 14:59:40 -0700 Subject: [PATCH 4/7] Create diagnostics, move to checker grammar check --- src/compiler/checker.ts | 7 ++++ src/compiler/diagnosticMessages.json | 4 ++ src/compiler/parser.ts | 4 -- .../genericCallWithoutArgs.errors.txt | 10 +++++ .../reference/genericCallWithoutArgs.js | 2 +- .../reference/genericCallWithoutArgs.types | 2 + .../instantiationExpressionErrors.errors.txt | 38 +------------------ .../instantiationExpressionErrors.js | 21 ++++------ .../instantiationExpressionErrors.symbols | 12 +++--- .../instantiationExpressionErrors.types | 37 +++++++++--------- ...ationExpression1(target=es2019).errors.txt | 9 ++--- ...InstantiationExpression1(target=es2019).js | 3 +- ...ntiationExpression1(target=es2019).symbols | 2 + ...tantiationExpression1(target=es2019).types | 3 +- ...ationExpression1(target=es2020).errors.txt | 9 ++--- ...InstantiationExpression1(target=es2020).js | 3 +- ...ntiationExpression1(target=es2020).symbols | 2 + ...tantiationExpression1(target=es2020).types | 3 +- .../parserMemberAccessExpression1.errors.txt | 16 +++----- .../parserMemberAccessExpression1.js | 6 +-- .../parserMemberAccessExpression1.types | 6 ++- ...erMemberAccessOffOfGenericType1.errors.txt | 12 ++---- .../parserMemberAccessOffOfGenericType1.js | 3 +- ...arserMemberAccessOffOfGenericType1.symbols | 1 - .../parserMemberAccessOffOfGenericType1.types | 4 +- 25 files changed, 91 insertions(+), 128 deletions(-) create mode 100644 tests/baselines/reference/genericCallWithoutArgs.errors.txt diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 65c89db785bcc..202dc1678fb32 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -28912,7 +28912,14 @@ namespace ts { return nonNullType; } + function checkGrammarPropertyAccessExpression(node: PropertyAccessExpression) { + if (node.expression.kind === SyntaxKind.ExpressionWithTypeArguments) { + grammarErrorOnNode(node.name, Diagnostics.Instantiation_expression_cannot_be_followed_by_property_access); + } + } + function checkPropertyAccessExpression(node: PropertyAccessExpression, checkMode: CheckMode | undefined) { + checkGrammarPropertyAccessExpression(node); return node.flags & NodeFlags.OptionalChain ? checkPropertyAccessChain(node as PropertyAccessChain, checkMode) : checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name, checkMode); } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 3a7f155f12d82..968786e2fde95 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1493,6 +1493,10 @@ "category": "Message", "code": 1476 }, + "Instantiation expression cannot be followed by property access.": { + "category": "Error", + "code": 1477 + }, "The types of '{0}' are incompatible between these types.": { "category": "Error", diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 3b34629dca6f6..8c16ff9a910da 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -5683,10 +5683,6 @@ namespace ts { } if (isPropertyAccess) { - // TODO: issue a better error? - if (expression.kind === SyntaxKind.ExpressionWithTypeArguments) { - return expression as MemberExpression; - } expression = parsePropertyAccessExpressionRest(pos, expression, questionDotToken); continue; } diff --git a/tests/baselines/reference/genericCallWithoutArgs.errors.txt b/tests/baselines/reference/genericCallWithoutArgs.errors.txt new file mode 100644 index 0000000000000..75a2d51a1da3e --- /dev/null +++ b/tests/baselines/reference/genericCallWithoutArgs.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/genericCallWithoutArgs.ts(4,18): error TS1003: Identifier expected. + + +==== tests/cases/compiler/genericCallWithoutArgs.ts (1 errors) ==== + function f(x: X, y: Y) { + } + + f. + +!!! error TS1003: Identifier expected. \ No newline at end of file diff --git a/tests/baselines/reference/genericCallWithoutArgs.js b/tests/baselines/reference/genericCallWithoutArgs.js index 0e4d8446f999c..aab48f5e047c6 100644 --- a/tests/baselines/reference/genericCallWithoutArgs.js +++ b/tests/baselines/reference/genericCallWithoutArgs.js @@ -7,4 +7,4 @@ f. //// [genericCallWithoutArgs.js] function f(x, y) { } -f; +f.; diff --git a/tests/baselines/reference/genericCallWithoutArgs.types b/tests/baselines/reference/genericCallWithoutArgs.types index b11961d0dfc95..6d4969a83ee7e 100644 --- a/tests/baselines/reference/genericCallWithoutArgs.types +++ b/tests/baselines/reference/genericCallWithoutArgs.types @@ -6,6 +6,8 @@ function f(x: X, y: Y) { } f. +>f. : any >f : (x: number, y: string) => void >f : (x: X, y: Y) => void +> : any diff --git a/tests/baselines/reference/instantiationExpressionErrors.errors.txt b/tests/baselines/reference/instantiationExpressionErrors.errors.txt index 5091e638f850c..8a725af6b4485 100644 --- a/tests/baselines/reference/instantiationExpressionErrors.errors.txt +++ b/tests/baselines/reference/instantiationExpressionErrors.errors.txt @@ -1,11 +1,3 @@ -tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(7,22): error TS1005: ',' expected. -tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(7,22): error TS2451: Cannot redeclare block-scoped variable 'g'. -tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(7,22): error TS7005: Variable 'g' implicitly has an 'any' type. -tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(8,22): error TS1005: ',' expected. -tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(8,22): error TS2451: Cannot redeclare block-scoped variable 'g'. -tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(8,22): error TS7005: Variable 'g' implicitly has an 'any' type. -tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(8,23): error TS1005: ',' expected. -tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(8,31): error TS1109: Expression expected. tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(13,12): error TS2365: Operator '>' cannot be applied to types 'boolean' and 'string[]'. tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(13,14): error TS2693: 'number' only refers to a type, but is being used as a value here. tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(18,12): error TS2365: Operator '>' cannot be applied to types 'boolean' and 'number'. @@ -14,10 +6,6 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpr tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(19,24): error TS2635: Type '{ (): number; g(): U; }' has no signatures for which the type argument list is applicable. tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(23,23): error TS1005: '(' expected. tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(26,24): error TS2558: Expected 0 type arguments, but got 1. -tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(30,13): error TS2451: Cannot redeclare block-scoped variable 'g'. -tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(32,14): error TS2635: Type 'any' has no signatures for which the type argument list is applicable. -tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(33,14): error TS2635: Type 'any' has no signatures for which the type argument list is applicable. -tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(34,14): error TS2635: Type 'any' has no signatures for which the type argument list is applicable. tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(39,2): error TS2554: Expected 0 arguments, but got 1. tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(43,12): error TS2365: Operator '<' cannot be applied to types '{ (): T; g(): U; }' and 'boolean'. tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(44,12): error TS2365: Operator '<' cannot be applied to types '{ (): T; g(): U; }' and 'boolean'. @@ -26,7 +14,7 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpr tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(45,12): error TS2365: Operator '>' cannot be applied to types 'boolean' and 'number'. -==== tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts (26 errors) ==== +==== tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts (14 errors) ==== declare let f: { (): T, g(): U }; // Type arguments in member expressions @@ -34,23 +22,7 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpr const a1 = f; // { (): number; g(): U; } const a2 = f.g; // () => number const a3 = f.g; // () => U - ~ -!!! error TS1005: ',' expected. - ~ -!!! error TS2451: Cannot redeclare block-scoped variable 'g'. - ~ -!!! error TS7005: Variable 'g' implicitly has an 'any' type. const a4 = f.g; // () => number - ~ -!!! error TS1005: ',' expected. - ~ -!!! error TS2451: Cannot redeclare block-scoped variable 'g'. - ~ -!!! error TS7005: Variable 'g' implicitly has an 'any' type. - ~ -!!! error TS1005: ',' expected. - ~ -!!! error TS1109: Expression expected. const a5 = f['g']; // () => number // `[` is an expression starter and cannot immediately follow a type argument list @@ -89,18 +61,10 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpr // Instantiation expression and binary operators declare let g: ((x: T) => T) | undefined; - ~ -!!! error TS2451: Cannot redeclare block-scoped variable 'g'. const c1 = g || ((x: string) => x); - ~~~~~~ -!!! error TS2635: Type 'any' has no signatures for which the type argument list is applicable. const c2 = g ?? ((x: string) => x); - ~~~~~~ -!!! error TS2635: Type 'any' has no signatures for which the type argument list is applicable. const c3 = g && ((x: string) => x); - ~~~~~~ -!!! error TS2635: Type 'any' has no signatures for which the type argument list is applicable. // Parsed as function call, even though this differs from JavaScript diff --git a/tests/baselines/reference/instantiationExpressionErrors.js b/tests/baselines/reference/instantiationExpressionErrors.js index 072969ff17195..de16b60071be2 100644 --- a/tests/baselines/reference/instantiationExpressionErrors.js +++ b/tests/baselines/reference/instantiationExpressionErrors.js @@ -110,9 +110,8 @@ var _a, _b, _c; // Type arguments in member expressions var a1 = (f); // { (): number; g(): U; } var a2 = (f.g); // () => number -var a3 = (f), g; // () => U -var a4 = (f), g; -; // () => number +var a3 = f.g; // () => U +var a4 = (f.g); // () => number var a5 = (f['g']); // () => number // `[` is an expression starter and cannot immediately follow a type argument list var a6 = f < number > ['g']; // Error @@ -200,14 +199,8 @@ declare const a1: { g(): U; }; declare const a2: () => number; -declare const a3: { - (): number; - g(): U; -}, g: any; -declare const a4: { - (): number; - g(): U; -}, g: any; +declare const a3: () => U; +declare const a4: () => number; declare const a5: () => number; declare const a6: boolean; declare const a7: () => U; @@ -220,9 +213,9 @@ declare const b2: number; declare const b3: number; declare const b4: number; declare let g: ((x: T) => T) | undefined; -declare const c1: any; -declare const c2: any; -declare const c3: any; +declare const c1: (x: string) => string; +declare const c2: (x: string) => string; +declare const c3: ((x: string) => string) | undefined; declare const x1: true; declare const r1: boolean; declare const r2: boolean; diff --git a/tests/baselines/reference/instantiationExpressionErrors.symbols b/tests/baselines/reference/instantiationExpressionErrors.symbols index 4a0af8fd1de35..eca85200cbd25 100644 --- a/tests/baselines/reference/instantiationExpressionErrors.symbols +++ b/tests/baselines/reference/instantiationExpressionErrors.symbols @@ -21,13 +21,15 @@ const a2 = f.g; // () => number const a3 = f.g; // () => U >a3 : Symbol(a3, Decl(instantiationExpressionErrors.ts, 6, 5)) +>f.g : Symbol(g, Decl(instantiationExpressionErrors.ts, 0, 26)) >f : Symbol(f, Decl(instantiationExpressionErrors.ts, 0, 11)) ->g : Symbol(g, Decl(instantiationExpressionErrors.ts, 6, 21)) +>g : Symbol(g, Decl(instantiationExpressionErrors.ts, 0, 26)) const a4 = f.g; // () => number >a4 : Symbol(a4, Decl(instantiationExpressionErrors.ts, 7, 5)) +>f.g : Symbol(g, Decl(instantiationExpressionErrors.ts, 0, 26)) >f : Symbol(f, Decl(instantiationExpressionErrors.ts, 0, 11)) ->g : Symbol(g, Decl(instantiationExpressionErrors.ts, 7, 21)) +>g : Symbol(g, Decl(instantiationExpressionErrors.ts, 0, 26)) const a5 = f['g']; // () => number >a5 : Symbol(a5, Decl(instantiationExpressionErrors.ts, 8, 5)) @@ -84,19 +86,19 @@ declare let g: ((x: T) => T) | undefined; const c1 = g || ((x: string) => x); >c1 : Symbol(c1, Decl(instantiationExpressionErrors.ts, 31, 5)) ->g : Symbol(g, Decl(instantiationExpressionErrors.ts, 6, 21)) +>g : Symbol(g, Decl(instantiationExpressionErrors.ts, 29, 11)) >x : Symbol(x, Decl(instantiationExpressionErrors.ts, 31, 26)) >x : Symbol(x, Decl(instantiationExpressionErrors.ts, 31, 26)) const c2 = g ?? ((x: string) => x); >c2 : Symbol(c2, Decl(instantiationExpressionErrors.ts, 32, 5)) ->g : Symbol(g, Decl(instantiationExpressionErrors.ts, 6, 21)) +>g : Symbol(g, Decl(instantiationExpressionErrors.ts, 29, 11)) >x : Symbol(x, Decl(instantiationExpressionErrors.ts, 32, 26)) >x : Symbol(x, Decl(instantiationExpressionErrors.ts, 32, 26)) const c3 = g && ((x: string) => x); >c3 : Symbol(c3, Decl(instantiationExpressionErrors.ts, 33, 5)) ->g : Symbol(g, Decl(instantiationExpressionErrors.ts, 6, 21)) +>g : Symbol(g, Decl(instantiationExpressionErrors.ts, 29, 11)) >x : Symbol(x, Decl(instantiationExpressionErrors.ts, 33, 26)) >x : Symbol(x, Decl(instantiationExpressionErrors.ts, 33, 26)) diff --git a/tests/baselines/reference/instantiationExpressionErrors.types b/tests/baselines/reference/instantiationExpressionErrors.types index a4430d794e100..c1296a6e8bf19 100644 --- a/tests/baselines/reference/instantiationExpressionErrors.types +++ b/tests/baselines/reference/instantiationExpressionErrors.types @@ -18,18 +18,19 @@ const a2 = f.g; // () => number >g : () => U const a3 = f.g; // () => U ->a3 : { (): number; g(): U; } +>a3 : () => U +>f.g : () => U >f : { (): number; g(): U; } >f : { (): T; g(): U; } ->g : any +>g : () => U const a4 = f.g; // () => number ->a4 : { (): number; g(): U; } +>a4 : () => number +>f.g : () => number +>f.g : () => U >f : { (): number; g(): U; } >f : { (): T; g(): U; } ->g : any -> : number -> : any +>g : () => U const a5 = f['g']; // () => number >a5 : () => number @@ -106,30 +107,30 @@ declare let g: ((x: T) => T) | undefined; >x : T const c1 = g || ((x: string) => x); ->c1 : any ->g || ((x: string) => x) : any ->g : any ->g : any +>c1 : (x: string) => string +>g || ((x: string) => x) : (x: string) => string +>g : ((x: string) => string) | undefined +>g : ((x: T) => T) | undefined >((x: string) => x) : (x: string) => string >(x: string) => x : (x: string) => string >x : string >x : string const c2 = g ?? ((x: string) => x); ->c2 : any ->g ?? ((x: string) => x) : any ->g : any ->g : any +>c2 : (x: string) => string +>g ?? ((x: string) => x) : (x: string) => string +>g : ((x: string) => string) | undefined +>g : ((x: T) => T) | undefined >((x: string) => x) : (x: string) => string >(x: string) => x : (x: string) => string >x : string >x : string const c3 = g && ((x: string) => x); ->c3 : any ->g && ((x: string) => x) : any ->g : any ->g : any +>c3 : ((x: string) => string) | undefined +>g && ((x: string) => x) : ((x: string) => string) | undefined +>g : ((x: string) => string) | undefined +>g : ((x: T) => T) | undefined >((x: string) => x) : (x: string) => string >(x: string) => x : (x: string) => string >x : string diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).errors.txt b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).errors.txt index 7b2c4620a8987..e33356fc5a9bf 100644 --- a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).errors.txt +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).errors.txt @@ -1,8 +1,7 @@ -tests/cases/compiler/optionalChainWithInstantiationExpression1.ts(12,9): error TS1005: ';' expected. -tests/cases/compiler/optionalChainWithInstantiationExpression1.ts(12,9): error TS2304: Cannot find name 'd'. +tests/cases/compiler/optionalChainWithInstantiationExpression1.ts(12,9): error TS1477: Instantiation expression cannot be followed by property access. -==== tests/cases/compiler/optionalChainWithInstantiationExpression1.ts (2 errors) ==== +==== tests/cases/compiler/optionalChainWithInstantiationExpression1.ts (1 errors) ==== declare namespace A { export class b { static d: number; @@ -16,9 +15,7 @@ tests/cases/compiler/optionalChainWithInstantiationExpression1.ts(12,9): error T a?.b.d; ~ -!!! error TS1005: ';' expected. - ~ -!!! error TS2304: Cannot find name 'd'. +!!! error TS1477: Instantiation expression cannot be followed by property access. a?.b.d \ No newline at end of file diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).js b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).js index 8ca2d1325f55c..593e340b04559 100644 --- a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).js +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).js @@ -16,6 +16,5 @@ 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; a === null || a === void 0 ? void 0 : a.b.d; diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).symbols b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).symbols index 1c803256ec3ee..160950e459108 100644 --- a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).symbols +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).symbols @@ -23,10 +23,12 @@ declare const a: typeof A | undefined; >A : Symbol(A, Decl(optionalChainWithInstantiationExpression1.ts, 0, 0)) 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)) >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)) diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).types b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).types index 806e8123ca2c7..11e0ab6572ae9 100644 --- a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).types +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).types @@ -21,11 +21,12 @@ declare const a: typeof A | undefined; >A : typeof A a?.b.d; +>a?.b.d : number >a?.b : { new (x: unknown): A.b; prototype: A.b; d: number; } >a?.b : typeof A.b >a : typeof A >b : typeof A.b ->d : any +>d : number a?.b.d >a?.b.d : number diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).errors.txt b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).errors.txt index 7b2c4620a8987..e33356fc5a9bf 100644 --- a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).errors.txt +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).errors.txt @@ -1,8 +1,7 @@ -tests/cases/compiler/optionalChainWithInstantiationExpression1.ts(12,9): error TS1005: ';' expected. -tests/cases/compiler/optionalChainWithInstantiationExpression1.ts(12,9): error TS2304: Cannot find name 'd'. +tests/cases/compiler/optionalChainWithInstantiationExpression1.ts(12,9): error TS1477: Instantiation expression cannot be followed by property access. -==== tests/cases/compiler/optionalChainWithInstantiationExpression1.ts (2 errors) ==== +==== tests/cases/compiler/optionalChainWithInstantiationExpression1.ts (1 errors) ==== declare namespace A { export class b { static d: number; @@ -16,9 +15,7 @@ tests/cases/compiler/optionalChainWithInstantiationExpression1.ts(12,9): error T a?.b.d; ~ -!!! error TS1005: ';' expected. - ~ -!!! error TS2304: Cannot find name 'd'. +!!! error TS1477: Instantiation expression cannot be followed by property access. a?.b.d \ No newline at end of file diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).js b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).js index 9c54fda5f15ca..86f3e9f520934 100644 --- a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).js +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).js @@ -16,6 +16,5 @@ a?.b.d //// [optionalChainWithInstantiationExpression1.js] -a?.b; -d; +a?.b.d; a?.b.d; diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).symbols b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).symbols index 1c803256ec3ee..160950e459108 100644 --- a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).symbols +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).symbols @@ -23,10 +23,12 @@ declare const a: typeof A | undefined; >A : Symbol(A, Decl(optionalChainWithInstantiationExpression1.ts, 0, 0)) 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)) >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)) diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).types b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).types index 806e8123ca2c7..11e0ab6572ae9 100644 --- a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).types +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).types @@ -21,11 +21,12 @@ declare const a: typeof A | undefined; >A : typeof A a?.b.d; +>a?.b.d : number >a?.b : { new (x: unknown): A.b; prototype: A.b; d: number; } >a?.b : typeof A.b >a : typeof A >b : typeof A.b ->d : any +>d : number a?.b.d >a?.b.d : number diff --git a/tests/baselines/reference/parserMemberAccessExpression1.errors.txt b/tests/baselines/reference/parserMemberAccessExpression1.errors.txt index dff099daa1052..4f0d5b5eb0cd1 100644 --- a/tests/baselines/reference/parserMemberAccessExpression1.errors.txt +++ b/tests/baselines/reference/parserMemberAccessExpression1.errors.txt @@ -3,15 +3,13 @@ tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(2,1): error TS2304: Cannot find name 'Foo'. tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(2,9): error TS2304: Cannot find name 'T'. tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(3,1): error TS2304: Cannot find name 'Foo'. -tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(3,8): error TS1005: ';' expected. -tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(3,8): error TS2304: Cannot find name 'Bar'. +tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(3,8): error TS1477: Instantiation expression cannot be followed by property access. tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(4,1): error TS2304: Cannot find name 'Foo'. -tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(4,8): error TS1005: ';' expected. -tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(4,8): error TS2304: Cannot find name 'Bar'. +tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(4,8): error TS1477: Instantiation expression cannot be followed by property access. tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(4,12): error TS2304: Cannot find name 'T'. -==== tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts (11 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts (9 errors) ==== Foo(); ~~~ !!! error TS2304: Cannot find name 'Foo'. @@ -26,16 +24,12 @@ tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression ~~~ !!! error TS2304: Cannot find name 'Foo'. ~~~ -!!! error TS1005: ';' expected. - ~~~ -!!! error TS2304: Cannot find name 'Bar'. +!!! error TS1477: Instantiation expression cannot be followed by property access. Foo.Bar(); ~~~ !!! error TS2304: Cannot find name 'Foo'. ~~~ -!!! error TS1005: ';' expected. - ~~~ -!!! error TS2304: Cannot find name 'Bar'. +!!! error TS1477: Instantiation expression cannot be followed by property access. ~ !!! error TS2304: Cannot find name 'T'. \ No newline at end of file diff --git a/tests/baselines/reference/parserMemberAccessExpression1.js b/tests/baselines/reference/parserMemberAccessExpression1.js index 63ad3a4c7e879..1b3df778063b2 100644 --- a/tests/baselines/reference/parserMemberAccessExpression1.js +++ b/tests/baselines/reference/parserMemberAccessExpression1.js @@ -8,7 +8,5 @@ Foo.Bar(); //// [parserMemberAccessExpression1.js] Foo(); Foo.Bar(); -Foo; -Bar(); -Foo; -Bar(); +Foo.Bar(); +Foo.Bar(); diff --git a/tests/baselines/reference/parserMemberAccessExpression1.types b/tests/baselines/reference/parserMemberAccessExpression1.types index 6c60687c5c0f3..395f91b2450f3 100644 --- a/tests/baselines/reference/parserMemberAccessExpression1.types +++ b/tests/baselines/reference/parserMemberAccessExpression1.types @@ -10,14 +10,16 @@ Foo.Bar(); >Bar : any Foo.Bar(); +>Foo.Bar() : any +>Foo.Bar : any >Foo : any >Foo : any ->Bar() : any >Bar : any Foo.Bar(); +>Foo.Bar() : any +>Foo.Bar : any >Foo : any >Foo : any ->Bar() : any >Bar : any diff --git a/tests/baselines/reference/parserMemberAccessOffOfGenericType1.errors.txt b/tests/baselines/reference/parserMemberAccessOffOfGenericType1.errors.txt index e5c340e72ac7d..9df16d7ea2aa8 100644 --- a/tests/baselines/reference/parserMemberAccessOffOfGenericType1.errors.txt +++ b/tests/baselines/reference/parserMemberAccessOffOfGenericType1.errors.txt @@ -1,16 +1,10 @@ tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessOffOfGenericType1.ts(1,9): error TS2304: Cannot find name 'List'. -tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessOffOfGenericType1.ts(1,22): error TS1005: ',' expected. -tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessOffOfGenericType1.ts(1,31): error TS1005: ',' expected. -tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessOffOfGenericType1.ts(1,32): error TS1109: Expression expected. +tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessOffOfGenericType1.ts(1,22): error TS1477: Instantiation expression cannot be followed by property access. -==== tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessOffOfGenericType1.ts (4 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessOffOfGenericType1.ts (2 errors) ==== var v = List.makeChild(); ~~~~ !!! error TS2304: Cannot find name 'List'. ~~~~~~~~~ -!!! error TS1005: ',' expected. - ~ -!!! error TS1005: ',' expected. - ~ -!!! error TS1109: Expression expected. \ No newline at end of file +!!! error TS1477: Instantiation expression cannot be followed by property access. \ No newline at end of file diff --git a/tests/baselines/reference/parserMemberAccessOffOfGenericType1.js b/tests/baselines/reference/parserMemberAccessOffOfGenericType1.js index eb0a0b94a0594..d73594d4a6d3e 100644 --- a/tests/baselines/reference/parserMemberAccessOffOfGenericType1.js +++ b/tests/baselines/reference/parserMemberAccessOffOfGenericType1.js @@ -2,5 +2,4 @@ var v = List.makeChild(); //// [parserMemberAccessOffOfGenericType1.js] -var v = (List), makeChild; -(); +var v = List.makeChild(); diff --git a/tests/baselines/reference/parserMemberAccessOffOfGenericType1.symbols b/tests/baselines/reference/parserMemberAccessOffOfGenericType1.symbols index 5813f78e326af..ab2eff6445126 100644 --- a/tests/baselines/reference/parserMemberAccessOffOfGenericType1.symbols +++ b/tests/baselines/reference/parserMemberAccessOffOfGenericType1.symbols @@ -1,5 +1,4 @@ === tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessOffOfGenericType1.ts === var v = List.makeChild(); >v : Symbol(v, Decl(parserMemberAccessOffOfGenericType1.ts, 0, 3)) ->makeChild : Symbol(makeChild, Decl(parserMemberAccessOffOfGenericType1.ts, 0, 21)) diff --git a/tests/baselines/reference/parserMemberAccessOffOfGenericType1.types b/tests/baselines/reference/parserMemberAccessOffOfGenericType1.types index 9a37bc4669af3..b89005fb0ca62 100644 --- a/tests/baselines/reference/parserMemberAccessOffOfGenericType1.types +++ b/tests/baselines/reference/parserMemberAccessOffOfGenericType1.types @@ -1,9 +1,9 @@ === tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessOffOfGenericType1.ts === var v = List.makeChild(); >v : any +>List.makeChild() : any +>List.makeChild : any >List : any >List : any >makeChild : any ->() : any -> : any From 2925fcf6433ddd36909b934d0612826548ac5b1a Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 22 Jun 2022 15:21:26 -0700 Subject: [PATCH 5/7] Try doing this instead in the parser --- src/compiler/checker.ts | 7 ------- src/compiler/parser.ts | 3 +++ .../reference/instantiationExpressionErrors.errors.txt | 8 +++++++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 202dc1678fb32..65c89db785bcc 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -28912,14 +28912,7 @@ namespace ts { return nonNullType; } - function checkGrammarPropertyAccessExpression(node: PropertyAccessExpression) { - if (node.expression.kind === SyntaxKind.ExpressionWithTypeArguments) { - grammarErrorOnNode(node.name, Diagnostics.Instantiation_expression_cannot_be_followed_by_property_access); - } - } - function checkPropertyAccessExpression(node: PropertyAccessExpression, checkMode: CheckMode | undefined) { - checkGrammarPropertyAccessExpression(node); return node.flags & NodeFlags.OptionalChain ? checkPropertyAccessChain(node as PropertyAccessChain, checkMode) : checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name, checkMode); } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 8c16ff9a910da..7fad8d856a51a 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -5646,6 +5646,9 @@ namespace ts { if (isOptionalChain && isPrivateIdentifier(propertyAccess.name)) { parseErrorAtRange(propertyAccess.name, Diagnostics.An_optional_chain_cannot_contain_private_identifiers); } + else if (isExpressionWithTypeArguments(expression)) { + parseErrorAtRange(propertyAccess.name, Diagnostics.Instantiation_expression_cannot_be_followed_by_property_access); + } return finishNode(propertyAccess, pos); } diff --git a/tests/baselines/reference/instantiationExpressionErrors.errors.txt b/tests/baselines/reference/instantiationExpressionErrors.errors.txt index 8a725af6b4485..1c51d967e568f 100644 --- a/tests/baselines/reference/instantiationExpressionErrors.errors.txt +++ b/tests/baselines/reference/instantiationExpressionErrors.errors.txt @@ -1,3 +1,5 @@ +tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(7,22): error TS1477: Instantiation expression cannot be followed by property access. +tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(8,22): error TS1477: Instantiation expression cannot be followed by property access. tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(13,12): error TS2365: Operator '>' cannot be applied to types 'boolean' and 'string[]'. tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(13,14): error TS2693: 'number' only refers to a type, but is being used as a value here. tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(18,12): error TS2365: Operator '>' cannot be applied to types 'boolean' and 'number'. @@ -14,7 +16,7 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpr tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(45,12): error TS2365: Operator '>' cannot be applied to types 'boolean' and 'number'. -==== tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts (14 errors) ==== +==== tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts (16 errors) ==== declare let f: { (): T, g(): U }; // Type arguments in member expressions @@ -22,7 +24,11 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpr const a1 = f; // { (): number; g(): U; } const a2 = f.g; // () => number const a3 = f.g; // () => U + ~ +!!! error TS1477: Instantiation expression cannot be followed by property access. const a4 = f.g; // () => number + ~ +!!! error TS1477: Instantiation expression cannot be followed by property access. const a5 = f['g']; // () => number // `[` is an expression starter and cannot immediately follow a type argument list From da5eb1a62fcf1f44b2b5befe5c555f27bdbc4ceb Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 24 Jun 2022 13:08:27 -0700 Subject: [PATCH 6/7] Move error to type argument range --- src/compiler/parser.ts | 6 ++++-- .../baselines/reference/genericCallWithoutArgs.errors.txt | 5 ++++- .../reference/instantiationExpressionErrors.errors.txt | 8 ++++---- ...WithInstantiationExpression1(target=es2019).errors.txt | 4 ++-- ...WithInstantiationExpression1(target=es2020).errors.txt | 4 ++-- .../reference/parserMemberAccessExpression1.errors.txt | 8 ++++---- .../parserMemberAccessOffOfGenericType1.errors.txt | 4 ++-- 7 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 7fad8d856a51a..05118ac339431 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -5646,8 +5646,10 @@ namespace ts { if (isOptionalChain && isPrivateIdentifier(propertyAccess.name)) { parseErrorAtRange(propertyAccess.name, Diagnostics.An_optional_chain_cannot_contain_private_identifiers); } - else if (isExpressionWithTypeArguments(expression)) { - parseErrorAtRange(propertyAccess.name, Diagnostics.Instantiation_expression_cannot_be_followed_by_property_access); + if (isExpressionWithTypeArguments(expression) && expression.typeArguments) { + const pos = expression.typeArguments.pos - 1; + const end = skipTrivia(sourceText, expression.typeArguments.end) + 1; + parseErrorAt(pos, end, Diagnostics.Instantiation_expression_cannot_be_followed_by_property_access); } return finishNode(propertyAccess, pos); } diff --git a/tests/baselines/reference/genericCallWithoutArgs.errors.txt b/tests/baselines/reference/genericCallWithoutArgs.errors.txt index 75a2d51a1da3e..f44750e805de3 100644 --- a/tests/baselines/reference/genericCallWithoutArgs.errors.txt +++ b/tests/baselines/reference/genericCallWithoutArgs.errors.txt @@ -1,10 +1,13 @@ +tests/cases/compiler/genericCallWithoutArgs.ts(4,2): error TS1477: Instantiation expression cannot be followed by 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: X, y: Y) { } f. + ~~~~~~~~~~~~~~~ +!!! error TS1477: Instantiation expression cannot be followed by property access. !!! error TS1003: Identifier expected. \ No newline at end of file diff --git a/tests/baselines/reference/instantiationExpressionErrors.errors.txt b/tests/baselines/reference/instantiationExpressionErrors.errors.txt index 1c51d967e568f..ccfc5c4077e21 100644 --- a/tests/baselines/reference/instantiationExpressionErrors.errors.txt +++ b/tests/baselines/reference/instantiationExpressionErrors.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(7,22): error TS1477: Instantiation expression cannot be followed by property access. -tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(8,22): error TS1477: Instantiation expression cannot be followed by property access. +tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(7,13): error TS1477: Instantiation expression cannot be followed by property access. +tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(8,13): error TS1477: Instantiation expression cannot be followed by property access. tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(13,12): error TS2365: Operator '>' cannot be applied to types 'boolean' and 'string[]'. tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(13,14): error TS2693: 'number' only refers to a type, but is being used as a value here. tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(18,12): error TS2365: Operator '>' cannot be applied to types 'boolean' and 'number'. @@ -24,10 +24,10 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpr const a1 = f; // { (): number; g(): U; } const a2 = f.g; // () => number const a3 = f.g; // () => U - ~ + ~~~~~~~~ !!! error TS1477: Instantiation expression cannot be followed by property access. const a4 = f.g; // () => number - ~ + ~~~~~~~~ !!! error TS1477: Instantiation expression cannot be followed by property access. const a5 = f['g']; // () => number diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).errors.txt b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).errors.txt index e33356fc5a9bf..3bfcaf2d80c57 100644 --- a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).errors.txt +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/optionalChainWithInstantiationExpression1.ts(12,9): error TS1477: Instantiation expression cannot be followed by property access. +tests/cases/compiler/optionalChainWithInstantiationExpression1.ts(12,5): error TS1477: Instantiation expression cannot be followed by property access. ==== tests/cases/compiler/optionalChainWithInstantiationExpression1.ts (1 errors) ==== @@ -14,7 +14,7 @@ tests/cases/compiler/optionalChainWithInstantiationExpression1.ts(12,9): error T declare const a: typeof A | undefined; a?.b.d; - ~ + ~~~ !!! error TS1477: Instantiation expression cannot be followed by property access. a?.b.d diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).errors.txt b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).errors.txt index e33356fc5a9bf..3bfcaf2d80c57 100644 --- a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).errors.txt +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/optionalChainWithInstantiationExpression1.ts(12,9): error TS1477: Instantiation expression cannot be followed by property access. +tests/cases/compiler/optionalChainWithInstantiationExpression1.ts(12,5): error TS1477: Instantiation expression cannot be followed by property access. ==== tests/cases/compiler/optionalChainWithInstantiationExpression1.ts (1 errors) ==== @@ -14,7 +14,7 @@ tests/cases/compiler/optionalChainWithInstantiationExpression1.ts(12,9): error T declare const a: typeof A | undefined; a?.b.d; - ~ + ~~~ !!! error TS1477: Instantiation expression cannot be followed by property access. a?.b.d diff --git a/tests/baselines/reference/parserMemberAccessExpression1.errors.txt b/tests/baselines/reference/parserMemberAccessExpression1.errors.txt index 4f0d5b5eb0cd1..091565c31e21e 100644 --- a/tests/baselines/reference/parserMemberAccessExpression1.errors.txt +++ b/tests/baselines/reference/parserMemberAccessExpression1.errors.txt @@ -3,9 +3,9 @@ tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(2,1): error TS2304: Cannot find name 'Foo'. tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(2,9): error TS2304: Cannot find name 'T'. tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(3,1): error TS2304: Cannot find name 'Foo'. -tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(3,8): error TS1477: Instantiation expression cannot be followed by property access. +tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(3,4): error TS1477: Instantiation expression cannot be followed by property access. tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(4,1): error TS2304: Cannot find name 'Foo'. -tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(4,8): error TS1477: Instantiation expression cannot be followed by property access. +tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(4,4): error TS1477: Instantiation expression cannot be followed by property access. tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(4,12): error TS2304: Cannot find name 'T'. @@ -23,12 +23,12 @@ tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression Foo.Bar(); ~~~ !!! error TS2304: Cannot find name 'Foo'. - ~~~ + ~~~ !!! error TS1477: Instantiation expression cannot be followed by property access. Foo.Bar(); ~~~ !!! error TS2304: Cannot find name 'Foo'. - ~~~ + ~~~ !!! error TS1477: Instantiation expression cannot be followed by property access. ~ !!! error TS2304: Cannot find name 'T'. diff --git a/tests/baselines/reference/parserMemberAccessOffOfGenericType1.errors.txt b/tests/baselines/reference/parserMemberAccessOffOfGenericType1.errors.txt index 9df16d7ea2aa8..e5ebfc726c45b 100644 --- a/tests/baselines/reference/parserMemberAccessOffOfGenericType1.errors.txt +++ b/tests/baselines/reference/parserMemberAccessOffOfGenericType1.errors.txt @@ -1,10 +1,10 @@ tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessOffOfGenericType1.ts(1,9): error TS2304: Cannot find name 'List'. -tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessOffOfGenericType1.ts(1,22): error TS1477: Instantiation expression cannot be followed by property access. +tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessOffOfGenericType1.ts(1,13): error TS1477: Instantiation expression cannot be followed by property access. ==== tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessOffOfGenericType1.ts (2 errors) ==== var v = List.makeChild(); ~~~~ !!! error TS2304: Cannot find name 'List'. - ~~~~~~~~~ + ~~~~~~~~ !!! error TS1477: Instantiation expression cannot be followed by property access. \ No newline at end of file From db3e06215c4b7faf9b2fab0d2e1dc88f3d1252bf Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 24 Jun 2022 13:13:58 -0700 Subject: [PATCH 7/7] Change diagnostic wording --- src/compiler/diagnosticMessages.json | 2 +- src/compiler/parser.ts | 2 +- .../baselines/reference/genericCallWithoutArgs.errors.txt | 4 ++-- .../reference/instantiationExpressionErrors.errors.txt | 8 ++++---- ...WithInstantiationExpression1(target=es2019).errors.txt | 4 ++-- ...WithInstantiationExpression1(target=es2020).errors.txt | 4 ++-- .../reference/parserMemberAccessExpression1.errors.txt | 8 ++++---- .../parserMemberAccessOffOfGenericType1.errors.txt | 4 ++-- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 968786e2fde95..0c914e1625dd0 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1493,7 +1493,7 @@ "category": "Message", "code": 1476 }, - "Instantiation expression cannot be followed by property access.": { + "An instantiation expression cannot be followed by a property access.": { "category": "Error", "code": 1477 }, diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 05118ac339431..ec10d015c3bc4 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -5649,7 +5649,7 @@ namespace ts { if (isExpressionWithTypeArguments(expression) && expression.typeArguments) { const pos = expression.typeArguments.pos - 1; const end = skipTrivia(sourceText, expression.typeArguments.end) + 1; - parseErrorAt(pos, end, Diagnostics.Instantiation_expression_cannot_be_followed_by_property_access); + parseErrorAt(pos, end, Diagnostics.An_instantiation_expression_cannot_be_followed_by_a_property_access); } return finishNode(propertyAccess, pos); } diff --git a/tests/baselines/reference/genericCallWithoutArgs.errors.txt b/tests/baselines/reference/genericCallWithoutArgs.errors.txt index f44750e805de3..40ad1145c0109 100644 --- a/tests/baselines/reference/genericCallWithoutArgs.errors.txt +++ b/tests/baselines/reference/genericCallWithoutArgs.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/genericCallWithoutArgs.ts(4,2): error TS1477: Instantiation expression cannot be followed by property access. +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. @@ -8,6 +8,6 @@ tests/cases/compiler/genericCallWithoutArgs.ts(4,18): error TS1003: Identifier e f. ~~~~~~~~~~~~~~~ -!!! error TS1477: Instantiation expression cannot be followed by property access. +!!! error TS1477: An instantiation expression cannot be followed by a property access. !!! error TS1003: Identifier expected. \ No newline at end of file diff --git a/tests/baselines/reference/instantiationExpressionErrors.errors.txt b/tests/baselines/reference/instantiationExpressionErrors.errors.txt index ccfc5c4077e21..446d469e34295 100644 --- a/tests/baselines/reference/instantiationExpressionErrors.errors.txt +++ b/tests/baselines/reference/instantiationExpressionErrors.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(7,13): error TS1477: Instantiation expression cannot be followed by property access. -tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(8,13): error TS1477: Instantiation expression cannot be followed by property access. +tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(7,13): error TS1477: An instantiation expression cannot be followed by a property access. +tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(8,13): error TS1477: An instantiation expression cannot be followed by a property access. tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(13,12): error TS2365: Operator '>' cannot be applied to types 'boolean' and 'string[]'. tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(13,14): error TS2693: 'number' only refers to a type, but is being used as a value here. tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(18,12): error TS2365: Operator '>' cannot be applied to types 'boolean' and 'number'. @@ -25,10 +25,10 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpr const a2 = f.g; // () => number const a3 = f.g; // () => U ~~~~~~~~ -!!! error TS1477: Instantiation expression cannot be followed by property access. +!!! error TS1477: An instantiation expression cannot be followed by a property access. const a4 = f.g; // () => number ~~~~~~~~ -!!! error TS1477: Instantiation expression cannot be followed by property access. +!!! error TS1477: An instantiation expression cannot be followed by a property access. const a5 = f['g']; // () => number // `[` is an expression starter and cannot immediately follow a type argument list diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).errors.txt b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).errors.txt index 3bfcaf2d80c57..4c953e73fd665 100644 --- a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).errors.txt +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2019).errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/optionalChainWithInstantiationExpression1.ts(12,5): error TS1477: Instantiation expression cannot be followed by property access. +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) ==== @@ -15,7 +15,7 @@ tests/cases/compiler/optionalChainWithInstantiationExpression1.ts(12,5): error T a?.b.d; ~~~ -!!! error TS1477: Instantiation expression cannot be followed by property access. +!!! error TS1477: An instantiation expression cannot be followed by a property access. a?.b.d \ No newline at end of file diff --git a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).errors.txt b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).errors.txt index 3bfcaf2d80c57..4c953e73fd665 100644 --- a/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).errors.txt +++ b/tests/baselines/reference/optionalChainWithInstantiationExpression1(target=es2020).errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/optionalChainWithInstantiationExpression1.ts(12,5): error TS1477: Instantiation expression cannot be followed by property access. +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) ==== @@ -15,7 +15,7 @@ tests/cases/compiler/optionalChainWithInstantiationExpression1.ts(12,5): error T a?.b.d; ~~~ -!!! error TS1477: Instantiation expression cannot be followed by property access. +!!! error TS1477: An instantiation expression cannot be followed by a property access. a?.b.d \ No newline at end of file diff --git a/tests/baselines/reference/parserMemberAccessExpression1.errors.txt b/tests/baselines/reference/parserMemberAccessExpression1.errors.txt index 091565c31e21e..a427715dbd793 100644 --- a/tests/baselines/reference/parserMemberAccessExpression1.errors.txt +++ b/tests/baselines/reference/parserMemberAccessExpression1.errors.txt @@ -3,9 +3,9 @@ tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(2,1): error TS2304: Cannot find name 'Foo'. tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(2,9): error TS2304: Cannot find name 'T'. tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(3,1): error TS2304: Cannot find name 'Foo'. -tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(3,4): error TS1477: Instantiation expression cannot be followed by property access. +tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(3,4): error TS1477: An instantiation expression cannot be followed by a property access. tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(4,1): error TS2304: Cannot find name 'Foo'. -tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(4,4): error TS1477: Instantiation expression cannot be followed by property access. +tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(4,4): error TS1477: An instantiation expression cannot be followed by a property access. tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(4,12): error TS2304: Cannot find name 'T'. @@ -24,12 +24,12 @@ tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression ~~~ !!! error TS2304: Cannot find name 'Foo'. ~~~ -!!! error TS1477: Instantiation expression cannot be followed by property access. +!!! error TS1477: An instantiation expression cannot be followed by a property access. Foo.Bar(); ~~~ !!! error TS2304: Cannot find name 'Foo'. ~~~ -!!! error TS1477: Instantiation expression cannot be followed by property access. +!!! error TS1477: An instantiation expression cannot be followed by a property access. ~ !!! error TS2304: Cannot find name 'T'. \ No newline at end of file diff --git a/tests/baselines/reference/parserMemberAccessOffOfGenericType1.errors.txt b/tests/baselines/reference/parserMemberAccessOffOfGenericType1.errors.txt index e5ebfc726c45b..51db92cbdfc09 100644 --- a/tests/baselines/reference/parserMemberAccessOffOfGenericType1.errors.txt +++ b/tests/baselines/reference/parserMemberAccessOffOfGenericType1.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessOffOfGenericType1.ts(1,9): error TS2304: Cannot find name 'List'. -tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessOffOfGenericType1.ts(1,13): error TS1477: Instantiation expression cannot be followed by property access. +tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessOffOfGenericType1.ts(1,13): error TS1477: An instantiation expression cannot be followed by a property access. ==== tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessOffOfGenericType1.ts (2 errors) ==== @@ -7,4 +7,4 @@ tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessOffOfGener ~~~~ !!! error TS2304: Cannot find name 'List'. ~~~~~~~~ -!!! error TS1477: Instantiation expression cannot be followed by property access. \ No newline at end of file +!!! error TS1477: An instantiation expression cannot be followed by a property access. \ No newline at end of file