Skip to content

Typescript could not resolve typing error #16014

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
artem-malko opened this issue May 23, 2017 · 2 comments
Closed

Typescript could not resolve typing error #16014

artem-malko opened this issue May 23, 2017 · 2 comments

Comments

@artem-malko
Copy link

artem-malko commented May 23, 2017

TypeScript Version: 2.3.3

Code

interface Animal {
    name: string;
    size: {
        w?: number;
        h?: number;
    };
}

var dog: Animal = {
    name: 'John',
    size: 'asd',
}

And you can open the link from typescript playground.

Expected behavior:

Typing error, because size is not a string, it is an object with specific shape.

Actual behavior:

No errors.

@ctizen
Copy link

ctizen commented May 23, 2017

Looks like it treats literal string as object, and it matches declared object shape which may be empty. I'm not sure if this is expected behavior.

@artem-malko
Copy link
Author

Sorry, I've just found the same issue In Progress) #7485

@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants