Closed
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
type Foo = {
foo: string,
bar: number,
};
export const a = () => ({
foo: "FOOO",
bar: 123,
}as const); // <-- This works as expected.
export const b = () => ({
foo: "FOOO",
bar: 123,
} as const satisfies Foo); // <-- This throws an error.
ESLint Config
module.exports = {
"rules": {
"@typescript-eslint/explicit-module-boundary-types": [
"error",
{ "allowDirectConstAssertionInArrowFunctions": true }
]
}
}
tsconfig
Expected Result
This concerns both explicit-module-boundary-types
and explicit-function-return-type
rules.
I have a situation where I want to use both as const
followed by satisfies
. With the rule currently as written as soon as you add a satisfies
after an as const
the rule will error. Leaving off the satisfies
works as expected.
In this scenario, the satisfies Foo
provides extra type safety ensuring that a satisfies Foo
but still keeping the ability to have explicit type literals for foo: "FOOO"
and bar: 123
.
Actual Result
The rule should not throw an error when using as const satisfies Foo
Additional Info
No response