From 88f182cc93216314956a647fbbeef6ed1ce9c3c0 Mon Sep 17 00:00:00 2001 From: Davide Iadeluca <146922689+DavideIadeluca@users.noreply.github.com> Date: Wed, 2 Oct 2024 13:13:26 +0200 Subject: [PATCH] [1.x] [extensibility] Add (some) missing shims (#4027) * chore: add some missing shims * chore: remove unused import --- extensions/approval/js/src/@types/shims.d.ts | 12 ++++++++++++ extensions/likes/js/src/@types/shims.d.ts | 2 +- extensions/lock/js/src/@types/shims.d.ts | 6 ++++++ extensions/nicknames/js/src/@types/shims.d.ts | 5 +++++ extensions/sticky/js/src/@types/shims.d.ts | 6 ++++++ extensions/suspend/js/src/@types/shims.d.ts | 8 ++++++++ 6 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 extensions/approval/js/src/@types/shims.d.ts create mode 100644 extensions/lock/js/src/@types/shims.d.ts create mode 100644 extensions/nicknames/js/src/@types/shims.d.ts create mode 100644 extensions/sticky/js/src/@types/shims.d.ts create mode 100644 extensions/suspend/js/src/@types/shims.d.ts diff --git a/extensions/approval/js/src/@types/shims.d.ts b/extensions/approval/js/src/@types/shims.d.ts new file mode 100644 index 0000000000..0f4135403c --- /dev/null +++ b/extensions/approval/js/src/@types/shims.d.ts @@ -0,0 +1,12 @@ +declare module 'flarum/common/models/Discussion' { + export default interface Discussion { + isApproved(): boolean; + } +} + +declare module 'flarum/common/models/Post' { + export default interface Post { + isApproved(): boolean; + canApprove(): boolean; + } +} diff --git a/extensions/likes/js/src/@types/shims.d.ts b/extensions/likes/js/src/@types/shims.d.ts index fb573ff95e..358a273932 100644 --- a/extensions/likes/js/src/@types/shims.d.ts +++ b/extensions/likes/js/src/@types/shims.d.ts @@ -1,9 +1,9 @@ -import Post from 'flarum/common/models/Post'; import User from 'flarum/common/models/User'; declare module 'flarum/common/models/Post' { export default interface Post { likes(): User[]; likesCount(): number; + canLike(): boolean; } } diff --git a/extensions/lock/js/src/@types/shims.d.ts b/extensions/lock/js/src/@types/shims.d.ts new file mode 100644 index 0000000000..38375c0792 --- /dev/null +++ b/extensions/lock/js/src/@types/shims.d.ts @@ -0,0 +1,6 @@ +declare module 'flarum/common/models/Discussion' { + export default interface Discussion { + isLocked(): boolean; + canLock(): boolean; + } +} diff --git a/extensions/nicknames/js/src/@types/shims.d.ts b/extensions/nicknames/js/src/@types/shims.d.ts new file mode 100644 index 0000000000..145fe8e5a3 --- /dev/null +++ b/extensions/nicknames/js/src/@types/shims.d.ts @@ -0,0 +1,5 @@ +declare module 'flarum/common/models/User' { + export default interface User { + canEditNickname(): boolean; + } +} diff --git a/extensions/sticky/js/src/@types/shims.d.ts b/extensions/sticky/js/src/@types/shims.d.ts new file mode 100644 index 0000000000..1a589e7429 --- /dev/null +++ b/extensions/sticky/js/src/@types/shims.d.ts @@ -0,0 +1,6 @@ +declare module 'flarum/common/models/Discussion' { + export default interface Discussion { + isSticky(): boolean; + canSticky(): boolean; + } +} diff --git a/extensions/suspend/js/src/@types/shims.d.ts b/extensions/suspend/js/src/@types/shims.d.ts new file mode 100644 index 0000000000..4cd4d2b6a5 --- /dev/null +++ b/extensions/suspend/js/src/@types/shims.d.ts @@ -0,0 +1,8 @@ +declare module 'flarum/common/models/User' { + export default interface User { + canSuspend(): boolean; + suspendedUntil(): Date | string | null | undefined; + suspendReason(): string | null | undefined; + suspendMessage(): string | null | undefined; + } +}