TypeStat
TypeStat copied to clipboard
🐛 Bug: strictNonNullAssertions changes "return undefined" to "return undefined!"
trafficstars
Bug Report Checklist
- [X] I have tried restarting my IDE and the issue persists.
- [X] I have pulled the latest
mainbranch of the repository. - [X] I have searched for related issues and found none that matched my issue.
Expected
It should allow returning undefined here
const collectFileNamesFromGlobs = async (
argv: TypeStatArgv,
cwd: string,
include: readonly string[] | undefined,
): Promise<[readonly string[], readonly string[]] | undefined> => {
if (argv.args.length) {
return [argv.args, await glob(argv.args)];
}
if (include === undefined) {
return undefined;
}
return [
include,
await glob(include.map((subInclude) => path.join(cwd, subInclude))),
];
};
Actual
The undefined return is changed to this
if (include === undefined) {
return undefined!;
}
Additional Info
This is probably related to https://github.com/JoshuaKGoldberg/TypeStat/issues/1494 - it does not understand that the function accepts return type Promise<undefined>.
typestat.json
[
{
"fixes": {
"strictNonNullAssertions": true
},
"include": [
"src/**/*.{ts,tsx}"
],
"projectPath": "./tsconfig.json",
"types": {
"strictNullChecks": true
}
}
]
tsconfig
{
"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"]
}