fromdeno / deno2node

Compile your Deno project to run on Node.js.
MIT License
115 stars 3 forks source link

Rewrite args parsing to use cliffy #22

Closed KnorpelSenf closed 2 years ago

KnorpelSenf commented 2 years ago

Towards #20.

KnorpelSenf commented 2 years ago

The fix in 36f42eefa11b3def055cdfac690afba99ae862ed uses getLocals which is documented as brittle. However, I did not find another way to obtain variable declarations from object binding patters such as const { Deno } = globalThis;. I trust E2E tests enough that this should work in the long run.

In addition, the declared locals include type declarations, not only variables. Is this desired? What if we declare an interface, and then shim a function with the same name? I think we then skip the shimming, however, those two declarations do not actually clash. Can this cause a problem?

KnorpelSenf commented 2 years ago

What if we declare an interface, and then shim a function with the same name?

TypeScript will report a conflicting definition, same as before this PR.

Did you test this? Because I am able to

interface A {}
const A = 0

and the code compiles.

wojpawlik commented 2 years ago

Yes I did: https://github.com/microsoft/TypeScript/issues/37712

KnorpelSenf commented 2 years ago

Understood. Merging.