Open
Description
π Search Terms
Mapper class explicite inference for primitive
π Version & Regression Information
- This changed between versions 5.7.3 and 5.6.3
β― Playground Link
if need, here is a very simple and epurate playground without all the tests.
SMALL_PLAYGROUND
π» Code
I have added some additional tests in order to gather more information and understand what is happening.
Bugs and fixes are the two adresse to verify.
declare function rollable( n:number ):number
export abstract class Abstract {
[key: string]: number
#Abstract!: never;
}
class Test {
bug = new class {
property1 = 1;
property2 = rollable( 2 );
}();
fix = new class {
property1:number = 1;
property2 = rollable( 2 );
}();
moreBug1 = new class {
property1 = 1 as const;
property2 = rollable( 2 );
}();
moreBug2 = new class extends Abstract {
property1 = 1 as const;
property2 = rollable( 2 );
}();
}
type Mapper<T> ={
[k in keyof T]: [k, T[k]];
}
type Mapper2<T> ={
[k in keyof T as string extends k ? never : k]: [k, T[k]];
}
type mapper_bug = Mapper<Test['bug']>; // work in version: 5.6.3
type mapper_fix = Mapper<Test['fix']>; // expected : property1: ["property1", number];
// ^?
type mapper_moreTest1 = Mapper<Test['moreBug1']>;
type mapper_moreTest2 = Mapper<Test['moreBug2']>;
type mapper2_bug = Mapper2<Test['bug']>;
type mapper2_fix = Mapper2<Test['fix']>;
π Actual behavior
the mapper ignore the field declaration !!
π Expected behavior
the mapper should consider the field declaration !
Additional information about the issue
No, but I just spent a whole day trying to understand before realizing that it's a TypeScript issue! I am exhausted.
please test the play ground in both version : 5.6.3 and 5.7.3