Skip to content
This repository was archived by the owner on Mar 12, 2025. It is now read-only.

Commit 285181c

Browse files
committed
disallow_creating_indexed_type_for_type_params
1 parent 4a48d97 commit 285181c

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

crates/stc_ts_file_analyzer/src/analyzer/assign/function.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,7 @@ impl Analyzer<'_, '_> {
864864
disallow_indexing_class_with_computed: true,
865865
disallow_inexact: true,
866866
use_last_element_for_tuple_on_out_of_bound: true,
867+
disallow_creating_indexed_type_for_type_params: true,
867868
..Default::default()
868869
},
869870
)
@@ -903,6 +904,7 @@ impl Analyzer<'_, '_> {
903904
disallow_indexing_class_with_computed: true,
904905
disallow_inexact: true,
905906
use_last_element_for_tuple_on_out_of_bound: true,
907+
disallow_creating_indexed_type_for_type_params: true,
906908
..Default::default()
907909
},
908910
)

crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,7 @@ pub(crate) struct AccessPropertyOpts {
656656
/// obj11.foo; // Error TS2339
657657
/// ```
658658
pub disallow_creating_indexed_type_from_ty_els: bool,
659+
pub disallow_creating_indexed_type_for_type_params: bool,
659660

660661
pub disallow_indexing_class_with_computed: bool,
661662

@@ -2187,6 +2188,15 @@ impl Analyzer<'_, '_> {
21872188
}
21882189
}
21892190

2191+
if opts.disallow_creating_indexed_type_for_type_params {
2192+
return Err(ErrorKind::NoSuchProperty {
2193+
span,
2194+
obj: Some(Box::new(obj.clone())),
2195+
prop: Some(Box::new(prop.clone())),
2196+
}
2197+
.context("disallow_creating_indexed_type_for_type_params = true"));
2198+
}
2199+
21902200
let mut prop_ty = match prop {
21912201
Key::Computed(key) => key.ty.clone(),
21922202
Key::Normal { span, sym } => Box::new(Type::Lit(LitType {

0 commit comments

Comments
 (0)