You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Maximum call stack size exceeded from getResolvedBaseConstraint #14940
I'm probably doing something stupid here but I can't quite wrap my mind around it and the compiler just crashes:
typeClassName<S>=keyofS;typeClassNameMap<S>={[KinkeyofS]?: boolean}typeClassNameObjectMap<S>=object&ClassNameMap<S>;// protects against passing non-objects, but breaks index lookups typeClassNameArg<S>=ClassName<S>|ClassNameObjectMap<S>;exportfunctioncss<Sextends{[KinkeyofS]: string}>(styles: S, ...classNames: ClassNameArg<S>[]): string{constargs=classNames.map(arg=>{if(arg==null){returnnull;}if(typeofarg=="string"){returnstyles[arg];}if(typeofarg=="object"){returnObject.keys(arg).reduce<ClassNameObject>((obj: ClassNameObject,key: keyofS)=>{constexportedClassName=styles[key];obj[exportedClassName]=(argasClassNameMap<S>)[key];returnobj;},{});}});// return classnamer(...args);return"";}
If I comment out the whole function body the errors go away.
Expected behavior:
No error, type S constrained to objects with only string properties and index lookups don't break.
Actual behavior:
Compiler fails with:
Process: Error processing message: Maximum call stack size exceeded RangeError: Maximum call stack size exceeded
at isSimpleTypeRelatedTo (evalmachine.<anonymous>:28208:39)
at isRelatedTo (evalmachine.<anonymous>:28354:21)
at isRelatedTo (evalmachine.<anonymous>:28413:38)
at isRelatedTo (evalmachine.<anonymous>:28413:38)
at isRelatedTo (evalmachine.<anonymous>:28413:38)
at isRelatedTo (evalmachine.<anonymous>:28413:38)
at isRelatedTo (evalmachine.<anonymous>:28413:38)
at isRelatedTo (evalmachine.<anonymous>:28413:38)
at isRelatedTo (evalmachine.<anonymous>:28413:38)
at isRelatedTo (evalmachine.<anonymous>:28413:38)
Activity
ahejlsberg commentedon Apr 3, 2017
This looks to be the same issue as #14896.