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

Imperfect error message for invoking null literal as function #20026

Closed
rhys-vdw opened this Issue Nov 15, 2017 · 3 comments

Comments

Projects
None yet
4 participants
@rhys-vdw
Contributor

rhys-vdw commented Nov 15, 2017

TypeScript Version: 2.6.1

Code

Minimal:

null()

Actual real-world mistake:

str !== 'hello' && thing !== null (
  <div>blah</div>
)

Expected behavior:

Clear error to the effect of:

Invoking 'null' as a function

Actual behavior:

Technically correct but slightly misleading error:

Object is possibly 'null'

@DanielRosenwasser

This comment has been minimized.

Member

DanielRosenwasser commented Nov 15, 2017

To be consistent, reasonable error message text would be something to the effect of

Cannot invoke an object which is possibly 'null'.
Cannot invoke an object which is possibly 'undefined'.
Cannot invoke an object which is possibly 'null' or 'undefined'.

@mhegazy mhegazy added this to the Community milestone Nov 16, 2017

@remojansen remojansen referenced this issue Nov 20, 2017

Merged

Fixes #20026 #20157

5 of 5 tasks complete
@remojansen

This comment has been minimized.

Contributor

remojansen commented Nov 20, 2017

I have sent a PR (#20157) for this issue. I was able to pass all the tests locally. I'm hoping that there will be no issues in CI. Please let me know if anything is wrong (This is my first PR for the TS compiler 🎉).

@mhegazy mhegazy added the Fixed label Jan 9, 2018

@mhegazy mhegazy modified the milestones: Community, TypeScript 2.7 Jan 9, 2018

mhegazy added a commit that referenced this issue Jan 9, 2018

Fixes #20026 (#20157)
* Added test case for #20026

* Implemented #20026

* Addresed comments at /pull/20157#discussion_r152086287

* Fixed merge issues

* Fixed baseline issue

* Merged upstream
@mhegazy

This comment has been minimized.

Contributor

mhegazy commented Jan 9, 2018

thanks @remojansen!

@Microsoft Microsoft locked and limited conversation to collaborators Jul 3, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.