-
-
Notifications
You must be signed in to change notification settings - Fork 168
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
importing and exporting an interface fails for type module in package.json and ESXXXX module in tsconfig.json #272
Comments
This is expected behavior and is consistent with TypeScript:
The fix here is declaring that you're importing a type: import type { Interf } from './interf.js';
export type { Interf } |
Besides
The de-facto compiler and the only usable TS type checker, aka
|
Hey, you're coming on a little strong. When asking a stranger for help online, consider rephrasing your message to sound less accusatory. If you feel entitled to some kind of result, maybe you should at least support the project by contributing or sponsoring first. Happy to discuss the differences in what you're seeing if you edit your comment to be respectful. |
Apologies for that. Bear in mind that different people come from different backgrounds and various degrees of diversity. Not everyone speaks English as 1st language. I removed my opinion (and I made sure it was phrased as opinion) and kept the statements of fact. I am not asking for help, merely reporting a bug that I have encountered whilst trying to use For me it was very time consuming to detect the root cause and wrap up the minimum amount of code to reproduce this problem which is isolated to As a project maintainer you are entitled to do whatever you wish. However, people are also entitled to their opinions, particularly when that's supported by the behaviour of most tooling in this space. Overall, I understand your position. I stopped developing free software particularly due to people demanding that I'd implement things in my own projects based on their desired outcome and having to justify/defend why I made particular choices despite the project goals being clearly stated. I am making no such demands. |
The problem was the accusatory tone of your message that I'm being misleading, all while being misinformed. You filed an issue on the project to seek support so you're asking for help. If it was merely an FYI, you'd be ok with a closed issue + explanation. Instead, you argued back prompting for more explanation (basically more help). Anyway, here's why it's expected behavior: You're comparing a bundlers (tsc, esbuild, swc) to runtimes (tsx, ts-node w/ transpileOnly) which are completely different. Bundlers analyze relevant files when compiling a module. Runtimes don't have this advantage because modules are compiled in isolation. ts-node (without transpileOnly) compiles the entire project with tsc before running it, which is why it's slow. With Further explanation in esbuild: evanw/esbuild#1941 (comment) You might also be interested to learn the motivation for the From the PR microsoft/TypeScript#35200:
BTW, your esbuild snippet doesn't demonstrate anything if you don't share what you're compiling. A link to the esbuild REPL would've been more insightful. |
Bug description
I tried tsx against a codebase where an interface is imported by a module, then re-exported. Basically it fails with:
See linked gist with the minimal context to reproduce this issue.
This doesn't happen with
ts-node
in ESM mode nor withesbuild
. Basically, I piped theesbuild
's STDOUT tonode
's STDIN and the whole codebase runs as expected. So, this behaviour is particular totsx
.Basically, anything from ES2015 to ESNext compilerOptions module in tsconfig.json and package.json
"type": "module"
triggers this failure when importing and exporting an interface. It does not happen if it imports and exports a function for example.Reproduction
https://gist.github.com/stefanrusu-loctax/8e02e07bc18d00a29c33b045d93a15a9
Environment
Can you work on a fix?
The text was updated successfully, but these errors were encountered: