rescript-association / genType

Auto generation of idiomatic bindings between Reason and JavaScript: either vanilla or typed with TypeScript/FlowType.
https://rescript-lang.org/docs/gentype/latest/introduction
MIT License
757 stars 44 forks source link

Enhancement: Use typescript "import type" syntax for type imports #549

Closed chrischen closed 3 years ago

chrischen commented 3 years ago

Please excuse the old ReasonML syntax...

[@genType.import "mongodb"]
[@genType.as "ObjectId"]
type t;

This generates

import {ObjectId as $$ObjectId_t} from 'mongodb';

Which works, and is correct, but in some cases can cause cyclical imports if only types are needed (this is a third party library so it wouldn't happen, but can happen with own library).

This syntax would be better as it's only compile-time and stripped at runtime.

import type {ObjectId as $$ObjectId_t} from 'mongodb';
cristianoc commented 3 years ago

Thanks, that's a nice suggestion.