Skip to content

Commit 52f2a40

Browse files
committed
fix(span/estree): skip ModuleKind::Unambiguous varient for estree (#10146)
close: #10139 The `ModuleKind::Unambiguous` can only occur in the parser stage, after being parsed, the `ModuleKind` certainly changes to `ModuleKind::Script` or `ModuleKind::Module`; otherwise is a bug in the parser.
1 parent 55b7b87 commit 52f2a40

File tree

5 files changed

+3
-6
lines changed

5 files changed

+3
-6
lines changed

crates/oxc_span/src/generated/derive_estree.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl ESTree for ModuleKind {
3333
match self {
3434
Self::Script => JsonSafeString("script").serialize(serializer),
3535
Self::Module => JsonSafeString("module").serialize(serializer),
36-
Self::Unambiguous => JsonSafeString("unambiguous").serialize(serializer),
36+
Self::Unambiguous => unreachable!("This enum variant is skipped."),
3737
}
3838
}
3939
}

crates/oxc_span/src/source_type/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ pub enum ModuleKind {
5858
/// Note2: Dynamic import expression is not ESM syntax.
5959
///
6060
/// See <https://babel.dev/docs/options#misc-options>
61+
#[estree(skip)]
6162
Unambiguous = 2,
6263
}
6364

napi/parser/deserialize-js.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4122,8 +4122,6 @@ function deserializeModuleKind(pos) {
41224122
return 'script';
41234123
case 1:
41244124
return 'module';
4125-
case 2:
4126-
return 'unambiguous';
41274125
default:
41284126
throw new Error(`Unexpected discriminant ${uint8[pos]} for ModuleKind`);
41294127
}

napi/parser/deserialize-ts.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4197,8 +4197,6 @@ function deserializeModuleKind(pos) {
41974197
return 'script';
41984198
case 1:
41994199
return 'module';
4200-
case 2:
4201-
return 'unambiguous';
42024200
default:
42034201
throw new Error(`Unexpected discriminant ${uint8[pos]} for ModuleKind`);
42044202
}

npm/oxc-types/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,7 @@ export interface Span {
14841484
end: number;
14851485
}
14861486

1487-
export type ModuleKind = 'script' | 'module' | 'unambiguous';
1487+
export type ModuleKind = 'script' | 'module';
14881488

14891489
export interface Pattern extends Span {
14901490
type: 'Pattern';

0 commit comments

Comments
 (0)