TypeStat icon indicating copy to clipboard operation
TypeStat copied to clipboard

🐛 Bug: strictNonNullAssertions does not understand that undefined is accepted in union array

Open rubiesonthesky opened this issue 10 months ago • 0 comments

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 and found none that matched my issue.

Expected

I expected it to not add ! to undefined

const someArray: (string | undefined)[] = [];
someArray.push(undefined);

Actual

const someArray: (string | undefined)[] = [];
someArray.push(undefined!);

Additional Info

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"]
}

rubiesonthesky avatar Apr 03 '24 18:04 rubiesonthesky