Skip to content

IIFEs' arguments are not inferred #7601

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
michaelmesser opened this issue Mar 20, 2016 · 4 comments
Closed

IIFEs' arguments are not inferred #7601

michaelmesser opened this issue Mar 20, 2016 · 4 comments
Labels
Duplicate An existing issue was already created

Comments

@michaelmesser
Copy link

Version: 1.9.0
Code:
(function (x){ return x.thisPropertyDoesNotExist })("Hi")
Expected Result:
Error type String does not have property thisPropertyDoesNotExist.

Actual Result:
No error

@DanielRosenwasser DanielRosenwasser added the By Design Deprecated - use "Working as Intended" or "Design Limitation" instead label Mar 20, 2016
@DanielRosenwasser
Copy link
Member

IIFEs are type checked, the problem is that x implicitly got the type any, so you can do anything. You can fix this with a type annotation.

What you probably expected is for the type of x to be inferred, but there are certain issues with that as outlined at #4142.

@michaelmesser
Copy link
Author

Flow can catch the error so it is possible.

@michaelmesser michaelmesser changed the title IIFEs are not type checked IIFEs arguments are not inferred Mar 20, 2016
@michaelmesser michaelmesser changed the title IIFEs arguments are not inferred IIFEs' arguments are not inferred Mar 20, 2016
@mhegazy mhegazy closed this as completed Mar 21, 2016
@michaelmesser
Copy link
Author

Since this issue was closed, does that mean the Typescript team has no plans of adding this feature?

@RyanCavanaugh
Copy link
Member

Correct; see comments in #4142

@RyanCavanaugh RyanCavanaugh added Duplicate An existing issue was already created and removed By Design Deprecated - use "Working as Intended" or "Design Limitation" instead labels Mar 21, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants