microsoft / microsoft/TypeScript
Readonly type breaks Set and Map
Open
Nobody has claimed this yet.
In Discussion
Suggestion
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TypeScript Version: 3.4.0-dev.201xxxxx
Search Terms:
Code
// A *self-contained* demonstration of the problem follows...
// Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp, Webpack, etc.
Expected behavior:
However, Set and Map can't use with es3 and es5. We need any workaround.
export type Readonly<T> =
T extends ReadonlySet<infer V> ? ReadonlySet<V> :
T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<K, V> :
{ readonly [P in keyof T]: T[P]; };
Actual behavior:
type Readonly<T> = {
readonly [P in keyof T]: T[P];
};
Playground Link:
Related Issues:
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
No repository file or test is named. Start by reducing the supplied Readonly snippets to a reproducible TypeScript example and run it with tsc; done means the intended Set and Map behavior for ES3/ES5 is clearly reproduced and covered by an appropriate compiler test.
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
- Needs clarification
- Newbie friendliness
- 25/100