From 3215d8d6f8f3157d65e42c57b096bf6996a55d7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20K=C3=BChn?= Date: Thu, 20 Jan 2022 11:53:45 +0100 Subject: [PATCH] docs: improve typescript docs, fix #2407 --- docs/guide/typescript.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/guide/typescript.md b/docs/guide/typescript.md index 8cc77401..12ad76bc 100644 --- a/docs/guide/typescript.md +++ b/docs/guide/typescript.md @@ -45,6 +45,8 @@ export interface CustomExtensionStorage { } const CustomExtension = Extension.create<{}, CustomExtensionStorage>({ + name: 'customExtension', + addStorage() { return { awesomeness: 100, @@ -53,6 +55,14 @@ const CustomExtension = Extension.create<{}, CustomExtensionStorage>({ }) ``` +When using storage outside of the extension you have to manually set the type. + +``` +import { CustomExtensionStorage } from './custom-extension + +const customStorage = editor.storage.customExtension as CustomExtensionStorage +``` + ### Command type The core package also exports a `Command` type, which needs to be added to all commands that you specify in your code. Here is an example: