Skip to content

[bug:7.5.3] Mapper class explicite field regression #61540

Description

@jonlepage

🔎 Search Terms

Mapper class explicite inference for primitive

🕗 Version & Regression Information

  • This changed between versions 5.7.3 and 5.6.3

⏯ Playground Link

PLAYGROUND

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.

declarefunctionrollable(n:number):numberexportabstractclassAbstract{[key: string]: number
#Abstract!: never;}classTest{bug=newclass{property1=1;property2=rollable(2);}();fix=newclass{property1:number=1;property2=rollable(2);}();moreBug1=newclass{property1=1asconst;property2=rollable(2);}();moreBug2=newclassextendsAbstract{property1=1asconst;property2=rollable(2);}();}typeMapper<T>={[kinkeyofT]: [k,T[k]];}typeMapper2<T>={[kinkeyofTasstringextendsk ? never : k]: [k,T[k]];}typemapper_bug=Mapper<Test['bug']>;// work in version: 5.6.3typemapper_fix=Mapper<Test['fix']>;// expected : property1: ["property1", number];// ^?typemapper_moreTest1=Mapper<Test['moreBug1']>;typemapper_moreTest2=Mapper<Test['moreBug2']>;typemapper2_bug=Mapper2<Test['bug']>;typemapper2_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.

Image

please test the play ground in both version : 5.6.3 and 5.7.3

Metadata

Metadata

Labels

BugA bug in TypeScriptDomain: Mapped TypesThe issue relates to mapped types

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions