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
typeLong=GetChars<"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWX">;// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// Type instantiation is excessively deep and possibly infinite.
typeToSnake<Textendsstring>=stringextendsT
? string// We want ToSnake<string> = string
: Textends `${infer First}${infer Rest}`
? (FirstextendsUppercase<First>// Is First a capital letter?
? `_${Lowercase<First>}${ToSnake<Rest>}` // e.g. "B" -> "_b"
: `${First}${ToSnake<Rest>}`)
: T;typeS=ToSnake<'fooBarBaz'>;// ^? type S = "foo_bar_baz"typeTwo=ToSnake<'className'|'tagName'>;// ^? type Two = "class_name" | "tag_name"
typeLong=ToSnake<'reallyDescriptiveNamePropThatsALittleTooLoquacious'>;// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// Type instantiation is excessively deep and possibly infinite.