Skip to content

Preserve TypeScript type coercions in Closure code #65

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

Closed
evmar opened this issue Feb 17, 2016 · 2 comments
Closed

Preserve TypeScript type coercions in Closure code #65

evmar opened this issue Feb 17, 2016 · 2 comments

Comments

@evmar
Copy link
Contributor

evmar commented Feb 17, 2016

Input:

function foo(str: string) {}
foo(<string>JSON.parse('"foo"'));

Outputs:

// @param {string} str
function foo(str) { }
foo(JSON.parse('"foo"'));

We drop the <string> so Closure doesn't know about the type cast, producing a warning.

@evmar
Copy link
Contributor Author

evmar commented Feb 17, 2016

Due to microsoft/TypeScript#6982 , I can't find any way to make TS preserve an inline Closure type coercion.

Start from this:
http://www.typescriptlang.org/Playground#src=let%20x%20%3D%20%2F**%20foo%20*%2F(3)%3B
and see if you can find some combination of parens etc. to make it work... hmm.

@mprobst
Copy link
Contributor

mprobst commented Feb 18, 2016

@martine maybe we could contribute an upstream patch?

Evan Martin [email protected] schrieb am Do., 18. Feb. 2016 um
00:27 Uhr:

Due to microsoft/TypeScript#6982
microsoft/TypeScript#6982 , I can't find any
way to make TS preserve an inline Closure type coercion.

Start from this:

http://www.typescriptlang.org/Playground#src=let%20x%20%3D%20%2F**%20foo%20*%2F(3)%3B
and see if you can find some combination of parens etc. to make it work...
hmm.


Reply to this email directly or view it on GitHub
#65 (comment).

@evmar evmar closed this as completed in #66 Feb 24, 2016
evmar added a commit that referenced this issue Feb 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants