flowgen
flowgen copied to clipboard
Import type, missing "type" keyword
Hi,
I have type import in my ts file:
import { HttpRequest } from "./httpRequests"
but the generated flow declaration states:
import { HttpRequest } from './httpRequests';
instead of import type { HttpRequest } from './httpRequests';
Shouldn't be this automatically transpiled? Tried last flowgen from repo. Thanks.
@sitnarf .ts
file or .d.ts
?
I am experiencing this also (using version 1.10.0). Here is a minimal reproducible example:
a.d.ts
export declare type A = {
a: string;
};
b.d.ts
import { A } from './a';
export declare const o: A;
Run:
$ npx flowgen ./b.d.ts
Actual Result:
import { A } from "./a";
declare export var o: A;
Expected result:
import type { A } from "./a";
declare export var o: A;
I don't think it's possible to know what is imported
I have a similar problem - but with exports ... meaning all the types are in 1 file
// .d.ts
type ToString = {toString: () => string}
export {ToString}
actual result
// .js.flow
declare type ToString = {
toString: () => string,
...
};
declare export {ToString}
expected result
// .js.flow
declare type ToString = {
toString: () => string,
...
};
declare export type {ToString} // or something that indicates that a type is exported, otherwise flow complains
Is this solvable? Or is there some kind of workaround at least?
I see a problem when a file exports both type
s and declare
d functions, but it would cool to have such functionality
Sorry, I didn't get the notification earlier. I believe, we used .ts files for generating .js.flow.
I am also having the same issue. When I import { MyType } from 'module';
in the d.ts
file, it doesn't get transpiled as import type { MyType } from 'module';
related to this, when having code like:
import type { MyType } from 'module';
it is also converted to:
import { MyType } from 'module';
tried to make a fix for it here https://github.com/zxbodya/flowgen/commit/823d624aa294cfcd4ef3214b8ec91f42c9460c9f (based on #115 but should be easy to backport)
I see the PR has been merged but I am still having this issue. Which version is this available in? I am using "flowgen": "^1.12.1",
I see the PR has been merged but I am still having this issue. Which version is this available in? I am using
"flowgen": "^1.12.1",
merged PR fixes only particular case of the issue - when there was import type
usage in typescript code