This repository was archived by the owner on Jun 11, 2026. It is now read-only.
Treat namespace and class exports differently#19
Merged
Conversation
…le $TypeOf wrapper
alloy
commented
Jan 28, 2021
| declare const $f2d_unforkEvent: typeof $3.unforkEvent; | ||
| declare const $f2d_Event: typeof $1.AnimatedEvent; | ||
| declare const $f2d___PropsOnlyForTests: typeof $6; | ||
| export { $f2d_Value as Value, $f2d_ValueXY as ValueXY, $f2d_Interpolation as Interpolation, $f2d_Node as Node, decay, timing, spring, $f2d_add as add, $f2d_subtract as subtract, $f2d_divide as divide, $f2d_multiply as multiply, $f2d_modulo as modulo, $f2d_diffClamp as diffClamp, delay, sequence, parallel, stagger, loop, event, $f2d_createAnimatedComponent as createAnimatedComponent, $f2d_attachNativeEvent as attachNativeEvent, $f2d_forkEvent as forkEvent, $f2d_unforkEvent as unforkEvent, $f2d_Event as Event, $f2d___PropsOnlyForTests as __PropsOnlyForTests }; |
Member
Author
There was a problem hiding this comment.
- So now we just export all the fields on the exported object as individual ES6 exports…
alloy
commented
Jan 28, 2021
| @@ -1,4 +1,4 @@ | |||
| import { $TypeOf } from "flow2dts-flow-types-polyfill"; | |||
| export * from "./AnimatedMock"; | |||
Member
Author
There was a problem hiding this comment.
- …then we re-export all those ES6 exports here…
alloy
commented
Jan 28, 2021
| import AnimatedView$f2tTypeof from "./components/AnimatedView"; | ||
| declare type AnimatedView = typeof AnimatedView$f2tTypeof; | ||
| import $1 from "./AnimatedMock"; | ||
| export { AnimatedFlatList$f2tTypeof as FlatList, AnimatedImage$f2tTypeof as Image, AnimatedScrollView$f2tTypeof as ScrollView, AnimatedSectionList$f2tTypeof as SectionList, AnimatedText$f2tTypeof as Text, AnimatedView$f2tTypeof as View }; |
Member
Author
There was a problem hiding this comment.
- …and add a few more ES6 exports, thus ‘extending’ the exports of
./AnimatedMock…
alloy
commented
Jan 28, 2021
| import Alert$f2tTypeof from "./Libraries/Alert/Alert"; | ||
| declare type Alert = typeof Alert$f2tTypeof; | ||
| import Animated$f2tTypeof from "./Libraries/Animated/Animated"; | ||
| import * as Animated$f2tTypeof from "./Libraries/Animated/Animated"; |
Member
Author
There was a problem hiding this comment.
- …and finally we capture all those ES6 exports as a
namespace, which is then exported to the consumer.
alloy
commented
Jan 28, 2021
| if (path.findParent((parentPath) => parentPath.isDeclareModuleExports())) { | ||
| // it's a class on `module.exports`, leave `typeof` for the `exportVisitor` | ||
| return | ||
| } |
Member
Author
There was a problem hiding this comment.
This is the one change I had to make when hints are enabled.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
AnimatedMock) and then capture all those ES6 exports (fromAnimated) as a namespace when importing.$TypeOfhelper