File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed
tests/cases/conformance/types/mapped Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -125,3 +125,9 @@ c.setState({ });
125
125
c . setState ( foo ) ;
126
126
c . setState ( { a : undefined } ) ; // Error
127
127
c . setState ( { c : true } ) ; // Error
128
+
129
+ type T2 = { a ?: number , [ key : string ] : any } ;
130
+
131
+ let x1 : T2 = { a : 'no' } ; // Error
132
+ let x2 : Partial < T2 > = { a : 'no' } ; // Error
133
+ let x3 : { [ P in keyof T2 ] : T2 [ P ] } = { a : 'no' } ; // Error
Original file line number Diff line number Diff line change 1
1
// @strictNullChecks : true
2
+ // @noimplicitany : true
2
3
3
4
type T = { a : number , b : string } ;
4
5
type TP = { a ?: number , b ?: string } ;
@@ -74,4 +75,26 @@ var b04: Readonly<BP>;
74
75
var b04 : Partial < Readonly < B > > ;
75
76
var b04 : Readonly < Partial < B > > ;
76
77
var b04 : { [ P in keyof BPR ] : BPR [ P ] }
77
- var b04 : Pick < BPR , keyof BPR > ;
78
+ var b04 : Pick < BPR , keyof BPR > ;
79
+
80
+ type Foo = { prop : number , [ x : string ] : number } ;
81
+
82
+ function f1 ( x : Partial < Foo > ) {
83
+ x . prop ; // ok
84
+ ( x [ "other" ] || 0 ) . toFixed ( ) ;
85
+ }
86
+
87
+ function f2 ( x : Readonly < Foo > ) {
88
+ x . prop ; // ok
89
+ x [ "other" ] . toFixed ( ) ;
90
+ }
91
+
92
+ function f3 ( x : Boxified < Foo > ) {
93
+ x . prop ; // ok
94
+ x [ "other" ] . x . toFixed ( ) ;
95
+ }
96
+
97
+ function f4 ( x : { [ P in keyof Foo ] : Foo [ P ] } ) {
98
+ x . prop ; // ok
99
+ x [ "other" ] . toFixed ( ) ;
100
+ }
You can’t perform that action at this time.
0 commit comments