diff --git a/crates/oxc_codegen/tests/integration/esbuild.rs b/crates/oxc_codegen/tests/integration/esbuild.rs index 68442b099ee32..b967ae8776f34 100644 --- a/crates/oxc_codegen/tests/integration/esbuild.rs +++ b/crates/oxc_codegen/tests/integration/esbuild.rs @@ -409,11 +409,11 @@ fn test_template() { test("let x = `$\\{y}`", "let x = `$\\{y}`;\n"); test("await tag`x`", "await tag`x`;\n"); - test("await (tag`x`)", "await tag`x`;\n"); + test("await (tag`x`)", "await(tag`x`);\n"); test("(await tag)`x`", "(await tag)`x`;\n"); test("await tag`${x}`", "await tag`${x}`;\n"); - test("await (tag`${x}`)", "await tag`${x}`;\n"); + test("await (tag`${x}`)", "await(tag`${x}`);\n"); test("(await tag)`${x}`", "(await tag)`${x}`;\n"); test("new tag`x`", "new tag`x`();\n"); diff --git a/crates/oxc_span/src/source_type.rs b/crates/oxc_span/src/source_type.rs index e93c2caa15332..2eef7e0d8754f 100644 --- a/crates/oxc_span/src/source_type.rs +++ b/crates/oxc_span/src/source_type.rs @@ -307,8 +307,9 @@ impl SourceType { /// Creates a [`SourceType`] representing a [`TypeScript`] file. /// - /// Unlike [`SourceType::cjs`], this method creates [`modules`]. Use - /// [`SourceType::tsx`] for TypeScript files with [`JSX`] support. + /// This method creates an [`unambiguous`] source type, which will be + /// treated as a module if it contains ESM syntax. Use [`SourceType::tsx`] + /// for TypeScript files with [`JSX`] support. /// /// ## Example /// ``` @@ -317,17 +318,17 @@ impl SourceType { /// let ts = SourceType::ts(); /// assert!(ts.is_typescript()); /// assert!(!ts.is_typescript_definition()); - /// assert!(ts.is_module()); + /// assert!(ts.is_unambiguous()); /// assert!(!ts.is_jsx()); /// ``` /// /// [`TypeScript`]: Language::TypeScript - /// [`modules`]: ModuleKind::Module + /// [`unambiguous`]: ModuleKind::Unambiguous /// [`JSX`]: LanguageVariant::Jsx pub const fn ts() -> Self { Self { language: Language::TypeScript, - module_kind: ModuleKind::Module, + module_kind: ModuleKind::Unambiguous, variant: LanguageVariant::Standard, } } @@ -341,7 +342,7 @@ impl SourceType { /// let tsx = SourceType::tsx(); /// assert!(tsx.is_typescript()); /// assert!(!tsx.is_typescript_definition()); - /// assert!(tsx.is_module()); + /// assert!(tsx.is_unambiguous()); /// assert!(tsx.is_jsx()); /// ``` /// diff --git a/crates/oxc_transformer_plugins/tests/integrations/replace_global_defines.rs b/crates/oxc_transformer_plugins/tests/integrations/replace_global_defines.rs index e181287f638f7..ebff808d7d5e4 100644 --- a/crates/oxc_transformer_plugins/tests/integrations/replace_global_defines.rs +++ b/crates/oxc_transformer_plugins/tests/integrations/replace_global_defines.rs @@ -11,7 +11,7 @@ use crate::codegen; #[track_caller] pub fn test(source_text: &str, expected: &str, config: &ReplaceGlobalDefinesConfig) { - let source_type = SourceType::ts(); + let source_type = SourceType::ts().with_module(true); let allocator = Allocator::default(); let ret = Parser::new(&allocator, source_text, source_type).parse(); assert!(ret.errors.is_empty());