I have built a react app with typescript and decided to move some code into a separate npm package using typescript references for easy builts. The moved code is mostly related to interacting with a 3rd party lib called Slate. (text editor written in react and typescript)
The separation here only moves the data core but not anything react related. So the shared lib is a simple typescript package with basically one main dependency being Slate. Later I want to be able to use this package in the backend as well as the frontend.
After having moved the code i start to see a few weird type conflicts. I already tried to install Slate in the shared package as peer dependency but that doesnt seem to have an effect on the "tsc --build".
Consumer (react app)
.d.ts file to augment 3rd party lib 'Slate'
import { Element, EventsEditor, TextNode } from 'law-document';
import { BaseEditor } from 'slate';
import { ReactEditor } from 'slate-react';
declare module 'slate' {
interface CustomTypes {
Editor: BaseEditor & EventsEditor & ReactEditor
Element: Element;
Text: TextNode;
}
}