agiledigital / agiledigital/readonly-types
immutable string
- 主要语言
- TypeScript
- 星标
- 17
- 派生
- 2
- PR 合并指标
- 30 天内没有已合并 PR
描述
Strings are Immutable at runtime, but only (strictly speaking) ReadonlyDeep at compile time.
As so often, the cause is method syntax, in particular:
```typescript
interface RelativeIndexable {
/**
* Takes an integer value and returns the item at that index,
* allowing for positive and negative integers.
* Negative integers count back from the last item in the array.
*/
at(index: number): T | undefined;
}
```
Observe:
```typescript
const foo = "hello";
// This compiles but throws at runtime
// eslint-disable-next-line functional/no-expression-statements, functional/immutable-data, functional/functional-parameters
foo.at = () => "";
```
It would be nice (if extremely low priority) if this could be caught at compile time, before linting and certainly before runtime.
贡献指南
这个仓库没有索引到贡献指南
评估
这个 Issue 还没有评估数据。