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
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)
The text was updated successfully, but these errors were encountered:
TypeScript Version: 2.2.1 / nightly (2.2.0-dev.201xxxxx)
Code
I'm probably doing something stupid here but I can't quite wrap my mind around it and the compiler just crashes:
If I comment out the whole function body the errors go away.
Expected behavior:
No error, type
S
constrained to objects with onlystring
properties and index lookups don't break.Actual behavior:
Compiler fails with:
The text was updated successfully, but these errors were encountered: