Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change handling declaration export for classes from flow defs to TS defs
Summary: The diff introduces exporting classes in TS defs using export default syntax. Previously subsequent flow definitions (output produced by flowToFlowDefs): ```js declare class Foo {} declare export default typeof Foo; ``` were translated into the following TS definitions: ```js declare class Foo {} declare const $$EXPORT_DEFAULT_DECLARATION$$: typeof Foo; export default $$EXPORT_DEFAULT_DECLARATION$$; ``` This exports constant that is of type Foo which is not the same as exporting typeof class Foo in TS. If there was another file that imported a Foo class and used it as a type, that would produce an error: ```js import Foo from './foo'; interface Bar { values: Array<Foo> // 'Foo' refers to a value, but is being used as a type here. } ``` The proposed solution is to export default class: ```js declare class Foo {} export default Foo; ``` This change is only applied to classes. ## Changelog: [flow-api-translator] - Changed generated default exports for declaration exports for classes from flow defs to TS defs Reviewed By: pieterv Differential Revision: D69050761 fbshipit-source-id: e6cb54b84262ac1d7a64e05e63b54f23947d236c
- Loading branch information