Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Improve Promise and remove --noStrictGenericChecks #830

Closed
wants to merge 1 commit into from

Conversation

teppeis
Copy link
Contributor

@teppeis teppeis commented Jan 14, 2019

--noStrictGenericChecks in DeclarationSyntaxTest was introduced temporary in #689.
This PR is minimum improvement of Promise to remove --noStrictGenericChecks from DeclarationSyntaxTest and the users environment.

Both goog.Thenable.prototype.then and goog.Promise.prototype.then can receive IThenable (that is mapped to PromiseLike in TypeScript) and this fix resolves the strict generic check error.
https://github.com/google/closure-library/blob/e656c0807353188f42b67722d56724a5afc13228/closure/goog/promise/thenable.js#L47-L75

I can improve more, but I can not understand the meaning of that TODO comment, so I will leave other code as it is.

+ " ) => "
+ classTemplatizedType
+ " | RESULT ) | null , "
+ " ) => PromiseLike < RESULT > | RESULT ) | null , "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a clever solution. In the past we just expected all promise implementations to be structurally compatible, so one can say they expect then((...): ಠ_ಠ.clutz.goog.Thenable<T>, ...) and expected that ಠ_ಠ.clutz.goog.Thenable<T> is mutually assignable with PromiseLike<T>.

However, we ran into issues when strictGenericChecks was on - the two types were not mutually assignable. That's why is is off here and we have it off in the google codebase. I think with your change the types are getting more obviously assignable, so this might no longer be an issue.

@rkirov
Copy link
Contributor

rkirov commented Jan 16, 2019

Looks good, can you rebase and I will merge it.

@teppeis teppeis force-pushed the remove-noStrictGenericChecks branch from 289cdbb to cee3c4a Compare January 17, 2019 13:59
@teppeis
Copy link
Contributor Author

teppeis commented Jan 17, 2019

@rkirov Rebased, but failed in latest Compiler 😢
Filed: #836

@rkirov
Copy link
Contributor

rkirov commented Jan 19, 2019

merged

@rkirov rkirov closed this Jan 19, 2019
@teppeis teppeis deleted the remove-noStrictGenericChecks branch January 19, 2019 02:47
@teppeis
Copy link
Contributor Author

teppeis commented Jan 19, 2019

@rkirov Thanks! #841

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

Successfully merging this pull request may close these issues.

3 participants