-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Inferring types: curried vs not curried #15005
Comments
Type inference will also work with this declaration: declare function props<P1 extends string, P2 extends string, O extends {[K in P1 | P2]: any}>
(ps: [P1, P2], obj: O): [O[P1], O[P2]]; In your first example, the mapped types for |
@PyroVortex So it wouldn't allow: // should be an error, as 'whatever' is not in {a: 1, b: '2'}`
props(['a', 'b', 'whatever'])({a: 1, b: '2'})[0] |
I run into similar problem: declare const a: { cb: (arg: number) => void }
declare function test1<T>(a: T, b: T): void;
test1(a, { cb(arg) { } }) // parameter 'arg' implicitly has an 'any' type
declare function test2<T>(a: T, b: () => T): void;
test2(a, () => ({ cb(arg) { } })) // parameter 'arg' implicitly has an 'any' type
declare function test3<T>(a: T): (b: T) => void // curried
test3(a)({ cb(arg) { } }) // (parameter) arg: number
declare function test4<T>(a: T): (b: () => T) => void // curried
test4(a)(() => ({ cb(arg) { } })) // (parameter) arg: number Looks like there're some related issues: #23429, #22715 #25092 |
* feat(react-kit): accept defaultProps in withrx selector result This allows to pass handlers along with props in WithRXSelector BREAKING CHANGE: - `defaultProps` argument is moved to `WithRXSelectorResult`; - `static defaultProps` property is removed; - `props$` stream passed to `selector` doesn't contain fields from `defaultProps` anymore - `withRX` now accepts `Target` separately for better type inference in `props`/`defaultProps` * chore(react-kit): update with-rx typechecking test * chore(react-kit): make withRX curried for better type inference microsoft/TypeScript#15005 (comment)
This issue has been marked as 'Question' and has seen no recent activity. It has been automatically closed for house-keeping purposes. If you're still waiting on a response, questions are usually better suited to stackoverflow. |
TypeScript Version: 2.2.2
This possible typings of props function from ramda for two arguments:
I wonder why if second object argument is not curried TS can not infer types in results:
And when curried it can:
Is TS going to make it work in future?
The text was updated successfully, but these errors were encountered: