From 96ca841cc0cfb98a0f3417a9df3e70ed264d34ab Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Tue, 14 Jan 2025 11:20:24 -0500 Subject: [PATCH] refactor(@ngtools/webpack): add types to exported module variables Adding explicit type information for a module's exported variables allows the `@ngtools/webpack` package to be built with the `isolatedDeclarations` option. --- packages/ngtools/webpack/src/ivy/index.ts | 2 +- packages/ngtools/webpack/src/ivy/paths.ts | 2 +- packages/ngtools/webpack/src/ivy/plugin.ts | 2 +- packages/ngtools/webpack/src/ivy/symbol.ts | 2 +- packages/ngtools/webpack/src/loaders/inline-resource.ts | 6 ++++-- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/ngtools/webpack/src/ivy/index.ts b/packages/ngtools/webpack/src/ivy/index.ts index 6c19f921f8a5..845d06385ff2 100644 --- a/packages/ngtools/webpack/src/ivy/index.ts +++ b/packages/ngtools/webpack/src/ivy/index.ts @@ -9,4 +9,4 @@ export { angularWebpackLoader as default } from './loader'; export { type AngularWebpackPluginOptions, AngularWebpackPlugin, imageDomains } from './plugin'; -export const AngularWebpackLoaderPath = __filename; +export const AngularWebpackLoaderPath: string = __filename; diff --git a/packages/ngtools/webpack/src/ivy/paths.ts b/packages/ngtools/webpack/src/ivy/paths.ts index 5aac2b307cd3..688aa65e5718 100644 --- a/packages/ngtools/webpack/src/ivy/paths.ts +++ b/packages/ngtools/webpack/src/ivy/paths.ts @@ -34,7 +34,7 @@ function externalizeForWindows(path: string): string { return result; } -export const externalizePath = (() => { +export const externalizePath: typeof externalizeForWindows = (() => { if (process.platform !== 'win32') { return (path: string) => path; } diff --git a/packages/ngtools/webpack/src/ivy/plugin.ts b/packages/ngtools/webpack/src/ivy/plugin.ts index 07daf99cab88..b77489146ee6 100644 --- a/packages/ngtools/webpack/src/ivy/plugin.ts +++ b/packages/ngtools/webpack/src/ivy/plugin.ts @@ -39,7 +39,7 @@ import { createAotTransformers, createJitTransformers, mergeTransformers } from */ const DIAGNOSTICS_AFFECTED_THRESHOLD = 1; -export const imageDomains = new Set(); +export const imageDomains: Set = new Set(); export interface AngularWebpackPluginOptions { tsconfig: string; diff --git a/packages/ngtools/webpack/src/ivy/symbol.ts b/packages/ngtools/webpack/src/ivy/symbol.ts index a2bde7931053..6d884a256144 100644 --- a/packages/ngtools/webpack/src/ivy/symbol.ts +++ b/packages/ngtools/webpack/src/ivy/symbol.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.dev/license */ -export const AngularPluginSymbol = Symbol.for('@ngtools/webpack[angular-compiler]'); +export const AngularPluginSymbol: unique symbol = Symbol.for('@ngtools/webpack[angular-compiler]'); export interface EmitFileResult { content?: string; diff --git a/packages/ngtools/webpack/src/loaders/inline-resource.ts b/packages/ngtools/webpack/src/loaders/inline-resource.ts index b061f8e4156f..9bdde8cb0707 100644 --- a/packages/ngtools/webpack/src/loaders/inline-resource.ts +++ b/packages/ngtools/webpack/src/loaders/inline-resource.ts @@ -8,9 +8,11 @@ import type { Compilation, LoaderContext } from 'webpack'; -export const InlineAngularResourceLoaderPath = __filename; +export const InlineAngularResourceLoaderPath: string = __filename; -export const InlineAngularResourceSymbol = Symbol('@ngtools/webpack[angular-resource]'); +export const InlineAngularResourceSymbol: unique symbol = Symbol( + '@ngtools/webpack[angular-resource]', +); export interface CompilationWithInlineAngularResource extends Compilation { [InlineAngularResourceSymbol]: string;