Reactive collections should type arguments as immutable
- Dominant language
- TypeScript
- Stars
- 22.6k
- Forks
- 4.2k
- Avg merge
- 3d 12h
- Merged PRs (30d)
- 15
Description
### 🐞 Describe the Bug
The utilities for creating tracked collections that are exported from `@ember/reactive/collections` are documented to treat their arguments as immutable, but are typed to only accept mutable arguments. For example, the following produces a type error:
```ts
interface FooSignature {
Args: {
items: readonly string[];
setItems: (items: readonly string[]) => void;
}
}
export default
{{#let (trackedArray @items) as |arr|}}
{{!-- etc --}}
{{/let}}
satisfies TOC
```
because `@items` is a `readonly string[]` and `trackedArray` is typed to accept `T[]`, not `readonly T[]`. The various other utilities have similarly mutable-typed arguments.
### 🔬 Minimal Reproduction
See above
### 😕 Actual Behavior
Type error -- unable to pass immutable collections to the reactive utilities
### 🤔 Expected Behavior
No type error -- should be able to pass immutable collections to the reactive utilities
### 🌍 Environment
- Ember: -6.8
- Ember-CLI: N/A
- Node.js/npm: N/A
- OS: N/A
- Browser: N/a
Contributor guide
Assessment
This issue has not been assessed yet.