Skip to content

'noUnusedParameters' compiler options warn the specified 'this' type as 'never used' parameter #9550

Closed
@tetsuharuohzeki

Description

@tetsuharuohzeki

Environment

  • TypeScript Version 2.0.0-dev.20160707

Step to Reproduce

compile the following code with tsc test.ts --noUnusedParameters

// test.ts
class A {
    constructor(private a: number) {}

    b(this: A): number {
        return this.a;
    }
}

function bar(this: Window): string {
    return window.location.href;
}

Expected behavior

There is not any compile error.

Actual behavior

tsc reports following compilation errors

test.ts(4,7): error TS6133: 'this' is declared but never used.
test.ts(10,14): error TS6133: 'this' is declared but never used.
// test.ts
class A {
    constructor(private a: number) {}

    b(this: A): number { // error TS6133: 'this' is declared but never used.
        return this.a;
    }
}

function bar(this: Window): string { //  error TS6133: 'this' is declared but never used.
    return window.location.href;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions