Skip to content

Commit

Permalink
[polyfill] $TEMPORARY$module$exports$assign for TS2304
Browse files Browse the repository at this point in the history
  • Loading branch information
alloy committed Nov 20, 2020
1 parent 942b63c commit 75ead21
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 5 deletions.
5 changes: 5 additions & 0 deletions packages/flow2dts-flow-types-polyfill/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ export type Stringish = string
* Flow types
*****************************************************************************/

/**
* @see https://github.com/facebook/flow/blob/34465eb6f528fc61de1b3a53db4c1a682b33de03/src/typing/__tests__/signature_generator_test.ml#L728-L756
*/
export type $TEMPORARY$module$exports$assign<T1, T2> = T1 & T2

/**
* @see https://github.com/facebook/flow/blob/41b0eab99cdc5199421f7cccad9e0c4950f8b2f9/tests/any/flowfixme.js
*/
Expand Down
5 changes: 4 additions & 1 deletion packages/flow2dts-flow-types-polyfill/index.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expectType } from "tsd"
import { $TypeOf } from "./index"
import { $TypeOf, $TEMPORARY$module$exports$assign } from "./index"

declare const ANY: any

Expand All @@ -9,3 +9,6 @@ expectType<{ foo: boolean }>(ANY as $TypeOf<typeof SomeValue>)
// $TypeOf: with a class returns the class
declare class SomeClass {}
expectType<SomeClass>(ANY as $TypeOf<typeof SomeClass>)

declare const Exports: $TEMPORARY$module$exports$assign<typeof SomeValue, { bar: number }>
expectType<typeof SomeValue & { bar: number }>(Exports)
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ type _OMTWithSingle = () => boolean
type OMTWithSingle = $ObjMapi<T, _OMTWithSingle>
type _OMTWithUnion = () => true | 42 | "42" | any | void | unknown | null | undefined
type OMTWithUnion = $ObjMap<T, _OMTWithUnion>
declare module.exports: $TEMPORARY$module$exports$assign<_OMTWithSingle, { foo: string }>
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { $TEMPORARY$module$exports$assign } from "flow2dts-flow-types-polyfill"
import { $Diff, $ElementType, $Keys, $NonMaybeType, $PropertyType, $Shape, Class } from "utility-types"
declare type T = {
foo: string
Expand Down Expand Up @@ -31,3 +32,10 @@ declare type _OMTWithUnion = () => true | 42 | "42" | any | void | unknown | nul
declare type OMTWithUnion =
/*[FLOW2DTS - Warning] This type was a $ObjMap type in the original Flow source.*/
{ [K in keyof T]: ReturnType<_OMTWithUnion> }
declare const $f2tExportDefault: $TEMPORARY$module$exports$assign<
_OMTWithSingle,
{
foo: string
}
>
export default $f2tExportDefault
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export const polyfillPackagesAndTypes: Record<string, string[]> = {
"flow2dts-flow-types-polyfill": [
"$TypeOf",
"$TEMPORARY$module$exports$assign",
"$ArrayBufferView",
"$FlowFixMe",
"$FlowFixMeProps",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { $TypeOf } from "flow2dts-flow-types-polyfill";
import { $TEMPORARY$module$exports$assign, $TypeOf } from "flow2dts-flow-types-polyfill";
import $1 from "./AssetSourceResolver";
import { ResolvedAssetSource } from "./AssetSourceResolver";
declare function setCustomSourceTransformer(transformer: (resolver: $TypeOf<typeof $1>) => ResolvedAssetSource): void;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { $TypeOf } from "flow2dts-flow-types-polyfill";
import { $TEMPORARY$module$exports$assign, $TypeOf } from "flow2dts-flow-types-polyfill";
// @flow
declare type LogListeners =
/*[FLOW2DTS - Warning] This type was an exact object type in the original Flow source.*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { $TypeOf } from "flow2dts-flow-types-polyfill";
import { $TEMPORARY$module$exports$assign, $TypeOf } from "flow2dts-flow-types-polyfill";
import $1 from "./AssetSourceResolver";
import { ResolvedAssetSource } from "./AssetSourceResolver";
declare function setCustomSourceTransformer(transformer: (resolver: $TypeOf<typeof $1>) => ResolvedAssetSource): void;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { $TypeOf } from "flow2dts-flow-types-polyfill";
import { $TEMPORARY$module$exports$assign, $TypeOf } from "flow2dts-flow-types-polyfill";
// @flow
declare type LogListeners =
/*[FLOW2DTS - Warning] This type was an exact object type in the original Flow source.*/
Expand Down

0 comments on commit 75ead21

Please sign in to comment.