Skip to content

Commit e613014

Browse files
committed
Update to TypeScript 4.4
Updates the required version of TypeScript to 4.4.2. Projects that currently depend on packages like `api-extractor` can't use the new `useUnknownInCatchVariables` compiler option, because the version of TypeScript is set to 4.3.5. These changes update to 4.4.2.
1 parent becc2d8 commit e613014

File tree

146 files changed

+893
-694
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+893
-694
lines changed

Diff for: apps/api-documenter/src/plugin/PluginLoader.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export class PluginLoader {
8787
try {
8888
markdownDocumenterFeature = new featureDefinition.subclass(initialization);
8989
} catch (e) {
90-
throw new Error(`Failed to construct feature subclass:\n` + e.toString());
90+
throw new Error(`Failed to construct feature subclass:\n` + (e as Error).toString());
9191
}
9292
if (!(markdownDocumenterFeature instanceof MarkdownDocumenterFeature)) {
9393
throw new Error('The constructed subclass was not an instance of MarkdownDocumenterFeature');
@@ -96,7 +96,7 @@ export class PluginLoader {
9696
try {
9797
markdownDocumenterFeature.onInitialized();
9898
} catch (e) {
99-
throw new Error('Error occurred during the onInitialized() event: ' + e.toString());
99+
throw new Error('Error occurred during the onInitialized() event: ' + (e as Error).toString());
100100
}
101101

102102
this.markdownDocumenterFeature = markdownDocumenterFeature;
@@ -105,7 +105,7 @@ export class PluginLoader {
105105
}
106106
}
107107
} catch (e) {
108-
throw new Error(`Error loading plugin ${configPlugin.packageName}: ` + e.message);
108+
throw new Error(`Error loading plugin ${configPlugin.packageName}: ` + (e as Error).message);
109109
}
110110
}
111111
}

Diff for: apps/api-extractor-model/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
},
2121
"devDependencies": {
2222
"@rushstack/eslint-config": "workspace:*",
23-
"@rushstack/heft": "0.34.6",
24-
"@rushstack/heft-node-rig": "1.1.11",
23+
"@rushstack/heft": "0.38.1",
24+
"@rushstack/heft-node-rig": "1.2.13",
2525
"@types/heft-jest": "1.0.1",
2626
"@types/node": "10.17.13"
2727
}

Diff for: apps/api-extractor-model/src/items/ApiItem.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export class ApiItem {
114114
this._canonicalReference = this.buildCanonicalReference();
115115
} catch (e) {
116116
const name: string = this.getScopedNameWithinPackage() || this.displayName;
117-
throw new InternalError(`Error building canonical reference for ${name}:\n` + e.message);
117+
throw new InternalError(`Error building canonical reference for ${name}:\n` + (e as Error).message);
118118
}
119119
}
120120
return this._canonicalReference;

Diff for: apps/api-extractor/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@
4545
"resolve": "~1.17.0",
4646
"semver": "~7.3.0",
4747
"source-map": "~0.6.1",
48-
"typescript": "~4.3.5"
48+
"typescript": "~4.4.2"
4949
},
5050
"devDependencies": {
5151
"@rushstack/eslint-config": "workspace:*",
52-
"@rushstack/heft": "0.34.6",
53-
"@rushstack/heft-node-rig": "1.1.11",
52+
"@rushstack/heft": "0.38.1",
53+
"@rushstack/heft-node-rig": "1.2.13",
5454
"@types/heft-jest": "1.0.1",
5555
"@types/lodash": "4.14.116",
5656
"@types/node": "10.17.13",

Diff for: apps/api-extractor/src/api/ExtractorConfig.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ export class ExtractorConfig {
518518
basedir: currentConfigFolderPath
519519
});
520520
} catch (e) {
521-
throw new Error(`Error resolving NodeJS path "${extendsField}": ${e.message}`);
521+
throw new Error(`Error resolving NodeJS path "${extendsField}": ${(e as Error).message}`);
522522
}
523523
}
524524
}
@@ -534,7 +534,7 @@ export class ExtractorConfig {
534534
currentConfigFilePath = extendsField;
535535
} while (currentConfigFilePath);
536536
} catch (e) {
537-
throw new Error(`Error loading ${currentConfigFilePath}:\n` + e.message);
537+
throw new Error(`Error loading ${currentConfigFilePath}:\n` + (e as Error).message);
538538
}
539539

540540
// Lastly, apply the defaults
@@ -973,7 +973,7 @@ export class ExtractorConfig {
973973
testMode: !!configObject.testMode
974974
};
975975
} catch (e) {
976-
throw new Error(`Error parsing ${filenameForErrors}:\n` + e.message);
976+
throw new Error(`Error parsing ${filenameForErrors}:\n` + (e as Error).message);
977977
}
978978

979979
let tsdocConfigFile: TSDocConfigFile | undefined = options.tsdocConfigFile;

Diff for: apps/heft/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
"devDependencies": {
5151
"@microsoft/api-extractor": "workspace:*",
5252
"@rushstack/eslint-config": "workspace:*",
53-
"@rushstack/heft": "0.34.6",
54-
"@rushstack/heft-node-rig": "1.1.11",
53+
"@rushstack/heft": "0.38.1",
54+
"@rushstack/heft-node-rig": "1.2.13",
5555
"@types/argparse": "1.0.38",
5656
"@types/eslint": "7.2.0",
5757
"@types/glob": "7.1.1",
@@ -60,6 +60,6 @@
6060
"@types/semver": "7.3.5",
6161
"colors": "~1.2.1",
6262
"tslint": "~5.20.1",
63-
"typescript": "~3.9.7"
63+
"typescript": "~4.4.2"
6464
}
6565
}

Diff for: apps/heft/src/cli/HeftToolsCommandLineParser.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ export class HeftToolsCommandLineParser extends CommandLineParser {
191191

192192
return await super.execute(args);
193193
} catch (e) {
194-
await this._reportErrorAndSetExitCode(e);
194+
await this._reportErrorAndSetExitCode(e as Error);
195195
return false;
196196
}
197197
}
@@ -215,7 +215,7 @@ export class HeftToolsCommandLineParser extends CommandLineParser {
215215
await super.onExecute();
216216
await this._metricsCollector.flushAndTeardownAsync();
217217
} catch (e) {
218-
await this._reportErrorAndSetExitCode(e);
218+
await this._reportErrorAndSetExitCode(e as Error);
219219
}
220220

221221
// If we make it here, things are fine and reset the exit code back to 0

Diff for: apps/heft/src/plugins/NodeServicePlugin.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ export class NodeServicePlugin implements IHeftPlugin {
432432
try {
433433
action();
434434
} catch (error) {
435-
this._logger.emitError(error);
435+
this._logger.emitError(error as Error);
436436
this._logger.terminal.writeErrorLine('An unexpected error occurred');
437437

438438
// TODO: Provide a Heft facility for this

Diff for: apps/heft/src/plugins/ProjectValidatorPlugin.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export class ProjectValidatorPlugin implements IHeftPlugin {
111111
}
112112
);
113113
} catch (e) {
114-
if (!FileSystem.isNotExistError(e)) {
114+
if (!FileSystem.isNotExistError(e as Error)) {
115115
throw e;
116116
} else {
117117
return;

Diff for: apps/heft/src/plugins/TypeScriptPlugin/LinterBase.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export abstract class LinterBase<TLintResult> {
114114
try {
115115
tslintCacheData = await JsonFile.loadAsync(cacheFilePath);
116116
} catch (e) {
117-
if (FileSystem.isNotExistError(e)) {
117+
if (FileSystem.isNotExistError(e as Error)) {
118118
tslintCacheData = undefined;
119119
} else {
120120
throw e;

Diff for: apps/heft/src/plugins/TypeScriptPlugin/TypeScriptBuilder.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ export class TypeScriptBuilder extends SubprocessRunnerBase<ITypeScriptBuilderCo
10701070
const stats: FileSystemStats = this._cachedFileSystem.getStatistics(directoryPath);
10711071
return stats.isDirectory() || stats.isSymbolicLink();
10721072
} catch (error) {
1073-
if (FileSystem.isNotExistError(error)) {
1073+
if (FileSystem.isNotExistError(error as Error)) {
10741074
return false;
10751075
} else {
10761076
throw error;
@@ -1083,7 +1083,7 @@ export class TypeScriptBuilder extends SubprocessRunnerBase<ITypeScriptBuilderCo
10831083
const stats: FileSystemStats = this._cachedFileSystem.getStatistics(filePath);
10841084
return stats.isFile();
10851085
} catch (error) {
1086-
if (FileSystem.isNotExistError(error)) {
1086+
if (FileSystem.isNotExistError(error as Error)) {
10871087
return false;
10881088
} else {
10891089
throw error;

Diff for: apps/heft/src/startWithVersionSelector.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function tryStartLocalHeft(): boolean {
6868
try {
6969
packageJson = JSON.parse(packageJsonContent);
7070
} catch (error) {
71-
throw new Error(`Error parsing ${packageJsonPath}:` + error.message);
71+
throw new Error(`Error parsing ${packageJsonPath}:` + (error as Error).message);
7272
}
7373

7474
// Does package.json have a dependency on Heft?
@@ -91,7 +91,7 @@ function tryStartLocalHeft(): boolean {
9191
console.log(`Using local Heft from ${heftFolder}`);
9292
console.log();
9393
} catch (error) {
94-
throw new Error('Error probing for local Heft version: ' + error.message);
94+
throw new Error('Error probing for local Heft version: ' + (error as Error).message);
9595
}
9696

9797
require(heftEntryPoint);

Diff for: apps/heft/src/utilities/Async.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class Async {
1818
try {
1919
fn().catch((e) => scopedLogger.emitError(e));
2020
} catch (e) {
21-
scopedLogger.emitError(e);
21+
scopedLogger.emitError(e as Error);
2222
}
2323
}
2424
}

Diff for: apps/heft/src/utilities/fileSystem/TypeScriptCachedFileSystem.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export class TypeScriptCachedFileSystem {
4343
this.getStatistics(path);
4444
return true;
4545
} catch (e) {
46-
if (FileSystem.isNotExistError(e)) {
46+
if (FileSystem.isNotExistError(e as Error)) {
4747
return false;
4848
} else {
4949
throw e;
@@ -56,7 +56,7 @@ export class TypeScriptCachedFileSystem {
5656
const stats: FileSystemStats = this.getStatistics(path);
5757
return stats.isDirectory();
5858
} catch (e) {
59-
if (FileSystem.isNotExistError(e)) {
59+
if (FileSystem.isNotExistError(e as Error)) {
6060
return false;
6161
} else {
6262
throw e;
@@ -184,7 +184,7 @@ export class TypeScriptCachedFileSystem {
184184
try {
185185
cacheEntry = { entry: fn(path) };
186186
} catch (e) {
187-
cacheEntry = { error: e, entry: undefined };
187+
cacheEntry = { error: e as Error, entry: undefined };
188188
}
189189

190190
cache.set(path, cacheEntry);

Diff for: apps/heft/src/utilities/subprocess/SubprocessRunnerBase.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ export abstract class SubprocessRunnerBase<
226226
try {
227227
await this.invokeAsync();
228228
} catch (e) {
229-
error = e;
229+
error = e as Error;
230230
} finally {
231231
process.removeAllListeners();
232232

Diff for: apps/heft/src/utilities/subprocess/SubprocessTerminator.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export class SubprocessTerminator {
173173
SubprocessTerminator.killProcessTree(trackedSubprocess.subprocess, { detached: true });
174174
} catch (error) {
175175
if (firstError === undefined) {
176-
firstError = error;
176+
firstError = error as Error;
177177
}
178178
}
179179
}

Diff for: apps/rush-lib/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,6 @@
7777
"@types/tar": "4.0.3",
7878
"@types/z-schema": "3.16.31",
7979
"jest": "~25.4.0",
80-
"typescript": "~3.9.7"
80+
"typescript": "~4.4.2"
8181
}
8282
}

Diff for: apps/rush-lib/src/api/CommonVersionsConfiguration.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export class CommonVersionsConfiguration {
102102
commonVersionsJson.allowedAlternativeVersions
103103
);
104104
} catch (e) {
105-
throw new Error(`Error loading "${path.basename(filePath)}": ${e.message}`);
105+
throw new Error(`Error loading "${path.basename(filePath)}": ${(e as Error).message}`);
106106
}
107107
}
108108
this._filePath = filePath;

Diff for: apps/rush-lib/src/api/PackageJsonEditor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export class PackageJsonEditor {
163163
Sort.sortMapKeys(this._dependencies);
164164
Sort.sortMapKeys(this._devDependencies);
165165
} catch (e) {
166-
throw new Error(`Error loading "${filepath}": ${e.message}`);
166+
throw new Error(`Error loading "${filepath}": ${(e as Error).message}`);
167167
}
168168
}
169169

Diff for: apps/rush-lib/src/api/RushUserConfiguration.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export class RushUserConfiguration {
4343
RushUserConfiguration._schema
4444
);
4545
} catch (e) {
46-
if (!FileSystem.isNotExistError(e)) {
46+
if (!FileSystem.isNotExistError(e as Error)) {
4747
throw e;
4848
}
4949
}

Diff for: apps/rush-lib/src/cli/RushCommandLineParser.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export class RushCommandLineParser extends CommandLineParser {
8787
this.rushConfiguration = RushConfiguration.loadFromConfigurationFile(rushJsonFilename);
8888
}
8989
} catch (error) {
90-
this._reportErrorAndSetExitCode(error);
90+
this._reportErrorAndSetExitCode(error as Error);
9191
}
9292

9393
NodeJsCompatibility.warnAboutCompatibilityIssues({
@@ -134,7 +134,7 @@ export class RushCommandLineParser extends CommandLineParser {
134134
// If we make it here, everything went fine, so reset the exit code back to 0
135135
process.exitCode = 0;
136136
} catch (error) {
137-
this._reportErrorAndSetExitCode(error);
137+
this._reportErrorAndSetExitCode(error as Error);
138138
}
139139
}
140140

@@ -184,7 +184,7 @@ export class RushCommandLineParser extends CommandLineParser {
184184

185185
this._populateScriptActions();
186186
} catch (error) {
187-
this._reportErrorAndSetExitCode(error);
187+
this._reportErrorAndSetExitCode(error as Error);
188188
}
189189
}
190190

@@ -300,8 +300,8 @@ export class RushCommandLineParser extends CommandLineParser {
300300
break;
301301
default:
302302
throw new Error(
303-
`${RushConstants.commandLineFilename} defines a command "${command!.name}"` +
304-
` using an unsupported command kind "${command!.commandKind}"`
303+
`${RushConstants.commandLineFilename} defines a command "${(command as CommandJson).name}"` +
304+
` using an unsupported command kind "${(command as CommandJson).commandKind}"`
305305
);
306306
}
307307
}

Diff for: apps/rush-lib/src/cli/RushXCommandLine.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export class RushXCommandLine {
150150

151151
process.exitCode = exitCode;
152152
} catch (error) {
153-
console.log(colors.red('Error: ' + error.message));
153+
console.log(colors.red('Error: ' + (error as Error).message));
154154
}
155155
}
156156

Diff for: apps/rush-lib/src/cli/actions/ChangeAction.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ export class ChangeAction extends BaseRushAction {
290290
interactiveMode
291291
);
292292
} catch (error) {
293-
throw new Error(`There was an error creating a change file: ${error.toString()}`);
293+
throw new Error(`There was an error creating a change file: ${(error as Error).toString()}`);
294294
}
295295
}
296296

Diff for: apps/rush-lib/src/cli/scriptActions/BaseScriptAction.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { CommandLineParameter } from '@rushstack/ts-command-line';
55
import { BaseRushAction, IBaseRushActionOptions } from '../actions/BaseRushAction';
66
import { CommandLineConfiguration } from '../../api/CommandLineConfiguration';
77
import { RushConstants } from '../../logic/RushConstants';
8+
import type { ParameterJson } from '../../api/CommandLineJson';
89

910
/**
1011
* Constructor parameters for BaseScriptAction
@@ -79,8 +80,8 @@ export abstract class BaseScriptAction extends BaseRushAction {
7980
break;
8081
default:
8182
throw new Error(
82-
`${RushConstants.commandLineFilename} defines a parameter "${parameterJson!.longName}"` +
83-
` using an unsupported parameter kind "${parameterJson!.parameterKind}"`
83+
`${RushConstants.commandLineFilename} defines a parameter "${(parameterJson as ParameterJson).longName}"` +
84+
` using an unsupported parameter kind "${(parameterJson as ParameterJson).parameterKind}"`
8485
);
8586
}
8687

Diff for: apps/rush-lib/src/cli/scriptActions/BulkScriptAction.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -332,11 +332,11 @@ export class BulkScriptAction extends BaseScriptAction {
332332
if (error instanceof AlreadyReportedError) {
333333
console.log(`rush ${this.actionName} (${stopwatch.toString()})`);
334334
} else {
335-
if (error && error.message) {
335+
if (error && (error as Error).message) {
336336
if (this.parser.isDebug) {
337-
console.log('Error: ' + error.stack);
337+
console.log('Error: ' + (error as Error).stack);
338338
} else {
339-
console.log('Error: ' + error.message);
339+
console.log('Error: ' + (error as Error).message);
340340
}
341341
}
342342

Diff for: apps/rush-lib/src/logic/CredentialCache.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export class CredentialCache implements IDisposable {
6868
try {
6969
loadedJson = await JsonFile.loadAndValidateAsync(cacheFilePath, jsonSchema);
7070
} catch (e) {
71-
if (!FileSystem.isErrnoException(e)) {
71+
if (!FileSystem.isErrnoException(e as Error)) {
7272
throw e;
7373
}
7474
}

Diff for: apps/rush-lib/src/logic/EventHooksManager.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export class EventHooksManager {
5555
)
5656
);
5757
if (isDebug) {
58-
console.error(os.EOL + error.message);
58+
console.error(os.EOL + (error as Error).message);
5959
}
6060
}
6161
});

Diff for: apps/rush-lib/src/logic/Git.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ export class Git {
416416
};
417417
} catch (e) {
418418
this._gitEmailResult = {
419-
error: e
419+
error: e as Error
420420
};
421421
}
422422
}

0 commit comments

Comments
 (0)