Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/oxc_codegen/tests/integration/esbuild.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
13 changes: 7 additions & 6 deletions crates/oxc_span/src/source_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
/// ```
Expand All @@ -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,
}
}
Expand All @@ -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());
/// ```
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Loading