Skip to content
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

Give a better error when using a 'this' parameter in an arrow function. #13768

Closed
DanielRosenwasser opened this issue Jan 30, 2017 · 2 comments
Closed
Labels
Duplicate An existing issue was already created Fixed A PR has been merged for this issue Help Wanted You can do this

Comments

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Jan 30, 2017

let f = (this: number) => 100;

Currently this gives an error on the : saying that ) was expected. Instead, we should

  1. Gracefully parse.
  2. Give a grammar error saying that this parameters are not allowed in arrow functions.

Source: a user ran into this hazard here.

@tony19
Copy link

tony19 commented Jan 31, 2017

Also note the change in error when noImplicitThis is enabled.

  • Without noImplicitThis, the error is:

    ')' expected
    

screen shot 2017-01-30 at 9 56 08 pm

  • With noImplicitThis, the error is:

    'this' implicitly has type 'any' because it does not have a type annotation
    

screen shot 2017-01-30 at 9 55 08 pm

@DanielRosenwasser DanielRosenwasser added the Bug A bug in TypeScript label Jan 31, 2017
@mhegazy mhegazy added the Help Wanted You can do this label Feb 3, 2017
@mhegazy mhegazy added this to the Community milestone Feb 3, 2017
@DanielRosenwasser DanielRosenwasser added Good First Issue Well scoped, documented and has the green light Domain: Error Messages The issue relates to error messaging labels Apr 20, 2018
@DanielRosenwasser
Copy link
Member Author

Looks like a duplicate of #9744.

Thanks @mattmccutchen!

@DanielRosenwasser DanielRosenwasser added Fixed A PR has been merged for this issue Duplicate An existing issue was already created and removed Bug A bug in TypeScript Domain: Error Messages The issue relates to error messaging Good First Issue Well scoped, documented and has the green light Help Wanted You can do this labels Jul 28, 2018
@mhegazy mhegazy closed this as completed Jul 28, 2018
@RyanCavanaugh RyanCavanaugh added the Help Wanted You can do this label Mar 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created Fixed A PR has been merged for this issue Help Wanted You can do this
Projects
None yet
Development

No branches or pull requests

4 participants