TypeScript Version: 3.9.0-dev.20200310
Search Terms:
Partial
Code
exportinterfaceMessages{[key: string]: string$: string}exporttypePartialMessages<TextendsMessages>=Partial<T>&{$: string}exportfunctioncreateMessages<TextendsMessages>(messages: T): T{returnmessages}exportconsten=createMessages({$: 'English',welcome: 'Welcome!',}exportconstfr_ca=createMessages<PartialMessages<typeofen>>({$: 'Français (Canada)',})Expected behavior:
Should compile. Messages in PartialMessages are either complying or absent.
- last tested working version: Typescript 3.7.5
- first tested failing version: Typescript 3.8.2
Actual behavior:
Fail in:
exportconstfr_ca=createMessages<PartialMessages<typeofen>>(
Consider that all messages are present, but may be undefined.
Type 'PartialMessages<{ $: string; welcome: string; }>' does not satisfy the constraint 'Messages'.
Property 'welcome' is incompatible with index signature.
Type 'string | undefined' is not assignable to type 'Message'.
Type 'undefined' is not assignable to type 'Message'.
TypeScript Version: 3.9.0-dev.20200310
Search Terms:
Partial
Code
Expected behavior:
Should compile. Messages in
PartialMessagesare either complying or absent.Actual behavior:
Fail in:
Consider that all messages are present, but may be
undefined.