Skip to content

[triple-slash-reference] TypeError: Cannot read property 'value' of undefined #2762

Closed
@timplateus

Description

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

.eslintrc.json

{
  "root": true,
  "overrides": [
    {
      "files": ["*.ts"],
      "parserOptions": {
        "project": [
          "tsconfig.json"
        ],
        "createDefaultProgram": true
      },
      "extends": ["plugin:@typescript-eslint/recommended"]
    }
  ]
}

.ts

/// <reference types="@types/googlemaps" />
import DistanceMatrixResponse = google.maps.DistanceMatrixResponse;

tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "src",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "module": "es2020",
    "moduleResolution": "node",
    "importHelpers": true,
    "resolveJsonModule": true,
    "target": "es2015",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2018",
      "dom"
    ]
  },
  "angularCompilerOptions": {
    "fullTemplateTypeCheck": false,
    "strictInjectionParameters": true,
    "preserveWhitespaces": true
  }
}

Expected Result

Evaluate the file, and pass/reject the rule

Actual Result

Unhandled Exception (see below). Note that disabling all rules (//eslint-disable-next-line) for the problematic line did not stop the exception from occurring.

TypeError: Cannot read property 'value' of undefined
Occurred while linting corrupted-file.ts:2
    at ...\node_modules\@typescript-eslint\eslint-plugin\dist\rules\triple-slash-reference.js:67:53
    at Array.forEach (<anonymous>)
    at hasMatchingReference (...\node_modules\@typescript-eslint\eslint-plugin\dist\rules\triple-slash-reference.js:66:24)
    at TSImportEqualsDeclaration (...\node_modules\@typescript-eslint\eslint-plugin\dist\rules\triple-slash-reference.js:88:21)
    at ...\node_modules\eslint\lib\linter\safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (...\node_modules\eslint\lib\linter\safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (...\node_modules\eslint\lib\linter\node-event-generator.js:254:26)
    at NodeEventGenerator.applySelectors (...\node_modules\eslint\lib\linter\node-event-generator.js:283:22)
    at NodeEventGenerator.enterNode (...\node_modules\eslint\lib\linter\node-event-generator.js:297:14)
Process finished with exit code -1

Additional Info

Versions

package version
@typescript-eslint/eslint-plugin 4.7.0
@typescript-eslint/parser 4.7.0
TypeScript 4.0.5
ESLint 7.13.0
node 14.15.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomerspackage: 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