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

Bug: Cannot read property 'flags' of undefined #2127

Closed
osi-oswald opened this issue Feb 24, 2015 · 3 comments · Fixed by #2356
Closed

Bug: Cannot read property 'flags' of undefined #2127

osi-oswald opened this issue Feb 24, 2015 · 3 comments · Fixed by #2356
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@osi-oswald
Copy link

osi-oswald commented Feb 24, 2015

Trying to compile

interface IBar {
    [barId: string]: any;
}

interface IFoo {
    foo<TBar extends IBar>(bar: TBar, bar1: (bar: TBar)=>any, bar2: (bar: TBar)=>any);
}

var foo: IFoo;
foo.foo({bar: null}, bar => null, bar => null);

leads to the following error

if (source.flags & 128 /* Enum */ && target === numberType
          ^
TypeError: Cannot read property 'flags' of undefined
    at isRelatedTo (tsc.js:13077:31)
    at checkTypeRelatedTo (tsc.js:13048:26)
    at checkTypeSubtypeOf (tsc.js:13029:20)
    at reportNoCommonSupertypeError (tsc.js:13618:13)
    at resolveCall (tsc.js:14945:21)
    at resolveCallExpression (tsc.js:15075:20)
    at getResolvedSignature (tsc.js:15125:47)
    at checkCallExpression (tsc.js:15140:29)
    at checkExpressionWorker (tsc.js:15648:28)
    at checkExpressionOrQualifiedName (tsc.js:15605:42)

tsc version 1.4.1.0

You can also put this code into the typescript Playground, which does not complie it as well.

@mhegazy mhegazy added the Bug A bug in TypeScript label Feb 24, 2015
@mhegazy mhegazy added this to the TypeScript 1.5 milestone Feb 24, 2015
@ahejlsberg ahejlsberg assigned JsonFreeman and unassigned ahejlsberg Feb 24, 2015
@ahejlsberg
Copy link
Member

@JsonFreeman Jason, the crash is caused by reportNoCommonSupertypeError computing the value undefined for bestSupertypeDownfallType and then passing that to checkTypeSubtypeOf.

@ahejlsberg
Copy link
Member

It's not entirely clear to me what that logic is doing. I think you wrote it, so I'm assigning the bug to you.

@JsonFreeman
Copy link
Contributor

Yeah I wrote that, so I can take a look. Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants