@@ -420,6 +420,14 @@ impl ExplicitFunctionReturnType {
420
420
let AstKind :: ArrowFunctionExpression ( func) = node. kind ( ) else { return false } ;
421
421
let Some ( expr) = func. get_expression ( ) else { return false } ;
422
422
423
+ let mut expr = expr;
424
+ loop {
425
+ expr = match expr {
426
+ Expression :: TSSatisfiesExpression ( e) => & e. expression ,
427
+ _ => break ,
428
+ } ;
429
+ }
430
+
423
431
match expr {
424
432
Expression :: TSAsExpression ( ts_expr) => {
425
433
let TSType :: TSTypeReference ( ts_type) = & ts_expr. type_annotation else {
@@ -606,7 +614,10 @@ fn is_typed_jsx(node: &AstNode) -> bool {
606
614
}
607
615
608
616
fn is_function ( expr : & Expression ) -> bool {
609
- matches ! ( expr, Expression :: ArrowFunctionExpression ( _) | Expression :: FunctionExpression ( _) )
617
+ matches ! (
618
+ expr. get_inner_expression( ) ,
619
+ Expression :: ArrowFunctionExpression ( _) | Expression :: FunctionExpression ( _)
620
+ )
610
621
}
611
622
612
623
fn ancestor_has_return_type < ' a > ( node : & AstNode < ' a > , ctx : & LintContext < ' a > ) -> bool {
@@ -1145,9 +1156,56 @@ fn test() {
1145
1156
) ,
1146
1157
(
1147
1158
"
1148
- new Promise(resolve => {});
1149
- new Foo(1, () => {});
1150
- " ,
1159
+ interface R {
1160
+ type: string;
1161
+ value: number;
1162
+ }
1163
+
1164
+ const func = (value: number) => ({ type: 'X', value }) as const satisfies R;
1165
+ " ,
1166
+ Some (
1167
+ serde_json:: json!( [ { "allowDirectConstAssertionInArrowFunctions" : true , } , ] ) ,
1168
+ ) ,
1169
+ None ,
1170
+ None ,
1171
+ ) ,
1172
+ (
1173
+ "
1174
+ interface R {
1175
+ type: string;
1176
+ value: number;
1177
+ }
1178
+
1179
+ const func = (value: number) =>
1180
+ ({ type: 'X', value }) as const satisfies R satisfies R;
1181
+ " ,
1182
+ Some (
1183
+ serde_json:: json!( [ { "allowDirectConstAssertionInArrowFunctions" : true , } , ] ) ,
1184
+ ) ,
1185
+ None ,
1186
+ None ,
1187
+ ) ,
1188
+ (
1189
+ "
1190
+ interface R {
1191
+ type: string;
1192
+ value: number;
1193
+ }
1194
+
1195
+ const func = (value: number) =>
1196
+ ({ type: 'X', value }) as const satisfies R satisfies R satisfies R;
1197
+ " ,
1198
+ Some (
1199
+ serde_json:: json!( [ { "allowDirectConstAssertionInArrowFunctions" : true , } , ] ) ,
1200
+ ) ,
1201
+ None ,
1202
+ None ,
1203
+ ) ,
1204
+ (
1205
+ "
1206
+ new Promise(resolve => {});
1207
+ new Foo(1, () => {});
1208
+ " ,
1151
1209
Some ( serde_json:: json!( [ { "allowTypedFunctionExpressions" : true , } , ] ) ) ,
1152
1210
None ,
1153
1211
None ,
0 commit comments