mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
34464fb16c
After the previous changes these upgrade are easy. - removes config options that were removed - object index access now requires an indexer key in the type, this cause a handful of errors that were fixed - undefined keys error in all places, this needed a few extra suppressions for repeated undefined identifiers. Flow's [CHANGELOG.md](https://github.com/facebook/flow/blob/main/Changelog.md).
44 lines
1.3 KiB
JavaScript
44 lines
1.3 KiB
JavaScript
/**
|
|
* 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
|
|
*/
|
|
|
|
function ignoreStrings(
|
|
methodName: string,
|
|
stringsToIgnore: Array<string>,
|
|
): void {
|
|
// $FlowFixMe[prop-missing] index access only allowed for objects with index keys
|
|
console[methodName] = (...args) => {
|
|
const maybeString = args[0];
|
|
if (typeof maybeString === 'string') {
|
|
for (let i = 0; i < stringsToIgnore.length; i++) {
|
|
if (maybeString.startsWith(stringsToIgnore[i])) {
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
// HACKY In the test harness, DevTools overrides the parent window's console.
|
|
// Our test app code uses the iframe's console though.
|
|
// To simulate a more accurate end-to-end environment,
|
|
// the shell's console patching should pass through to the parent override methods.
|
|
window.parent.console[methodName](...args);
|
|
};
|
|
}
|
|
|
|
export function ignoreErrors(errorsToIgnore: Array<string>): void {
|
|
ignoreStrings('error', errorsToIgnore);
|
|
}
|
|
|
|
export function ignoreWarnings(warningsToIgnore: Array<string>): void {
|
|
ignoreStrings('warn', warningsToIgnore);
|
|
}
|
|
|
|
export function ignoreLogs(logsToIgnore: Array<string>): void {
|
|
ignoreStrings('log', logsToIgnore);
|
|
}
|