Skip to content

Commit

Permalink
fix estree plugin type declaration (#15018)
Browse files Browse the repository at this point in the history
Co-authored-by: fisker Cheung <lionkay@gmail.com>
  • Loading branch information
kingyue737 and fisker committed Jul 7, 2023
1 parent e2f4ce3 commit 7543021
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions changelog_unreleased/api/15018.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#### Fix plugins/estree.d.ts to make it a module (#15018 by @kingyue737)

Add `export {}` in `plugins/estree.d.ts` to fix the "File is not a module" error
8 changes: 4 additions & 4 deletions scripts/build/build-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ async function buildPluginTypes({ file: { input, output } }) {
const parserNames = Object.keys(plugin.parsers ?? {});

// We only add `parsers` to types file, printers should not be used alone
// For `estree` plugin, we just write an empty file
// For `estree` plugin, we just export an empty object to ensure it treated as a module
const code =
parserNames.length === 0
? ""
? "export {};"
: outdent`
import { Parser } from "../index.js";
Expand All @@ -52,10 +52,10 @@ async function buildPluginTypes({ file: { input, output } }) {
`${" ".repeat(2)}${toPropertyKey(parserName)}: Parser;`,
)
.join("\n")}
};\n
};
`;

await writeFile(path.join(DIST_DIR, output.file), code);
await writeFile(path.join(DIST_DIR, output.file), `${code}\n`);
}

function buildTypes(options) {
Expand Down

0 comments on commit 7543021

Please sign in to comment.