Skip to content

Stack overflow for subclass as static property #24194

Description

@rjamesnw

TypeScript Version:
2.8 and 2.9

Search Terms:
Out of stack space

Code

namespaceTest{exportinterfaceIType<TInstance=object>{new(...args: any[]): TInstance;}exportfunctionClassFactory<TBaseClassextendsIType,TClassextendsIType,TFactoryextendsIType,TNamespaceextendsobject>(namespace: TNamespace,base: IClassFactory&{$__type: TBaseClass},getType: (base: TBaseClass)=>[TClass,TFactory],exportName?: keyofTNamespace,addMemberTypeInfo=true)
: TClass&TFactory&{$__type: TClass}{returnnull;}exportfunctionFactoryBase<TClassextendsIType,TBaseFactoryextendsIType,TStaticPropertiesextendskeyofTClass>(type: TClass,baseFactoryType: TBaseFactory){returnclassFactoryBaseextendstype{static'new'?(...args: any[]): any;staticinit?(o: InstanceType<TClass>,isnew: boolean, ...args: any[]): void;};}exportnamespaceLoader{exportvarSomeClass=ClassFactory(Loader,void0,(base)=>{classSomeClass{privatex: number;protectedstaticreadonly'SomeClassFactory'=classFactoryextendsFactoryBase(SomeClass,null){static'new'(): SomeClass{returnnull;}staticinit(o: SomeClass,isnew: boolean){o.x=1;}};}return[SomeClass,SomeClass["SomeClassFactory"]];});}}

Configuration used:

{
"compilerOptions": {
"experimentalDecorators": true,
"suppressImplicitAnyIndexErrors": true,
"traceResolution": true,
"listFiles": true,
"diagnostics": true,
"forceConsistentCasingInFileNames": false,
"noImplicitAny": true,
"noEmitOnError": false,
"removeComments": false,
"noEmitHelpers": true,
"declaration": true,
"declarationDir": "wwwroot/js",
//"typeRoots": [ "typings" ],
"sourceMap": true,
"target": "es5", // IE11=es5, Edge+ es2015=ES6
"outDir": "wwwroot/js",
"downlevelIteration": true,
"rootDir": "Scripts", // *** location of the scripts ***
"lib": [ "dom", "es6", "dom.iterable", "scripthost" ] // (target es5 but use es6 libs, since there is partial support of some es6 in es5; lib options: https://www.typescriptlang.org/docs/handbook/compiler-options.html)
},
"include": [
"typings/**/*.ts",
"Scripts/testscript.ts"
]
}

Compiled using this line:
tsc.exe --project "{path too source}\tsconfig.json" --locale en-US

Expected behavior:
Good behavior: Not out of stack space error.

Actual behavior:
Bad: Out of stack space error.

Playground Link:
https://goo.gl/UHStFt

This works PERFECT when this is commented out:

 "declaration": true,
"declarationDir": "wwwroot/js",

I had to spend a lot of time whittling down the production source (many, many, files) down to this test. The production code this is taken from compiles AND runs PERFECT! Everyone is a happy camper (this code also compiles ok when declarations are turned off), BUT when I switch on declaration file generation, everything craps out (and the campers are not happy anymore). ;)

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