Skip to content

Commit

Permalink
Fix offset type erros (facebook#2435)
Browse files Browse the repository at this point in the history
  • Loading branch information
thegreatercurve authored Jun 16, 2022
1 parent ce201e9 commit 04c7dec
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions packages/lexical-offset/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,23 +387,20 @@ function $searchForNodeWithOffset(
return null;
}

function $createInternalOffsetNode<
TChild extends OffsetNode,
TParent extends OffsetElementNode = OffsetElementNode,
>(
child: null | TChild,
function $createInternalOffsetNode(
child: null | OffsetNode,
type: 'element' | 'text' | 'inline',
start: number,
end: number,
key: NodeKey,
parent: null | TParent,
parent: null | OffsetElementNode,
): {
child: null | TChild;
child: null | OffsetNode;
type: 'element' | 'text' | 'inline';
start: number;
end: number;
key: NodeKey;
parent: null | TParent;
parent: null | OffsetElementNode;
next: null;
prev: null;
} {
Expand Down Expand Up @@ -459,8 +456,8 @@ function $createOffsetNode(
state.offset += blockOffsetSize;
}

const offsetNode = $createInternalOffsetNode<OffsetElementNode>(
child as OffsetElementNode,
const offsetNode = $createInternalOffsetNode(
child,
'element',
start,
start,
Expand All @@ -484,15 +481,18 @@ function $createOffsetNode(
const length = isText ? node.__text.length : 1;
const end = (state.offset += length);

const offsetNode = $createInternalOffsetNode<
OffsetTextNode | OffsetInlineNode
>(null, isText ? 'text' : 'inline', start, end, key, parent) as
| OffsetTextNode
| OffsetInlineNode;
const offsetNode = $createInternalOffsetNode(
null,
isText ? 'text' : 'inline',
start,
end,
key,
parent,
);

offsetMap.set(key, offsetNode);
offsetMap.set(key, offsetNode as OffsetNode);

return offsetNode;
return offsetNode as OffsetNode;
}

function $createOffsetChild(
Expand Down

0 comments on commit 04c7dec

Please sign in to comment.