Skip to content

Better errors when using properties/methods from newer versions of ECMAScript #40320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DanielRosenwasser opened this issue Aug 30, 2020 · 6 comments · Fixed by #40650
Closed
Labels
Domain: Error Messages The issue relates to error messaging Experience Enhancement Noncontroversial enhancements Good First Issue Well scoped, documented and has the green light Help Wanted You can do this PursuitFellowship Help wanted from Pursuit fellowship; others please avoid until Dec 19 Suggestion An idea for TypeScript

Comments

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Aug 30, 2020

This is kind of the progression of #25309, and this issue's fix should be inspired by #27034.


Lots of users seem to be confused by misconfiguration when using popular new methods added to built-in types. A recent example is #40319.

The idea here come up with a static list of methods added to

  • Array
  • String
  • RegExp
  • ObjectConstructor
  • Promise
  • Map
  • Set
  • Iterator
  • AsyncIterator

in newer versions of ECMAScript. These can be found in src/lib.

When a user tries to access a property on any of these types, and that type appears in the list, we can provide a suggestion to set their lib or target (which we've done in other error messages). For example:

Property '{0}' does not exist on type '{1}'. Do you need to change your target library? Try changing the `lib` compiler option to '{2}' or later.
@DanielRosenwasser DanielRosenwasser added Help Wanted You can do this Good First Issue Well scoped, documented and has the green light Domain: Error Messages The issue relates to error messaging Experience Enhancement Noncontroversial enhancements labels Aug 30, 2020
@DanielRosenwasser DanielRosenwasser changed the title Suggest useful augmentations from newer versions of ECMAScript Better errors when using properties/methods from newer versions of ECMAScript Aug 30, 2020
@sarathps93
Copy link

Is it ok if I take this up as my first issue? @DanielRosenwasser

@Vboivin
Copy link
Contributor

Vboivin commented Sep 9, 2020

Hey @sarathps93, are you still working on this? If not, I'll try this issue

@RyanCavanaugh RyanCavanaugh added the Suggestion An idea for TypeScript label Sep 11, 2020
@sandersn sandersn added the PursuitFellowship Help wanted from Pursuit fellowship; others please avoid until Dec 19 label Sep 18, 2020
@sandersn
Copy link
Member

As a first step, it would help to have a list of methods with their respective versions added to this bug, if anybody is looking for an easy way to help with no overhead.

@Vboivin
Copy link
Contributor

Vboivin commented Sep 18, 2020

@sandersn Great idea. I am actually working on it since @sarathps93 did not respond.
Here is the mapping I have done by taking a quick look at the declaration files:

es2016

  • Array.includes()

es2017

  • String.padStart()
  • String.padEnd()
  • Object.values()
  • Object.entries()
  • Object.getOwnPropertyDescriptors()
  • Intl
  • TypedArrays
  • SharedMemory

es2018

  • Promise.finally()
  • RegExp
  • Intl2018
  • AsyncGenerator
  • AsyncIterable

es2019

  • Array.flat()
  • Array.flatMap()
  • Object.fromEntries()
  • String.trimStart()
  • String.trimEnd()
  • String trimLeft()
  • String.trimRight()
  • Symbol.description

es2020

  • BigInt
  • Intl2020
  • Promise.allSettled()
  • String.matchAll()
  • RegExp.matchAll()

@Vboivin
Copy link
Contributor

Vboivin commented Sep 19, 2020

@DanielRosenwasser @RyanCavanaugh @sandersn I attempted a solution for this problem, it might not be the best, waiting for feedback!

@DanielRosenwasser
Copy link
Member Author

Thank you @Vboivin!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Domain: Error Messages The issue relates to error messaging Experience Enhancement Noncontroversial enhancements Good First Issue Well scoped, documented and has the green light Help Wanted You can do this PursuitFellowship Help wanted from Pursuit fellowship; others please avoid until Dec 19 Suggestion An idea for TypeScript
Projects
None yet
5 participants