forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #584 from microsoft/main
Create a new pull request by comparing changes across two branches
- Loading branch information
Showing
10 changed files
with
166 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
tests/baselines/reference/assignmentToInstantiationExpression.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
assignmentToInstantiationExpression.ts(2,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. | ||
assignmentToInstantiationExpression.ts(6,1): error TS2454: Variable 'getValue' is used before being assigned. | ||
assignmentToInstantiationExpression.ts(6,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. | ||
assignmentToInstantiationExpression.ts(10,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. | ||
|
||
|
||
==== assignmentToInstantiationExpression.ts (4 errors) ==== | ||
let obj: { fn?: <T>() => T } = {}; | ||
obj.fn<number> = () => 1234; | ||
~~~~~~~~~~~~~~ | ||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access. | ||
|
||
|
||
let getValue: <T>() => T; | ||
getValue<number> = () => 1234; | ||
~~~~~~~~ | ||
!!! error TS2454: Variable 'getValue' is used before being assigned. | ||
~~~~~~~~~~~~~~~~ | ||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access. | ||
|
||
|
||
let getValue2!: <T>() => T; | ||
getValue2<number> = () => 1234; | ||
~~~~~~~~~~~~~~~~~ | ||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access. | ||
|
23 changes: 23 additions & 0 deletions
23
tests/baselines/reference/assignmentToInstantiationExpression.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//// [tests/cases/compiler/assignmentToInstantiationExpression.ts] //// | ||
|
||
//// [assignmentToInstantiationExpression.ts] | ||
let obj: { fn?: <T>() => T } = {}; | ||
obj.fn<number> = () => 1234; | ||
|
||
|
||
let getValue: <T>() => T; | ||
getValue<number> = () => 1234; | ||
|
||
|
||
let getValue2!: <T>() => T; | ||
getValue2<number> = () => 1234; | ||
|
||
|
||
//// [assignmentToInstantiationExpression.js] | ||
"use strict"; | ||
var obj = {}; | ||
(obj.fn) = function () { return 1234; }; | ||
var getValue; | ||
(getValue) = function () { return 1234; }; | ||
var getValue2; | ||
(getValue2) = function () { return 1234; }; |
32 changes: 32 additions & 0 deletions
32
tests/baselines/reference/assignmentToInstantiationExpression.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
//// [tests/cases/compiler/assignmentToInstantiationExpression.ts] //// | ||
|
||
=== assignmentToInstantiationExpression.ts === | ||
let obj: { fn?: <T>() => T } = {}; | ||
>obj : Symbol(obj, Decl(assignmentToInstantiationExpression.ts, 0, 3)) | ||
>fn : Symbol(fn, Decl(assignmentToInstantiationExpression.ts, 0, 10)) | ||
>T : Symbol(T, Decl(assignmentToInstantiationExpression.ts, 0, 17)) | ||
>T : Symbol(T, Decl(assignmentToInstantiationExpression.ts, 0, 17)) | ||
|
||
obj.fn<number> = () => 1234; | ||
>obj.fn : Symbol(fn, Decl(assignmentToInstantiationExpression.ts, 0, 10)) | ||
>obj : Symbol(obj, Decl(assignmentToInstantiationExpression.ts, 0, 3)) | ||
>fn : Symbol(fn, Decl(assignmentToInstantiationExpression.ts, 0, 10)) | ||
|
||
|
||
let getValue: <T>() => T; | ||
>getValue : Symbol(getValue, Decl(assignmentToInstantiationExpression.ts, 4, 3)) | ||
>T : Symbol(T, Decl(assignmentToInstantiationExpression.ts, 4, 15)) | ||
>T : Symbol(T, Decl(assignmentToInstantiationExpression.ts, 4, 15)) | ||
|
||
getValue<number> = () => 1234; | ||
>getValue : Symbol(getValue, Decl(assignmentToInstantiationExpression.ts, 4, 3)) | ||
|
||
|
||
let getValue2!: <T>() => T; | ||
>getValue2 : Symbol(getValue2, Decl(assignmentToInstantiationExpression.ts, 8, 3)) | ||
>T : Symbol(T, Decl(assignmentToInstantiationExpression.ts, 8, 17)) | ||
>T : Symbol(T, Decl(assignmentToInstantiationExpression.ts, 8, 17)) | ||
|
||
getValue2<number> = () => 1234; | ||
>getValue2 : Symbol(getValue2, Decl(assignmentToInstantiationExpression.ts, 8, 3)) | ||
|
61 changes: 61 additions & 0 deletions
61
tests/baselines/reference/assignmentToInstantiationExpression.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
//// [tests/cases/compiler/assignmentToInstantiationExpression.ts] //// | ||
|
||
=== assignmentToInstantiationExpression.ts === | ||
let obj: { fn?: <T>() => T } = {}; | ||
>obj : { fn?: <T>() => T; } | ||
> : ^^^^^^^ ^^^ | ||
>fn : (<T>() => T) | undefined | ||
> : ^^ ^^^^^^^ ^^^^^^^^^^^^^ | ||
>{} : {} | ||
> : ^^ | ||
|
||
obj.fn<number> = () => 1234; | ||
>obj.fn<number> = () => 1234 : () => number | ||
> : ^^^^^^^^^^^^ | ||
>obj.fn<number> : (() => number) | undefined | ||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
>obj.fn : (<T>() => T) | undefined | ||
> : ^^ ^^^^^^^ ^^^^^^^^^^^^^ | ||
>obj : { fn?: <T>() => T; } | ||
> : ^^^^^^^ ^^^ | ||
>fn : (<T>() => T) | undefined | ||
> : ^^ ^^^^^^^ ^^^^^^^^^^^^^ | ||
>() => 1234 : () => number | ||
> : ^^^^^^^^^^^^ | ||
>1234 : 1234 | ||
> : ^^^^ | ||
|
||
|
||
let getValue: <T>() => T; | ||
>getValue : <T>() => T | ||
> : ^ ^^^^^^^ | ||
|
||
getValue<number> = () => 1234; | ||
>getValue<number> = () => 1234 : () => number | ||
> : ^^^^^^^^^^^^ | ||
>getValue<number> : () => number | ||
> : ^^^^^^^^^^^^ | ||
>getValue : <T>() => T | ||
> : ^ ^^^^^^^ | ||
>() => 1234 : () => number | ||
> : ^^^^^^^^^^^^ | ||
>1234 : 1234 | ||
> : ^^^^ | ||
|
||
|
||
let getValue2!: <T>() => T; | ||
>getValue2 : <T>() => T | ||
> : ^ ^^^^^^^ | ||
|
||
getValue2<number> = () => 1234; | ||
>getValue2<number> = () => 1234 : () => number | ||
> : ^^^^^^^^^^^^ | ||
>getValue2<number> : () => number | ||
> : ^^^^^^^^^^^^ | ||
>getValue2 : <T>() => T | ||
> : ^ ^^^^^^^ | ||
>() => 1234 : () => number | ||
> : ^^^^^^^^^^^^ | ||
>1234 : 1234 | ||
> : ^^^^ | ||
|
12 changes: 12 additions & 0 deletions
12
tests/cases/compiler/assignmentToInstantiationExpression.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// @strict: true | ||
|
||
let obj: { fn?: <T>() => T } = {}; | ||
obj.fn<number> = () => 1234; | ||
|
||
|
||
let getValue: <T>() => T; | ||
getValue<number> = () => 1234; | ||
|
||
|
||
let getValue2!: <T>() => T; | ||
getValue2<number> = () => 1234; |