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

be conservative or reject code we can't make safe #76

Open
fergald opened this issue Sep 10, 2019 · 0 comments
Open

be conservative or reject code we can't make safe #76

fergald opened this issue Sep 10, 2019 · 0 comments

Comments

@fergald
Copy link
Collaborator

fergald commented Sep 10, 2019

function f(arg) {
  if (!arg) {
    arg = document.createElement("div");
  }
  arg.scrollIntoView();
}

is currently rewritten to

    import { createElement as Document_createElement } from "std:global/Document";
    import { apply as Reflect_apply } from "std:global/Reflect";
    import { document_get as Window_document_get } from "std:global/Window";
    function f(arg) {
        if (!arg) {
            arg = Reflect_apply(Document_createElement, Window_document_get(), ["div"]);
        }
        arg.scrollIntoView();
    }

I think ts-morph gives us enough info to know that arg is HTMLDivElement|Any and so we should either be conservative and rewrite it to be assume the worse case (HTMLDivElement) or refuse to rewrite it.

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

1 participant