joarwilk / flowgen

Generate flowtype definition files from TypeScript
Other
658 stars 78 forks source link

Missing node parse NamespaceExportDeclaration #20

Open DullReferenceException opened 7 years ago

DullReferenceException commented 7 years ago

Thought I'd report this if it wasn't already a known issue. I am attempting to generate some types from this definition:

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/sinon/index.d.ts

I currently get this error output:

Missing node parse NamespaceExportDeclaration
"NO PRINT IMPLEMENTED: TypeOperator"
"NO PRINT IMPLEMENTED: TypeOperator"
"NO PRINT IMPLEMENTED: TypeOperator"
"NO PRINT IMPLEMENTED: MappedType"
stereobooster commented 6 years ago
"NO PRINT IMPLEMENTED: MappedType"

for https://github.com/redux-loop/redux-loop/blob/master/index.d.ts

Will take a look if I have time. See Mapped types

export type ReducerMapObject<S, A extends Action = AnyAction> = {
  [K in keyof S]: LoopReducer<S[K], A>;
}

↓↓↓

declare export type ReducerMapObject<S, A> = {
  [K: $Keys<S>]: LoopReducer<$Values<S>, A>
};

This is not precise transformation, other approach

type A<T extends { [key: string]: any }> =
    { [P in keyof T]?: (value: T[P]) => null };
let x: A<{ a: string, b: number, c: symbol }>;

In Flow this doesn't work

type m = <T>(T) => (T) => null
type A<T> = $Shape<$ObjMap<T, m>>
const test = (x: A<{| a: number, b: string |}>) => x.a && x.a('')
test({a: (x) => { if (typeof x !== "number") throw TypeError(); return null }})

Related https://github.com/facebook/flow/issues/6399