1
0
mirror of https://github.com/flarum/core.git synced 2025-08-06 08:27:42 +02:00

fix: Assorted Typing Fixes (#3348)

With all the commits below, we resolve all outstanding typing issues in the repo, and CI jobs run green.

* fix: Convert DashboardPage and DashboardWidget to TypeScript

* fix: fix type errors in package manager ext

* fix: Convert Post component to TypeScript

* fix: avatar typings should accept null user

* fix: convert Notification component to TypeScript

* fix: properly use `typeof` in ForumApplication

* feat: make Notification content attr generic

* chore: format Notification component

* fix: Convert DiscussionRenamedNotification to TypeScript

* fix(pusher) move shims to a location where they get applied

* fix(pusher): fix some typing errors

* fix(akismet): fix some typing issues

* chore: update core dist typings

* chore(pusher): format

* fix: anchorScroll should accept string selectors

* fix: more accurately represent ApiQueryParamsPlural

* fix: convert PostStreamState to TypeScript

* chore(core): rebuild typings

* feat: allow extending app.routes

* fix: more flexible typings for highlight.ts

* fix: use primitive `number` type for Discussion typings

* fix: convert DiscussionListItem to TypeScript

* chore: rebuild core typings

* fix: final pusher type fixes

* feat: start tags TypeScript conversion

* fix: require-dev tags in pusher for CI TypeScript purposes.

* chore(core): format

* chore(tags): build dist typings

* feat(pusher): use dist types from tags.

* feat: convert flags to TypeScript

* chore(flags): generate dist typings

* fix(akismet): last type errors

* chore: update .yarn-integrity

* chore: partially run flarum-cli audit infra --fix

The tsconfig changes from that command are ignored, since we don't yet support "replacable sections" that would let us add custom config.

* chore: use type imports

* fix: broader gitattributes

* chore: run flarum-cli audit infra --monorepo --fix

* feat: make `app.data` typings extensible

* chore(core): format

* chore: boost tags TypeScript coverage

* fix(tags): further increase type coverage.
This commit is contained in:
Alexander Skvortsov
2022-03-23 11:43:14 -04:00
committed by GitHub
parent 4ecd9a9b2f
commit a595665bfb
255 changed files with 1578 additions and 1218 deletions

22
extensions/flags/js/dist-typings/@types/shims.d.ts generated vendored Normal file
View File

@@ -0,0 +1,22 @@
import Flag from '../forum/models/Flag';
import FlagListState from '../forum/states/FlagListState';
import Mithril from 'mithril';
declare module 'flarum/common/models/Post' {
export default interface Post {
flags: () => false | (Flag | undefined)[];
canFlag: () => boolean;
}
}
declare module 'flarum/forum/ForumApplication' {
export default interface ForumApplication {
flags: FlagListState;
}
}
declare module 'flarum/forum/components/Post' {
export default interface Post {
flagReason: (flag: Flag) => Mithril.Children;
}
}

1
extensions/flags/js/dist-typings/admin/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1 @@
export default function _default(): void;

View File

@@ -0,0 +1 @@
export default function _default(): void;

View File

@@ -0,0 +1 @@
export default function _default(): void;

19
extensions/flags/js/dist-typings/forum/compat.d.ts generated vendored Normal file
View File

@@ -0,0 +1,19 @@
declare var _default: {
'flags/addFlagsToPosts': typeof addFlagsToPosts;
'flags/addFlagControl': typeof addFlagControl;
'flags/addFlagsDropdown': typeof addFlagsDropdown;
'flags/models/Flag': typeof Flag;
'flags/components/FlagList': typeof FlagList;
'flags/components/FlagPostModal': typeof FlagPostModal;
'flags/components/FlagsPage': typeof FlagsPage;
'flags/components/FlagsDropdown': typeof FlagsDropdown;
};
export default _default;
import addFlagsToPosts from "./addFlagsToPosts";
import addFlagControl from "./addFlagControl";
import addFlagsDropdown from "./addFlagsDropdown";
import Flag from "./models/Flag";
import FlagList from "./components/FlagList";
import FlagPostModal from "./components/FlagPostModal";
import FlagsPage from "./components/FlagsPage";
import FlagsDropdown from "./components/FlagsDropdown";

View File

@@ -0,0 +1,7 @@
export default class FlagList extends Component<import("flarum/common/Component").ComponentAttrs, undefined> {
constructor();
oninit(vnode: any): void;
state: any;
view(): JSX.Element;
}
import Component from "flarum/common/Component";

View File

@@ -0,0 +1,15 @@
/// <reference types="flarum/@types/translator-icu-rich" />
export default class FlagPostModal extends Modal<import("flarum/common/components/Modal").IInternalModalAttrs> {
constructor();
oninit(vnode: any): void;
success: boolean | undefined;
reason: Stream<string> | undefined;
reasonDetail: Stream<string> | undefined;
title(): import("@askvortsov/rich-icu-message-formatter").NestedStringArray;
content(): JSX.Element;
flagReasons(): ItemList<any>;
onsubmit(e: any): void;
}
import Modal from "flarum/common/components/Modal";
import Stream from "flarum/common/utils/Stream";
import ItemList from "flarum/common/utils/ItemList";

View File

@@ -0,0 +1,7 @@
export default class FlagsDropdown {
static initAttrs(attrs: any): void;
getMenu(): JSX.Element;
goToRoute(): void;
getUnreadCount(): any;
getNewCount(): unknown;
}

View File

@@ -0,0 +1,9 @@
/**
* The `FlagsPage` component shows the flags list. It is only
* used on mobile devices where the flags dropdown is within the drawer.
*/
export default class FlagsPage {
oninit(vnode: any): void;
bodyClass: string | undefined;
view(): JSX.Element;
}

1
extensions/flags/js/dist-typings/forum/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,11 @@
import Model from 'flarum/common/Model';
import Post from 'flarum/common/models/Post';
import User from 'flarum/common/models/User';
export default class Flag extends Model {
type(): string;
reason(): string | null;
reasonDetail(): string | null;
createdAt(): Date | null | undefined;
post(): false | Post;
user(): false | User | null;
}

View File

@@ -0,0 +1,16 @@
export default class FlagListState {
constructor(app: any);
app: any;
/**
* Whether or not the flags are loading.
*
* @type {Boolean}
*/
loading: boolean;
/**
* Load flags into the application's cache if they haven't already
* been loaded.
*/
load(): void;
cache: any;
}