diff --git a/src/transform/DeclarationScope.ts b/src/transform/DeclarationScope.ts index ec002ae..c05e4ea 100644 --- a/src/transform/DeclarationScope.ts +++ b/src/transform/DeclarationScope.ts @@ -92,6 +92,8 @@ export class DeclarationScope { } } } + // `this` is a reserved keyword that retrains meaning in certain Type-only contexts, including classes + if (name === "this") return; const { ident, expr } = createReference(id); this.declaration.params.push(expr); diff --git a/tests/testcases/type-typeof-this/expected.d.ts b/tests/testcases/type-typeof-this/expected.d.ts new file mode 100644 index 0000000..12ad33e --- /dev/null +++ b/tests/testcases/type-typeof-this/expected.d.ts @@ -0,0 +1,4 @@ +declare class NumberSchema { + min: () => typeof this; +} +export { NumberSchema }; diff --git a/tests/testcases/type-typeof-this/index.d.ts b/tests/testcases/type-typeof-this/index.d.ts new file mode 100644 index 0000000..87cfdae --- /dev/null +++ b/tests/testcases/type-typeof-this/index.d.ts @@ -0,0 +1,3 @@ +export declare class NumberSchema { + min: () => typeof this; +}