Format and Type Import Cleanup

Co-authored-by: David Wheatley <hi@davwheat.dev>
This commit is contained in:
Alexander Skvortsov 2021-12-12 22:56:22 -05:00
parent 2dea2f09a4
commit a82a160ecb
5 changed files with 14 additions and 15 deletions

View File

@ -23,19 +23,18 @@ declare type KeyOfType<Type extends object, Match> = KeysOfType<Type, Match>[key
type Component<A> = import('mithril').Component<A>;
declare type ComponentClass<
Attrs = Record<string, unknown>, C extends Component<Attrs> = Component<Attrs>> = { new (...args: any[]): Component<Attrs>, prototype: C };
declare type ComponentClass<Attrs = Record<string, unknown>, C extends Component<Attrs> = Component<Attrs>> = {
new (...args: any[]): Component<Attrs>;
prototype: C;
};
/**
* Unfortunately, TypeScript only supports strings and classes for JSX tags.
* Therefore, our type definition should only allow for those two types.
*
*
* @see https://github.com/microsoft/TypeScript/issues/14789#issuecomment-412247771
*/
declare type VnodeElementTag<
Attrs = Record<string, unknown>,
C extends Component<Attrs> = Component<Attrs>
> = string | ComponentClass<Attrs, C>;
declare type VnodeElementTag<Attrs = Record<string, unknown>, C extends Component<Attrs> = Component<Attrs>> = string | ComponentClass<Attrs, C>;
/**
* @deprecated Please import `app` from a namespace instead of using it as a global variable.

View File

@ -4,7 +4,7 @@ import LoadingIndicator from '../../common/components/LoadingIndicator';
import Placeholder from '../../common/components/Placeholder';
import ExtensionReadme from '../models/ExtensionReadme';
import type Mithril from 'mithril';
import { Extension } from '../AdminApplication';
import type { Extension } from '../AdminApplication';
export interface IReadmeModalAttrs extends IInternalModalAttrs {
extension: Extension;

View File

@ -6,9 +6,9 @@ import Group from '../models/Group';
import extractText from '../utils/extractText';
import ItemList from '../utils/ItemList';
import Stream from '../utils/Stream';
import Mithril from 'mithril';
import User from '../models/User';
import { SaveAttributes, SaveRelationships } from '../Model';
import type Mithril from 'mithril';
import type User from '../models/User';
import type { SaveAttributes, SaveRelationships } from '../Model';
export interface IEditUserModalAttrs extends IInternalModalAttrs {
user: User;

View File

@ -1,10 +1,10 @@
import RequestError from '../utils/RequestError';
import type RequestError from '../utils/RequestError';
import Modal, { IInternalModalAttrs } from './Modal';
export interface IRequestErrorModalAttrs extends IInternalModalAttrs {
error: RequestError;
formattedError: string[];
};
}
export default class RequestErrorModal<CustomAttrs extends IRequestErrorModalAttrs = IRequestErrorModalAttrs> extends Modal<CustomAttrs> {
className() {

View File

@ -1,4 +1,4 @@
import Component from '../Component';
import type Component from '../Component';
import Modal from '../components/Modal';
/**
@ -8,7 +8,7 @@ import Modal from '../components/Modal';
* https://github.com/Microsoft/TypeScript/issues/1213
* Therefore, we have to use this ugly, messy workaround.
*/
type UnsafeModalClass = ComponentClass<any, Modal> & {isDismissible: boolean, component: typeof Component.component};
type UnsafeModalClass = ComponentClass<any, Modal> & { isDismissible: boolean; component: typeof Component.component };
/**
* Class used to manage modal state.