8000 [no-unsafe-member-access] Not allowing "interface X extends" for a type in a nested namespace · Issue #3292 · typescript-eslint/typescript-eslint · GitHub 8000
[go: up one dir, main page]

Skip to content

[no-unsafe-member-access] Not allowing "interface X extends" for a type in a nested namespace #3292

D75C New issue
@cbdeveloper

Description

@cbdeveloper
  • 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

Playground

I wasn't able to build a repro for this issue, but it really seems like a bug.

I have the following d.ts file on my project (I'm using namespaces to organize my types).

XXX.d.ts

declare namespace XXX {

  interface Temp1 {
    foo: "bar"
  }

  namespace WWW {

    interface Temp2 {
      foo: "bar"
    }

  }

}

So the XXX is ambient and the WWW namespace is nested within it.

I need to extend the Temp2 interface, that lives on the nested WWW namespace.

So I did this:

interface Test2 extends XXX.WWW.Temp2 {}

And I got this error:

image

So I thought: "eslint might not be detecting the XXX namespace". But that is not true, as you can see that the following code works fine when extending Temp1 which is a direct member of the XXX namespace.

interface Test1 extends XXX.Temp1 {}

image

And what is even weirder is that if I use an intermediate AUX type, it works fine:

type AUX = XXX.WWW.Temp2;
interface Test2A extends AUX {}

image

Expected Result

There shouldn't be any errors when extending a nested namespace.

interface Test2 extends XXX.WWW.Temp2 {}

Actual Result

The @typescript-eslint/no-unsafe-member-access is being triggered.

Additional Info

Versions

package version
@typescript-eslint/eslint-plugin 4.22.0
@typescript-eslint/parser 4.22.0
TypeScript 4.2.4
ESLint 7.24.0
node 10.19.0

.eslintrc.js

const config = {

  root: true,
  

  env: {
    browser : true,
    commonjs: true,
    es2017: true,
    node: true
  },
  parser: "@typescript-eslint/parser",
  ignorePatterns: [
    ".eslintrc.js",
    "webpack.*.ts",
    "babel.config.*.js"
  ],
  parserOptions: {
    project: "./tsconfig.json",
    sourceType: "module",
  },

  globals: {
    gtag: "readonly"
  },

  extends: [
    "eslint:recommended",
    "plugin:react/recommended",
    "plugin:react-hooks/recommended",
    "plugin:@typescript-eslint/recommended",
    "plugin:@typescript-eslint/recommended-requiring-type-checking"
  ],

  plugins:[
    "react",
    "react-hooks",
    "@typescript-eslint"
  ],

  rules: {
    "semi": "error",
    "react/prop-types": "off",
    "react-hooks/rules-of-hooks": "error",
    "react-hooks/exhaustive-deps": "warn",
    "@typescript-eslint/no-unused-vars": ["warn", {"args":"none"}],
    "@typescript-eslint/no-empty-interface": "off",
    "@typescript-eslint/prefer-regexp-exec": "off",
    "@typescript-eslint/require-await": "off"
  },
  
  settings: {
    "react": {
      version: "detect"
    }
  },

  overrides: [
    { 
      files: ["*.js"],
      rules: {
        "@typescript-eslint/no-var-requires": 0
      }
    }
  ]
};

module.exports = config;

tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": false,
    "strictNullChecks": true,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "types": ["node"],
    "baseUrl": ".",
    "paths": {
      "@app/*": ["./app/*"],
      "@lib/*": ["./lib/*"]
    }
  },
  "include": [
    "next-env.d.ts",
    "**/*.ts",
    "**/*.tsx"
  ],
  "exclude": [
    "node_modules"
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workinglocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.package: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0