mirror of
https://github.com/loro-dev/loro.git
synced 2024-11-28 17:41:49 +00:00
fix: type error
This commit is contained in:
parent
c3d5e92407
commit
367975e1ac
1 changed files with 10 additions and 10 deletions
|
@ -179,10 +179,10 @@ export function isContainer(value: any): value is Container {
|
||||||
*/
|
*/
|
||||||
export function getType<T>(
|
export function getType<T>(
|
||||||
value: T,
|
value: T,
|
||||||
): T extends LoroText<any> ? "Text"
|
): T extends LoroText ? "Text"
|
||||||
: T extends LoroMap<any, any> ? "Map"
|
: T extends LoroMap<any> ? "Map"
|
||||||
: T extends LoroTree<any, any> ? "Tree"
|
: T extends LoroTree<any> ? "Tree"
|
||||||
: T extends LoroList<any, any> ? "List"
|
: T extends LoroList<any> ? "List"
|
||||||
: "Json" {
|
: "Json" {
|
||||||
if (isContainer(value)) {
|
if (isContainer(value)) {
|
||||||
return value.kind() as unknown as any;
|
return value.kind() as unknown as any;
|
||||||
|
@ -212,7 +212,7 @@ declare module "loro-wasm" {
|
||||||
interface LoroList<
|
interface LoroList<
|
||||||
T extends any[] = any[],
|
T extends any[] = any[],
|
||||||
> {
|
> {
|
||||||
new (): LoroList<T, false>;
|
new (): LoroList<T>;
|
||||||
insertContainer<C extends Container>(
|
insertContainer<C extends Container>(
|
||||||
pos: number,
|
pos: number,
|
||||||
child: C,
|
child: C,
|
||||||
|
@ -223,13 +223,13 @@ declare module "loro-wasm" {
|
||||||
insert(pos: number, value: Value): void;
|
insert(pos: number, value: Value): void;
|
||||||
delete(pos: number, len: number): void;
|
delete(pos: number, len: number): void;
|
||||||
subscribe(txn: Loro, listener: Listener): number;
|
subscribe(txn: Loro, listener: Listener): number;
|
||||||
getAttached(): undefined | LoroList<T, true>;
|
getAttached(): undefined | LoroList<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface LoroMap<
|
interface LoroMap<
|
||||||
T extends Record<string, any> = Record<string, any>,
|
T extends Record<string, any> = Record<string, any>,
|
||||||
> {
|
> {
|
||||||
new (): LoroMap<T, false>;
|
new (): LoroMap<T>;
|
||||||
getOrCreateContainer<C extends Container>(
|
getOrCreateContainer<C extends Container>(
|
||||||
key: string,
|
key: string,
|
||||||
child: C,
|
child: C,
|
||||||
|
@ -246,8 +246,8 @@ declare module "loro-wasm" {
|
||||||
subscribe(txn: Loro, listener: Listener): number;
|
subscribe(txn: Loro, listener: Listener): number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface LoroText<Attached extends boolean = false> {
|
interface LoroText {
|
||||||
new (): LoroText<false>;
|
new (): LoroText;
|
||||||
insert(pos: number, text: string): void;
|
insert(pos: number, text: string): void;
|
||||||
delete(pos: number, len: number): void;
|
delete(pos: number, len: number): void;
|
||||||
subscribe(txn: Loro, listener: Listener): number;
|
subscribe(txn: Loro, listener: Listener): number;
|
||||||
|
@ -256,7 +256,7 @@ declare module "loro-wasm" {
|
||||||
interface LoroTree<
|
interface LoroTree<
|
||||||
T extends Record<string, any> = Record<string, any>,
|
T extends Record<string, any> = Record<string, any>,
|
||||||
> {
|
> {
|
||||||
new (): LoroTree<T, false>;
|
new (): LoroTree<T>;
|
||||||
createNode(parent: TreeID | undefined): LoroTreeNode<T>;
|
createNode(parent: TreeID | undefined): LoroTreeNode<T>;
|
||||||
move(target: TreeID, parent: TreeID | undefined): void;
|
move(target: TreeID, parent: TreeID | undefined): void;
|
||||||
delete(target: TreeID): void;
|
delete(target: TreeID): void;
|
||||||
|
|
Loading…
Reference in a new issue