JoshuaKGoldberg / JoshuaKGoldberg/TypeStat
🐛 Bug: strictNonNullAssertions adds !!!!!!!!!!!!!!!!!!!!!
- Dominant language
- TypeScript
- Stars
- 2.3k
- Forks
- 47
- Avg merge
- 15h 55m
- Merged PRs (30d)
- 21
Description
### Bug Report Checklist
- [X] I have tried restarting my IDE and the issue persists.
- [X] I have pulled the latest `main` branch of the repository.
- [X] I have [searched for related issues](https://github.com/JoshuaKGoldberg/TypeStat/issues?q=is%3Aissue) and found none that matched my issue.
### Expected
There should not be reason to add `!` here. `attributeTypesAndRequirements` should be always Map
```ts
const visitReactComponentNode = (
node: ReactComponentNode,
request: FileMutationsRequest,
) => {
// ...
// Find all types of props later passed to the node
const attributeTypesAndRequirements = collectComponentAttributeTypes(
request,
node,
);
// ! ts language server says `attributeTypes` is `attributeTypes: Map`, so it should not be undefined
if (!attributeTypesAndRequirements?.attributeTypes.size) {
return undefined;
}
// ...
};
```
### Actual
```ts
const visitReactComponentNode = (
node: ReactComponentNode,
request: FileMutationsRequest,
) => {
// ...
// Find all types of props later passed to the node
const attributeTypesAndRequirements = collectComponentAttributeTypes(
request,
node,
);
// ! ts language server says `attributeTypes` is `attributeTypes: Map`, so it should not be undefined
if (!attributeTypesAndRequirements?.attributeTypes!!!!!!!!!!!!!!!!!!!!!.size) {
return undefined;
}
// ...
};
```
### Additional Info
typestat.json
```json
[
{
"fixes": {
"strictNonNullAssertions": true
},
"include": [
"src/**/*.{ts,tsx}"
],
"projectPath": "./tsconfig.json",
"types": {
"strictNullChecks": true
}
}
]
```
tsconfig
```tsconfig.json
{
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
"module": "NodeNext",
"moduleResolution": "NodeNext",
"noEmit": true,
"outDir": "lib",
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"target": "ES2022"
},
"include": ["src", "test/*.ts"]
}
Contributor guide
Assessment
This issue has not been assessed yet.