-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
Milestone
Description
Bug Report
🔎 Search Terms
- javascript
- static class property
- assign outside of the class body
- declaration
- namespace
- read-only
- allowJs
🕗 Version & Regression Information
- This is the behavior in every version I tried (4.9.5 and 5.1.0-dev.20230227), and I reviewed the FAQ for entries.
⏯ Playground Link
For some reason, there is no assert emitted in the workbench. But it's emitted when you run tsc
manually.
Workbench link with relevant code
💻 Code
// @declaration
// @emitDeclarationOnly
// @filename: Foo.js
class Base {
static foo = '';
}
export class Foo extends Base {}
Foo.foo = 'foo';
// @filename: Bar.ts
import { Foo } from './Foo.js';
class Bar extends Foo {}
Bar.foo = 'foo';
🙁 Actual behavior
Here is generated FooJS.d.ts
:
export class FooJS extends BaseJS {
}
export namespace FooJS {
const foo: string;
}
declare class BaseJS {
static foo: string;
}
export {};
There shouldn't be a namespace because foo
is inherited static property.
We got error TS2540: Cannot assign to 'foo' because it is a read-only property.
as a consequence.
This problem is only reproduced when emitting declarations for javascript files. For TS files it's OK - see workbench.
🙂 Expected behavior
Generated FooJS.d.ts
shouldn't contain namespace:
export class FooJS extends BaseJS {
}
declare class BaseJS {
static foo: string;
}
export {};
foxeyes and robpalmerobpalme