rescript-association / genType

Auto generation of idiomatic bindings between Reason and JavaScript: either vanilla or typed with TypeScript/FlowType.

Home Page:https://rescript-lang.org/docs/gentype/latest/introduction

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

chrischen opened this issue · comments

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';

Thanks, that's a nice suggestion.