19 lines
326 B
TypeScript
19 lines
326 B
TypeScript
//// [unionThisTypeInFunctions.ts]
|
|
interface Real {
|
|
method(this: this, n: number): void;
|
|
data: string;
|
|
}
|
|
interface Fake {
|
|
method(this: this, n: number): void;
|
|
data: number;
|
|
}
|
|
function test(r: Real | Fake) {
|
|
r.method(12);
|
|
}
|
|
|
|
|
|
//// [unionThisTypeInFunctions.js]
|
|
function test(r) {
|
|
r.method(12);
|
|
}
|