Update: based on @jerico's answer below The following type alias will return the type of the elements in an array or tuple: type ArrayElement<ArrayType extends readonly unknown[]> = ArrayType extends readonly (infer ElementType)[] ? ElementType : never; So these examples would work: type A = ArrayElement<string[]>; // string type B = ArrayElement<readonly string[]>; // string type C = ArrayElement
I want to be able to assign an object property to a value given a key and value as inputs yet still be able to determine the type of the value. It's a bit hard to explain so this code should reveal the problem: type JWT = { id: string, token: string, expire: Date }; const obj: JWT = { id: 'abc123', token: 'tk01', expire: new Date(2018, 2, 14) }; function print(key: keyof JWT) { switch (key) { case
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く