babel-plugin-preval icon indicating copy to clipboard operation
babel-plugin-preval copied to clipboard

Writing preval files in TypeScript

Open alexgleason opened this issue 2 years ago • 2 comments

When using // @preval at the top of the file, it's first evaluated in Node.js. This means that TypeScript has no idea what's going on. If I leave these files as vanilla JS (.js) it's okay (the import gets an any type in TS), but then we don't get the advantages of TypeScript.

Can I write preval files themselves in TypeScript? Maybe with ts-node?

alexgleason avatar May 26 '22 20:05 alexgleason

@mpeyper since you converted this repo to TypeScript in #86... do you know if this is possible?

alexgleason avatar Nov 04 '22 17:11 alexgleason

Sorry, I’m not sure.

It might be possible to support processing of preval snippets with ts, but I think having the resulting types pass through to other code trying to use the output would be quite difficult, if not impossible.

mpeyper avatar Nov 04 '22 20:11 mpeyper