Skip to content

Crash: TypeError: Cannot read property 'kind' of undefined (at isConstraintPosition) #26978

Closed
@calebsander

Description

@calebsander

TypeScript Version: 3.1.0-dev.20180907

Search Terms: compile error strict mode

Code:
test.ts:

class Abc {
  def: boolean
  constructor() {
    this.def = true
  }
}

tsconfig.json:

{
  "compilerOptions": {
    "strict": true
  }
}

Expected behavior:
Running tsc successfully compiles the module.

Actual behavior:
tsc exits with the following error:

node_modules/typescript/lib/tsc.js:68651
                throw e;
                ^

TypeError: Cannot read property 'kind' of undefined
    at isConstraintPosition (node_modules/typescript/lib/tsc.js:36644:27)
    at getConstraintForLocation (node_modules/typescript/lib/tsc.js:36653:25)
    at getInitialOrAssignedType (node_modules/typescript/lib/tsc.js:35754:20)
    at getTypeAtFlowAssignment (node_modules/typescript/lib/tsc.js:36094:71)
    at getTypeAtFlowNode (node_modules/typescript/lib/tsc.js:36028:32)
    at getFlowTypeOfReference (node_modules/typescript/lib/tsc.js:35993:51)
    at isPropertyInitializedInConstructor (node_modules/typescript/lib/tsc.js:44521:28)
    at checkPropertyInitialization (node_modules/typescript/lib/tsc.js:44504:50)
    at checkClassLikeDeclaration (node_modules/typescript/lib/tsc.js:44360:17)
    at checkClassDeclaration (node_modules/typescript/lib/tsc.js:44262:13)

The code compiles successfully if the strict flag is disabled. Also, the code compiles fine if def is instead a number or string (and assigned the appropriate type of value).

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptCrashFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad output

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions