microsoft / microsoft/TypeScript
Index signature is assignable to weak type whose properties don't match the signature type
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
From https://stackoverflow.com/q/52368008 . Based on https://github.com/Microsoft/TypeScript/pull/16047#issue-122101801, it appears that @sandersn may have thought about the rule, but it still makes no sense to me and no rationale is stated.
TypeScript Version: master (394ee31a56c40033f31a3a8461ec267463033194)
Search Terms: weak type index signature
Code
interface Foo {
a?: string;
}
interface Bar {
[n: string]: number;
}
declare let b: Bar;
// No error; expected "Type 'Bar' has no properties in common with type 'Foo'."
let a: Foo = b;
Expected behavior: Error: "Type 'Bar' has no properties in common with type 'Foo'."
Actual behavior: No error.
Playground Link: link
Related Issues: Possibly #9900
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 with the TypeScript Playground reproduction and compare the current result with the expected weak-type diagnostic. Read the discussion in related issue #9900 and pull request #16047 for the existing rule and rationale. Done means the sample reports the stated error without regressing related index-signature assignments.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100