mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: The types we were using before weren't very strict and it had been on my list to fix this. I *think* this is the right type. With Flow's type first project having these exported types will be necessary anyways so we can just use that for the ref. Changelog: [Internal] Reviewed By: JoshuaGross Differential Revision: D16930573 fbshipit-source-id: 05c1e097794633a2cefa7384c9d81ab15a63d8af
89 lines
2.1 KiB
JavaScript
89 lines
2.1 KiB
JavaScript
/**
|
|
* 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.
|
|
*
|
|
* @flow
|
|
* @format
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const COMMANDS_EXPORTED_WITH_DIFFERENT_NAME = `
|
|
// @flow
|
|
|
|
const codegenNativeComponent = require('codegenNativeComponent');
|
|
|
|
import type {ViewProps} from 'ViewPropTypes';
|
|
import type {NativeComponent} from 'codegenNativeComponent';
|
|
|
|
type ModuleProps = $ReadOnly<{|
|
|
...ViewProps,
|
|
|}>;
|
|
|
|
type NativeType = NativeComponent<ModuleProps>;
|
|
|
|
interface NativeCommands {
|
|
+hotspotUpdate: (viewRef: React.ElementRef<NativeType>) => void;
|
|
}
|
|
|
|
export const Foo = codegenNativeCommands<NativeCommands>();
|
|
|
|
export default (codegenNativeComponent<ModuleProps>('Module'): NativeType);
|
|
`;
|
|
|
|
const OTHER_COMMANDS_EXPORT = `
|
|
// @flow
|
|
|
|
const codegenNativeComponent = require('codegenNativeComponent');
|
|
|
|
import type {ViewProps} from 'ViewPropTypes';
|
|
import type {NativeComponent} from 'codegenNativeComponent';
|
|
|
|
type ModuleProps = $ReadOnly<{|
|
|
...ViewProps,
|
|
|}>;
|
|
|
|
type NativeType = NativeComponent<ModuleProps>;
|
|
|
|
interface NativeCommands {
|
|
+hotspotUpdate: (viewRef: React.ElementRef<NativeType>) => void;
|
|
}
|
|
|
|
export const Commands = 4;
|
|
|
|
export default (codegenNativeComponent<ModuleProps>('Module'): NativeType);
|
|
`;
|
|
|
|
const COMMANDS_EXPORTED_WITH_SHORTHAND = `
|
|
// @flow
|
|
|
|
const codegenNativeComponent = require('codegenNativeComponent');
|
|
import type {NativeComponent} from 'codegenNativeComponent';
|
|
|
|
import type {ViewProps} from 'ViewPropTypes';
|
|
|
|
type ModuleProps = $ReadOnly<{|
|
|
...ViewProps,
|
|
|}>;
|
|
|
|
type NativeType = NativeComponent<ModuleProps>;
|
|
|
|
interface NativeCommands {
|
|
+hotspotUpdate: (viewRef: React.ElementRef<NativeType>) => void;
|
|
}
|
|
|
|
const Commands = 4;
|
|
|
|
export {Commands};
|
|
|
|
export default (codegenNativeComponent<ModuleProps>('Module'): NativeType);
|
|
`;
|
|
|
|
module.exports = {
|
|
'CommandsExportedWithDifferentNameNativeComponent.js': COMMANDS_EXPORTED_WITH_DIFFERENT_NAME,
|
|
'CommandsExportedWithShorthandNativeComponent.js': COMMANDS_EXPORTED_WITH_SHORTHAND,
|
|
'OtherCommandsExportNativeComponent.js': OTHER_COMMANDS_EXPORT,
|
|
};
|