rushstack icon indicating copy to clipboard operation
rushstack copied to clipboard

[api-extractor] Better support for type imports of the form `import { type X }`

Open D4N14L opened this issue 3 years ago • 0 comments

Summary

Use of import { type X } appears to be ignored by API-Extractor for roll-up/documentation scenarios.

Details

Currently, if you (for example) export an interface that takes only a type dependency on a module from some package using import { type X }, that type import becomes a full module import in the generated API-Extractor typings. Type imports of the form import type { X } do not encounter this issue.

Repro steps

MyInterface.ts

import { type X } from 'somePackage'

export interface MyInterface {
  myField: X
}

index.ts

export { MyInterface } from './MyInterface.ts';

API-Extractor generated .d.ts

import { X } from 'somePackage';

export declare interface MyInterface {
  myField: X
}

Standard questions

Please answer these questions to help us investigate your issue more quickly:

Question Answer
@microsoft/api-extractor version? 7.23.1
Operating system? Windows
API Extractor scenario? rollups (.d.ts)
Would you consider contributing a PR? Yes
TypeScript compiler version? 4.6.3
Node.js version (node -v)? 14.19.1

D4N14L avatar May 24 '22 19:05 D4N14L