slate icon indicating copy to clipboard operation
slate copied to clipboard

Docs: Typescript examples are faulty or missing

Open schlenger opened this issue 3 years ago • 7 comments

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.

schlenger avatar Jul 27 '21 08:07 schlenger

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

schlenger avatar Jul 28 '21 16:07 schlenger

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.

ghost avatar Aug 03 '21 10:08 ghost

@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[] = []
  //...
}

image

Andrewnt219 avatar Aug 24 '21 14:08 Andrewnt219

@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[] = []
  //...
}

image

Not sure why you tagged me, but just submit a PR.

ghost avatar Aug 24 '21 14:08 ghost

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

TrySpace avatar Jan 07 '22 12:01 TrySpace

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.

BrentFarese avatar Oct 11 '22 16:10 BrentFarese

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...

maral avatar Mar 13 '24 19:03 maral