Skip to content

Intellisense missing for generic type extending an all partial type #28470

Closed
@AviVahl

Description

@AviVahl

TypeScript Version:
3.1.3 and 3.2.0-dev.20181110

Search Terms:
Intellisense suggestions generic type

Code

interface Options {
    someFunction?: () => string
    anotherFunction?: () => string
}

export class Clazz<T extends Options> {
    constructor(public a: T) {
    }
}

new Clazz({

// ctrl + space on above line does not provide any suggestion
// it does when:
// - making some/anotherFunction required instead of optional (in Options)
//   OR
// - giving constructor's first param a type of `T | Options`
})

Expected behavior:
suggest someFunction and anotherFunction.

Actual behavior:
no suggestions

Playground Link:
http://www.typescriptlang.org/play/#src=interface%20Options%20%7B%0D%0A%20%20%20%20someFunction%3F%3A%20()%20%3D%3E%20string%0D%0A%20%20%20%20anotherFunction%3F%3A%20()%20%3D%3E%20string%0D%0A%7D%0D%0A%0D%0Aexport%20class%20Clazz%3CT%20extends%20Options%3E%20%7B%0D%0A%20%20%20%20constructor(public%20a%3A%20T)%20%7B%0D%0A%20%20%20%20%7D%0D%0A%7D%0D%0A%0D%0Anew%20Clazz(%7B%0D%0A%0D%0A%2F%2F%20ctrl%20%2B%20space%20in%20line%2012%20does%20not%20provide%20any%20suggestion%0D%0A%2F%2F%20it%20does%20when%3A%0D%0A%2F%2F%20-%20making%20some%2FanotherFunction%20required%20instead%20of%20optional%20(in%20Options)%0D%0A%2F%2F%20%20%20OR%0D%0A%2F%2F%20-%20giving%20constructor's%20first%20param%20a%20type%20of%20%60T%20%7C%20Options%60%0D%0A%7D)%0D%0A

Related Issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions