@samitouri / QOS-React / commits / a9d63f3f97

fix: incorrect type in getTypeSymbol (#32825)

`getTypeSymbol` also returns string

Jason Zhang committed Apr 7, 2025 at 19:21 UTC a9d63f3f9798355cd814237b5f5391d6adbfa750
1 file changed +3 -4
packages/react-devtools-shared/src/backend/fiber/renderer.js
+3 -4
@@ -248,7 +248,7 @@ function createVirtualInstance(
248 type DevToolsInstance = FiberInstance | VirtualInstance | FilteredFiberInstance;
249
250 type getDisplayNameForFiberType = (fiber: Fiber) => string | null;
251 -type getTypeSymbolType = (type: any) => symbol | number;
251 +type getTypeSymbolType = (type: any) => symbol | string | number;
252
253 type ReactPriorityLevelsType = {
254 ImmediatePriority: number,
@@ -541,13 +541,12 @@ export function getInternalReactConstants(version: string): {
541 // End of copied code.
542 // **********************************************************
543
544 - function getTypeSymbol(type: any): symbol | number {
544 + function getTypeSymbol(type: any): symbol | string | number {
545 const symbolOrNumber =
546 typeof type === 'object' && type !== null ? type.$$typeof : type;
547
548 return typeof symbolOrNumber === 'symbol'
549 - ? // $FlowFixMe[incompatible-return] `toString()` doesn't match the type signature?
550 - symbolOrNumber.toString()
549 + ? symbolOrNumber.toString()
550 : symbolOrNumber;
551 }
552