Skip to content

Commit 5165265

Browse files
committed
refactor: reduce dependencies on @angular-devkit/core
By converting schemas from TypeScript `interfaces` to `types`, we can minimize the reliance on `json.JsonObject`. This approach avoids the error "Type 'Schema' does not satisfy the constraint 'JsonObject'" caused by the missing index signature for type 'string' in 'Schema'. (cherry picked from commit e7413d3)
1 parent bce32c1 commit 5165265

File tree

13 files changed

+50
-62
lines changed

13 files changed

+50
-62
lines changed

goldens/public-api/angular/build/index.api.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export interface ApplicationBuilderExtensions {
1919
}
2020

2121
// @public
22-
export interface ApplicationBuilderOptions {
22+
export type ApplicationBuilderOptions = {
2323
allowedCommonJsDependencies?: string[];
2424
aot?: boolean;
2525
appShell?: boolean;
@@ -69,7 +69,7 @@ export interface ApplicationBuilderOptions {
6969
verbose?: boolean;
7070
watch?: boolean;
7171
webWorkerTsConfig?: string;
72-
}
72+
};
7373

7474
// @public
7575
export function buildApplication(options: ApplicationBuilderOptions, context: BuilderContext, extensions?: ApplicationBuilderExtensions): AsyncIterable<BuilderOutput>;
@@ -107,7 +107,7 @@ export enum BuildOutputFileType {
107107
}
108108

109109
// @public
110-
export interface DevServerBuilderOptions {
110+
export type DevServerBuilderOptions = {
111111
buildTarget: string;
112112
headers?: {
113113
[key: string]: string;
@@ -127,7 +127,7 @@ export interface DevServerBuilderOptions {
127127
sslKey?: string;
128128
verbose?: boolean;
129129
watch?: boolean;
130-
}
130+
};
131131

132132
// @public
133133
export interface DevServerBuilderOutput extends BuilderOutput {
@@ -153,21 +153,21 @@ export function executeExtractI18nBuilder(options: ExtractI18nBuilderOptions, co
153153
export function executeNgPackagrBuilder(options: NgPackagrBuilderOptions, context: BuilderContext): AsyncIterableIterator<BuilderOutput>;
154154

155155
// @public
156-
export interface ExtractI18nBuilderOptions {
156+
export type ExtractI18nBuilderOptions = {
157157
buildTarget?: string;
158158
format?: Format;
159159
outFile?: string;
160160
outputPath?: string;
161161
progress?: boolean;
162-
}
162+
};
163163

164164
// @public
165-
export interface NgPackagrBuilderOptions {
165+
export type NgPackagrBuilderOptions = {
166166
poll?: number;
167167
project: string;
168168
tsConfig?: string;
169169
watch?: boolean;
170-
}
170+
};
171171

172172
// (No @packageDocumentation comment for this package)
173173

goldens/public-api/angular_devkit/build_angular/index.api.md

+27-32
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { Configuration } from 'webpack';
1313
import { DevServerBuilderOutput } from '@angular/build';
1414
import type http from 'node:http';
1515
import { IndexHtmlTransform } from '@angular/build/private';
16-
import { json } from '@angular-devkit/core';
1716
import { Observable } from 'rxjs';
1817
import type { Plugin as Plugin_2 } from 'esbuild';
1918
import webpack from 'webpack';
@@ -25,16 +24,16 @@ export { ApplicationBuilderOptions }
2524
export type AssetPattern = AssetPatternObject | string;
2625

2726
// @public (undocumented)
28-
export interface AssetPatternObject {
27+
export type AssetPatternObject = {
2928
followSymlinks?: boolean;
3029
glob: string;
3130
ignore?: string[];
3231
input: string;
3332
output?: string;
34-
}
33+
};
3534

3635
// @public
37-
export interface BrowserBuilderOptions {
36+
export type BrowserBuilderOptions = {
3837
allowedCommonJsDependencies?: string[];
3938
aot?: boolean;
4039
assets?: AssetPattern[];
@@ -75,7 +74,7 @@ export interface BrowserBuilderOptions {
7574
verbose?: boolean;
7675
watch?: boolean;
7776
webWorkerTsConfig?: string;
78-
}
77+
};
7978

8079
// @public
8180
export type BrowserBuilderOutput = BuilderOutput & {
@@ -89,7 +88,7 @@ export type BrowserBuilderOutput = BuilderOutput & {
8988
};
9089

9190
// @public (undocumented)
92-
export interface Budget {
91+
export type Budget = {
9392
baseline?: string;
9493
error?: string;
9594
maximumError?: string;
@@ -99,7 +98,7 @@ export interface Budget {
9998
name?: string;
10099
type: Type;
101100
warning?: string;
102-
}
101+
};
103102

104103
export { buildApplication }
105104

@@ -114,7 +113,7 @@ export enum CrossOrigin {
114113
}
115114

116115
// @public
117-
export interface DevServerBuilderOptions {
116+
export type DevServerBuilderOptions = {
118117
allowedHosts?: string[];
119118
buildTarget: string;
120119
disableHostCheck?: boolean;
@@ -138,7 +137,7 @@ export interface DevServerBuilderOptions {
138137
sslKey?: string;
139138
verbose?: boolean;
140139
watch?: boolean;
141-
}
140+
};
142141

143142
export { DevServerBuilderOutput }
144143

@@ -189,28 +188,24 @@ export function executeSSRDevServerBuilder(options: SSRDevServerBuilderOptions,
189188
export type ExecutionTransformer<T> = (input: T) => T | Promise<T>;
190189

191190
// @public
192-
export interface ExtractI18nBuilderOptions {
191+
export type ExtractI18nBuilderOptions = {
193192
buildTarget?: string;
194193
format?: Format;
195194
outFile?: string;
196195
outputPath?: string;
197196
progress?: boolean;
198-
}
197+
};
199198

200199
// @public (undocumented)
201-
export interface FileReplacement {
202-
// (undocumented)
200+
export type FileReplacement = {
203201
replace?: string;
204-
// (undocumented)
205202
replaceWith?: string;
206-
// (undocumented)
207203
src?: string;
208-
// (undocumented)
209204
with?: string;
210-
}
205+
};
211206

212207
// @public
213-
export interface KarmaBuilderOptions {
208+
export type KarmaBuilderOptions = {
214209
assets?: AssetPattern_2[];
215210
browsers?: Browsers;
216211
builderMode?: BuilderMode;
@@ -234,7 +229,7 @@ export interface KarmaBuilderOptions {
234229
tsConfig: string;
235230
watch?: boolean;
236231
webWorkerTsConfig?: string;
237-
}
232+
};
238233

239234
// @public (undocumented)
240235
export type KarmaConfigOptions = ConfigOptions & {
@@ -243,19 +238,19 @@ export type KarmaConfigOptions = ConfigOptions & {
243238
};
244239

245240
// @public
246-
export interface NgPackagrBuilderOptions {
241+
export type NgPackagrBuilderOptions = {
247242
poll?: number;
248243
project: string;
249244
tsConfig?: string;
250245
watch?: boolean;
251-
}
246+
};
252247

253248
// @public (undocumented)
254-
export interface OptimizationObject {
249+
export type OptimizationObject = {
255250
fonts?: FontsUnion;
256251
scripts?: boolean;
257252
styles?: StylesUnion;
258-
}
253+
};
259254

260255
// @public
261256
export type OptimizationUnion = boolean | OptimizationObject;
@@ -273,7 +268,7 @@ export enum OutputHashing {
273268
}
274269

275270
// @public
276-
export interface ProtractorBuilderOptions {
271+
export type ProtractorBuilderOptions = {
277272
baseUrl?: string;
278273
devServerTarget?: string;
279274
grep?: string;
@@ -284,10 +279,10 @@ export interface ProtractorBuilderOptions {
284279
specs?: string[];
285280
suite?: string;
286281
webdriverUpdate?: boolean;
287-
}
282+
};
288283

289284
// @public (undocumented)
290-
export interface ServerBuilderOptions {
285+
export type ServerBuilderOptions = {
291286
assets?: AssetPattern_3[];
292287
buildOptimizer?: boolean;
293288
deleteOutputPath?: boolean;
@@ -315,7 +310,7 @@ export interface ServerBuilderOptions {
315310
vendorChunk?: boolean;
316311
verbose?: boolean;
317312
watch?: boolean;
318-
}
313+
};
319314

320315
// @public
321316
export type ServerBuilderOutput = BuilderOutput & {
@@ -328,18 +323,18 @@ export type ServerBuilderOutput = BuilderOutput & {
328323
};
329324

330325
// @public (undocumented)
331-
export interface SourceMapObject {
326+
export type SourceMapObject = {
332327
hidden?: boolean;
333328
scripts?: boolean;
334329
styles?: boolean;
335330
vendor?: boolean;
336-
}
331+
};
337332

338333
// @public
339334
export type SourceMapUnion = boolean | SourceMapObject;
340335

341336
// @public (undocumented)
342-
export type SSRDevServerBuilderOptions = Schema & json.JsonObject;
337+
export type SSRDevServerBuilderOptions = Schema;
343338

344339
// @public (undocumented)
345340
export type SSRDevServerBuilderOutput = BuilderOutput & {
@@ -348,9 +343,9 @@ export type SSRDevServerBuilderOutput = BuilderOutput & {
348343
};
349344

350345
// @public
351-
export interface StylePreprocessorOptions {
346+
export type StylePreprocessorOptions = {
352347
includePaths?: string[];
353-
}
348+
};
354349

355350
// @public
356351
export enum Type {

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

+1-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88

99
import { Builder, BuilderContext, BuilderOutput, createBuilder } from '@angular-devkit/architect';
10-
import { json } from '@angular-devkit/core';
1110
import assert from 'node:assert';
1211
import fs from 'node:fs/promises';
1312
import path from 'node:path';
@@ -260,7 +259,6 @@ function generateFullPath(
260259
return fullFilePath;
261260
}
262261

263-
const builder: Builder<ApplicationBuilderOptions & json.JsonObject> =
264-
createBuilder(buildApplication);
262+
const builder: Builder<ApplicationBuilderOptions> = createBuilder(buildApplication);
265263

266264
export default builder;

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88

99
import { Builder, createBuilder } from '@angular-devkit/architect';
10-
import { json } from '@angular-devkit/core';
1110
import { execute } from './builder';
1211
import type { DevServerBuilderOutput } from './output';
1312
import type { Schema as DevServerBuilderOptions } from './schema';
@@ -17,7 +16,7 @@ export {
1716
type DevServerBuilderOutput,
1817
execute as executeDevServerBuilder,
1918
};
20-
const builder: Builder<DevServerBuilderOptions & json.JsonObject> = createBuilder<
19+
const builder: Builder<DevServerBuilderOptions> = createBuilder<
2120
DevServerBuilderOptions,
2221
DevServerBuilderOutput
2322
>(execute);

packages/angular/build/src/builders/extract-i18n/index.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@
77
*/
88

99
import { Builder, createBuilder } from '@angular-devkit/architect';
10-
import { json } from '@angular-devkit/core';
1110
import { execute } from './builder';
1211
import type { Schema as ExtractI18nBuilderOptions } from './schema';
1312

1413
export { ExtractI18nBuilderOptions, execute };
1514

16-
const builder: Builder<ExtractI18nBuilderOptions & json.JsonObject> =
15+
const builder: Builder<ExtractI18nBuilderOptions> =
1716
createBuilder<ExtractI18nBuilderOptions>(execute);
1817

1918
export default builder;

packages/angular/build/src/builders/ng-packagr/index.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@
77
*/
88

99
import { Builder, createBuilder } from '@angular-devkit/architect';
10-
import { json } from '@angular-devkit/core';
1110
import { execute } from './builder';
1211
import type { Schema as NgPackagrBuilderOptions } from './schema';
1312

1413
export { type NgPackagrBuilderOptions, execute };
1514

16-
const builder: Builder<NgPackagrBuilderOptions & json.JsonObject> =
17-
createBuilder<NgPackagrBuilderOptions>(execute);
15+
const builder: Builder<NgPackagrBuilderOptions> = createBuilder<NgPackagrBuilderOptions>(execute);
1816

1917
export default builder;

packages/angular_devkit/build_angular/src/builders/dev-server/tests/jasmine-helpers.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import { setupApplicationTarget, setupBrowserTarget } from './setup';
1515

1616
const optionSchemaCache = new Map<string, json.schema.JsonSchema>();
1717

18-
export function describeServeBuilder<T>(
19-
builderHandler: BuilderHandlerFn<T & json.JsonObject>,
18+
export function describeServeBuilder<T extends json.JsonObject>(
19+
builderHandler: BuilderHandlerFn<T>,
2020
options: { name?: string; schemaPath: string },
2121
specDefinitions: ((
2222
harness: JasmineBuilderHarness<T>,

packages/angular_devkit/build_angular/src/builders/protractor/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
createBuilder,
1313
targetFromTargetString,
1414
} from '@angular-devkit/architect';
15-
import { json, tags } from '@angular-devkit/core';
15+
import { tags } from '@angular-devkit/core';
1616
import { resolve } from 'path';
1717
import * as url from 'url';
1818
import { runModuleAsObservableFork } from '../../utils';
@@ -118,7 +118,7 @@ export async function execute(
118118
const overrides = {
119119
watch: false,
120120
liveReload: false,
121-
} as DevServerBuilderOptions & json.JsonObject;
121+
} as DevServerBuilderOptions;
122122

123123
if (options.host !== undefined) {
124124
overrides.host = options.host;

packages/angular_devkit/build_angular/src/builders/ssr-dev-server/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const IGNORED_STDOUT_MESSAGES = [
5252
'Angular is running in development mode. Call enableProdMode() to enable production mode.',
5353
];
5454

55-
export type SSRDevServerBuilderOptions = Schema & json.JsonObject;
55+
export type SSRDevServerBuilderOptions = Schema;
5656
export type SSRDevServerBuilderOutput = BuilderOutput & {
5757
baseUrl?: string;
5858
port?: string;

packages/angular_devkit/build_webpack/BUILD.bazel

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ ts_project(
4848
module_name = "@angular-devkit/build-webpack",
4949
deps = [
5050
":node_modules/@angular-devkit/architect",
51-
":node_modules/@angular-devkit/core",
5251
"//:node_modules/@types/node",
5352
"//:node_modules/rxjs",
5453
"//:node_modules/webpack",

packages/angular_devkit/build_webpack/src/builders/webpack-dev-server/index.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88

99
import { Builder, BuilderContext, createBuilder } from '@angular-devkit/architect';
10-
import { json } from '@angular-devkit/core';
1110
import { resolve as pathResolve } from 'path';
1211
import { Observable, from, isObservable, of, switchMap } from 'rxjs';
1312
import webpack from 'webpack';
@@ -125,7 +124,7 @@ export function runWebpackDevServer(
125124
);
126125
}
127126

128-
const builder: Builder<WebpackDevServerBuilderSchema & json.JsonObject> = createBuilder<
127+
const builder: Builder<WebpackDevServerBuilderSchema> = createBuilder<
129128
WebpackDevServerBuilderSchema,
130129
DevServerBuildOutput
131130
>((options, context) => {

0 commit comments

Comments
 (0)