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

Contextual type of 'any' should be ignored #6190

Closed
sandersn opened this issue Dec 21, 2015 · 3 comments
Closed

Contextual type of 'any' should be ignored #6190

sandersn opened this issue Dec 21, 2015 · 3 comments
Assignees
Labels
Bug A bug in TypeScript By Design Deprecated - use "Working as Intended" or "Design Limitation" instead

Comments

@sandersn
Copy link
Member

getContextuallyTypedParameterType should return undefined instead of any

let x: { f(a, b): any, g(): any } = {
    f: (a = "none", b) => a.length, 
    g: (a = "none", b) { return a.length }
}

For both f and g, the parameter a: any but should be a: string.

I also ran into this with implemented/inherited functions in PR #6118.

@sandersn sandersn self-assigned this Dec 21, 2015
@sandersn sandersn added the Bug A bug in TypeScript label Dec 21, 2015
@RyanCavanaugh
Copy link
Member

I don't think that's correct. In this example (slightly modified):

let x: { f(a: any, b: any): any, g(): any } = {
    f: (a = "none", b) => a.length, 
    g: (a = "none", b) { return a.length }
}

... you shouldn't see any implicit any warnings, which would happen if getContextuallyTypedParameterType return undefined

@sandersn
Copy link
Member Author

Maybe it should be handled above (getTypeForVariableLikeDeclaration) or below (getTypeAtPosition) then.

@mhegazy
Copy link
Contributor

mhegazy commented Jan 5, 2016

i agree with @RyanCavanaugh this is by design.

@mhegazy mhegazy added the By Design Deprecated - use "Working as Intended" or "Design Limitation" instead label Jan 5, 2016
@mhegazy mhegazy closed this as completed Jan 5, 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
Bug A bug in TypeScript By Design Deprecated - use "Working as Intended" or "Design Limitation" instead
Projects
None yet
Development

No branches or pull requests

3 participants