-
Notifications
You must be signed in to change notification settings - Fork 41
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
Doesn’t check that imports inside the package work #22
Comments
Not every problem is a module resolution / kind detection problem, and this doesn’t really try to go beyond module resolution at this point. What code is giving you an error? |
@andrewbranch just this import in
I have {
"include": ["test.ts"],
"compilerOptions": {
"target": "ESNext",
"module": "nodenext",
"moduleResolution": "nodenext",
"forceConsistentCasingInFileNames": true,
"strict": false,
"skipLibCheck": true
}
} |
Okay I had a wise idea, I figured out how to enable module resolution tracing and I think I figured out the problem:
The problem is the |
Ouch, yes indeed. Yeah, this kind of check is definitely on my radar. So far, none of the checks use the type checker, so things are pretty fast. This kind of analysis is basically just running tsc on the output, which will take a bit longer, but I think is worth it. Nice find! |
Ugh I would have caught the issue sooner if
|
I would likewise to see |
node16 === nodenext right now. |
nodenext
module resolution
Thank you, I didn't realize that. It's all green checkmarks on that package so I guess it's back to the drawing board for me. It's a great tool, thank you for building it. |
I think the issue you’re having is kind of visible in the tool by what’s not there. You also say in the issue that
But be aware that this is Node’s rule, not TypeScript’s, so if you were dealing with runtime imports rather than type-only ones, you would be getting rid of a compile-time error, but would crash at runtime. |
I really appreciate your expertise here. Thank you for shedding some light on the problem even though it's off-topic from what the original poster asked about. If I can ask you for your expert opinion, what do you think is the right way to resolve the issue I described so that I would be able to do a deep import? There are many types defined within the recesses of the package that I'd like to be able to access. With a little guidance I would be able to open a PR against the repo to try to encourage some progress from the Google team. |
I think it’s usually good for packages to block arbitrary deep imports, because it lets them define boundaries on their public API, and moving a file that’s supposed to be considered internal doesn’t need to be a breaking change. If those files contain types that are useful, the libraries just need to ensure those types get exported from one of the public API entrypoints. |
Great answer, thank you. |
When I check
[email protected]
it appears to show that everything is okay, and I can use that package withnode
module resolution. But when I try to use that package withnodenext
module resolution, I get errors likeModule '"antlr4"' has no exported member 'CommonTokenStream'.
CommonTokenStream
shows up in thenode16-esm
resolutions on arethetypeswrong so it seems like it may not be matching the behavior of tsc 5.0.3. That or maybe there's a bug in tsc? The docs don't make it very clear what I should expect tsc to do in this case.I haven't figured out what I would need to change in a PR to
antlr4
but I've been asking around. In addition to needing better package authoring guidance from the docs, it would be good if arethetypeswrong catches problems like this.The text was updated successfully, but these errors were encountered: