Support TypeScript declaration merging
See original GitHub issueSlate: 0.58.1
I’d really like to refine the internal editor types. Typescript supposedly has support for this:
https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
But I think its not working currently, because for example text.d.ts exports a interface Text and a const Text so I think Typescript is having trouble with that.
Ideally, I can just write this code:
declare module "slate" {
interface Text {
bold?: string
}
}
And now the text type everywhere in my codebase has a bold property.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:19 (1 by maintainers)
Top Results From Across the Web
Documentation - Declaration Merging - TypeScript
For the purposes of this article, “declaration merging” means that the compiler merges two separate declarations declared with the same name into a...
Read more >Declaration merging in TypeScript for regular devs - Merixstudio
In TypeScript, when two separate declarations with the same name are being merged into a single definition, it is called declaration merging. It ......
Read more >TypeScript: Enhance Variable Types with Declaration Merging
TypeScript : Enhance Variable Types with Declaration Merging. This story is about an often applied technique by libraries that offer full TypeScript support....
Read more >What is Declaration Merging in Typescript ? - GeeksforGeeks
In Typescript, the term “declaration merging” refers to the compiler combining two declarations with the same name into a single definition.
Read more >How can I use Typescript's declaration merging with an ...
I'm currently using Typescript 3.0.3. This does what I want, but I don't understand why I can't do the same thing with declaration...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Declaration merging requires an interface; however, an interface doesn’t support union types.
Because of this, I wonder if we should close this issue in favour of a generic
type
. An example is a block that can be a paragraph, heading or list. With atype
, we can define it as:The benefit is that we can use type discrimination:
Yeah, I don’t like that pattern either (and don’t do it myself). I was just trying to come up with a small and pragmatic solution for you all.
On Wed, May 13, 2020 at 11:59 PM Oleksii Shurubura notifications@github.com wrote: