From 8f189fce03db367abdceca6ad57ae28b613fdd7d Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Mon, 2 Jun 2025 09:39:26 -0700 Subject: [PATCH] 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: [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 --- .../react-native/types/modules/Devtools.d.ts | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/packages/react-native/types/modules/Devtools.d.ts b/packages/react-native/types/modules/Devtools.d.ts index d287d97c5a4..8dce2c84511 100644 --- a/packages/react-native/types/modules/Devtools.d.ts +++ b/packages/react-native/types/modules/Devtools.d.ts @@ -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; + codeFrame: CodeFrame | null | undefined; + }>; + export default function symbolicateStackTrace( stack: ReadonlyArray, extraData?: any, - ): Promise; + ): Promise; }