mirror of
https://github.com/danbulant/oxc
synced 2026-05-25 04:42:10 +00:00
feat(transformer/typescript): report error for namespace exporting non-const (#3447)
This commit is contained in:
parent
150255c704
commit
a6b073a47c
3 changed files with 16 additions and 4 deletions
|
|
@ -15,3 +15,8 @@ pub fn ambient_module_nested(span0: Span) -> OxcDiagnostic {
|
|||
OxcDiagnostic::warn("Ambient modules cannot be nested in other modules or namespaces.")
|
||||
.with_label(span0)
|
||||
}
|
||||
|
||||
pub fn namespace_exporting_non_const(span0: 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(span0)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
use rustc_hash::FxHashSet;
|
||||
|
||||
use super::{diagnostics::ambient_module_nested, TypeScript};
|
||||
use super::{
|
||||
diagnostics::{ambient_module_nested, namespace_exporting_non_const},
|
||||
TypeScript,
|
||||
};
|
||||
|
||||
use oxc_allocator::{Box, Vec};
|
||||
use oxc_ast::{ast::*, syntax_directed_operations::BoundNames};
|
||||
|
|
@ -238,6 +241,11 @@ impl<'a> TypeScript<'a> {
|
|||
);
|
||||
}
|
||||
Declaration::VariableDeclaration(var_decl) => {
|
||||
var_decl.declarations.iter().for_each(|decl| {
|
||||
if !decl.kind.is_const() {
|
||||
self.ctx.error(namespace_exporting_non_const(decl.span));
|
||||
}
|
||||
});
|
||||
is_empty = false;
|
||||
let stmts = self.handle_variable_declaration(var_decl, &name);
|
||||
new_stmts.extend(stmts);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
commit: 4bd1b2c2
|
||||
|
||||
Passed: 473/930
|
||||
Passed: 474/930
|
||||
|
||||
# All Passed:
|
||||
* babel-preset-react
|
||||
|
|
@ -445,13 +445,12 @@ Passed: 473/930
|
|||
* opts/optimizeConstEnums/input.ts
|
||||
* opts/rewriteImportExtensions/input.ts
|
||||
|
||||
# babel-plugin-transform-typescript (130/154)
|
||||
# babel-plugin-transform-typescript (131/154)
|
||||
* enum/mix-references/input.ts
|
||||
* enum/ts5.0-const-foldable/input.ts
|
||||
* exports/declared-types/input.ts
|
||||
* imports/type-only-export-specifier-2/input.ts
|
||||
* namespace/empty-removed/input.ts
|
||||
* namespace/mutable-fail/input.ts
|
||||
* namespace/namespace-flag/input.ts
|
||||
* namespace/nested/input.ts
|
||||
* namespace/nested-destructuring/input.ts
|
||||
|
|
|
|||
Loading…
Reference in a new issue