/
githubmr
/
facebook-react-native
Обзор
Документация
Войти
/
githubmr
/
facebook-react-native
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
packages/react-native/Libraries/Utilities/codegenNativeCommands.js
33 строки
861 B
Sam Zhou
Standardize subtyping error code into `incompatible-type` in react native and metro (#53312)
18 авг 2025, 19:04
18 авг 2025, 19:04
cf664c6
Код
Авторство
О чём код?
/** * Copyright (c) Meta Platforms, Inc. and 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 */ const {dispatchCommand} = require('../ReactNative/RendererProxy'); type NativeCommandsOptions<T = string> = $ReadOnly<{ supportedCommands: $ReadOnlyArray<T>, }>; function codegenNativeCommands<T: interface {}>( options: NativeCommandsOptions<$Keys<T>>, ): T { const commandObj: {[$Keys<T>]: (...$ReadOnlyArray<mixed>) => void} = {}; options.supportedCommands.forEach(command => { // $FlowFixMe[missing-local-annot] commandObj[command] = (ref, ...args) => { // $FlowFixMe[incompatible-type] dispatchCommand(ref, command, args); }; }); return ((commandObj: any): T); } export default codegenNativeCommands;