-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Declare createSynchronizedPrettier
as only named export
#12
base: main
Are you sure you want to change the base?
Conversation
Includes type discovery and autocomplete in `test.js` too
For example Prettier uses `export {}`
@@ -36,7 +36,7 @@ test("version", () => { | |||
fakePrettierUrl.href, | |||
fileURLToPath(fakePrettierUrl), | |||
]) { | |||
test(prettierEntry, async () => { | |||
test(prettierEntry.toString(), async () => { |
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.
The compiler flagged this line because test()
only accepts string
not URL
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 see what you’re trying to do, but I’m not sure if there is a proper way to do this correctly.
Interestingly, this works, but it relies on errors in the local type definitions:
// @ts-expect-error
declare const synchronizedPrettier: SynchronizedPrettier;
// @ts-expect-error
declare namespace synchronizedPrettier {
function createSynchronizedPrettier(options: {
prettierEntry: string | URL;
}): SynchronizedPrettier
}
867d27c
to
bb011b8
Compare
Updates types to show that `createSynchronizedPrettier` is the only ESM named export to ensure TypeScript throws errors for invalid named exports such as: ``` import { format } from '@prettier/sync' ```
bb011b8
to
308ba4c
Compare
As discussed in alphagov/govuk-frontend#3971 (comment)
@prettier/sync
doesn't support named exports:This PR updates the type declarations to show that
I've also updated the tsconfig.json file so local
test.js
imports are checked too