-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Property does not exist on selected type, but available via callback #60835
Comments
This is not a bug in TS. The caller chooses the type argument (which is why you can do this when you call your function). The implementation needs to handle any choice the caller makes, including things like unions: tryFunc(Math.random() < 0.999 ? 'second' : 'first', { arg0: "abc", arg1: "def" }); // no compiler error Here there is a 99.9% chance you'll see I think you need #27808 if you want to be able to narrow type parameters this way. The feature at #56941 for #33014 doesn't address this because |
so why don't |
With |
🔎 Search Terms
I was thinking this code works like how the
addEventLister
oron
behavior happens. Are there other less complex solutions?🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play/?#code/C4TwDgpgBAKgFhACgJwPZgM5QLxQN4BQUxUAZgJbIbABc+RJjAhsgOYAMd1y5AdqwG4GjYi1YBGLsB78hjAL7CoGCAGNUvACZ1CIkmM5ReAVwC2AIwjI5eqGIBMdc6lQAbCE143iixsDiU2vS2dmwAzFIygkrMbAAsdCYWVt5QiooEmmquLNDqvNRQ0iAAwuZ0ADwA0lAQAB7AEFpYANYQIKiksAgo6BgAfAAUYGhgAHJMphB0VQA0UKrlUMOjGHTwSKsA2lUAugCUOP1QAG6o5JqH2MdnFwQExWWDAOQq+ZrP8yN9RwsaGG4IAA6VyoVgrPpAhz7fb3fKFYoAMWMvFUOCg1VqDSamla7U63U2fSG33Gk2mUDmUFJa0JvUwOwOv10JHIXQhZKmOFwrzUGg+hxZenhgJBYI5GChbHssIUBEUQA
💻 Code
🙁 Actual behavior
Property does not exist on selected type, but available via callback
🙂 Expected behavior
no error occurs same as using callback
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: