mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-27 06:43:19 +08:00
12 lines
427 B
TypeScript
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(","));
|