File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed
crates/oxc_linter/src/rules/eslint/no_unused_vars Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -1202,6 +1202,30 @@ fn test_type_references() {
1202
1202
. test_and_snapshot ( ) ;
1203
1203
}
1204
1204
1205
+ #[ test]
1206
+ fn test_ts_in_assignment ( ) {
1207
+ let pass = vec ! [
1208
+ r"export const onClick = (value, key) => {
1209
+ const obj: Record<string, string> = {};
1210
+ (obj[key] as any) = value;
1211
+ }" ,
1212
+ r"export const onClick = (value, key) => {
1213
+ const obj: Record<string, string> = {};
1214
+ (obj[key] satisfies any) = value;
1215
+ }" ,
1216
+ r"export const onClick = (value, key) => {
1217
+ const obj: Record<string, string> = {};
1218
+ (obj[key]!) = value;
1219
+ }" ,
1220
+ ] ;
1221
+ let fail = vec ! [ ] ;
1222
+
1223
+ Tester :: new ( NoUnusedVars :: NAME , NoUnusedVars :: PLUGIN , pass, fail)
1224
+ . intentionally_allow_no_fix_tests ( )
1225
+ . with_snapshot_suffix ( "oxc-assignment-ts" )
1226
+ . test ( ) ;
1227
+ }
1228
+
1205
1229
// #[test]
1206
1230
// fn test_template() {
1207
1231
// let pass = vec![];
Original file line number Diff line number Diff line change @@ -411,6 +411,27 @@ impl<'a> Symbol<'_, 'a> {
411
411
return false ; // we can short-circuit
412
412
}
413
413
}
414
+ AssignmentTarget :: TSAsExpression ( v)
415
+ if v. expression . is_member_expression ( ) =>
416
+ {
417
+ return false ;
418
+ }
419
+ AssignmentTarget :: TSSatisfiesExpression ( v)
420
+ if v. expression . is_member_expression ( ) =>
421
+ {
422
+ return false ;
423
+ }
424
+ AssignmentTarget :: TSNonNullExpression ( v)
425
+ if v. expression . is_member_expression ( ) =>
426
+ {
427
+ return false ;
428
+ }
429
+ AssignmentTarget :: TSTypeAssertion ( v)
430
+ if v. expression . is_member_expression ( ) =>
431
+ {
432
+ return false ;
433
+ }
434
+
414
435
// variable is being used to index another variable, this is
415
436
// always a usage
416
437
// todo: check self index?
You can’t perform that action at this time.
0 commit comments