元组类型中的IntelliSense

时间:2019-12-20 01:36:54

标签: typescript types tuples intellisense

是否可以对元组类型的内容进行自动完成?还有为什么不能使用“简单”类型,如下面的示例所示;

type Litterals = 'foo' | 'bar';

type T1<T extends Litterals> = T;
// good autocomplete on simple literal
type Test1 = T1<'bar'>;

type T2<T extends Litterals[]> = T;
// no autocomplete
type Test2 = T2<['']>

type TBonus<...(T extends Litterals)> = T;
// how to achieve that?
type TestBonus = TBonus<'foo', 'bar', 'bar', 'foo' /* ... and as much as we want */>

Playground link

0 个答案:

没有答案