Converted some left-over JavaScript file to TypeScript

Summary: Found some errors in a CI failure originating from a JavaScript file. The horror!

Reviewed By: jknoxville

Differential Revision: D29549998

fbshipit-source-id: 633100ec9a446050bb0c703dcc37e9b132b17198
This commit is contained in:
Michel Weststrate
2021-07-06 01:45:41 -07:00
committed by Facebook GitHub Bot
parent 9ca8bee208
commit 04ec026034
11 changed files with 41 additions and 33 deletions

View File

@@ -0,0 +1,53 @@
/**
* 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
*/
import {default as HmrClient} from './HMRClient';
// @ts-ignore
import {default as ReactRefreshRuntime} from 'react-refresh/runtime';
HmrClient.setup(
'web',
'/app/src/init-fast-refresh.bundle',
'localhost',
'3000',
true,
);
ReactRefreshRuntime.injectIntoGlobalHook(window);
const Refresh = {
performFullRefresh(reason: string) {
console.log('Perform full refresh', reason);
window.location.reload();
},
createSignatureFunctionForTransform:
ReactRefreshRuntime.createSignatureFunctionForTransform,
isLikelyComponentType: ReactRefreshRuntime.isLikelyComponentType,
getFamilyByType: ReactRefreshRuntime.getFamilyByType,
register: ReactRefreshRuntime.register,
performReactRefresh() {
if (ReactRefreshRuntime.hasUnrecoverableErrors()) {
console.error('Fast refresh - Unrecolverable');
window.location.reload();
return;
}
ReactRefreshRuntime.performReactRefresh();
console.log('Perform react refresh');
},
};
(require as any).Refresh = Refresh;
// eslint-disable-next-line import/no-commonjs
require('./init.tsx');