We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
题目链接:KebabCase,答题
实现 KebabCase,满足下面需求
KebabCase
import type { Equal, Expect } from "@type-challenges/utils"; type cases = [ Expect<Equal<KebabCase<"FooBarBaz">, "foo-bar-baz">>, Expect<Equal<KebabCase<"fooBarBaz">, "foo-bar-baz">>, Expect<Equal<KebabCase<"foo-bar">, "foo-bar">>, Expect<Equal<KebabCase<"foo_bar">, "foo_bar">>, Expect<Equal<KebabCase<"Foo-Bar">, "foo--bar">>, Expect<Equal<KebabCase<"ABC">, "a-b-c">>, Expect<Equal<KebabCase<"-">, "-">>, Expect<Equal<KebabCase<"">, "">>, Expect<Equal<KebabCase<"😎">, "😎">> ];
type KebabCase<T> = T extends `${infer FirstLetter}${infer RestLetter}` ? Rest extends Uncapitalize<Rest> ? `${Uncapitalize<FirstLetter>}${KebabCase<RestLetter>}` : `${Uncapitalize<FirstLetter>}-${KebabCase<RestLetter>}` : T;
FirstLetter
RestLetter
-
The text was updated successfully, but these errors were encountered:
No branches or pull requests
题目
题目链接:KebabCase,答题
实现
KebabCase
,满足下面需求答案
方法一
知识点
FirstLetter
和RestLetter
FirstLetter
部分,而是判断RestLetter
部分首字母是否大写-
FirstLetter
,那单词首字母大写的话,就会在单词前面添加-
不符合题意The text was updated successfully, but these errors were encountered: