Skip to content

No contextual typing for interfaces that extends interface with index signature #3804

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
tinganho opened this issue Jul 10, 2015 · 4 comments
Labels
By Design Deprecated - use "Working as Intended" or "Design Limitation" instead

Comments

@tinganho
Copy link
Contributor

I was hoping this could work:

class A {
    public a: string;
}

interface B {
    [index: string]: A;
}

interface C extends B {
    a;
    b;
    c;
}

let c: C;
c.a.a // c.a of type A

but members of interface C has type any instead I was hoping I could get type A?

Notice I don't want to define directly:

let c: B;

because I need to pass C as a type with defined props.

@tinganho tinganho changed the title No contextual typings for interfaces that extends interface with index signature No contextual typing for interfaces that extends interface with index signature Jul 10, 2015
@RyanCavanaugh RyanCavanaugh added the By Design Deprecated - use "Working as Intended" or "Design Limitation" instead label Jul 10, 2015
@RyanCavanaugh
Copy link
Member

Contextual typing applies to expressions, not declarations, so that part isn't exactly relevant.

It's legal to declare members of type any (which is what you've done) even when you have an index signature. I don't think we would take a breaking change here.

@tinganho
Copy link
Contributor Author

This is my problem right now:

interface StyleRules extends Radium.StyleRules {
    feed: Radium.CSSStyleDeclaration;
    feedTitle: Radium.CSSStyleDeclaration;
    feedLoadMoreButton: Radium.CSSStyleDeclaration;
.   ...
}

Having to repeat a type that I think could be inferred from a base interface. If not inferred maybe be able to reference the base signature value type?

@RyanCavanaugh
Copy link
Member

#1373 ?

@tinganho
Copy link
Contributor Author

Yes sort of related. Though this suggestion is an interface derived from an
interface/class. His suggestion where a class derived from a
interface/class.

tis 14 juli 2015 kl 00:45 skrev Ryan Cavanaugh notifications@github.com:

#1373 #1373 ?


Reply to this email directly or view it on GitHub
#3804 (comment)
.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
By Design Deprecated - use "Working as Intended" or "Design Limitation" instead
Projects
None yet
Development

No branches or pull requests

2 participants