Closed
Description
TypeScript Version: 3.7-beta
Search Terms:
Mixin declaration
Code
The issue can be reproduced with the following files:
- timestamp.ts
export type Constructor<T = {}> = new (...args: any[]) => T;
export function Timestamped<TBase extends Constructor>(Base: TBase) {
return class extends Base {
timestamp = Date.now();
};
}
- user.ts
import { Timestamped } from './timestamp';
// Simple class
export class User {
name = '';
}
// User that is Timestamped
export class TimestampedUser extends Timestamped(User) {
constructor() {
super();
}
}
- tsconfig.json
{
"$schema": "http://json.schemastore.org/tsconfig",
"compilerOptions": {
"skipLibCheck": true,
"strict": true,
"incremental": false,
"lib": ["es2018"],
"module": "commonjs",
"moduleResolution": "node",
"target": "es2017",
"sourceMap": true,
// declaration true fails the compilation
"declaration": true,
"outDir": "dist",
"rootDir": "src"
},
"include": ["src"]
}
Expected behavior:
tsc -p tsconfig.json should be successful as TS 3.6.x does.
Actual behavior:
src/user.ts:9:38 - error TS4020: 'extends' clause of exported class 'TimestampedUser' has or is using private name '(Anonymous class)'.
9 export class TimestampedUser extends Timestamped(User) {
~~~~~~~~~~~~~~~~~
Found 1 error.
Playground Link:
Related Issues: