Improve diagnostic when string from property is not assignable to string literal. #26413
Labels
Domain: Error Messages
The issue relates to error messaging
Effort: Moderate
Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".
Help Wanted
You can do this
Suggestion
An idea for TypeScript
Milestone
TypeScript Version: 3.1.0-dev.20180810
Code
Expected behavior:
Error message recommending to add a type annotation to
options
. This should be detectable because the source of the failing property is aPropertyAssignment
in an object literal being assigned to a variable. (If there is no variable assignment, we could still recommend using ``"yes" as "yes"although that isn't as pretty.) Could also come with a codefix. Note that in JS the fix is slightly different: put
/** @type {IceCreamOptions} /` before the `const` or use `/* @type {"yes"} */ ("yes")`.Actual behavior:
Error messages says
Type 'string' is not assignable to type '"yes" | "no"'.
with no information on how to fix it.The text was updated successfully, but these errors were encountered: