-
Notifications
You must be signed in to change notification settings - Fork 45.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Flow to 0.70 #12875
Update Flow to 0.70 #12875
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -432,7 +432,11 @@ export function setInitialProperties( | |
const isCustomComponentTag = isCustomComponent(tag, rawProps); | ||
if (__DEV__) { | ||
validatePropertiesInDevelopment(tag, rawProps); | ||
if (isCustomComponentTag && !didWarnShadyDOM && domElement.shadyRoot) { | ||
if ( | ||
isCustomComponentTag && | ||
!didWarnShadyDOM && | ||
(domElement: any).shadyRoot | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a real property (we're detecting a bad polyfill). Fair game IMO. |
||
) { | ||
warning( | ||
false, | ||
'%s is using shady DOM. Using shady DOM with React can ' + | ||
|
@@ -820,7 +824,11 @@ export function diffHydratedProperties( | |
suppressHydrationWarning = rawProps[SUPPRESS_HYDRATION_WARNING] === true; | ||
isCustomComponentTag = isCustomComponent(tag, rawProps); | ||
validatePropertiesInDevelopment(tag, rawProps); | ||
if (isCustomComponentTag && !didWarnShadyDOM && domElement.shadyRoot) { | ||
if ( | ||
isCustomComponentTag && | ||
!didWarnShadyDOM && | ||
(domElement: any).shadyRoot | ||
) { | ||
warning( | ||
false, | ||
'%s is using shady DOM. Using shady DOM with React can ' + | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,20 +63,21 @@ function trackValueOnNode(node: any): ?ValueTracker { | |
// (needed for certain tests that spyOn input values and Safari) | ||
if ( | ||
node.hasOwnProperty(valueField) || | ||
typeof descriptor === 'undefined' || | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In theory this could happen and then the code would crash. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Happened to me in practice :) |
||
typeof descriptor.get !== 'function' || | ||
typeof descriptor.set !== 'function' | ||
) { | ||
return; | ||
} | ||
|
||
const {get, set} = descriptor; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Help Flow know these exist (we just refined). |
||
Object.defineProperty(node, valueField, { | ||
configurable: true, | ||
get: function() { | ||
return descriptor.get.call(this); | ||
return get.call(this); | ||
}, | ||
set: function(value) { | ||
currentValue = '' + value; | ||
descriptor.set.call(this, value); | ||
set.call(this, value); | ||
}, | ||
}); | ||
// We could've passed this the first time | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,9 +63,11 @@ function findNodeHandle(componentOrHandle: any): ?number { | |
if (hostInstance == null) { | ||
return hostInstance; | ||
} | ||
if (hostInstance.canonical) { | ||
// TODO: the code is right but the types here are wrong. | ||
// https://github.com/facebook/react/pull/12863 | ||
if ((hostInstance: any).canonical) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll be working on a followup to fix this. The types are already wrong due to reconciler |
||
// Fabric | ||
return (hostInstance.canonical: any)._nativeTag; | ||
return (hostInstance: any).canonical._nativeTag; | ||
} | ||
return hostInstance._nativeTag; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,12 +49,13 @@ function scheduleDeferredCallback( | |
): number { | ||
// We assume only one callback is scheduled at a time b'c that's how Fiber works. | ||
scheduledCallback = callback; | ||
return setTimeout(setTimeoutCallback, 1); | ||
const timeoutId = setTimeout(setTimeoutCallback, 1); | ||
return (timeoutId: any); // Timeouts are always numbers on RN | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could keep an object mapping but doesn't seem worth it in this case. |
||
} | ||
|
||
function cancelDeferredCallback(callbackID: number) { | ||
scheduledCallback = null; | ||
clearTimeout(callbackID); | ||
clearTimeout((callbackID: any)); // Timeouts are always numbers on RN | ||
} | ||
|
||
export {now, scheduleDeferredCallback, cancelDeferredCallback}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,9 +66,9 @@ function findNodeHandle(componentOrHandle: any): ?number { | |
if (hostInstance == null) { | ||
return hostInstance; | ||
} | ||
if (hostInstance.canonical) { | ||
if ((hostInstance: any).canonical) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above, will fix in a follow up. |
||
// Fabric | ||
return (hostInstance.canonical: any)._nativeTag; | ||
return (hostInstance: any).canonical._nativeTag; | ||
} | ||
return hostInstance._nativeTag; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -151,6 +151,7 @@ function coerceRef( | |
if ( | ||
current !== null && | ||
current.ref !== null && | ||
typeof current.ref === 'function' && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only attempt to read |
||
current.ref._stringRef === stringRef | ||
) { | ||
return current.ref; | ||
|
@@ -901,18 +902,15 @@ function ChildReconciler(shouldTrackSideEffects) { | |
|
||
if (__DEV__) { | ||
// Warn about using Maps as children | ||
if (typeof newChildrenIterable.entries === 'function') { | ||
const possibleMap = (newChildrenIterable: any); | ||
if (possibleMap.entries === iteratorFn) { | ||
warning( | ||
didWarnAboutMaps, | ||
'Using Maps as children is unsupported and will likely yield ' + | ||
'unexpected results. Convert it to a sequence/iterable of keyed ' + | ||
'ReactElements instead.%s', | ||
getCurrentFiberStackAddendum(), | ||
); | ||
didWarnAboutMaps = true; | ||
} | ||
if ((newChildrenIterable: any).entries === iteratorFn) { | ||
warning( | ||
didWarnAboutMaps, | ||
'Using Maps as children is unsupported and will likely yield ' + | ||
'unexpected results. Convert it to a sequence/iterable of keyed ' + | ||
'ReactElements instead.%s', | ||
getCurrentFiberStackAddendum(), | ||
); | ||
didWarnAboutMaps = true; | ||
} | ||
|
||
// First, validate keys. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,24 +60,34 @@ let scheduleWork: ( | |
callback: FrameCallbackType, | ||
options?: {timeout: number}, | ||
) => number; | ||
let cancelScheduledWork: (callbackID: number) => void; | ||
let cancelScheduledWork: (callbackId: number) => void; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consistent naming throughout the file. |
||
|
||
if (!ExecutionEnvironment.canUseDOM) { | ||
let callbackIdCounter = 0; | ||
// Timeouts are objects in Node. | ||
// For consistency, we'll use numbers in the public API anyway. | ||
const timeoutIds: {[number]: TimeoutID} = {}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not super efficient (number keys are slow) but it can only fire in Node so it probably doesn't matter. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The advantage of this isn't obvious to me. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In Node Since our intentional API is to return a number I think it would be confusing if we started returning objects in Node environment. The fact that it uses setTimeout in Node should be an implementation detail. |
||
|
||
scheduleWork = function( | ||
callback: FrameCallbackType, | ||
options?: {timeout: number}, | ||
): number { | ||
return setTimeout(() => { | ||
const callbackId = callbackIdCounter++; | ||
const timeoutId = setTimeout(() => { | ||
callback({ | ||
timeRemaining() { | ||
return Infinity; | ||
}, | ||
didTimeout: false, | ||
}); | ||
}); | ||
timeoutIds[callbackId] = timeoutId; | ||
return callbackId; | ||
}; | ||
cancelScheduledWork = function(timeoutID: number) { | ||
clearTimeout(timeoutID); | ||
cancelScheduledWork = function(callbackId: number) { | ||
const timeoutId = timeoutIds[callbackId]; | ||
delete timeoutIds[callbackId]; | ||
clearTimeout(timeoutId); | ||
}; | ||
} else { | ||
// We keep callbacks in a queue. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Posted about this internally.