From 027ba0ca0c2c1911ce58da45efa97ecc25007578 Mon Sep 17 00:00:00 2001 From: "Jacob D. Castro" Date: Thu, 14 May 2020 12:07:07 -0700 Subject: [PATCH] Add Null return value type in code example TypeScript threw this error when I attempted to copy and paste in my code: ``` Type 'null' is not assignable to type 'string'.ts(2322) ``` The `getDefaultKeyBinding()` method may return null. So I added `| null` to the return type declaration. Just thought it would help others who may also be copying/pasting the code! --- docs/Advanced-Topics-Key-Bindings.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Advanced-Topics-Key-Bindings.md b/docs/Advanced-Topics-Key-Bindings.md index 8ee64f13d2..52f8acaf4f 100644 --- a/docs/Advanced-Topics-Key-Bindings.md +++ b/docs/Advanced-Topics-Key-Bindings.md @@ -44,7 +44,7 @@ First, let's define our key binding function: import {getDefaultKeyBinding, KeyBindingUtil} from 'draft-js'; const {hasCommandModifier} = KeyBindingUtil; -function myKeyBindingFn(e: SyntheticKeyboardEvent): string { +function myKeyBindingFn(e: SyntheticKeyboardEvent): string | null { if (e.keyCode === 83 /* `S` key */ && hasCommandModifier(e)) { return 'myeditor-save'; }