-
Notifications
You must be signed in to change notification settings - Fork 17
fix: don't remove namespaced imports if they are external #112
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
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 9428527 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I approved this before running the tests... it's failing because on older versions of TypeScript this gets generated:
declare module 'import-external-all-as' {
import * as v from 'all-as-external';
/// <reference path="external.d.ts" />
export const Schema: v.BaseType<string>;
export type Test = v.Infer<typeof Schema>;
export {};
}
//# sourceMappingURL=index.d.ts.map
Is that harmless to leave in or does it need to be stripped out?
Mmm i suppose is harmless and i think it's only generated in this case because i'm using the external.d.ts to show the result...let me check quickly |
So testing with an actual library the path is not generated...however someone might actually do this? In theory the reference comment should be at the top of the file but i don't know how TS will behave if it finds one in a weird place and i don't know if we can just remove it without causing problems...let me test a bit |
I think the right move is to move them at the top of the
WDYT? |
Even tho reading at the reason they removed them i would say we can go the typescript route and just remove them 😄 |
Mmm on a second thought: I think if we do encounter such behaviour we should probably bundle that reference too. For libraries it's fine because if they are part of your api you should include them as a dependency so even the host project it should resolve that name. But if you do the same degenerate thing i did here (create a .d.ts that declare a module) for some reason then that module will not be available in the host project if we don't bundle it. This kinda opened a can of worms 🪱 |
I've added a declaration file for
all-as-external
in the test because otherwise the fix was not really visible (i didn't useexternal
or it would've effected the other tests)