mirror of
https://github.com/flarum/framework.git
synced 2025-02-22 20:37:40 +08:00
Format and Type Import Cleanup
Co-authored-by: David Wheatley <hi@davwheat.dev>
This commit is contained in:
parent
4444357563
commit
cbbb574e37
13
js/src/@types/global.d.ts
vendored
13
js/src/@types/global.d.ts
vendored
@ -23,19 +23,18 @@ declare type KeyOfType<Type extends object, Match> = KeysOfType<Type, Match>[key
|
|||||||
|
|
||||||
type Component<A> = import('mithril').Component<A>;
|
type Component<A> = import('mithril').Component<A>;
|
||||||
|
|
||||||
declare type ComponentClass<
|
declare type ComponentClass<Attrs = Record<string, unknown>, C extends Component<Attrs> = Component<Attrs>> = {
|
||||||
Attrs = Record<string, unknown>, C extends Component<Attrs> = Component<Attrs>> = { new (...args: any[]): Component<Attrs>, prototype: C };
|
new (...args: any[]): Component<Attrs>;
|
||||||
|
prototype: C;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unfortunately, TypeScript only supports strings and classes for JSX tags.
|
* Unfortunately, TypeScript only supports strings and classes for JSX tags.
|
||||||
* Therefore, our type definition should only allow for those two types.
|
* Therefore, our type definition should only allow for those two types.
|
||||||
*
|
*
|
||||||
* @see https://github.com/microsoft/TypeScript/issues/14789#issuecomment-412247771
|
* @see https://github.com/microsoft/TypeScript/issues/14789#issuecomment-412247771
|
||||||
*/
|
*/
|
||||||
declare type VnodeElementTag<
|
declare type VnodeElementTag<Attrs = Record<string, unknown>, C extends Component<Attrs> = Component<Attrs>> = string | ComponentClass<Attrs, C>;
|
||||||
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.
|
* @deprecated Please import `app` from a namespace instead of using it as a global variable.
|
||||||
|
@ -4,7 +4,7 @@ import LoadingIndicator from '../../common/components/LoadingIndicator';
|
|||||||
import Placeholder from '../../common/components/Placeholder';
|
import Placeholder from '../../common/components/Placeholder';
|
||||||
import ExtensionReadme from '../models/ExtensionReadme';
|
import ExtensionReadme from '../models/ExtensionReadme';
|
||||||
import type Mithril from 'mithril';
|
import type Mithril from 'mithril';
|
||||||
import { Extension } from '../AdminApplication';
|
import type { Extension } from '../AdminApplication';
|
||||||
|
|
||||||
export interface IReadmeModalAttrs extends IInternalModalAttrs {
|
export interface IReadmeModalAttrs extends IInternalModalAttrs {
|
||||||
extension: Extension;
|
extension: Extension;
|
||||||
|
@ -6,9 +6,9 @@ import Group from '../models/Group';
|
|||||||
import extractText from '../utils/extractText';
|
import extractText from '../utils/extractText';
|
||||||
import ItemList from '../utils/ItemList';
|
import ItemList from '../utils/ItemList';
|
||||||
import Stream from '../utils/Stream';
|
import Stream from '../utils/Stream';
|
||||||
import Mithril from 'mithril';
|
import type Mithril from 'mithril';
|
||||||
import User from '../models/User';
|
import type User from '../models/User';
|
||||||
import { SaveAttributes, SaveRelationships } from '../Model';
|
import type { SaveAttributes, SaveRelationships } from '../Model';
|
||||||
|
|
||||||
export interface IEditUserModalAttrs extends IInternalModalAttrs {
|
export interface IEditUserModalAttrs extends IInternalModalAttrs {
|
||||||
user: User;
|
user: User;
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import RequestError from '../utils/RequestError';
|
import type RequestError from '../utils/RequestError';
|
||||||
import Modal, { IInternalModalAttrs } from './Modal';
|
import Modal, { IInternalModalAttrs } from './Modal';
|
||||||
|
|
||||||
export interface IRequestErrorModalAttrs extends IInternalModalAttrs {
|
export interface IRequestErrorModalAttrs extends IInternalModalAttrs {
|
||||||
error: RequestError;
|
error: RequestError;
|
||||||
formattedError: string[];
|
formattedError: string[];
|
||||||
};
|
}
|
||||||
|
|
||||||
export default class RequestErrorModal<CustomAttrs extends IRequestErrorModalAttrs = IRequestErrorModalAttrs> extends Modal<CustomAttrs> {
|
export default class RequestErrorModal<CustomAttrs extends IRequestErrorModalAttrs = IRequestErrorModalAttrs> extends Modal<CustomAttrs> {
|
||||||
className() {
|
className() {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import Component from '../Component';
|
import type Component from '../Component';
|
||||||
import Modal from '../components/Modal';
|
import Modal from '../components/Modal';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -8,7 +8,7 @@ import Modal from '../components/Modal';
|
|||||||
* https://github.com/Microsoft/TypeScript/issues/1213
|
* https://github.com/Microsoft/TypeScript/issues/1213
|
||||||
* Therefore, we have to use this ugly, messy workaround.
|
* 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.
|
* Class used to manage modal state.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user