Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
fix(noRedeclare): allow merging namespace + variable (#4772)
Browse files Browse the repository at this point in the history
  • Loading branch information
llllvvuu authored Aug 19, 2023
1 parent 85645de commit 9f3bbe9
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,28 @@ export namespace Orientation {
export function f(): void {}
}

// variable and namespace merging
declare namespace bodyParser {
interface BodyParser {
/** @deprecated */
(): void
}
interface Options {
inflate?: boolean | undefined
}
}
declare const bodyParser: bodyParser.BodyParser

namespace ConcreteNamespaceMergeVar {
export interface Foo {
foo: string
}
}

export const ConcreteNamespaceMergeVar = { foo: 'bar' }
ConcreteNamespaceMergeVar.foo = 'baz'
type Bar = ConcreteNamespaceMergeVar.Foo

// namespace merging
export namespace X {
export function f(): void {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: crates/rome_js_analyze/tests/spec_tests.rs
assertion_line: 91
assertion_line: 80
expression: valid-declaration-merging.ts
---
# Input
Expand Down Expand Up @@ -76,6 +76,28 @@ export namespace Orientation {
export function f(): void {}
}

// variable and namespace merging
declare namespace bodyParser {
interface BodyParser {
/** @deprecated */
(): void
}
interface Options {
inflate?: boolean | undefined
}
}
declare const bodyParser: bodyParser.BodyParser

namespace ConcreteNamespaceMergeVar {
export interface Foo {
foo: string
}
}

export const ConcreteNamespaceMergeVar = { foo: 'bar' }
ConcreteNamespaceMergeVar.foo = 'baz'
type Bar = ConcreteNamespaceMergeVar.Foo

// namespace merging
export namespace X {
export function f(): void {}
Expand Down
1 change: 1 addition & 0 deletions crates/rome_js_syntax/src/binding_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ impl AnyJsBindingDeclaration {
AnyJsBindingDeclaration::TsModuleDeclaration(_),
AnyJsBindingDeclaration::JsClassDeclaration(_)
| AnyJsBindingDeclaration::JsFunctionDeclaration(_)
| AnyJsBindingDeclaration::JsVariableDeclarator(_)
| AnyJsBindingDeclaration::TsDeclareFunctionDeclaration(_)
| AnyJsBindingDeclaration::TsEnumDeclaration(_)
| AnyJsBindingDeclaration::TsInterfaceDeclaration(_)
Expand Down

0 comments on commit 9f3bbe9

Please sign in to comment.