Repository navigation
Add LegacyObject to keep Flow Object as Object in the TypeScript API - #59086
Closed
SamChou19815 wants to merge 1 commit into
Closed
SamChou19815 wants to merge 1 commit into
SamChou19815 wants to merge 1 commit into
Conversation
…t API Summary: Flow will soon give `Object` the same meaning as TypeScript's `Object`, rather than treating it as `any`. React Native sources that use `Object` as an untyped escape hatch need to move off it. But the generated TypeScript API (`ReactNativeApi.d.ts`) relies on Flow `Object` mapping to TS `Object`, and it should keep emitting `Object`. This adds a `LegacyObject` global type to bridge the two: - Flow: `flow/LegacyObject.js` declares `LegacyObject` as `any`, next to `Stringish`. - TypeScript: build-types replaces `LegacyObject` with `Object` before translation, via a new `replaceLegacyObjectWithObject` pre-transform that mirrors `replaceStringishWithString`. - Codegen: native module specs accept `LegacyObject` as a generic object, like `Object` and `UnsafeObject`. `CodegenTypes.UnsafeObject`, the event object types in `EventEmitter` and `NativeEventEmitter`, `PushNotificationIOS`, and the native module specs that used bare `Object` now use `LegacyObject`. Neither the generated TypeScript API nor the codegen schema changes. The codegen parser's internal AST aliases (`PropAST`, `ASTNode`) switch to plain `any`. Changelog: [Internal] Differential Revision: D125245815
|
@SamChou19815 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D125245815. |
|
This pull request has been merged in 6671827. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Flow will soon give
Objectthe same meaning as TypeScript'sObject, rather than treating it asany. React Native sources that useObjectas an untyped escape hatch need to move off it. But the generated TypeScript API (ReactNativeApi.d.ts) relies on FlowObjectmapping to TSObject, and it should keep emittingObject.This adds a
LegacyObjectglobal type to bridge the two:flow/LegacyObject.jsdeclaresLegacyObjectasany, next toStringish.LegacyObjectwithObjectbefore translation, via a newreplaceLegacyObjectWithObjectpre-transform that mirrorsreplaceStringishWithString.LegacyObjectas a generic object, likeObjectandUnsafeObject.CodegenTypes.UnsafeObject, the event object types inEventEmitterandNativeEventEmitter,PushNotificationIOS, and the native module specs that used bareObjectnow useLegacyObject. Neither the generated TypeScript API nor the codegen schema changes. The codegen parser's internal AST aliases (PropAST,ASTNode) switch to plainany.Changelog: [Internal]
Differential Revision: D125245815