File tree 4 files changed +32
-2
lines changed
4 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -995,7 +995,7 @@ declare namespace React {
995
995
*/
996
996
context : unknown ;
997
997
998
- constructor ( props : Readonly < P > | P ) ;
998
+ constructor ( props : P ) ;
999
999
/**
1000
1000
* @deprecated
1001
1001
* @see {@link https://legacy.reactjs.org/docs/legacy-context.html React Docs }
Original file line number Diff line number Diff line change @@ -82,6 +82,14 @@ declare const container: Element;
82
82
}
83
83
}
84
84
class BetterPropsAndStateChecksComponent extends React . Component < Props , State , Snapshot > {
85
+ constructor ( props : Props ) {
86
+ super ( props ) ;
87
+ // This should ideally error since `props` should not be mutated, but it doesn't.
88
+ props . foo = 2 ;
89
+ // @ts -expect-error
90
+ this . props = { type : "foo" } ;
91
+ }
92
+
85
93
render ( ) {
86
94
return null ;
87
95
}
@@ -117,6 +125,13 @@ declare const container: Element;
117
125
} ;
118
126
}
119
127
}
128
+
129
+ class InferredConstructorProps extends React . Component < { value : string } > {
130
+ // @ts -expect-error ts(7006) Ideally, this would infer the props type from the type parameter but has implicit any.
131
+ constructor ( props ) {
132
+ super ( props ) ;
133
+ }
134
+ }
120
135
}
121
136
122
137
class ModernComponent extends React . Component < Props , State , Snapshot >
Original file line number Diff line number Diff line change @@ -996,7 +996,7 @@ declare namespace React {
996
996
*/
997
997
context : unknown ;
998
998
999
- constructor ( props : Readonly < P > | P ) ;
999
+ constructor ( props : P ) ;
1000
1000
/**
1001
1001
* @deprecated
1002
1002
* @see {@link https://legacy.reactjs.org/docs/legacy-context.html React Docs }
Original file line number Diff line number Diff line change @@ -82,6 +82,14 @@ declare const container: Element;
82
82
}
83
83
}
84
84
class BetterPropsAndStateChecksComponent extends React . Component < Props , State , Snapshot > {
85
+ constructor ( props : Props ) {
86
+ super ( props ) ;
87
+ // This should ideally error since `props` should not be mutated, but it doesn't.
88
+ props . foo = 2 ;
89
+ // @ts -expect-error
90
+ this . props = { type : "foo" } ;
91
+ }
92
+
85
93
render ( ) {
86
94
return null ;
87
95
}
@@ -117,6 +125,13 @@ declare const container: Element;
117
125
} ;
118
126
}
119
127
}
128
+
129
+ class InferredConstructorProps extends React . Component < { value : string } > {
130
+ // @ts -expect-error ts(7006) Ideally, this would infer the props type from the type parameter but has implicit any.
131
+ constructor ( props ) {
132
+ super ( props ) ;
133
+ }
134
+ }
120
135
}
121
136
122
137
class ModernComponent extends React . Component < Props , State , Snapshot >
You can’t perform that action at this time.
0 commit comments