fix(editor): improve type declaration definition (#10866)

Closes: [BS-2809](https://linear.app/affine-design/issue/BS-2809/改进继承自抽象类的类型后-createidentifier-类型定义)

### What's Changed!

* Improved type declaration definition
This commit is contained in:
fundon
2025-03-14 10:38:16 +00:00
parent d8dfea6ccf
commit 99fdfe821a
7 changed files with 22 additions and 36 deletions

View File

@@ -78,10 +78,11 @@ import type {
export function createIdentifier<T>(
name: string,
variant: ServiceVariant = DEFAULT_SERVICE_VARIANT
): ServiceIdentifier<T> & ((variant: ServiceVariant) => ServiceIdentifier<T>) {
): ServiceIdentifier<T> &
(<U extends T = T>(variant: ServiceVariant) => ServiceIdentifier<U>) {
return Object.assign(
(variant: ServiceVariant) => {
return createIdentifier<T>(name, variant);
<U extends T = T>(variant: ServiceVariant) => {
return createIdentifier<U>(name, variant);
},
{
identifierName: name,