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

Typing array elements #67

Closed
laurensdijkstra opened this issue May 15, 2019 · 3 comments
Closed

Typing array elements #67

laurensdijkstra opened this issue May 15, 2019 · 3 comments

Comments

@laurensdijkstra
Copy link

In the Readme.MD you wrote Note: Currently creating type from array element is not supported in TypeScript. See https://github.com/Microsoft/TypeScript/issues/28046

In that issue thread someone seems to have posted a solution that works with TS > 3.4. Does this help typed-graphqlify?

microsoft/TypeScript#28046 (comment)

@acro5piano
Copy link
Owner

Thanks! I'll check it later.

@acro5piano
Copy link
Owner

acro5piano commented Jun 20, 2019

Very slow response, but I've finally checked it.

import { query, types } from 'typed-graphqlify'

const UserType = ['Student',  'Teacher',] as const

query('getUser', {
  user: {
    id: types.number,
    name: types.string,
    type: types.oneOf(UserType),
  },
})

We may also support TS < 3.4 with overload signature.

And this utility-type do the same thing:
https://github.com/piotrwitek/utility-types#elementtypet-k

@acro5piano acro5piano mentioned this issue Jul 16, 2019
acro5piano added a commit that referenced this issue Mar 2, 2020
@acro5piano
Copy link
Owner

@laurensdijkstra
I've add the feature in the following PR. Thanks!
#68

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

No branches or pull requests

2 participants