Samantha J T Star
Samantha J T Star

Reputation: 32808

Why does Visual Studio 2013 not know the definition of a property I defined?

I declared an interface like this:

interface IConfigAdmin {
    contentCreatedBy: number;
} 

Here I am using it:

    private getDefaultAdminConfigs = (): IConfigAdmin => {
        return {
            contentCreatedBy: null
        };
    }

If I try to set this to [] instead of null it gives an error as I would expect but why is it that when I hover over contentCreatedBy in VS2013 that it says this is a (property) contentCreatedBy: any

Upvotes: 0

Views: 36

Answers (1)

Dick van den Brink
Dick van den Brink

Reputation: 14519

You can fix this by casting it to IConfigAdmin first. This way you get autocompletion to while typing. I guess it could have inferred the type because of the return statement but I'm not sure.

return <IConfigAdmin> { }

See playground: link

Upvotes: 2

Related Questions