fix(types): Devtools.d.ts (#51737)

Summary:
- This is similar to https://github.com/facebook/react-native/pull/43566, but include also updated `StackFrame` type.

The current `Devtools.d.ts` doesn't match the `parseErrorStack.js` and `symbolicateStackTrace.js` implementations.

I've tried to run `build-types`, but only `symbolicateStackTrace.d.ts` was generated. I've not checked why.

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[GENERAL] [FIXED] - Devtools TS Types

Pull Request resolved: https://github.com/facebook/react-native/pull/51737

Test Plan: Call `parseErrorStack` and `symbolicateStackTrace` in TS.

Reviewed By: rshest

Differential Revision: D75782013

Pulled By: huntie

fbshipit-source-id: 91fe560f079731af2a5834c8de8eafb723d00bf9
This commit is contained in:
Krystof Woldrich
2025-06-02 09:39:26 -07:00
committed by Facebook GitHub Bot
parent 581097b8ea
commit 8f189fce03
+23 -9
View File
@@ -9,24 +9,38 @@
declare module 'react-native/Libraries/Core/Devtools/parseErrorStack' {
export type StackFrame = {
file: string;
column: number | null | undefined;
file: string | null | undefined;
lineNumber: number | null | undefined;
methodName: string;
lineNumber: number;
column: number | null;
};
export interface ExtendedError extends Error {
framesToPop?: number | undefined;
}
export default function parseErrorStack(error: ExtendedError): StackFrame[];
export default function parseErrorStack(errorStack?: string): StackFrame[];
}
declare module 'react-native/Libraries/Core/Devtools/symbolicateStackTrace' {
import {StackFrame} from 'react-native/Libraries/Core/Devtools/parseErrorStack';
export type CodeFrame = Readonly<{
content: string;
location:
| {
row: number;
column: number;
[key: string]: any;
}
| null
| undefined;
fileName: string;
}>;
export type SymbolicatedStackTrace = Readonly<{
stack: ReadonlyArray<StackFrame>;
codeFrame: CodeFrame | null | undefined;
}>;
export default function symbolicateStackTrace(
stack: ReadonlyArray<StackFrame>,
extraData?: any,
): Promise<StackFrame[]>;
): Promise<SymbolicatedStackTrace>;
}