Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declaration file emitted with esModuleInterop can't be consumed without it #28009

Open
ghost opened this issue Oct 20, 2018 · 3 comments
Open
Labels
Domain: Declaration Emit The issue relates to the emission of d.ts files Experience Enhancement Noncontroversial enhancements Suggestion An idea for TypeScript
Milestone

Comments

@ghost
Copy link

ghost commented Oct 20, 2018

TypeScript Version: 3.2.0-dev.20181019

Search Terms:

Code

import abs from "abs"; // using @types/abs which uses `export =`
export const x: typeof abs = <any>null;

Expected behavior:

Output .d.ts is:

import abs = require("abs");
export declare const x: typeof abs;

Actual behavior:

import abs from "abs";
export declare const x: typeof abs;

Discovered in quill on DefinitelyTyped, which imports from quill-delta, which is written in TypeScript with esModuleInterop.

@ghost ghost added the Domain: Declaration Emit The issue relates to the emission of d.ts files label Oct 20, 2018
@weswigham
Copy link
Member

This is entirely because we strive not to rewrite people's code, and so during declaration emit, we preserve their interop-requiring-import-style. I'm... not sure if it's a bug or just unfortunate? I know prior to the new declaration emitter it'd be in the "unfortunate" category, since we also had the same problem with noImplicitAny; but the new declaration emitter solved all those problems by annotating any's on anything missing them. So in that same vein, I can conceive us changing our emit to automatically fix this up, too.

@weswigham weswigham added the Experience Enhancement Noncontroversial enhancements label Oct 20, 2018
@amitdahan
Copy link
Contributor

IMO - this is the (implied) expected behavior of auto-generated declaration files.
You would think your generated declarations would be "universally" consumable, but as of now - they're unfortunately not :(
I'd be very happy to see this fixed (assuming I can call it a bug).

@aleclarson
Copy link

Bump. It would be great if this was fixed. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Domain: Declaration Emit The issue relates to the emission of d.ts files Experience Enhancement Noncontroversial enhancements Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

5 participants
@aleclarson @weswigham @RyanCavanaugh @amitdahan and others