Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Commit

Permalink
Add Null return value type in code example (#2429)
Browse files Browse the repository at this point in the history
Summary:
**Summary**

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!

**Test Plan**

No testing required.
Pull Request resolved: #2429

Reviewed By: kedromelon

Differential Revision: D21652264

Pulled By: mrkev

fbshipit-source-id: c820028da1ec6eb17055aceb5a751f7d01636b83
  • Loading branch information
Jacob D. Castro authored and facebook-github-bot committed May 21, 2020
1 parent e3a689d commit 45bb6b5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/Advanced-Topics-Key-Bindings.md
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand Down

0 comments on commit 45bb6b5

Please sign in to comment.