Skip to content

Strongly type D.set for known keys#76

Open
banjerluke wants to merge 1 commit intomobily:masterfrom
banjerluke:patch-1
Open

Strongly type D.set for known keys#76
banjerluke wants to merge 1 commit intomobily:masterfrom
banjerluke:patch-1

Conversation

@banjerluke
Copy link

With existing typing, D.set will accept any value type with no complaints from TypeScript:

const obj = { foo: 1 };
D.set(obj, 'foo', 'uh oh'); // wrong type, but no TypeScript errors
```kL

With the updated types in this commit, not only does TypeScript now give errors for mistyped values, but VS Code also does autocomplete for keys. 😎

You can still pass in non-existing keys to add them to the object, in which case `value` can be any type.

With existing typing, `D.set` will accept any value type with no complaints from TypeScript:

```ts
const obj = { foo: 1 };
D.set(obj, 'foo', 'uh oh'); // wrong type, but no TypeScript errors
```kL

With the updated types in this commit, not only does TypeScript now give errors for mistyped values, but VS Code also does autocomplete for keys. 😎

You can still pass in non-existing keys to add them to the object, in which case `value` can be any type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant