Skip to content

[no-undef] this in typeof this is reported as undefined incorrectly #4364

Closed
@Zzzen

Description

@Zzzen
  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro

{
  "rules": {
    "no-undef": []
  }
}
// Add code below to valid cases of `packages/eslint-plugin/tests/eslint-rules/no-undef.test.ts`
// and run `yarn test no-undef`
const obj = {
  foo: '',
  bar() {
    let foo: typeof this.foo;
  },
};

Expected Result

No error should be reported.

Actual Result

this in typeof this is reported as undefined.

  ● no-undef › valid › 
const obj = {
  foo: '',
  bar() {
    let foo: typeof this.foo;
  },
};
    

    assert.strictEqual(received, expected)

    Expected value to strictly be equal to:
      0
    Received:
      1
    
    Message:
      Should have no errors but had 1: [
      {
        ruleId: 'no-undef',
        severity: 1,
        message: "'this' is not defined.",
        line: 5,
        column: 21,
        nodeType: 'Identifier',
        messageId: 'undef',
        endLine: 5,
        endColumn: 25
      }
    ]

Additional Info

Versions

Tested on latest commit, a9eb0b9.

package version
@typescript-eslint/eslint-plugin X.Y.Z
@typescript-eslint/parser X.Y.Z
TypeScript X.Y.Z
ESLint X.Y.Z
node X.Y.Z

Metadata

Metadata

Assignees

No one assigned

    Labels

    ASTPRs and Issues about the AST structureaccepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workinggood first issueGood for newcomershas prthere is a PR raised to close thispackage: typescript-estreeIssues related to @typescript-eslint/typescript-estree

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions