mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 02:33:53 -06:00
Try adopting 'useUnknownInCatchVariables' on our own codebase.
This commit is contained in:
parent
7c01840b7d
commit
144381f97b
@ -1633,7 +1633,7 @@ namespace ts {
|
||||
text = readFile(fileName);
|
||||
}
|
||||
catch (e) {
|
||||
return createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message);
|
||||
return createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, fileName, (e as Error).message);
|
||||
}
|
||||
return text === undefined ? createCompilerDiagnostic(Diagnostics.Cannot_read_file_0, fileName) : text;
|
||||
}
|
||||
|
||||
@ -83,7 +83,7 @@ namespace ts {
|
||||
performance.measure("I/O Read", "beforeIORead", "afterIORead");
|
||||
}
|
||||
catch (e) {
|
||||
if (onError) {
|
||||
if (onError && e instanceof Error) {
|
||||
onError(e.message);
|
||||
}
|
||||
text = "";
|
||||
@ -121,7 +121,7 @@ namespace ts {
|
||||
performance.measure("I/O Write", "beforeIOWrite", "afterIOWrite");
|
||||
}
|
||||
catch (e) {
|
||||
if (onError) {
|
||||
if (onError && e instanceof Error) {
|
||||
onError(e.message);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1242,7 +1242,7 @@ namespace ts {
|
||||
_fs.mkdirSync(directoryName);
|
||||
}
|
||||
catch (e) {
|
||||
if (e.code !== "EEXIST") {
|
||||
if ((e as {code: string}).code !== "EEXIST") {
|
||||
// Failed for some other reason (access denied?); still throw
|
||||
throw e;
|
||||
}
|
||||
@ -1312,7 +1312,7 @@ namespace ts {
|
||||
const modulePath = resolveJSModule(moduleName, baseDir, nodeSystem);
|
||||
return { module: require(modulePath), modulePath, error: undefined };
|
||||
}
|
||||
catch (error) {
|
||||
catch (error: any) {
|
||||
return { module: undefined, modulePath: undefined, error };
|
||||
}
|
||||
}
|
||||
|
||||
@ -291,7 +291,7 @@ namespace ts {
|
||||
performance.measure("I/O Read", "beforeIORead", "afterIORead");
|
||||
}
|
||||
catch (e) {
|
||||
if (onError) {
|
||||
if (onError && e instanceof Error) {
|
||||
onError(e.message);
|
||||
}
|
||||
text = "";
|
||||
@ -317,7 +317,7 @@ namespace ts {
|
||||
readDirectory: maybeBind(host, host.readDirectory),
|
||||
};
|
||||
|
||||
function writeFile(fileName: string, text: string, writeByteOrderMark: boolean, onError: (message: string) => void) {
|
||||
function writeFile(fileName: string, text: string, writeByteOrderMark: boolean, onError?: (message: string) => void) {
|
||||
try {
|
||||
performance.mark("beforeIOWrite");
|
||||
|
||||
@ -336,7 +336,7 @@ namespace ts {
|
||||
performance.measure("I/O Write", "beforeIOWrite", "afterIOWrite");
|
||||
}
|
||||
catch (e) {
|
||||
if (onError) {
|
||||
if (onError && e instanceof Error) {
|
||||
onError(e.message);
|
||||
}
|
||||
}
|
||||
|
||||
@ -451,7 +451,7 @@ namespace ts {
|
||||
return JSON.parse(diagnosticMessagesJson);
|
||||
}
|
||||
catch (e) {
|
||||
this.log(e.description || "diagnosticMessages.generated.json has invalid JSON format");
|
||||
this.log((e as { description?: string }).description || "diagnosticMessages.generated.json has invalid JSON format");
|
||||
return null;
|
||||
}
|
||||
/* eslint-enable no-null/no-null */
|
||||
@ -579,7 +579,7 @@ namespace ts {
|
||||
const result = simpleForwardCall(logger, actionDescription, action, logPerformance);
|
||||
return returnJson ? JSON.stringify({ result }) : result as T;
|
||||
}
|
||||
catch (err) {
|
||||
catch (err: any) {
|
||||
if (err instanceof OperationCanceledException) {
|
||||
return JSON.stringify({ canceled: true });
|
||||
}
|
||||
@ -1283,7 +1283,7 @@ namespace ts {
|
||||
const languageService = createLanguageService(hostAdapter, this.documentRegistry, /*syntaxOnly*/ false);
|
||||
return new LanguageServiceShimObject(this, host, languageService);
|
||||
}
|
||||
catch (err) {
|
||||
catch (err: any) {
|
||||
logInternalError(host, err);
|
||||
throw err;
|
||||
}
|
||||
@ -1293,7 +1293,7 @@ namespace ts {
|
||||
try {
|
||||
return new ClassifierShimObject(this, logger);
|
||||
}
|
||||
catch (err) {
|
||||
catch (err: any) {
|
||||
logInternalError(logger, err);
|
||||
throw err;
|
||||
}
|
||||
@ -1304,7 +1304,7 @@ namespace ts {
|
||||
const adapter = new CoreServicesShimHostAdapter(host);
|
||||
return new CoreServicesShimObject(this, <Logger>host, adapter);
|
||||
}
|
||||
catch (err) {
|
||||
catch (err: any) {
|
||||
logInternalError(<Logger>host, err);
|
||||
throw err;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user