mockdeep / typewiz

Automatically discover and add missing types in your TypeScript code
https://medium.com/@urish/manual-typing-is-no-fun-introducing-typewiz-58e3e8813f4c
1.1k stars 46 forks source link

typewiz-node annotating types at wrong offsets in files (but only when separating application from collection) #90

Closed zxti closed 5 years ago

zxti commented 5 years ago

Hello, I have created a simple minimal repo here to repro this issue:

https://github.com/zxti/simple-node-typewiz-repro

Basically, just run:

yarn
yarn ts-node run.js
yarn typewiz applyTypes collected-types.json
cat a.ts

And you will see this:

export function greet(who) {
  return `hello ${who}`;
}
: string

The run.js is from https://github.com/urish/typewiz-node-no-apply (via #87), and the problem only appears this way.

For some reason I do not see anything wrong when just running typewiz-node directly, so I may very well be doing something wrong here:

yarn typewiz-node b.ts

But (per #87) I'm interested in not immediately applying types....

urish commented 5 years ago

Thanks for reporting!

I couldn't reproduce, though, I did one step differently: node run.js instead of using ts-node.

Here is the content of my collected-types.json:

[["C:/P/simple-node-typewiz-repro/a.ts",25,[["string",null]],{}]]

What does yours look like?

zxti commented 5 years ago

Oh, that works for me as well! I'm guessing there's some interference between ts-node and typewiz-node - maybe typewiz is instrumenting some transpiled version of the code that ts-node is handing it? I don't really know how node loaders compose. Closing as a non-issue, thank you.