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
6 changes: 6 additions & 0 deletions crates/oxc_transformer/src/jsx/diagnostics.rs
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
use oxc_diagnostics::OxcDiagnostic;
use oxc_span::Span;

#[cold]
pub fn pragma_and_pragma_frag_cannot_be_set() -> OxcDiagnostic {
OxcDiagnostic::warn("pragma and pragmaFrag cannot be set when runtime is automatic.")
.with_help("Remove `pragma` and `pragmaFrag` options.")
}

#[cold]
pub fn invalid_pragma() -> OxcDiagnostic {
OxcDiagnostic::warn("pragma and pragmaFrag must be of the form `foo` or `foo.bar`.")
.with_help("Fix `pragma` and `pragmaFrag` options.")
}

#[cold]
pub fn import_source_cannot_be_set() -> OxcDiagnostic {
OxcDiagnostic::warn("importSource cannot be set when runtime is classic.")
.with_help("Remove `importSource` option.")
}

#[cold]
pub fn invalid_import_source() -> OxcDiagnostic {
OxcDiagnostic::warn("importSource cannot be an empty string or longer than u32::MAX bytes")
.with_help("Fix `importSource` option.")
}

#[cold]
pub fn namespace_does_not_support(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Namespace tags are not supported by default. React's JSX doesn't support namespace tags. You can set `throwIfNamespace: false` to bypass this warning.")
.with_label(span)
}

#[cold]
pub fn valueless_key(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Please provide an explicit key value. Using \"key\" as a shorthand for \"key={true}\" is not allowed.")
.with_label(span)
Expand Down
5 changes: 5 additions & 0 deletions crates/oxc_transformer/src/typescript/diagnostics.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use oxc_diagnostics::OxcDiagnostic;
use oxc_span::Span;

#[cold]
pub fn import_equals_cannot_be_used_in_esm(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Import assignment cannot be used when targeting ECMAScript modules.")
.with_help(
Expand All @@ -11,23 +12,27 @@ pub fn import_equals_cannot_be_used_in_esm(span: Span) -> OxcDiagnostic {
.with_error_code("TS", "1202")
}

#[cold]
pub fn export_assignment_cannot_bed_used_in_esm(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Export assignment cannot be used when targeting ECMAScript modules.")
.with_help("Consider using 'export default' or another module format instead.")
.with_label(span)
.with_error_code("TS", "1203")
}

#[cold]
pub fn ambient_module_nested(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Ambient modules cannot be nested in other modules or namespaces.")
.with_label(span)
}

#[cold]
pub fn namespace_exporting_non_const(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Namespaces exporting non-const are not supported by Babel. Change to const or see: https://babeljs.io/docs/en/babel-plugin-transform-typescript")
.with_label(span)
}

#[cold]
pub fn namespace_not_supported(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Namespace not marked type-only declare. Non-declarative namespaces are only supported experimentally in Babel. To enable and review caveats see: https://babeljs.io/docs/en/babel-plugin-transform-typescript")
.with_label(span)
Expand Down
Loading