mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Give a more explicit message about why number isn't supported
Summary: Give a more explicit message about why `number` isn't supported Reviewed By: rickhanlonii Differential Revision: D16926698 fbshipit-source-id: 292cb13aa11205e1350209178bde1977a2a7ad4c
This commit is contained in:
committed by
Facebook Github Bot
parent
43f042eb7d
commit
11dc847ec9
+30
@@ -403,6 +403,35 @@ export default (codegenNativeComponent<ModuleProps>(
|
||||
): NativeComponent<ModuleProps>);
|
||||
`;
|
||||
|
||||
const PROP_NUMBER_TYPE = `
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
* @flow
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import type {ViewProps} from 'ViewPropTypes';
|
||||
import type {NativeComponent} from 'codegenNativeComponent';
|
||||
|
||||
const codegenNativeComponent = require('codegenNativeComponent');
|
||||
|
||||
export type ModuleProps = $ReadOnly<{|
|
||||
...ViewProps,
|
||||
|
||||
someProp: number
|
||||
|}>;
|
||||
|
||||
export default (codegenNativeComponent<ModuleProps>(
|
||||
'Module',
|
||||
): NativeComponent<ModuleProps>);
|
||||
`;
|
||||
|
||||
module.exports = {
|
||||
COMMANDS_DEFINED_INLINE,
|
||||
COMMANDS_DEFINED_MULTIPLE_TIMES,
|
||||
@@ -415,4 +444,5 @@ module.exports = {
|
||||
PROPS_CONFLICT_NAMES,
|
||||
PROPS_CONFLICT_WITH_SPREAD_PROPS,
|
||||
PROPS_SPREAD_CONFLICTS_WITH_PROPS,
|
||||
PROP_NUMBER_TYPE,
|
||||
};
|
||||
|
||||
+2
@@ -16,6 +16,8 @@ exports[`RN Codegen Flow Parser Fails with error message NON_OPTIONAL_KEY_WITH_D
|
||||
|
||||
exports[`RN Codegen Flow Parser Fails with error message NULLABLE_WITH_DEFAULT 1`] = `"WithDefault<> is optional and does not need to be marked as optional. Please remove the ? annotation in front of it."`;
|
||||
|
||||
exports[`RN Codegen Flow Parser Fails with error message PROP_NUMBER_TYPE 1`] = `"Cannot use \\"NumberTypeAnnotation\\" type annotation for \\"someProp\\": must use a specific numeric type like Int32, Double, or Float"`;
|
||||
|
||||
exports[`RN Codegen Flow Parser Fails with error message PROPS_CONFLICT_NAMES 1`] = `"A prop was already defined with the name isEnabled"`;
|
||||
|
||||
exports[`RN Codegen Flow Parser Fails with error message PROPS_CONFLICT_WITH_SPREAD_PROPS 1`] = `"A prop was already defined with the name isEnabled"`;
|
||||
|
||||
@@ -229,6 +229,10 @@ function getTypeAnnotation(name, annotation, defaultValue, types) {
|
||||
};
|
||||
}
|
||||
throw new Error(`A default enum value is required for "${name}"`);
|
||||
case 'NumberTypeAnnotation':
|
||||
throw new Error(
|
||||
`Cannot use "${type}" type annotation for "${name}": must use a specific numeric type like Int32, Double, or Float`,
|
||||
);
|
||||
default:
|
||||
(type: empty);
|
||||
throw new Error(`Unknown prop type for "${name}": "${type}"`);
|
||||
|
||||
Reference in New Issue
Block a user