Skip to content

Regression: Partial properties became undefined instead of optional #37324

Description

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'.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions