From 4735f29b2ebf75d08186336561f13dd2857170ff Mon Sep 17 00:00:00 2001 From: Shigma Date: Thu, 18 Jan 2024 13:52:35 +0800 Subject: [PATCH] feat(element): add typing support for JSX --- adapters/discord/src/message.ts | 2 +- packages/element/package.json | 2 +- packages/element/src/index.ts | 28 ++++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/adapters/discord/src/message.ts b/adapters/discord/src/message.ts index 6776bdc1..4d005e1a 100644 --- a/adapters/discord/src/message.ts +++ b/adapters/discord/src/message.ts @@ -338,7 +338,7 @@ export class DiscordMessageEncoder extends MessageE } const quote = await this.bot.getMessage(channelId, replyId) if (!guildId) { - let c = await this.bot.internal.getChannel(channelId) + const c = await this.bot.internal.getChannel(channelId) if (c.guild_id) guildId = c.guild_id } if (!guildId) { diff --git a/packages/element/package.json b/packages/element/package.json index f268c243..a81705ca 100644 --- a/packages/element/package.json +++ b/packages/element/package.json @@ -1,7 +1,7 @@ { "name": "@satorijs/element", "description": "Element Manipulation", - "version": "3.0.0", + "version": "3.1.1", "main": "lib/index.cjs", "module": "lib/index.mjs", "types": "lib/index.d.ts", diff --git a/packages/element/src/index.ts b/packages/element/src/index.ts index 8b78b695..660eb979 100644 --- a/packages/element/src/index.ts +++ b/packages/element/src/index.ts @@ -1,5 +1,33 @@ import { arrayBufferToBase64, Awaitable, camelize, defineProperty, Dict, hyphenate, is, isNullable, makeArray } from 'cosmokit' +declare global { + namespace JSX { + interface IntrinsicElements { + message: { + id?: string + forward?: boolean + } + quote: { + id?: string + name?: string + avatar?: string + } + at: { + id?: string + name?: string + avatar?: string + role?: string + type?: string + } + sharp: { + id?: string + name?: string + avatar?: string + } + } + } +} + const kElement = Symbol.for('satori.element') interface Element {