agiledigital / agiledigital/readonly-types

immutable string

未关闭
#523 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
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 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。