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

Load declarations for dynamic imports #49731

Closed
5 tasks
LabEG opened this issue Jun 29, 2022 · 5 comments
Closed
5 tasks

Load declarations for dynamic imports #49731

LabEG opened this issue Jun 29, 2022 · 5 comments
Labels
Duplicate An existing issue was already created

Comments

@LabEG
Copy link

LabEG commented Jun 29, 2022

Suggestion

⭐ Suggestion

Now the typescript import declaration files only from node_modules.
I also suggest importing declaration files for dynamic imports.

📃 Motivating Example

In the current version of the typescript, the widget will have the type any.
After the implementation of this feature, the widget must have a type from declarations, check types, and help the developer write code.

const widget = await import("https://some-site/widget-microfront.esnext.min.js");
widget.render(this.microfontElement, {app: {serverUrl: location.origin}});

💻 Use Cases

Development of distributed microfrontends.
This feature will allow you to make much larger distributed applications.

✅ Viability 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, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.
@MartinJohns
Copy link
Contributor

This sounds like #24550.

@LabEG
Copy link
Author

LabEG commented Jun 29, 2022

No. This is another feature.
Proposal #24550 asks to add static imports from external domains.
My suggestion is to import declarations for dynamic imports.

@fatcerberus
Copy link

fatcerberus commented Jun 29, 2022

#24550 specifically mentions dynamic import from a domain in the OP and wants the import to be typed, just like this issue.

@MartinJohns
Copy link
Contributor

Then it sounds like #35749.

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Jun 29, 2022
@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

5 participants