esModuleInterop in TypeScript compilations (#43431)
Enables the `esModuleInterop` for all TypeScript compilations in the project. This allows us to emit proper ESM-compatible code. e.g. consider the following import: ```ts import * as ts from 'typescript'; ``` This import currently will break at runtime in NodeJS because the `typescript` package is not shipping ESM. It's still a CommonJS module. ES modules are able to import from `typescript` though, using an import statement as above, but everything in `module.exports` is being exposed as the `default` named export. TypeScript at runtime does not have any other named exports, so for actual ESM compatibility, all of our imports need to be switched to: ``` import ts from 'typescript'; ``` The `esModuleInterop` option allows this to work even though the `d.ts` file of TS currently suggests that there are _only_ named exports. The TypeScript language service will now suggest the correct import form as shown above. It doesn't enforce that unfortunately, but this commit also adds a lint rule that enforces certain patterns so that we emit imports that are compatible with both ESM and CJS output (CJS still needed here since tests run with CJS devmode output still; this is a future project to switch that over to ESM!) PR Close #43431
Angular - The modern web developer's platform.
Angular is a development platform for building mobile and desktop web applications
using Typescript/JavaScript and other languages.
Contributing Guidelines
·
Submit an Issue
·
Blog
Documentation
Get started with Angular, learn the fundamentals and explore advanced topics on our documentation website.
Advanced
Development Setup
Prerequisites
- Install Node.js which includes Node Package Manager
Setting Up a Project
Install the Angular CLI globally:
npm install -g @angular/cli
Create workspace:
ng new [PROJECT NAME]
Run the application:
cd [PROJECT NAME]
ng serve
Angular is cross-platform, fast, scalable, has incredible tooling, and is loved by millions.
Quickstart
Ecosystem
Changelog
Learn about the latest improvements.
Upgrading
Check out our upgrade guide to find out the best way to upgrade your project.
Contributing
Contributing Guidelines
Read through our contributing guidelines to learn about our submission process, coding rules and more.
Want to Help?
Want to file a bug, contribute some code, or improve documentation? Excellent! Read up on our guidelines for contributing and then check out one of our issues labeled as help wanted or good first issue.
Code of Conduct
Help us keep Angular open and inclusive. Please read and follow our Code of Conduct.
Community
Join the conversation and help the community.
Love Angular? Give our repo a star ⭐ ⬆️.
