Skip to content
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

Casting tricks don't work #18

Closed
jrieken opened this issue Nov 27, 2020 · 4 comments
Closed

Casting tricks don't work #18

jrieken opened this issue Nov 27, 2020 · 4 comments

Comments

@jrieken
Copy link

jrieken commented Nov 27, 2020

  • get https:/microsoft/vscode
  • run yarn && yarn tsec-compile-check
  • 🐛 you see errors being reported for things that should be ok, like usages of trustedOrString as unknown as string

This is an example (there are a few more) where tsec complaints although it shouldn't

https:/microsoft/vscode/blob/5f569de4cd54e43d0239e339b5f4e60f367cf75f/src%2Fvs%2Fworkbench%2Fcontrib%2Fnotebook%2Fbrowser%2Fview%2Frenderers%2FcellRenderer.ts#L595

@Siegrift
Copy link
Contributor

This is intended.

Variable linesHtml has type string | TrustedHTML so you only need casting to string.
Assignment element.innerHTML = linesHtml as string; works properly.

The reason for this is, that the casting trick through unknown requires the variable type to be exactly TrustedHTML (and it's an union in your case).

@jrieken
Copy link
Author

jrieken commented Nov 30, 2020

Assignment element.innerHTML = linesHtml as string; works properly.

Pretty sure that I have tried this but without success. Tho, I might have been on a wrong version of tsec - the yarn upgrade trick seems to be buggy and we are kinda desperate for #17. Folks keep getting a wrong version of tsec and aren't happy with tsec at all

@engelsdamien
Copy link

I think I figured it out. The latest version of tsec seems to have lost the postinstall script that allows it to build, so even with the upgrade, it is still running old code. I've raised the issue internally and we'll work on a fix.

@jrieken
Copy link
Author

jrieken commented Dec 9, 2020

Oh, that explains a lot

@uraj uraj closed this as completed Dec 31, 2020
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

4 participants