microsoft / microsoft/TypeScript
`symbol` does not match interface
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TypeScript Version: playground and 3.3
Search Terms: symbol interface
Code
const sym: symbol = Symbol();
function f(arg: { constructor?: unknown }): void {
}
f(sym);
Expected behavior:
symbol is a non-nullish primitive, as such, it should be able to potentially match any interface.
Actual behavior:
Type error.
Related Issues: #29536 (discovered in relation to #28900), #1863, #24587
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 example in the linked TypeScript Playground and review the related issues for the intended assignability behavior. Trace the compiler's handling of symbol values against the { constructor?: unknown } interface, then add a regression test and verify that the example type-checks without weakening unrelated type rules.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100