-
-
Notifications
You must be signed in to change notification settings - Fork 504
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
Speed up inference by providing more type annotations #69
Comments
Do we have any ideas where we should add the type annotations? My project which uses fp-ts does not compile because of microsoft/TypeScript#15443. I'm very keen to unblock this, so I can continue using fp-ts in my project. To get us started, it would be good to take a look at this simple test case, and figure out which type annotations are needed to get it compiling again. |
@OliverJAsh The major problem in the test case is mixing If you start from -task.of(validation.success('foo'))
+task.of(validation.success<any[], string>('foo')) then in export const getUserTwitterCredentials = (userId: string) => {
const task = new fp.task.Task(() => Promise.resolve('{}'));
return task
.map(result => t.validate(result, UserTwitterCredentials))
// .map((validation): ApiResponseNew<UserTwitterCredentialsT> => (
// validation.mapLeft(validationErrors => (
// [{ }]
// ))
// ));
}; then you get 2 errors:
If you fake const session = {
userId: '678'
}
const req = {
ip: '387'
} then you get the last error credentialsM.chain(credentials => {
// requestIpM :: Task<string>
const requestIpM = normalizeRequestIp(req.ip);
// y :: task.Task<ApiResponseNew<string>>
const y = requestIpM.chain(a => getIanaTimeZoneFromIp(a))
// this is not valid: y is a Validation but EitherT expects a Either
// const ianaTimeZoneM = new fp.eitherT.EitherT(fp.task, y);
// return ianaTimeZoneM
})
const y = requestIpM.chain(a => getIanaTimeZoneFromIp(a))
.map(v => v.toEither()) will let you compile the project |
@gcanti That's really helpful. My project compiles now. How did you deduce that the memory issue was because of this? I knew the project had type errors, I just didn't know what they were because of the memory/compilation issue. |
The deduction comes from the following helpful comment by @sandersn
Unfortunately always provide type parameters seems necessary (to get fail fast errors like in
|
Update from microsoft/TypeScript#15443: It looks like we might have a fix on the typescript side so being explicit about type parameters probably won't be needed. |
thanks @sandersn |
Verified so I close |
Just verified as well, amazing. Many thanks to the TypeScript team! You rock |
The motivation here is to follow @sandersn advices (maybe @ahejlsberg will also give us some guidance on that matter)
microsoft/TypeScript#15443 (comment)
The text was updated successfully, but these errors were encountered: