Skip to content

Commit 0892f59

Browse files
crisbetodgp1130
authored andcommitted
build: prepare TypeScript 4.7
Expands the version range to allow TypeScript 4.7 and makes the necessary code changes in order to support it. (cherry picked from commit 0301cf6)
1 parent d76911a commit 0892f59

File tree

20 files changed

+60
-48
lines changed

20 files changed

+60
-48
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export function applyContentTemplate<T>(options: T): FileOperator;
7171
export function applyPathTemplate<T extends PathTemplateData>(data: T, options?: PathTemplateOptions): FileOperator;
7272

7373
// @public (undocumented)
74-
export function applyTemplates<T>(options: T): Rule;
74+
export function applyTemplates<T extends object>(options: T): Rule;
7575

7676
// @public (undocumented)
7777
export function applyToSubtree(path: string, rules: Rule[]): Rule;
@@ -904,11 +904,11 @@ export class TaskScheduler {
904904
// (undocumented)
905905
finalize(): ReadonlyArray<TaskInfo>;
906906
// (undocumented)
907-
schedule<T>(taskConfiguration: TaskConfiguration<T>): TaskId;
907+
schedule<T extends object>(taskConfiguration: TaskConfiguration<T>): TaskId;
908908
}
909909

910910
// @public (undocumented)
911-
export function template<T>(options: T): Rule;
911+
export function template<T extends object>(options: T): Rule;
912912

913913
// @public (undocumented)
914914
export const TEMPLATE_FILENAME_RE: RegExp;
@@ -939,7 +939,7 @@ export const TreeSymbol: symbol;
939939
// @public
940940
export interface TypedSchematicContext<CollectionMetadataT extends object, SchematicMetadataT extends object> {
941941
// (undocumented)
942-
addTask<T>(task: TaskConfigurationGenerator<T>, dependencies?: Array<TaskId>): TaskId;
942+
addTask<T extends object>(task: TaskConfigurationGenerator<T>, dependencies?: Array<TaskId>): TaskId;
943943
// (undocumented)
944944
readonly debug: boolean;
945945
// (undocumented)

goldens/public-api/angular_devkit/schematics/testing/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ export class SchematicTestRunner {
2525
// (undocumented)
2626
registerCollection(collectionName: string, collectionPath: string): void;
2727
// (undocumented)
28-
runExternalSchematicAsync<SchematicSchemaT>(collectionName: string, schematicName: string, opts?: SchematicSchemaT, tree?: Tree_2): Observable<UnitTestTree>;
28+
runExternalSchematicAsync<SchematicSchemaT extends object>(collectionName: string, schematicName: string, opts?: SchematicSchemaT, tree?: Tree_2): Observable<UnitTestTree>;
2929
// (undocumented)
30-
runSchematicAsync<SchematicSchemaT>(schematicName: string, opts?: SchematicSchemaT, tree?: Tree_2): Observable<UnitTestTree>;
30+
runSchematicAsync<SchematicSchemaT extends object>(schematicName: string, opts?: SchematicSchemaT, tree?: Tree_2): Observable<UnitTestTree>;
3131
// (undocumented)
3232
get tasks(): TaskConfiguration[];
3333
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@
169169
"magic-string": "0.26.1",
170170
"mini-css-extract-plugin": "2.6.0",
171171
"minimatch": "5.0.1",
172-
"ng-packagr": "14.0.0-next.5",
172+
"ng-packagr": "14.0.0-next.8",
173173
"node-fetch": "^2.2.0",
174174
"npm-package-arg": "9.0.2",
175175
"open": "8.4.0",

packages/angular/cli/src/command-builder/architect-base-command-module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export interface MissingTargetChoice {
3232
value: string;
3333
}
3434

35-
export abstract class ArchitectBaseCommandModule<T>
35+
export abstract class ArchitectBaseCommandModule<T extends object>
3636
extends CommandModule<T>
3737
implements CommandModuleImplementation<T>
3838
{

packages/angular/cli/src/command-builder/utilities/command.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { CommandContext, CommandModule, CommandModuleImplementation } from '../c
1212
export const demandCommandFailureMessage = `You need to specify a command before moving on. Use '--help' to view the available commands.`;
1313

1414
export function addCommandModuleToYargs<
15-
T,
15+
T extends object,
1616
U extends Partial<CommandModuleImplementation> & {
1717
new (context: CommandContext): Partial<CommandModuleImplementation> & CommandModule;
1818
},

packages/angular_devkit/architect/src/create-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ export function createBuilder<OptT = json.JsonObject, OutT extends BuilderOutput
202202
context.reportRunning();
203203
let result;
204204
try {
205-
result = fn(i.options as OptT, context);
205+
result = fn(i.options as unknown as OptT, context);
206206
if (isBuilderOutput(result)) {
207207
result = of(result);
208208
} else if (!isObservable(result) && isAsyncIterable(result)) {

packages/angular_devkit/build_angular/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
"ng-packagr": "^14.0.0 || ^14.0.0-next",
8181
"protractor": "^7.0.0",
8282
"tailwindcss": "^2.0.0 || ^3.0.0",
83-
"typescript": "~4.6.2"
83+
"typescript": ">=4.6.2 <4.8"
8484
},
8585
"peerDependenciesMeta": {
8686
"@angular/localize": {

packages/angular_devkit/build_angular/src/testing/builder-harness.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export class BuilderHarness<T> {
113113
return this;
114114
}
115115

116-
withBuilderTarget<O>(
116+
withBuilderTarget<O extends object>(
117117
target: string,
118118
handler: BuilderHandlerFn<O & json.JsonObject>,
119119
options?: O,
@@ -178,12 +178,12 @@ export class BuilderHarness<T> {
178178
getOptions: async (project, target, configuration) => {
179179
this.validateProjectName(project);
180180
if (target === this.targetName) {
181-
return this.options.get(configuration ?? null) ?? {};
181+
return (this.options.get(configuration ?? null) ?? {}) as json.JsonObject;
182182
} else if (configuration !== undefined) {
183183
// Harness builder targets currently do not support configurations
184184
return {};
185185
} else {
186-
return (this.builderTargets.get(target)?.options as json.JsonObject) || {};
186+
return (this.builderTargets.get(target)?.options || {}) as json.JsonObject;
187187
}
188188
},
189189
hasTarget: async (project, target) => {

packages/angular_devkit/core/src/json/schema/registry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ export class CoreSchemaRegistry implements SchemaRegistry {
402402
throw new Error(source);
403403
}
404404

405-
this._sourceMap.set(source, provider);
405+
this._sourceMap.set(source, provider as unknown as SmartDefaultProvider<{}>);
406406

407407
if (!this._smartDefaultKeyword) {
408408
this._smartDefaultKeyword = true;

packages/angular_devkit/core/src/utils/object.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export function deepCopy<T>(value: T): T {
1212
if (Array.isArray(value)) {
1313
return value.map((o) => deepCopy(o)) as unknown as T;
1414
} else if (value && typeof value === 'object') {
15-
const valueCasted = value as {
15+
const valueCasted = value as unknown as {
1616
[copySymbol]?: T;
1717
toJSON?: () => string;
1818
// eslint-disable-next-line @typescript-eslint/no-explicit-any

0 commit comments

Comments
 (0)