Browse Source

fix(ui): Declare context type on more class components (#65760)

Scott Cooper 1 year ago
parent
commit
f0f8169e79

+ 1 - 0
static/app/utils/withProject.tsx

@@ -21,6 +21,7 @@ const withProject = <P extends InjectedProjectProps>(
     static contextTypes = {
       project: SentryPropTypeValidators.isProject,
     };
+    declare context: {project: Project};
 
     render() {
       const {project, ...props} = this.props;

+ 1 - 0
static/app/views/organizationContext.spec.tsx

@@ -100,6 +100,7 @@ describe('OrganizationContext', function () {
     static contextTypes = {
       organization: SentryPropTypeValidators.isOrganization,
     };
+    declare context: {organization: Organization | undefined};
 
     render() {
       return <div>{this.context.organization?.slug ?? 'no-org'}</div>;

+ 5 - 1
static/app/views/settings/organizationDeveloperSettings/permissionSelection.tsx

@@ -108,6 +108,7 @@ export default class PermissionSelection extends Component<Props, State> {
     permissions: this.props.permissions,
   };
 
+  declare context: Required<React.ContextType<typeof FormContext>>;
   static contextType = FormContext;
 
   onChange = (resource: PermissionResource, choice: PermissionValue) => {
@@ -119,7 +120,10 @@ export default class PermissionSelection extends Component<Props, State> {
   save = (permissions: Permissions) => {
     this.setState({permissions});
     this.props.onChange(permissions);
-    this.context.form.setValue('scopes', permissionStateToList(this.state.permissions));
+    this.context.form.setValue(
+      'scopes',
+      permissionStateToList(this.state.permissions) as string[]
+    );
   };
 
   render() {