Skip to content
New issue

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

help 4260 #33267

Open
huangxinrui opened this issue May 16, 2024 · 0 comments
Open

help 4260 #33267

huangxinrui opened this issue May 16, 2024 · 0 comments
Labels

Comments

@huangxinrui
Copy link

type StringToUnion = S extends ${infer L}${infer R} ? L | StringToUnion : S;
type PermutationUnion<All extends string, Item extends string = All> = Item extends ''
? ''
: Item extends any
? ${Item}${PermutationUnion<Exclude<All, Item>>}
: never;
type PermutationUnion2<All extends string, Item extends string = All> = All extends ''
? ''
: Item extends any
? ${Item}${PermutationUnion2<Exclude<All, Item>>}
: never;

type A = PermutationUnion<'' | 'a' | 'b'>;
type B = PermutationUnion2<'' | 'a' | 'b'>;

A会得到全排列的值,但是B则只会返回空的字符串,PermutationUnion2也只是修改了第一个All为Item。
请问递归中Item始终没有赋值,所以Item永远和All相等,为什么修改第一个判断的来源就会出现结果不同呢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant