Skip to content

Allow export as namespace alongside commonJS's export = #30327

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

Closed
tnrich opened this issue Mar 12, 2019 · 1 comment
Closed

Allow export as namespace alongside commonJS's export = #30327

tnrich opened this issue Mar 12, 2019 · 1 comment
Labels
Declined The issue was declined as something which matches the TypeScript vision

Comments

@tnrich
Copy link

tnrich commented Mar 12, 2019

Search Terms

export as namespace lodash umd commonjs

Suggestion

This is coming from this issue:
#29039

Basically vscode auto-import won't work with lodash's .d.ts file because, and I quote @aleclarson:

When export = is used, a CommonJS module is implied, which means named exports (eg: export const) are no longer allowed (since that's an ESM feature). The problem is that named exports are required for auto-import to work.

He suggested that I open a new proposal for:

export as namespace to be used as a hint that auto-import can suggest the namespace's properties.

Use Cases

This would allow lodash to be auto-completed because named exports would then be allowed side-by-side with commonJS.

Checklist

My suggestion meets these guidelines:

  • [?] This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • [?] This wouldn't change the runtime behavior of existing JavaScript code
  • [?] This could be implemented without emitting different JS based on the types of the expressions
  • [?] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • [?] This feature would agree with the rest of TypeScript's Design Goals.

Thanks!

Linked issues:
#10907
#24719
#26299

@RyanCavanaugh RyanCavanaugh added the Declined The issue was declined as something which matches the TypeScript vision label Mar 19, 2019
@RyanCavanaugh
Copy link
Member

#29039 is completely off the rails 😢

export as namespace has nothing to do with import _ = require("lodash"), and UMD-ness doesn't affect whether or not auto-imports are available from a file. The ability to destructure from a module that purports to be a CommonJS module via an export = declaration is a feature that would occur based on the loader, not the module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Declined The issue was declined as something which matches the TypeScript vision
Projects
None yet
Development

No branches or pull requests

2 participants