mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
fix(isolated-declarations): binding elements with export should report an error (#4025)
close: #3976
This commit is contained in:
parent
05a047c17d
commit
7c915f4665
3 changed files with 25 additions and 8 deletions
|
|
@ -49,13 +49,11 @@ impl<'a> IsolatedDeclarations<'a> {
|
||||||
check_binding: bool,
|
check_binding: bool,
|
||||||
) -> Option<VariableDeclarator<'a>> {
|
) -> Option<VariableDeclarator<'a>> {
|
||||||
if decl.id.kind.is_destructuring_pattern() {
|
if decl.id.kind.is_destructuring_pattern() {
|
||||||
if check_binding {
|
|
||||||
decl.id.bound_names(&mut |id| {
|
decl.id.bound_names(&mut |id| {
|
||||||
if self.scope.has_reference(&id.name) {
|
if !check_binding || self.scope.has_reference(&id.name) {
|
||||||
self.error(binding_element_export(id.span));
|
self.error(binding_element_export(id.span));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,3 +8,5 @@ export function foo(): number {
|
||||||
const { c, d } = { c: 1, d: 2 };
|
const { c, d } = { c: 1, d: 2 };
|
||||||
const [ e ] = [4];
|
const [ e ] = [4];
|
||||||
export { c, d, e }
|
export { c, d, e }
|
||||||
|
|
||||||
|
export const { f, g } = { f: 5, g: 6 };
|
||||||
|
|
@ -6,10 +6,27 @@ input_file: crates/oxc_isolated_declarations/tests/fixtures/non-exported-binding
|
||||||
|
|
||||||
export declare function foo(): number;
|
export declare function foo(): number;
|
||||||
export { c, d, e };
|
export { c, d, e };
|
||||||
|
export declare const;
|
||||||
|
|
||||||
|
|
||||||
==================== Errors ====================
|
==================== Errors ====================
|
||||||
|
|
||||||
|
x TS9019: Binding elements can't be exported directly with
|
||||||
|
| --isolatedDeclarations.
|
||||||
|
,-[12:16]
|
||||||
|
11 |
|
||||||
|
12 | export const { f, g } = { f: 5, g: 6 };
|
||||||
|
: ^
|
||||||
|
`----
|
||||||
|
|
||||||
|
x TS9019: Binding elements can't be exported directly with
|
||||||
|
| --isolatedDeclarations.
|
||||||
|
,-[12:19]
|
||||||
|
11 |
|
||||||
|
12 | export const { f, g } = { f: 5, g: 6 };
|
||||||
|
: ^
|
||||||
|
`----
|
||||||
|
|
||||||
x TS9019: Binding elements can't be exported directly with
|
x TS9019: Binding elements can't be exported directly with
|
||||||
| --isolatedDeclarations.
|
| --isolatedDeclarations.
|
||||||
,-[8:9]
|
,-[8:9]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue