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

Error: Class incorrectly extends base class... cannot assign type #2073

Closed
omidkrad opened this issue Feb 19, 2015 · 2 comments
Closed

Error: Class incorrectly extends base class... cannot assign type #2073

omidkrad opened this issue Feb 19, 2015 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@omidkrad
Copy link

Please see comments:

interface ObjectHash {
    [key: string]: any;
}

var hash: ObjectHash;

hash = {
    "key": "value"
}

declare class Model {
    defaults: ObjectHash;
}

class MyModel1 extends Model { // Okay
    defaults = hash;
}

class MyModel2 extends Model { // Why ERROR?!
    defaults = {
        "key": "value"
    };
}

class MyModel3 extends Model { // Okay
    defaults: ObjectHash = {
        "key": "value"
    };
}
@DanielRosenwasser
Copy link
Member

I think what you're looking for is issue #1373. Essentially we're not contextually typing with base-class properties.

@DanielRosenwasser DanielRosenwasser added the Duplicate An existing issue was already created label Feb 19, 2015
@omidkrad
Copy link
Author

I think it's also a duplicate of #178. It caught me again!

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

2 participants