[babel-plugin] TypeScript types are wrong
Describe the issue
The resolved types use export default where the JavaScript file appears to use module.exports =. This will cause TypeScript under the node16 module mode to think an extra .default property access is required, but that will likely fail at runtime.
Expected behavior
These types should use export = instead of export default.
Steps to reproduce
See https://arethetypeswrong.github.io/?p=%40stylexjs%2Fbabel-plugin%400.10.1
Test case
No response
Additional comments
No response
Just noticed this myself. Thanks, also following this issue.
I spent some time understanding this issue, here are my findings
Since output generated is in cjs format it results in module.exports output. d.ts file should have typescript export = instead of export default since output is cjs.
The functionality which generates the types today ( .js -> .flow -> .d.ts ) there is no way for us to tell translateFlowDefToTSDef to use export = instead of export default
I tried changing export in index.js from export default to common js module.exports but it throws error in translateFlowDefToTSDef method.
@jfirebaugh @nmn
This is a bug in the flow-api-translator package due to differences in how Flow and Typescript.
The easiest fix would be to add a manual .d.ts file. Our script already prioritize those when they exist.
I created another slight-related issue because the TypeScript types appear to be super invalid beyond what is discussed here.
https://github.com/facebook/stylex/issues/969