TypeScript Version: 2.8.1 and 2.9.0-dev.20180329
Search Terms:
I tried actually a lot of terms around mapped types, arrays, conditional types, array member dereferencing in mapped types etc..
Code
exporttypeRecursivePartial<T>={[PinkeyofT]?: T[P]extendsArray<any> ? {[index: number]: RecursivePartial<T[P][0]>} :
T[P]extendsobject ? RecursivePartial<T[P]> : T[P];};vara={o: 1,b: 2,c: [{a: 1,c: '213'}]}functionassign<T>(o: T,a: RecursivePartial<T>){}assign(a,{o: 2,c: {0: {a: 2,c: '213123'}}})Expected behavior:
T[P][0] is usable and doesn't produce an error, since T[P] extends any[] and should thus be indexable on [0] (it seems this is the way to dereference an array)
Actual behavior:
I am getting type 0 cannot be used to index type T[P].
The odd part is that behaviour-wise it seems to be working ! I can't change the type of the nested c to anything other than string and I can't create random properties or what.
Am I missing something ?
TypeScript Version: 2.8.1 and 2.9.0-dev.20180329
Search Terms:
I tried actually a lot of terms around mapped types, arrays, conditional types, array member dereferencing in mapped types etc..
Code
Expected behavior:
T[P][0]is usable and doesn't produce an error, since T[P] extends any[] and should thus be indexable on [0] (it seems this is the way to dereference an array)Actual behavior:
I am getting
type 0 cannot be used to index type T[P].The odd part is that behaviour-wise it seems to be working ! I can't change the type of the nested
cto anything other than string and I can't create random properties or what.Am I missing something ?