Skip to content

Bug: tsc crash TypeError: Cannot read property 'flags' of undefined #25264

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
purificant opened this issue Jun 27, 2018 · 0 comments
Closed

Bug: tsc crash TypeError: Cannot read property 'flags' of undefined #25264

purificant opened this issue Jun 27, 2018 · 0 comments
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@purificant
Copy link

TypeScript Version: 2.9.2 and typescript@next at the time of writing.

Search Terms: TypeError: Cannot read property 'flags' of undefined

Code

class Abstract {
  protected constructor() {
  }
}

class Concrete extends Abstract {
}

type Constructor<T = {}> = new (...args: any[]) => T;

function Mixin<TBase extends Constructor>(Base: TBase) {
  return class extends Base {
  };
}

class Empty {
}

class CrashTrigger extends Mixin(Empty) {
  public trigger() {
    new Concrete();
  }
}

Example repo with code to reproduce: https://github.com/purificant/typescript-crash-example

Expected behavior:
tsc emits an error along the lines of "TS2674: Constructor of class 'Abstract' is protected and only accessible within the class declaration."

Actual behavior:
tsc crashes with the following stack trace:

typescript-crash-example/node_modules/typescript/lib/tsc.js:63860
                throw e;
                ^

TypeError: Cannot read property 'flags' of undefined
    at getBaseTypes (typescript-crash-example/node_modules/typescript/lib/tsc.js:25683:38)
    at isConstructorAccessible (typescript-crash-example/node_modules/typescript/lib/tsc.js:36070:37)
    at resolveNewExpression (typescript-crash-example/node_modules/typescript/lib/tsc.js:36024:22)
    at resolveSignature (typescript-crash-example/node_modules/typescript/lib/tsc.js:36180:28)
    at getResolvedSignature (typescript-crash-example/node_modules/typescript/lib/tsc.js:36209:26)
    at checkCallExpression (typescript-crash-example/node_modules/typescript/lib/tsc.js:36282:29)
    at checkExpressionWorker (typescript-crash-example/node_modules/typescript/lib/tsc.js:37687:28)
    at checkExpression (typescript-crash-example/node_modules/typescript/lib/tsc.js:37629:42)
    at checkExpressionStatement (typescript-crash-example/node_modules/typescript/lib/tsc.js:39545:13)
    at checkSourceElement (typescript-crash-example/node_modules/typescript/lib/tsc.js:41180:28)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

3 participants