-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include primitives in type-as-value error message
Previously, you would get the generic message when writing incorrect code like `let y = number`. "Cannot find name 'number'". Now the message says "'number' is a type but is used a value here." Fixes #15565
- Loading branch information
Showing
25 changed files
with
96 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
tests/cases/compiler/badArrayIndex.ts(1,15): error TS2552: Cannot find name 'number'. Did you mean 'Number'? | ||
tests/cases/compiler/badArrayIndex.ts(1,15): error TS2693: 'number' only refers to a type, but is being used as a value here. | ||
tests/cases/compiler/badArrayIndex.ts(1,22): error TS1109: Expression expected. | ||
|
||
|
||
==== tests/cases/compiler/badArrayIndex.ts (2 errors) ==== | ||
var results = number[]; | ||
~~~~~~ | ||
!!! error TS2552: Cannot find name 'number'. Did you mean 'Number'? | ||
!!! error TS2693: 'number' only refers to a type, but is being used as a value here. | ||
~ | ||
!!! error TS1109: Expression expected. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
tests/baselines/reference/cannotInvokeNewOnIndexExpression.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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
tests/cases/compiler/cannotInvokeNewOnIndexExpression.ts(1,23): error TS2552: Cannot find name 'any'. Did you mean 'NaN'? | ||
tests/cases/compiler/cannotInvokeNewOnIndexExpression.ts(1,23): error TS2693: 'any' only refers to a type, but is being used as a value here. | ||
|
||
|
||
==== tests/cases/compiler/cannotInvokeNewOnIndexExpression.ts (1 errors) ==== | ||
var test: any[] = new any[1]; | ||
~~~ | ||
!!! error TS2552: Cannot find name 'any'. Did you mean 'NaN'? | ||
!!! error TS2693: 'any' only refers to a type, but is being used as a value here. |
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
Oops, something went wrong.