microsoft / microsoft/TypeScript
Object.freeze after object creation doesn't error
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.5.1
Search Terms: Object.freeze, freeze, freezing, properties, object, objects, property
Code
const a = Object.freeze({a: 0});
a.a = 1; // Error: Cannot assign read-only property
const b = {b: 0};
Object.freeze(b);
b.b = 1; // No error?
const c = {c: {d: 0}};
Object.freeze(c.c);
c.c.d = 1; // No error?
Expected behavior:
Cannot assign read-only property errors for the two lines with "No error?" above.
Actual behavior:
No errors
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
Reproduce the three Object.freeze examples in the linked TypeScript Playground and compare the diagnostics for each assignment. Trace the type-checking path that handles Object.freeze calls and verify the behavior against focused compiler tests. Done means both post-creation assignments produce the expected read-only-property error without regressing the first example.
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
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100