Description
Bug Report
We migrated our codebase with >1.5M lines of TS code to use strict mode everywhere, resulting in >30k new errors caught by strict mode. To ease the migration, we annotated each error with // @ts-expect-error
and additional comments pointing to a wiki about the migration. However, we're finding the disable comment to be overly-broad, suppressing new errors that are unrelated to the line in question or strict mode. In particular, adding a new property to a type doesn't flag instances where we have a @ts-expect-error
suppressing a strictNullChecks
error.
🔎 Search Terms
ignore, expect, error, @ts-ignore, @ts-expect-error
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about
@ts-ignore
and@ts-expect-error
⏯ Playground Link
Playground link with relevant code
💻 Code
interface Foo {
a: number;
b: string;
}
// Expected error due to `undefined` property `a`,
// but suppresses error due to missing property `b`
const bar: Foo = {
// @ts-expect-error
a: undefined
}
// Compiler correctly errors on the below line (`const baz: Foo = {`)
// due to the missing property `b`
const baz: Foo = {
a: 1
}
🙁 Actual behavior
Compiler suppresses error about missing property.
🙂 Expected behavior
Compiler raises error about missing property that is not on the line covered by @ts-expect-error