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

Update type #21

Open
goodmind opened this issue Nov 14, 2016 · 2 comments
Open

Update type #21

goodmind opened this issue Nov 14, 2016 · 2 comments

Comments

@goodmind
Copy link
Owner

Rewrite Update type to support
microsoft/TypeScript#12114

@goodmind
Copy link
Owner Author

@goodmind goodmind added this to the Future milestone Nov 27, 2016
@goodmind
Copy link
Owner Author

goodmind commented Dec 2, 2016

Some thoughts:

type Matcher<T> = {
  [P in keyof T]: (u: Pick<T, P>) => void
}

function checkType (u: Matcher<Update>) {

}

checkType({
  'callback_query': (u) => {
    u.bad_type // bad
    u.callback_query // ok
  },
  'message': (u) => {
    u.callback_query // bad
    u.message // ok
  },
  'edited_message': (u) => {
    u.edited_message // ok
  },
  'inline_query': (u) => {
    u.inline_query // ok
  },
  'chosen_inline_result': (u) => {
    u.chosen_inline_result // ok
  },
})

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

No branches or pull requests

1 participant