slate
slate copied to clipboard
Docs: Typescript examples are faulty or missing
Problem I tried to setup a sample project by reading the docs and stumbled upon some missing dependencies and wrongly formatted code which is hard to fix if someone tries to implement the initial setup as a beginner.
Solution The sections in https://docs.slatejs.org/walkthroughs/01-installing-slate as well as https://docs.slatejs.org/concepts/12-typescript need formatting updates as well as a check if things work if you stick to the documentation.
Context I can take care of this, if it is helpful.
Sidenote: When implementing https://docs.slatejs.org/walkthroughs/05-executing-commands in TS, there is an issue, that bold
is used for spans in prior and in this example for the complete blocks
I found the docs hard to follow too when using TS. The best solution would be to split every page into two separate JS and TS sections.
@ilovecommits In the 01-installing-slate
, the TypeScript code for setting up the component has a compilation error. CustomElement
should be an array.
// Correct version
const App = () => {
const initialValue: CustomElement[] = []
//...
}
@ilovecommits In the
01-installing-slate
, the TypeScript code for setting up the component has a compilation error.CustomElement
should be an array.// Correct version const App = () => { const initialValue: CustomElement[] = [] //... }
Not sure why you tagged me, but just submit a PR.
Same, getting:
Subsequent property declarations must have the same type. Property 'Element' must be of type 'CustomElement', but here has type 'CustomElement'.
When trying the first example
Sidenote: When implementing https://docs.slatejs.org/walkthroughs/05-executing-commands in TS, there is an issue, that
bold
is used for spans in prior and in this example for the complete blocks
@TrySpace were you able to resolve this? I am getting a similar error in my codebase.
In 2024 I came here to complain about this, once again. It would be really nice to be able to understand which types I should use for all the different use cases, instead of putting any
or @ts-ignore
everywhere so the code even compiles...