-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typescript definition from example #4290
Comments
@aboveyunhai Thanks for submitting the issue. Yes, please feel free to make a PR. I had no idea you could do I think some of the typings were missed during the upgrade to TypeScript. Please feel free to add them in. |
@thesunny I don't think it's a proper solution yet because |
I guess you could try Not sure if that works in TypeScript or not... I define text like FYI, the solution I'm currently using is to define the unstyled text like |
Description
There are some Typescript errors from the example if it's under a stricter typescript check environment, I would expect same problem from other areas that use the similar codes.
slate/site/examples/richtext.tsx
Lines 128 to 135 in 29051c8
Since type
{ leaf }
is eitherCustomText
orEmptyText
, there will be a typescript error thatbold does not exist
onEmptytext
when you try to do
leaf.bold
.A better way to do it without worry about
leaf
definition and type-safe isif("bold" in leaf) { }
I can create a PR for it but I am not sure it's suitable.
It's quite confusing that all files are using
.tsx
but none of them actually use typescript. I understand the slate.js typescript is a bit unusual and require some readings but then why not just make these file pure.js
since developer would definitely look at the.tsx
to get some typescript ideas.Expectation
No confused type error appearing.
Environment
Context
Add any other context about the problem here. (The fastest way to have an issue fixed is to create a pull request with working, tested code and we'll help merge it. Slate is solving a pretty complex problem, and we can't do it without active contributors, so thank you so much for your help!)
The text was updated successfully, but these errors were encountered: