Files
scriptc/tests/diagnostics/object-assign-class-copy.ts
T
2026-10-20 17:56:44 -05:00

12 lines
427 B
TypeScript

// Object.assign copying a class instance into a fresh object: the result
// is a plain object holding the instance's own fields, never an instance,
// so a result the checker types as the class is refused rather than
// failing its checked cast at run time.
class Config {
b = 1;
a = 2;
}
const config = new Config();
const copy = Object.assign({}, config);
console.log(JSON.stringify(copy), Object.keys(copy).join(","));