Closed
Description
Suggestion
✅ Viability Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
⭐ Suggestion
It is not allowed merging namespace with variables. But, in some cases, it should be when the value itself is a allowed merging.
This is allowed:
function foo() {
// ...
}
namespace foo {
export const bar = 'bar'
}
class Foo {
// ...
}
namespace Foo {
export const bar = 'bar'
}
But this is not:
const foo = function() {
// ...
}
namespace foo {
export const bar = 'bar'
}
const Foo = class {
// ...
}
namespace Foo {
export const bar = 'bar'
}
As class A {...
and const A = class {...
are equivalent, it should compile with no erros.