angular/tools/tsconfig.json
Paul Gschwendtner d15a692789 build: enable 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
2021-10-01 18:28:45 +00:00

37 lines
726 B
JSON

{
"compilerOptions": {
"baseUrl": ".",
"declaration": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"module": "commonjs",
"esModuleInterop": true,
"moduleResolution": "node",
"outDir": "../dist/tools/",
"noImplicitAny": true,
"noFallthroughCasesInSwitch": true,
"paths": {},
"rootDir": ".",
"sourceMap": true,
"inlineSources": true,
"lib": [
"es6",
"dom"
],
"target": "es5",
"skipLibCheck": true,
"types": [
"node"
]
},
"exclude": [
"testing",
"node_modules",
"typings-test",
"public_api_guard",
"docs"
],
"bazelOptions": {
"suppressTsconfigOverrideWarnings": true
}
}