Skip to content

Commit ffbd01e

Browse files
authored
Update TS version to 4.5.5 (microsoft#18603)
* Update TS version in package.json * Fix TS errors * News entry
1 parent 387b589 commit ffbd01e

23 files changed

Lines changed: 74 additions & 55 deletions

File tree

news/3 Code Health/18602.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update TypeScript version to 4.5.5.

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2076,7 +2076,7 @@
20762076
"ts-node": "^8.3.0",
20772077
"tsconfig-paths-webpack-plugin": "^3.2.0",
20782078
"typemoq": "^2.1.0",
2079-
"typescript": "4.1.5",
2079+
"typescript": "4.5.5",
20802080
"typescript-formatter": "^7.1.0",
20812081
"uuid": "^3.3.2",
20822082
"vsce": "^2.6.6",

src/client/common/editor.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,8 @@ export async function getTempFileWithDocumentContents(document: TextDocument, fs
259259
await fs.writeFile(fileName, document.getText());
260260
} catch (ex) {
261261
traceError('Failed to create a temporary file', ex);
262-
throw new WrappedError(`Failed to create a temporary file, ${ex.message}`, ex);
262+
const exception = ex as Error;
263+
throw new WrappedError(`Failed to create a temporary file, ${exception.message}`, exception);
263264
}
264265
return fileName;
265266
}

src/client/common/platform/errors.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,21 +97,23 @@ function isSystemError(err: Error, expectedCode: string): boolean | undefined {
9797
}
9898

9999
// Return true if the given error is ENOENT.
100-
export function isFileNotFoundError(err: Error): boolean | undefined {
101-
const matched = vscErrors.isFileNotFound(err);
100+
export function isFileNotFoundError(err: unknown | Error): boolean | undefined {
101+
const error = err as Error;
102+
const matched = vscErrors.isFileNotFound(error);
102103
if (matched !== undefined) {
103104
return matched;
104105
}
105-
return isSystemError(err, 'ENOENT');
106+
return isSystemError(error, 'ENOENT');
106107
}
107108

108109
// Return true if the given error is EEXIST.
109-
export function isFileExistsError(err: Error): boolean | undefined {
110-
const matched = vscErrors.isFileExists(err);
110+
export function isFileExistsError(err: unknown | Error): boolean | undefined {
111+
const error = err as Error;
112+
const matched = vscErrors.isFileExists(error);
111113
if (matched !== undefined) {
112114
return matched;
113115
}
114-
return isSystemError(err, 'EEXIST');
116+
return isSystemError(error, 'EEXIST');
115117
}
116118

117119
// Return true if the given error is EISDIR.
@@ -133,10 +135,11 @@ export function isNotDirError(err: Error): boolean | undefined {
133135
}
134136

135137
// Return true if the given error is EACCES.
136-
export function isNoPermissionsError(err: Error): boolean | undefined {
137-
const matched = vscErrors.isNoPermissions(err);
138+
export function isNoPermissionsError(err: unknown | Error): boolean | undefined {
139+
const error = err as Error;
140+
const matched = vscErrors.isNoPermissions(error);
138141
if (matched !== undefined) {
139142
return matched;
140143
}
141-
return isSystemError(err, 'EACCES');
144+
return isSystemError(error, 'EACCES');
142145
}

src/client/common/utils/async.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ async function getNext<T>(it: AsyncIterator<T, T | void>, indexMaybe?: number):
122122
const result = await it.next();
123123
return { index, result, err: null };
124124
} catch (err) {
125-
return { index, err, result: null };
125+
return { index, err: err as Error, result: null };
126126
}
127127
}
128128

src/client/common/utils/filesystem.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ export async function getFileType(
6464
try {
6565
stat = await fs.promises.lstat(filename);
6666
} catch (err) {
67-
if (err.code === 'ENOENT') {
67+
const error = err as NodeJS.ErrnoException;
68+
if (error.code === 'ENOENT') {
6869
return undefined;
6970
}
7071
if (opts.ignoreErrors) {

src/client/common/utils/workerPool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class Worker<T, R> implements IWorker {
6161
const result = await this.workFunc(workItem);
6262
this.postResult(workItem, result);
6363
} catch (ex) {
64-
this.postResult(workItem, undefined, ex);
64+
this.postResult(workItem, undefined, ex as Error);
6565
}
6666
} catch (ex) {
6767
// Next got rejected. Likely worker pool is shutting down.

src/client/interpreter/activation/service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ export class EnvironmentActivationService implements IEnvironmentActivationServi
243243
} catch (exc) {
244244
// Special case. Conda for some versions will state a file is in use. If
245245
// that's the case, wait and try again. This happens especially on AzDo
246-
const excString = exc.toString();
246+
const excString = (exc as Error).toString();
247247
if (condaRetryMessages.find((m) => excString.includes(m)) && tryCount < 10) {
248248
traceInfo(`Conda is busy, attempting to retry ...`);
249249
result = undefined;

src/client/interpreter/configuration/pythonPathUpdaterService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ export class PythonPathUpdaterService implements IPythonPathUpdaterServiceManage
2828
let failed = false;
2929
try {
3030
await pythonPathUpdater.updatePythonPath(pythonPath ? path.normalize(pythonPath) : undefined);
31-
} catch (reason) {
31+
} catch (err) {
3232
failed = true;
33-
33+
const reason = err as Error;
3434
const message = reason && typeof reason.message === 'string' ? (reason.message as string) : '';
3535
window.showErrorMessage(`Failed to set interpreter path. Error: ${message}`);
3636
traceError(reason);

0 commit comments

Comments
 (0)