-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Closed
Description
Current behavior
Custom array class methods disappear:
class MyArray extends Array<number> {
public toString(): string {
return 'Custom toString method called!';
}
public toDB(): string[] {
return Array.from(this.map((t) => t.toString()));
}
public static fromDB(record: string[]): MyArray {
return new MyArray(...record.map((t) => Number(t)));
}
}
// Logs an empty array `[]`
console.log('MyArray:', new MyArray());
// Logs an empty string (calls Array#toString instead of MyArray#toString)
console.log(`MyArray: ${new MyArray().toString()}`);
// Logs `undefined` (even though I defined a MyArray#toDB method)
console.log('MyArray toDB:', new MyArray().toDB);
// Logs `[Function (anonymous)]` (so static methods are preserved)
console.log('MyArray fromDB:', MyArray.fromDB);
Desired behavior
Cypress should compile that custom MyArray
class and it's methods properly.
// Should log `Custom toString method called!` instead of an empty string
console.log(`MyArray: ${new MyArray().toString()}`);
// Should log `[Function (anonymous)]` instead of `undefined`
console.log('MyArray toDB:', new MyArray().toDB);
Test code to reproduce
See description above.
Cypress Version
Cypress package version: 8.1.0
Cypress binary version: 8.1.0
Electron version: 12.0.0-beta.14
Bundled Node version: 14.15.1
Metadata
Metadata
Assignees
Labels
No labels