microsoft / microsoft/TypeScript
Improve diagnostic when string from property is not assignable to string literal.
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TypeScript Version: 3.1.0-dev.20180810
Code
interface IceCreamOptions {
readonly cherry: "yes" | "no"
}
declare function iceCream(options: IceCreamOptions): void;
const options = { cherry: "yes" };
iceCream(options);
Expected behavior:
Error message recommending to add a type annotation to options. This should be detectable because the source of the failing property is a PropertyAssignment 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the provided TypeScript 3.1 example and tracing the assignability diagnostic for the object-literal property assignment. Determine where the existing message is produced and how TypeScript identifies the source property; done means the diagnostic recommends an appropriate annotation, with a codefix only if that scope is accepted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100