-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
Domain: Error MessagesThe issue relates to error messagingThe issue relates to error messagingExperience EnhancementNoncontroversial enhancementsNoncontroversial enhancementsFixedA PR has been merged for this issueA PR has been merged for this issueGood First IssueWell scoped, documented and has the green lightWell scoped, documented and has the green lightHelp WantedYou can do thisYou can do this
Milestone
Description
Search Terms
bigint literal error message identifierstart numeric
Suggestion
@DanielRosenwasser's comment in #28857:
!!! error TS1351: An identifier or keyword cannot immediately follow a numeric literal.
This could be better if you want to send a follow-up PR to see if you have a length of 1 and the identifier is named n.
Use Cases
This seems like a good low-hanging fruit for a more specific error message per type of syntax error.
Examples
The parseBigInt.ts baseline test has the following cases:
{ const legacyOct = 0123n; }{ const scientific = 1e2n; }{ const decimal = 4.1n; }{ const leadingDecimal = .1n; }
How about in order...
A bigint literal cannot start with a zero.A bigint literal cannot be a scientific number.A bigint literal cannot be a decimal number- ☝
Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
I can quickly send this in as an addendum to #28857 so they land in the same release.
calebsander
Metadata
Metadata
Assignees
Labels
Domain: Error MessagesThe issue relates to error messagingThe issue relates to error messagingExperience EnhancementNoncontroversial enhancementsNoncontroversial enhancementsFixedA PR has been merged for this issueA PR has been merged for this issueGood First IssueWell scoped, documented and has the green lightWell scoped, documented and has the green lightHelp WantedYou can do thisYou can do this