Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect compile time type for dictionary #75

Closed
OliverJAsh opened this issue Sep 28, 2017 · 2 comments
Closed

Incorrect compile time type for dictionary #75

OliverJAsh opened this issue Sep 28, 2017 · 2 comments
Assignees
Labels

Comments

@OliverJAsh
Copy link
Contributor

Given

const Dic = t.dictionary(t.literal('foo'), t.string);
type DicT = t.TypeOf<typeof Dic>;

const dic: DicT = {
    foo: 'bar',
    baz: 'bob'
};

I expect this to error because baz in not an allowed property. DicT should be equivalent to { [key in 'foo']: string } (mapped type with string literals), however it is equivalent to { [key: string]: string }.

Is this intentional or can we fix it?

@gcanti gcanti added the bug label Sep 29, 2017
@gcanti gcanti self-assigned this Sep 29, 2017
@gcanti gcanti closed this as completed in ca025d3 Sep 29, 2017
@gcanti
Copy link
Owner

gcanti commented Sep 29, 2017

@OliverJAsh thanks for reporting, just released a fix

@OliverJAsh
Copy link
Contributor Author

OliverJAsh commented Sep 29, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants