-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
Domain: Error MessagesThe issue relates to error messagingThe issue relates to error messagingExperience EnhancementNoncontroversial enhancementsNoncontroversial enhancementsFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
Description
A project under --strict
will likely break in TypeScript 4.4, and it won't be obvious why.
foo/thing.ts:37:5 - error TS2322: Type 'SomeData | undefined' is not assignable to type 'SomeData'.
Type 'undefined' is not assignable to type 'SomeData'.
37 data: data,
~~~~
What I would propose is that we give some better error message in these cases such as
The source property type 'SomeData | undefined' is not compatible with the target property type 'SomeData' under '--strictOptionalProperties'. Consider adding 'undefined' to the type of the target property.
This could then be given a quick fix.
We could give this error when
- The source property is optional and the target type includes
undefined
ness - The types would otherwise be compatible if you were to remove the
undefined
from the target.
RyanCavanaugh, IllusionMH, whzx5byb, amcasey, sandersn and 6 more
Metadata
Metadata
Assignees
Labels
Domain: Error MessagesThe issue relates to error messagingThe issue relates to error messagingExperience EnhancementNoncontroversial enhancementsNoncontroversial enhancementsFix AvailableA PR has been opened for this issueA PR has been opened for this issue