Skip to content

Commit

Permalink
RN: Cleanup ExtendedError Type
Browse files Browse the repository at this point in the history
Summary:
Cleans up the `ExtendedError` internal type and moves it into a separate module instead of burying it in `parseErrorStack.js`.

Also, this resolves some unnecessary Flow type suppressions.

Changelog:
[Internal]

Reviewed By: GijsWeterings

Differential Revision: D28470299

fbshipit-source-id: 04093243f06f67f41567270ef9778f01c7549b05
  • Loading branch information
yungsters authored and facebook-github-bot committed May 19, 2021
1 parent 0dba0af commit ede74e5
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion IntegrationTests/GlobalEvalWithSourceUrlTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

'use strict';

import type {ExtendedError} from 'react-native/Libraries/Core/Devtools/parseErrorStack';
import type {ExtendedError} from 'react-native/Libraries/Core/ExtendedError';

const React = require('react');
const ReactNative = require('react-native');
Expand Down
2 changes: 1 addition & 1 deletion Libraries/BatchedBridge/NativeModules.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const BatchedBridge = require('./BatchedBridge');

const invariant = require('invariant');

import type {ExtendedError} from '../Core/Devtools/parseErrorStack';
import type {ExtendedError} from '../Core/ExtendedError';

export type ModuleConfig = [
string /* name */,
Expand Down
10 changes: 0 additions & 10 deletions Libraries/Core/Devtools/parseErrorStack.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,6 @@ import type {HermesParsedStack} from './parseHermesStack';

const parseHermesStack = require('./parseHermesStack');

// $FlowFixMe[incompatible-exact]
export type ExtendedError = Error &
interface {
jsEngine?: string,
preventSymbolication?: boolean,
componentStack?: string,
forceRedbox?: boolean,
isComponentError?: boolean,
};

function convertHermesStack(stack: HermesParsedStack): Array<StackFrame> {
const frames = [];
for (const entry of stack.entries) {
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Core/ExceptionsManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

'use strict';

import type {ExtendedError} from './Devtools/parseErrorStack';
import type {ExtendedError} from './ExtendedError';
import type {ExceptionData} from './NativeExceptionsManager';

class SyntheticError extends Error {
Expand Down
18 changes: 18 additions & 0 deletions Libraries/Core/ExtendedError.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* 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 strict
* @format
*/

export type ExtendedError = Error & {
jsEngine?: string,
preventSymbolication?: boolean,
componentStack?: string,
forceRedbox?: boolean,
isComponentError?: boolean,
...
};
2 changes: 1 addition & 1 deletion Libraries/Core/ReactFiberErrorDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import {handleException, SyntheticError} from './ExceptionsManager';

import type {ExtendedError} from './Devtools/parseErrorStack';
import type {ExtendedError} from './ExtendedError';

export type CapturedError = {
+componentStack: string,
Expand Down
2 changes: 1 addition & 1 deletion Libraries/LogBox/Data/LogBoxData.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import type {
ExtendedExceptionData,
} from './parseLogBoxLog';
import parseErrorStack from '../../Core/Devtools/parseErrorStack';
import type {ExtendedError} from '../../Core/Devtools/parseErrorStack';
import type {ExtendedError} from '../../Core/ExtendedError';
import NativeLogBox from '../../NativeModules/specs/NativeLogBox';
export type LogBoxLogs = Set<LogBoxLog>;
export type LogData = $ReadOnly<{|
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Utilities/HMRClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const prettyFormat = require('pretty-format');
import getDevServer from '../Core/Devtools/getDevServer';
import NativeRedBox from '../NativeModules/specs/NativeRedBox';
import LogBox from '../LogBox/LogBox';
import type {ExtendedError} from '../Core/Devtools/parseErrorStack';
import type {ExtendedError} from '../Core/ExtendedError';

const pendingEntryPoints = [];
let hmrClient = null;
Expand Down

0 comments on commit ede74e5

Please sign in to comment.