@@ -655,7 +655,7 @@ pub(crate) struct AccessPropertyOpts {
655655 ///
656656 /// obj11.foo; // Error TS2339
657657 /// ```
658- pub disallow_creating_indexed_type_from_ty_els : bool ,
658+ pub disallow_creating_indexed_type : bool ,
659659
660660 pub disallow_indexing_class_with_computed : bool ,
661661
@@ -1165,7 +1165,7 @@ impl Analyzer<'_, '_> {
11651165 }
11661166 }
11671167
1168- if has_index_signature && !opts. disallow_creating_indexed_type_from_ty_els {
1168+ if has_index_signature && !opts. disallow_creating_indexed_type {
11691169 // This check exists to prefer a specific property over generic index signature.
11701170 if prop. is_computed ( ) || matching_elements. is_empty ( ) {
11711171 warn ! ( "Creating a indexed access type from a type literal" ) ;
@@ -1278,7 +1278,7 @@ impl Analyzer<'_, '_> {
12781278 id_ctx,
12791279 AccessPropertyOpts {
12801280 disallow_indexing_array_with_string : true ,
1281- disallow_creating_indexed_type_from_ty_els : true ,
1281+ disallow_creating_indexed_type : true ,
12821282 is_key_computed : true ,
12831283 ..opts
12841284 } ,
@@ -2187,6 +2187,15 @@ impl Analyzer<'_, '_> {
21872187 }
21882188 }
21892189
2190+ if opts. disallow_creating_indexed_type {
2191+ return Err ( ErrorKind :: NoSuchProperty {
2192+ span,
2193+ obj : Some ( Box :: new ( obj. clone ( ) ) ) ,
2194+ prop : Some ( Box :: new ( prop. clone ( ) ) ) ,
2195+ }
2196+ . context ( "type parameter" ) ) ;
2197+ }
2198+
21902199 let mut prop_ty = match prop {
21912200 Key :: Computed ( key) => key. ty . clone ( ) ,
21922201 Key :: Normal { span, sym } => Box :: new ( Type :: Lit ( LitType {
@@ -2398,8 +2407,7 @@ impl Analyzer<'_, '_> {
23982407 type_mode,
23992408 id_ctx,
24002409 AccessPropertyOpts {
2401- disallow_creating_indexed_type_from_ty_els : opts. disallow_creating_indexed_type_from_ty_els
2402- || has_better_default,
2410+ disallow_creating_indexed_type : opts. disallow_creating_indexed_type || has_better_default,
24032411 ..opts
24042412 } ,
24052413 )
@@ -2591,7 +2599,7 @@ impl Analyzer<'_, '_> {
25912599 id_ctx,
25922600 AccessPropertyOpts {
25932601 use_undefined_for_tuple_index_error,
2594- disallow_creating_indexed_type_from_ty_els : true ,
2602+ disallow_creating_indexed_type : true ,
25952603 is_in_union : true ,
25962604 ..opts
25972605 } ,
0 commit comments