mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
82 lines
1.3 KiB
TypeScript
82 lines
1.3 KiB
TypeScript
//// [tests/cases/conformance/types/thisType/declarationFiles.ts] ////
|
|
|
|
//// [declarationFiles.ts]
|
|
class C1 {
|
|
x: this;
|
|
f(x: this): this { return undefined; }
|
|
constructor(x: this) { }
|
|
}
|
|
|
|
class C2 {
|
|
[x: string]: this;
|
|
}
|
|
|
|
interface Foo<T> {
|
|
x: T;
|
|
y: this;
|
|
}
|
|
|
|
class C3 {
|
|
a: this[];
|
|
b: [this, this];
|
|
c: this | Date;
|
|
d: this & Date;
|
|
e: (((this)));
|
|
f: (x: this) => this;
|
|
g: new (x: this) => this;
|
|
h: Foo<this>;
|
|
i: Foo<this | (() => this)>;
|
|
j: (x: any) => x is this;
|
|
}
|
|
|
|
class C4 {
|
|
x1 = { a: this };
|
|
x2 = [this];
|
|
x3 = [{ a: this }];
|
|
x4 = () => this;
|
|
f1() {
|
|
return { a: this };
|
|
}
|
|
f2() {
|
|
return [this];
|
|
}
|
|
f3() {
|
|
return [{ a: this }];
|
|
}
|
|
f4() {
|
|
return () => this;
|
|
}
|
|
}
|
|
|
|
|
|
//// [declarationFiles.js]
|
|
"use strict";
|
|
class C1 {
|
|
f(x) { return undefined; }
|
|
constructor(x) { }
|
|
}
|
|
class C2 {
|
|
}
|
|
class C3 {
|
|
}
|
|
class C4 {
|
|
constructor() {
|
|
this.x1 = { a: this };
|
|
this.x2 = [this];
|
|
this.x3 = [{ a: this }];
|
|
this.x4 = () => this;
|
|
}
|
|
f1() {
|
|
return { a: this };
|
|
}
|
|
f2() {
|
|
return [this];
|
|
}
|
|
f3() {
|
|
return [{ a: this }];
|
|
}
|
|
f4() {
|
|
return () => this;
|
|
}
|
|
}
|