镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Contextual type of 'any' should be ignored #6190

Description

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.

Activity

  1. RyanCavanaugh commented on Dec 21, 2015

    @RyanCavanaugh
    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

  2. sandersn commented on Dec 21, 2015

    @sandersn
    MemberAuthor

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

  3. mhegazy commented on Jan 5, 2016

    @mhegazy
    Contributor

    i agree with Ryan Cavanaugh (@RyanCavanaugh) this is by design.

  4. locked and limited conversation to collaborators on Jun 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScriptBy DesignDeprecated - use "Working as Intended" or "Design Limitation" instead

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions