Skip to content

Commit 39f946a

Browse files
clydinalan-agius4
authored andcommitted
build: enabled isolated modules TypeScript option
The TypeScript `isolatedModules` option is now enabled for all TypeScript code within the repository. As a result, all packages will now be built with the option enabled. This does not affect projects created with the CLI and is only related to the building of the actual Angular CLI code. The `isolatedModules` option ensures that code can be emitted without the TypeScript typechecker and allows tools other than TypeScript to potentially be used. Code was updated to correct all errors after the option was enabled. Additionally, some early code fixes were done to add function and accessor return types to prepare for future `isolatedDeclarations` usage. More changes would be needed to consider turning on `isolatedDeclarations`, however.
1 parent 8fc62d0 commit 39f946a

File tree

33 files changed

+128
-85
lines changed

33 files changed

+128
-85
lines changed

.yarn/patches/@bazel-concatjs-npm-5.8.1-1bf81df846.patch

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,38 @@ index 9e5cda684f0456b61d1b6c0f9c56ae021594713f..6c45196bda5880531d32618dfca0dee4
1212

1313
_DEVMODE_TARGET_DEFAULT = "es2015"
1414
diff --git a/internal/common/tsconfig.bzl b/internal/common/tsconfig.bzl
15-
index b01c999f5e02b388f51a508b0b608cf69db9b664..ec3e4ccb321fa230546e34c1c2ea87f7457fa108 100755
15+
index b01c999f5e02b388f51a508b0b608cf69db9b664..847c23fe4829d0c847e9b4bd1ad698e1ccea720e 100755
1616
--- a/internal/common/tsconfig.bzl
1717
+++ b/internal/common/tsconfig.bzl
18-
@@ -278,11 +278,6 @@ def create_tsconfig(
18+
@@ -211,9 +211,6 @@ def create_tsconfig(
19+
# will convert that to goog.module syntax.
20+
"module": "umd" if devmode_manifest or has_node_runtime else "esnext",
21+
22+
- # Has no effect in closure/ES2015 mode. Always true just for simplicity.
23+
- "downlevelIteration": True,
24+
-
25+
# Do not type-check the lib.*.d.ts.
26+
# We think this shouldn't be necessary but haven't figured out why yet
27+
# and builds are faster with the setting on.
28+
@@ -248,13 +245,6 @@ def create_tsconfig(
29+
# "short name" mappings for npm packages, such as "@angular/core"
30+
"paths": mapped_module_roots,
31+
32+
- # Inline const enums.
33+
- "preserveConstEnums": False,
34+
-
35+
- # permit `@Decorator` syntax and allow runtime reflection on their types.
36+
- "experimentalDecorators": True,
37+
- "emitDecoratorMetadata": True,
38+
-
39+
# Interpret JSX as React calls (until someone asks for something different)
40+
"jsx": "react",
41+
42+
@@ -277,12 +267,6 @@ def create_tsconfig(
43+
# always emit declaration files in the same location as outDir.
1944
"declarationDir": "/".join([workspace_path, outdir_path]),
2045
"stripInternal": True,
21-
46+
-
2247
- # Embed source maps and sources in .js outputs
2348
- "inlineSourceMap": True,
2449
- "inlineSources": True,

modules/testing/builder/src/file-watching.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,4 @@ export class WatcherNotifier implements BuilderWatcherFactory {
5656
}
5757
}
5858

59-
export { BuilderWatcherFactory };
59+
export type { BuilderWatcherFactory };

modules/testing/builder/src/index.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@
88

99
export {
1010
BuilderHarness,
11-
BuilderHarnessExecutionOptions,
12-
BuilderHarnessExecutionResult,
11+
type BuilderHarnessExecutionOptions,
12+
type BuilderHarnessExecutionResult,
1313
} from './builder-harness';
14-
export { HarnessFileMatchers, JasmineBuilderHarness, describeBuilder } from './jasmine-helpers';
14+
export {
15+
type HarnessFileMatchers,
16+
JasmineBuilderHarness,
17+
describeBuilder,
18+
} from './jasmine-helpers';
1519
export * from './test-utils';

packages/angular/build/src/builders/application/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
} from './options';
2323
import { Schema as ApplicationBuilderOptions } from './schema';
2424

25-
export { ApplicationBuilderOptions };
25+
export type { ApplicationBuilderOptions };
2626

2727
export async function* buildApplicationInternal(
2828
options: ApplicationBuilderInternalOptions,

packages/angular/build/src/builders/dev-server/index.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@
88

99
import { createBuilder } from '@angular-devkit/architect';
1010
import { execute } from './builder';
11-
import { DevServerBuilderOutput } from './output';
12-
import { Schema as DevServerBuilderOptions } from './schema';
11+
import type { DevServerBuilderOutput } from './output';
12+
import type { Schema as DevServerBuilderOptions } from './schema';
1313

14-
export { DevServerBuilderOptions, DevServerBuilderOutput, execute as executeDevServerBuilder };
14+
export {
15+
type DevServerBuilderOptions,
16+
type DevServerBuilderOutput,
17+
execute as executeDevServerBuilder,
18+
};
1519
export default createBuilder<DevServerBuilderOptions, DevServerBuilderOutput>(execute);
1620

1721
// Temporary export to support specs

packages/angular/build/src/builders/dev-server/internal.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
export { BuildOutputFile, BuildOutputFileType } from '@angular/build';
9+
export { type BuildOutputFile, BuildOutputFileType } from '@angular/build';
1010
export { createRxjsEsmResolutionPlugin } from '../../tools/esbuild/rxjs-esm-resolution-plugin';
1111
export { JavaScriptTransformer } from '../../tools/esbuild/javascript-transformer';
1212
export { getFeatureSupport, isZonelessApp } from '../../tools/esbuild/utils';
@@ -16,5 +16,5 @@ export { purgeStaleBuildCache } from '../../utils/purge-cache';
1616
export { getSupportedBrowsers } from '../../utils/supported-browsers';
1717
export { transformSupportedBrowsersToTargets } from '../../tools/esbuild/utils';
1818
export { buildApplicationInternal } from '../../builders/application';
19-
export { ApplicationBuilderInternalOptions } from '../../builders/application/options';
20-
export { ExternalResultMetadata } from '../../tools/esbuild/bundler-execution-result';
19+
export type { ApplicationBuilderInternalOptions } from '../../builders/application/options';
20+
export type { ExternalResultMetadata } from '../../tools/esbuild/bundler-execution-result';

packages/angular/build/src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ export type { BuildOutputAsset } from './tools/esbuild/bundler-execution-result'
1616

1717
export {
1818
executeDevServerBuilder,
19-
DevServerBuilderOptions,
20-
DevServerBuilderOutput,
19+
type DevServerBuilderOptions,
20+
type DevServerBuilderOutput,
2121
} from './builders/dev-server';
2222

2323
export {
2424
execute as executeExtractI18nBuilder,
25-
ExtractI18nBuilderOptions,
25+
type ExtractI18nBuilderOptions,
2626
} from './builders/extract-i18n';

packages/angular/build/src/private.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515

1616
// Builders
1717
export { buildApplicationInternal } from './builders/application';
18-
export { ApplicationBuilderInternalOptions } from './builders/application/options';
18+
export type { ApplicationBuilderInternalOptions } from './builders/application/options';
1919
export { serveWithVite } from './builders/dev-server/vite-server';
2020

2121
// Tools
2222
export * from './tools/babel/plugins';
23-
export { ExternalResultMetadata } from './tools/esbuild/bundler-execution-result';
23+
export type { ExternalResultMetadata } from './tools/esbuild/bundler-execution-result';
2424
export { emitFilesToDisk } from './tools/esbuild/utils';
2525
export { transformSupportedBrowsersToTargets } from './tools/esbuild/utils';
2626
export { SassWorkerImplementation } from './tools/sass/sass-service';
@@ -34,7 +34,7 @@ export { createCompilerPlugin } from './tools/esbuild/angular/compiler-plugin';
3434
export * from './utils/bundle-calculator';
3535
export { checkPort } from './utils/check-port';
3636
export { deleteOutputDir } from './utils/delete-output-dir';
37-
export { I18nOptions, createI18nOptions, loadTranslations } from './utils/i18n-options';
37+
export { type I18nOptions, createI18nOptions, loadTranslations } from './utils/i18n-options';
3838
export {
3939
IndexHtmlGenerator,
4040
type IndexHtmlGeneratorOptions,
@@ -51,6 +51,6 @@ export { loadProxyConfiguration } from './utils/load-proxy-config';
5151
export { type TranslationLoader, createTranslationLoader } from './utils/load-translations';
5252
export { purgeStaleBuildCache } from './utils/purge-cache';
5353
export { augmentAppWithServiceWorker } from './utils/service-worker';
54-
export { BundleStats, generateBuildStatsTable } from './utils/stats-table';
54+
export { type BundleStats, generateBuildStatsTable } from './utils/stats-table';
5555
export { getSupportedBrowsers } from './utils/supported-browsers';
5656
export { assertCompatibleAngularVersion } from './utils/version';

packages/angular/build/src/utils/bundle-calculator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Budget as BudgetEntry, Type as BudgetType } from '../builders/applicati
1010
import { formatSize } from './format-bytes';
1111

1212
// Re-export to avoid direct schema importing throughout code
13-
export { BudgetEntry, BudgetType };
13+
export { type BudgetEntry, BudgetType };
1414

1515
interface Size {
1616
size: number;

packages/angular/ssr/public_api.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
export { CommonEngine, CommonEngineRenderOptions, CommonEngineOptions } from './src/common-engine';
9+
export {
10+
CommonEngine,
11+
type CommonEngineRenderOptions,
12+
type CommonEngineOptions,
13+
} from './src/common-engine';

0 commit comments

Comments
 (0)