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_transformer/src/typescript/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ pub fn ambient_module_nested(span: Span) -> OxcDiagnostic {

#[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")
OxcDiagnostic::warn("Namespaces exporting non-const are not supported by Oxc. Change to const or see: https://oxc.rs/docs/guide/usage/transformer/typescript.html#partial-namespace-support")
.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")
OxcDiagnostic::warn("Namespace not marked type-only declare are disabled. To enable and review caveats see: https://oxc.rs/docs/guide/usage/transformer/typescript.html#partial-namespace-support")
.with_label(span)
}
39 changes: 24 additions & 15 deletions napi/transform/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export declare function isolatedDeclarationSync(filename: string, sourceText: st
/**
* Configure how TSX and JSX are transformed.
*
* @see {@link https://babeljs.io/docs/babel-plugin-transform-react-jsx#options}
* @see {@link https://oxc.rs/docs/guide/usage/transformer/jsx}
*/
export interface JsxOptions {
/**
Expand All @@ -201,8 +201,6 @@ export interface JsxOptions {
* Emit development-specific information, such as `__source` and `__self`.
*
* @default false
*
* @see {@link https://babeljs.io/docs/babel-plugin-transform-react-jsx-development}
*/
development?: boolean
/**
Expand All @@ -216,11 +214,7 @@ export interface JsxOptions {
*/
throwIfNamespace?: boolean
/**
* Enables `@babel/plugin-transform-react-pure-annotations`.
*
* It will mark JSX elements and top-level React method calls as pure for tree shaking.
*
* @see {@link https://babeljs.io/docs/en/babel-plugin-transform-react-pure-annotations}
* Mark JSX elements and top-level React method calls as pure for tree shaking.
*
* @default true
*/
Expand Down Expand Up @@ -342,7 +336,7 @@ export interface ReactRefreshOptions {
/**
* Configure how styled-components are transformed.
*
* @see {@link https://styled-components.com/docs/tooling#babel-plugin}
* @see {@link https://oxc.rs/docs/guide/usage/transformer/plugins#styled-components}
*/
export interface StyledComponentsOptions {
/**
Expand Down Expand Up @@ -461,9 +455,15 @@ export interface TransformOptions {
sourcemap?: boolean
/** Set assumptions in order to produce smaller output. */
assumptions?: CompilerAssumptions
/** Configure how TypeScript is transformed. */
/**
* Configure how TypeScript is transformed.
* @see {@link https://oxc.rs/docs/guide/usage/transformer/typescript}
*/
typescript?: TypeScriptOptions
/** Configure how TSX and JSX are transformed. */
/**
* Configure how TSX and JSX are transformed.
* @see {@link https://oxc.rs/docs/guide/usage/transformer/jsx}
*/
jsx?: 'preserve' | JsxOptions
/**
* Sets the target environment for the generated JavaScript.
Expand All @@ -477,18 +477,27 @@ export interface TransformOptions {
*
* @default `esnext` (No transformation)
*
* @see [esbuild#target](https://esbuild.github.io/api/#target)
* @see {@link https://oxc.rs/docs/guide/usage/transformer/lowering#target}
*/
target?: string | Array<string>
/** Behaviour for runtime helpers. */
helpers?: Helpers
/** Define Plugin */
/**
* Define Plugin
* @see {@link https://oxc.rs/docs/guide/usage/transformer/global-variable-replacement#define}
*/
define?: Record<string, string>
/** Inject Plugin */
/**
* Inject Plugin
* @see {@link https://oxc.rs/docs/guide/usage/transformer/global-variable-replacement#inject}
*/
inject?: Record<string, string | [string, string]>
/** Decorator plugin */
decorator?: DecoratorOptions
/** Third-party plugins to use. */
/**
* Third-party plugins to use.
* @see {@link https://oxc.rs/docs/guide/usage/transformer/plugins}
*/
plugins?: PluginsOptions
}

Expand Down
19 changes: 9 additions & 10 deletions napi/transform/src/transformer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,11 @@ pub struct TransformOptions {
pub assumptions: Option<CompilerAssumptions>,

/// Configure how TypeScript is transformed.
/// @see {@link https://oxc.rs/docs/guide/usage/transformer/typescript}
pub typescript: Option<TypeScriptOptions>,

/// Configure how TSX and JSX are transformed.
/// @see {@link https://oxc.rs/docs/guide/usage/transformer/jsx}
#[napi(ts_type = "'preserve' | JsxOptions")]
pub jsx: Option<Either<String, JsxOptions>>,

Expand All @@ -128,24 +130,27 @@ pub struct TransformOptions {
///
/// @default `esnext` (No transformation)
///
/// @see [esbuild#target](https://esbuild.github.io/api/#target)
/// @see {@link https://oxc.rs/docs/guide/usage/transformer/lowering#target}
pub target: Option<Either<String, Vec<String>>>,

/// Behaviour for runtime helpers.
pub helpers: Option<Helpers>,

/// Define Plugin
/// @see {@link https://oxc.rs/docs/guide/usage/transformer/global-variable-replacement#define}
#[napi(ts_type = "Record<string, string>")]
pub define: Option<FxHashMap<String, String>>,

/// Inject Plugin
/// @see {@link https://oxc.rs/docs/guide/usage/transformer/global-variable-replacement#inject}
#[napi(ts_type = "Record<string, string | [string, string]>")]
pub inject: Option<FxHashMap<String, Either<String, Vec<String>>>>,

/// Decorator plugin
pub decorator: Option<DecoratorOptions>,

/// Third-party plugins to use.
/// @see {@link https://oxc.rs/docs/guide/usage/transformer/plugins}
pub plugins: Option<PluginsOptions>,
}

Expand Down Expand Up @@ -397,7 +402,7 @@ impl From<DecoratorOptions> for oxc::transformer::DecoratorOptions {

/// Configure how styled-components are transformed.
///
/// @see {@link https://styled-components.com/docs/tooling#babel-plugin}
/// @see {@link https://oxc.rs/docs/guide/usage/transformer/plugins#styled-components}
#[napi(object)]
#[derive(Default)]
pub struct StyledComponentsOptions {
Expand Down Expand Up @@ -507,7 +512,7 @@ impl From<StyledComponentsOptions> for oxc::transformer::StyledComponentsOptions

/// Configure how TSX and JSX are transformed.
///
/// @see {@link https://babeljs.io/docs/babel-plugin-transform-react-jsx#options}
/// @see {@link https://oxc.rs/docs/guide/usage/transformer/jsx}
#[napi(object)]
pub struct JsxOptions {
/// Decides which runtime to use.
Expand All @@ -522,8 +527,6 @@ pub struct JsxOptions {
/// Emit development-specific information, such as `__source` and `__self`.
///
/// @default false
///
/// @see {@link https://babeljs.io/docs/babel-plugin-transform-react-jsx-development}
pub development: Option<bool>,

/// Toggles whether or not to throw an error if an XML namespaced tag name
Expand All @@ -535,11 +538,7 @@ pub struct JsxOptions {
/// @default true
pub throw_if_namespace: Option<bool>,

/// Enables `@babel/plugin-transform-react-pure-annotations`.
///
/// It will mark JSX elements and top-level React method calls as pure for tree shaking.
///
/// @see {@link https://babeljs.io/docs/en/babel-plugin-transform-react-pure-annotations}
/// Mark JSX elements and top-level React method calls as pure for tree shaking.
///
/// @default true
pub pure: Option<bool>,
Expand Down
2 changes: 1 addition & 1 deletion tasks/coverage/snapshots/semantic_babel.snap
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ after transform: ScopeId(0): ["foo"]
rebuilt : ScopeId(0): []

semantic Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/scope/namespace-declaration-var-2/input.js
Namespaces exporting non-const are not supported by Babel. Change to const or see: https://babeljs.io/docs/en/babel-plugin-transform-typescript
Namespaces exporting non-const are not supported by Oxc. Change to const or see: https://oxc.rs/docs/guide/usage/transformer/typescript.html#partial-namespace-support

semantic Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-class-interface/input.ts
Bindings mismatch:
Expand Down
Loading
Loading