Description
Before You File a Bug Report Please Confirm You Have Done The Following...
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I have searched for related issues and found none that matched my issue.
- I have read the FAQ and my problem is not listed.
Playground Link
Repro Code
export const marker = "marker" as const;
export interface Data {
marker: typeof marker;
value: string;
}
function createData(): Data {
const base = { marker: marker };
return { ...base, value: "" };
}
ESLint Config
module.exports = {
"rules": {
"@typescript-eslint/no-unnecessary-type-assertion": "error"
}
}
tsconfig
Expected Result
The first line of this code should not report an error for the as const
assertion, since this assertion is necessary - removing it is a TypeScript compilation error (see TypeScript playground).
Actual Result
Starting in typescript-eslint@7.3 (presumably #8558), the first line of this code reports a @typescript-eslint/no-unnecessary-type-assertion error.
Additional Info
No response