Add oxc-ts parser (#17483)

This commit is contained in:
fisker Cheung authored and GitHub committed 2025-05-27 13:32:23 +08:00
1 parent 3c1475b1e7
commit 9e814108ca
57 files changed
+545 -63

No files matched your search

+15 -7
View File
@@ -97,6 +97,12 @@ const oxcDisabledTests = new Set(
"js/ignore/class-expression-decorator.js",
].map((file) => path.join(__dirname, "../format", file)),
);
const oxcTsDisabledTests = new Set(
[
// https://github.com/oxc-project/oxc/issues/11029
"typescript/decorators/abstract-method.ts",
].map((file) => path.join(__dirname, "../format", file)),
);
const isUnstable = (filename, options) => {
const testFunction = unstableTests.get(filename);
@@ -255,12 +261,13 @@ function runFormatTest(fixtures, parsers, options) {
}
}
if (
parsers.includes("typescript") &&
!parsers.includes("babel-ts") &&
!IS_TYPESCRIPT_ONLY_TEST
) {
allParsers.push("babel-ts");
if (parsers.includes("typescript") && !IS_TYPESCRIPT_ONLY_TEST) {
if (!parsers.includes("babel-ts")) {
allParsers.push("babel-ts");
}
if (!parsers.includes("oxc-ts")) {
allParsers.push("oxc-ts");
}
}
if (parsers.includes("flow") && !parsers.includes("babel-flow")) {
@@ -306,6 +313,7 @@ function runFormatTest(fixtures, parsers, options) {
(currentParser === "espree" && espreeDisabledTests.has(filename)) ||
(currentParser === "meriyah" && meriyahDisabledTests.has(filename)) ||
(currentParser === "oxc" && oxcDisabledTests.has(filename)) ||
(currentParser === "oxc-ts" && oxcTsDisabledTests.has(filename)) ||
(currentParser === "babel-ts" && babelTsDisabledTests.has(filename))
) {
continue;
@@ -554,7 +562,7 @@ async function format(originalText, originalOptions) {
}
async function loadPlugins(options) {
if (options.parser === "oxc") {
if (options.parser === "oxc" || options.parser === "oxc-ts") {
const plugins = options.plugins ?? [];
const url = new URL(
isProduction
+4 -3
View File
@@ -57,13 +57,14 @@ const categoryParsers = new Map([
[
"js",
{
parsers: ["babel", "acorn", "espree", "meriyah", "oxc"],
parsers: ["babel", "acorn", "espree", "meriyah", "oxc", "oxc-ts"],
verifyParsers: [
"babel",
"acorn",
"espree",
"meriyah",
"oxc",
"oxc-ts",
"flow",
"babel-flow",
"typescript",
@@ -133,8 +134,8 @@ const categoryParsers = new Map([
[
"typescript",
{
parsers: ["typescript", "babel-ts"],
verifyParsers: ["typescript", "babel-ts", "flow", "babel-flow"],
parsers: ["typescript", "babel-ts", "oxc-ts"],
verifyParsers: ["typescript", "babel-ts", "flow", "babel-flow", "oxc-ts"],
extensions: [".ts", ".tsx", ".cts", ".mts"],
},
],