[flow] type KeyEscapeUtils (#7079)
Summary: The only call site ensures that the value is not null: https://github.com/facebook/react/blob/dc6fc8cc0726458a14f0544a30514af208d0098b/src/shared/utils/traverseAllChildren.js#L44 key is stringified inside of createElement, so we are guaranteed to receive a string right now: https://github.com/facebook/react/blob/dc6fc8cc0726458a14f0544a30514af208d0098b/src/isomorphic/classic/element/ReactElement.js#L142 Test Plan: npm run flow Reviewers: @zpao @spicyj
Christopher Chedeau committed
Jun 19, 2016 at 21:58 UTC
12a6ad1ef5e537d20817da93b2346064862589e3
1 file changed
+4
-3
src/shared/utils/KeyEscapeUtils.js
+4
-3
@@ -7,6 +7,7 @@
7
* of patent rights can be found in the PATENTS file in the same directory.
8
*
9
* @providesModule KeyEscapeUtils
10
+ * @flow
11
*/
12
13
'use strict';
@@ -14,10 +15,10 @@
15
/**
16
* Escape and wrap key so it is safe to use as a reactid
17
*
17
- * @param {*} key to be escaped.
18
+ * @param {string} key to be escaped.
19
* @return {string} the escaped key.
20
*/
20
-function escape(key) {
21
+function escape(key: string): string {
22
var escapeRegex = /[=:]/g;
23
var escaperLookup = {
24
'=': '=0',
@@ -39,7 +40,7 @@ function escape(key) {
40
* @param {string} key to unescape.
41
* @return {string} the unescaped key.
42
*/
42
-function unescape(key) {
43
+function unescape(key: string): string {
44
var unescapeRegex = /(=0|=2)/g;
45
var unescaperLookup = {
46
'=0': '=',