Skip to content

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

Closed

Description

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.

Activity

  1. ahejlsberg commented on Feb 24, 2015

    @ahejlsberg
    Member

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

  2. ahejlsberg commented on Feb 24, 2015

    @ahejlsberg
    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.

  3. JsonFreeman commented on Feb 24, 2015

    @JsonFreeman
    Contributor

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

  4. locked and limited conversation to collaborators on Jun 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions