-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Ensure moduleType is structured during cloneTypeAsModuleType #51136
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
We should probably just |
That does change: import * as exportSymbol from "./exportSymbol.cjs";
->exportSymbol : symbol
+>exportSymbol : { toString(): string; valueOf(): symbol; readonly description: string | undefined; [Symbol.toPrimitive](hint: string): symbol; readonly [Symbol.toStringTag]: string; } But it unfortunately still makes |
Hm. Yeah, makes sense I guess, since |
In #51099 the goal is to actually make the import The weird thing is that this code already will return any of those non-structured types, it's just that in the special condition of |
If that’s the goal, I don’t think it’s a goal we should support. Whatever is the target of So I think it stands to reason if you |
Aside from the crash, our checking for this appears to be super wrong right now. |
Yeah. I'm not super familiar, but it seemed suspect. I just don't know quite what the intended behavior is here. I could reasonably remove the debug check and allow this code to proceed as it did before, if the answer isn't obvious. Maybe we need the real example to provide an alternative? @dsherret |
It seems doing It's been used for some time in Deno when the types of a module can't be resolved in certain cases in order to have an
Resolving that to instead a Edit: For now what I've done is ignored these diagnostics. Edit 2: No, this was not sufficient. The real issue/fix was #51321
That makes sense to me. Edit: actually, maybe not. See two comments below. |
Out of curiosity, is it possible to instead ignore the "missing types" error on the module, rather than hiding the errors in the library itself? |
@andrewbranch actually, I think this should be the |
I mean, sure, you can’t prove that |
@andrewbranch it could be defined that way, but I think it would be nice if an I also can't think of another way that typescript could be used to allow anything to be used on an import declaration, or is there? |
I guess you’d have to assign or cast to |
I mean, without affecting the importing code Anyway, it seems inconsistent for |
Actually, I've discovered that #51321 is our main issue in Deno (related to the diagnostics I was getting earlier, but didn't investigate until now), so I don't really mind whatever is decided here for |
…y of that type instead
I've revived this PR with the approach suggested in #51136 (comment), which makes the type match what we get at runtime; see |
Fixes #51099