-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issueenhancement: plugin rule optionNew rule option for an existing eslint-plugin ruleNew rule option for an existing eslint-plugin rulepackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin
Description
- 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": {
"@typescript-eslint/no-unsafe-member-access": ["error"]
}
}const handleEvent = (event: { detail: any }): void => {
const uuid: unknown = event.detail?.uuid;
if (typeof uuid === "string") {
console.log(uuid);
}
};{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"lib": [
"es5",
"es2015.promise",
"es2015.iterable",
"dom",
"dom.iterable"
],
"incremental": true,
"module": "esnext",
"moduleResolution": "node",
"jsx": "react",
"noEmitOnError": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"sourceMap": false,
"strict": true,
"target": "es5"
}
}Expected Result
I'd like to not have an error when accessing event.detail?.uuid, either by default or by special rule config, because I'm not seeing what is unsafe about this member access. I've already satisfied the no-unsafe-assignment rule by declaring uuid to be of type unknown, and with optional chaining, it should not be possible to get a runtime error here, no matter what the value of event.detail actually is.
Actual Result
The .uuid access yielded:
error Unsafe member access .uuid on an any value @typescript-eslint/no-unsafe-member-access
Versions
| package | version |
|---|---|
@typescript-eslint/eslint-plugin |
4.5.0 |
@typescript-eslint/parser |
4.5.0 |
TypeScript |
4.0.3 |
ESLint |
7.11.0 |
node |
14.12.0 |
JasCodes, btmills, drc-ericm, synaestheory, unional and 18 more
Metadata
Metadata
Assignees
Labels
accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issueenhancement: plugin rule optionNew rule option for an existing eslint-plugin ruleNew rule option for an existing eslint-plugin rulepackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin