(value: mixed)
| 102 | } |
| 103 | |
| 104 | export function describeValueForErrorMessage(value: mixed): string { |
| 105 | switch (typeof value) { |
| 106 | case 'string': { |
| 107 | return JSON.stringify( |
| 108 | value.length <= 10 ? value : value.slice(0, 10) + '...', |
| 109 | ); |
| 110 | } |
| 111 | case 'object': { |
| 112 | if (isArray(value)) { |
| 113 | return '[...]'; |
| 114 | } |
| 115 | if (value !== null && value.$$typeof === CLIENT_REFERENCE_TAG) { |
| 116 | return describeClientReference(value); |
| 117 | } |
| 118 | const name = objectName(value); |
| 119 | if (name === 'Object') { |
| 120 | return '{...}'; |
| 121 | } |
| 122 | return name; |
| 123 | } |
| 124 | case 'function': { |
| 125 | if ((value: any).$$typeof === CLIENT_REFERENCE_TAG) { |
| 126 | return describeClientReference(value); |
| 127 | } |
| 128 | const name = (value: any).displayName || value.name; |
| 129 | return name ? 'function ' + name : 'function'; |
| 130 | } |
| 131 | default: |
| 132 | // eslint-disable-next-line react-internal/safe-string-coercion |
| 133 | return String(value); |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | function describeElementType(type: any): string { |
| 138 | if (typeof type === 'string') { |
no test coverage detected