fix: incorrect type in getTypeSymbol (#32825)

`getTypeSymbol` also returns string
This commit is contained in:
Jason Zhang 2025-04-07 19:21:28 +09:30 committed by GitHub
parent 6a7650c75c
commit a9d63f3f97
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -248,7 +248,7 @@ function createVirtualInstance(
type DevToolsInstance = FiberInstance | VirtualInstance | FilteredFiberInstance;
type getDisplayNameForFiberType = (fiber: Fiber) => string | null;
type getTypeSymbolType = (type: any) => symbol | number;
type getTypeSymbolType = (type: any) => symbol | string | number;
type ReactPriorityLevelsType = {
ImmediatePriority: number,
@ -541,13 +541,12 @@ export function getInternalReactConstants(version: string): {
// End of copied code.
// **********************************************************
function getTypeSymbol(type: any): symbol | number {
function getTypeSymbol(type: any): symbol | string | number {
const symbolOrNumber =
typeof type === 'object' && type !== null ? type.$$typeof : type;
return typeof symbolOrNumber === 'symbol'
? // $FlowFixMe[incompatible-return] `toString()` doesn't match the type signature?
symbolOrNumber.toString()
? symbolOrNumber.toString()
: symbolOrNumber;
}