Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
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 havesearched for related issues and found none that matched my issue.
- I haveread the FAQ and my problem is not listed.
Playground Link
Repro Code
typeFoo={foo:string,bar:number,};exportconsta=()=>({foo:"FOOO",bar:123,}asconst);// <-- This works as expected.exportconstb=()=>({foo:"FOOO",bar:123,}asconstsatisfiesFoo);// <-- This throws an error.
ESLint Config
module.exports={"rules":{"@typescript-eslint/explicit-module-boundary-types":["error",{"allowDirectConstAssertionInArrowFunctions":true}]}}
tsconfig
{"compilerOptions": {"strictNullChecks":true }}
Expected Result
This concerns bothexplicit-module-boundary-types
andexplicit-function-return-type
rules.
I have a situation where I want to use bothas const
followed bysatisfies
. With the rule currently as written as soon as you add asatisfies
after anas const
the rule will error. Leaving off thesatisfies
works as expected.
In this scenario, thesatisfies Foo
provides extra type safety ensuring thata satisfies Foo
but still keeping the ability to have explicit type literals forfoo: "FOOO"
andbar: 123
.
Actual Result
The rule should not throw an error when usingas const satisfies Foo
Additional Info
No response