Skip to content

Cannot read property 'heritageClauses' of undefined #10268

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
mhevery opened this issue Aug 10, 2016 · 2 comments
Closed

Cannot read property 'heritageClauses' of undefined #10268

mhevery opened this issue Aug 10, 2016 · 2 comments
Labels
Bug A bug in TypeScript Needs More Info The issue still hasn't been fully clarified

Comments

@mhevery
Copy link

mhevery commented Aug 10, 2016

TypeScript Version: 1.8.0 / nightly (2.0.0-dev.201xxxxx)
Version 1.9.0-dev.20160409

Code

type.ts:

export var Type = Function;

export interface Type<T> extends Function { new (...args: any[]): T; }
import {Type} from './type';

interface TypeProvider extends Type<any>
;

It provides a correct error here:
https://www.typescriptlang.org/play/#src=export%20var%20Type%20%3D%20Function%3B%0D%0A%0D%0Aexport%20interface%20Type%3CT%3E%20extends%20Function%20%7B%20new%20(...args%3A%20any%5B%5D)%3A%20T%3B%20%7D%0D%0A%0D%0Ainterface%20TypeProvider%20extends%20Type%3Cany%3E%0D%0A%3B%0D%0A

Expected behavior:

a reasonable error

Actual behavior:

TypeError: Cannot read property 'heritageClauses' of undefined
    at Object.getClassExtendsHeritageClauseElement (/Users/misko/work/angular/node_modules/typescript/lib/typescript.js:6149:52)
    at getBaseTypeNodeOfClass (/Users/misko/work/angular/node_modules/typescript/lib/typescript.js:17884:23)
    at getBaseConstructorTypeOfClass (/Users/misko/work/angular/node_modules/typescript/lib/typescript.js:17905:36)
    at resolveBaseTypesOfClass (/Users/misko/work/angular/node_modules/typescript/lib/typescript.js:17948:39)
    at Object.writeBaseConstructorTypeOfClass (/Users/misko/work/angular/node_modules/typescript/lib/typescript.js:30259:13)
    at emitTypeOfTypeReference (/Users/misko/work/angular/node_modules/typescript/lib/typescript.js:32596:30)
    at emitSeparatedList (/Users/misko/work/angular/node_modules/typescript/lib/typescript.js:31999:21)
    at emitCommaList (/Users/misko/work/angular/node_modules/typescript/lib/typescript.js:32004:13)
    at emitHeritageClause (/Users/misko/work/angular/node_modules/typescript/lib/typescript.js:32585:17)
    at writeInterfaceDeclaration (/Users/misko/work/angular/node_modules/typescript/lib/typescript.js:32662:13)
Compilation failed
@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Aug 10, 2016
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 2.0.1 milestone Aug 10, 2016
@ghost
Copy link

ghost commented Aug 15, 2016

I tested this code with the typescript version you gave (1.9.0-dev.20160409) .
I used two files, type.ts and a.ts, with the contents you provided, and an empty tsconfig.json.
I just get the errors:

a.ts(4,1): error TS1005: '(' expected.
a.ts(4,2): error TS1005: '{' expected.

If I change the code in a.ts to end in interface TypeProvider extends Type<any> {}, it compiles with no errors.

As you said, it was working for you on the playground, so there must be something unique to your configuration. Can you reproduce the error in a sample project, and provide the tsconfig.json that you used to reproduce it?

I can tell that you are emitting declaration files, because that's where the error happens, but running tsc --declaration still won't reproduce the error.

@yuit yuit assigned ghost and unassigned yuit Aug 15, 2016
@mhegazy mhegazy added the Needs More Info The issue still hasn't been fully clarified label Aug 17, 2016
@mhegazy mhegazy modified the milestones: TypeScript 2.1, TypeScript 2.0.1 Aug 17, 2016
@mhegazy
Copy link
Contributor

mhegazy commented Sep 21, 2016

This sample seems to work fine. Please try typescript@next, and if this still an issue, reopen.

@mhegazy mhegazy closed this as completed Sep 21, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Needs More Info The issue still hasn't been fully clarified
Projects
None yet
Development

No branches or pull requests

4 participants