Skip to content

tsc TypeError: Cannot read property 'flags' of undefined #16861

Description

@koloboid

TypeScript Version: 2.4.1

Code

// This is minimal chunk of code
class BaseType<T> {
    bar: T
}

class NextType<C extends { someProp: any }, T = C['someProp']> extends BaseType<T> {
}

class Foo extends NextType<Foo> {
    someProp: {
        test: true
    }
}

const foo = new Foo();
foo.bar.test

Expected behavior:
Just to compile and run. May be this code violates TypeScript rules, but the actual result is unexpected, anyway
Both atom-typescript and WebStorm EAP consider this code as valid, and even correctly auto-complete "foo.bar.test"

Actual behavior:

$ tsc
/usr/lib/node_modules/typescript/lib/tsc.js:55776
                throw e;
                ^

TypeError: Cannot read property 'flags' of undefined
    at Object.getCheckFlags (/usr/lib/node_modules/typescript/lib/tsc.js:7996:22)
    at getTargetSymbol (/usr/lib/node_modules/typescript/lib/tsc.js:37957:23)
    at checkKindsOfPropertyMemberOverrides (/usr/lib/node_modules/typescript/lib/tsc.js:37975:31)
    at checkClassLikeDeclaration (/usr/lib/node_modules/typescript/lib/tsc.js:37915:21)
    at checkClassDeclaration (/usr/lib/node_modules/typescript/lib/tsc.js:37858:13)
    at checkSourceElement (/usr/lib/node_modules/typescript/lib/tsc.js:38767:28)
    at Object.forEach (/usr/lib/node_modules/typescript/lib/tsc.js:298:30)
    at checkSourceFileWorker (/usr/lib/node_modules/typescript/lib/tsc.js:38836:20)
    at checkSourceFile (/usr/lib/node_modules/typescript/lib/tsc.js:38821:13)
    at getDiagnosticsWorker (/usr/lib/node_modules/typescript/lib/tsc.js:38874:17)

Activity

  1. koloboid commented on Dec 24, 2017

    @koloboid
    Author

    Thank you guys, works like a charm in 2.7.0-dev.20171224

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

Metadata

Metadata

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