Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error in signature of withReact

See original GitHub issue

Description Attempting to start a new Typescript project on @next is causing interface issues from the 1st line.

const editor = React.useMemo(() => withReact(createEditor()), []);

Immediately complains because createEditor() returns a BaseEditor and the definition for withReact requires a generic type T that extends from ReactEditor and then returns a union of T & ReactEditor which doesn’t seem right.

Recording (Definition: slate-react/dist/plugin/with-react.d.ts)

Steps To reproduce the behavior:

  1. On a fresh TS app write const editor = React.useMemo(() => withReact(createEditor()), []);
  2. See error

Expectation I expect this is an error, and that withReact wants a generic extending BaseEditor


  • Slate Version: [e.g. 0.60.15]
  • Operating System: [N/A]
  • Browser: [N/A]
  • TypeScript Version: 4.1.5

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:18
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

santialbocommented, Nov 30, 2021

This is weird, the types are correct in the source

However on the generated type definitions they are wrong

export declare const withReact: <T extends ReactEditor>(editor: T) => T & ReactEditor;

should be

export declare const withReact: <T extends Editor>(editor: T) => T & ReactEditor;
johnsorianodevcommented, Mar 22, 2022

Same here, but I was able to resolve like the implementation of @abdessamadelhamdany

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to solve customHooks call signature error in react with ...
I tried to solve call signature error but I couldn't figure it out. I try to use custom hooks which it takes a...
Read more >
Azure Identity Authentication error "invalid signature" with ...
Azure Identity Authentication error "invalid signature" with React + Core Web API. Anyone know how I can go about finding out why I...
Read more >
Getting started with React Signature component - Syncfusion
The following section explains the required steps to build the Signature component with its basic usage in step-by-step procedure. If playback doesn't begin ......
Read more >
react-signature-canvas - npm
A React wrapper component around signature_pad. Unopinionated and heavily updated fork of react-signature-pad. Latest version: 1.0.6, ...
Read more >
Sign and Verify messages with React.js and MetaMask
Learn how to generate and verify signatures from React.js code using MetaMask wallet.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found