mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-28 06:53:42 +08:00
17 lines
384 B
TypeScript
17 lines
384 B
TypeScript
// A method that never reads `this`, taken off an instance of a class
|
|
// declared inside a function: the detached method runs without a receiver.
|
|
function helper(): string {
|
|
return "helper";
|
|
}
|
|
function make() {
|
|
return class Local {
|
|
tag = "t";
|
|
plain(): string {
|
|
return helper();
|
|
}
|
|
};
|
|
}
|
|
const C = make();
|
|
const detached = new C().plain;
|
|
console.log(detached());
|