Convert most ts-ignore-calls to ts-expect-error (#93617)

Changes over to use ts-expect-error: https://devblogs.microsoft.com/typescript/announcing-typescript-3-9-beta/#ts-expect-error-comments

This revealed a number of places where we no longer need to supress errors
This commit is contained in:
Matt Bierner 2020-03-30 17:31:37 -07:00 committed by GitHub
parent 84a38533dd
commit 273a4a389d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 12 additions and 32 deletions

View file

@ -6,7 +6,6 @@
const fs = require('fs');
const path = require('path');
const os = require('os');
// @ts-ignore review
const { remote } = require('electron');
const dialog = remote.dialog;

View file

@ -455,10 +455,8 @@ function createTscCompileTask(watch) {
// e.g. src/vs/base/common/strings.ts(663,5): error TS2322: Type '1234' is not assignable to type 'string'.
let fullpath = path.join(root, match[1]);
let message = match[3];
// @ts-ignore
reporter(fullpath + message);
} else {
// @ts-ignore
reporter(str);
}
}

View file

@ -37,10 +37,8 @@ const { compileBuildTask } = require('./gulpfile.compile');
const { compileExtensionsBuildTask } = require('./gulpfile.extensions');
const productionDependencies = deps.getProductionDependencies(path.dirname(__dirname));
// @ts-ignore
const baseModules = Object.keys(process.binding('natives')).filter(n => !/^_|\//.test(n));
const nodeModules = ['electron', 'original-fs']
// @ts-ignore JSON checking: dependencies property is optional
.concat(Object.keys(product.dependencies || {}))
.concat(_.uniq(productionDependencies.map(d => d.name)))
.concat(baseModules);

View file

@ -91,9 +91,7 @@ function prepareDebPackage(arch) {
const postinst = gulp.src('resources/linux/debian/postinst.template', { base: '.' })
.pipe(replace('@@NAME@@', product.applicationName))
.pipe(replace('@@ARCHITECTURE@@', debArch))
// @ts-ignore JSON checking: quality is optional
.pipe(replace('@@QUALITY@@', product.quality || '@@QUALITY@@'))
// @ts-ignore JSON checking: updateUrl is optional
.pipe(replace('@@UPDATEURL@@', product.updateUrl || '@@UPDATEURL@@'))
.pipe(rename('DEBIAN/postinst'));
@ -167,9 +165,7 @@ function prepareRpmPackage(arch) {
.pipe(replace('@@RELEASE@@', linuxPackageRevision))
.pipe(replace('@@ARCHITECTURE@@', rpmArch))
.pipe(replace('@@LICENSE@@', product.licenseName))
// @ts-ignore JSON checking: quality is optional
.pipe(replace('@@QUALITY@@', product.quality || '@@QUALITY@@'))
// @ts-ignore JSON checking: updateUrl is optional
.pipe(replace('@@UPDATEURL@@', product.updateUrl || '@@UPDATEURL@@'))
.pipe(replace('@@DEPENDENCIES@@', rpmDependencies[rpmArch].join(', ')))
.pipe(rename('SPECS/' + product.applicationName + '.spec'));

View file

@ -25,7 +25,6 @@ function watch(root) {
var child = cp.spawn(watcherPath, [root]);
child.stdout.on('data', function (data) {
// @ts-ignore
var lines = data.toString('utf8').split('\n');
for (var i = 0; i < lines.length; i++) {
var line = lines[i].trim();
@ -47,7 +46,6 @@ function watch(root) {
path: changePathFull,
base: root
});
//@ts-ignore
file.event = toChangeType(changeType);
result.emit('data', file);
}
@ -106,4 +104,4 @@ module.exports = function (pattern, options) {
});
}))
.pipe(rebase);
};
};

View file

@ -68,7 +68,7 @@ module.exports = function withDefaults(/**@type WebpackConfig*/extConfig) {
// yes, really source maps
devtool: 'source-map',
plugins: [
// @ts-ignore
// @ts-expect-error
new CopyWebpackPlugin([
{ from: 'src', to: '.', ignore: ['**/test/**', '*.ts'] }
]),

View file

@ -142,13 +142,11 @@ function pipeLoggingToParent() {
function handleExceptions() {
// Handle uncaught exceptions
// @ts-ignore
process.on('uncaughtException', function (err) {
console.error('Uncaught Exception: ', err);
});
// Handle unhandled promise rejections
// @ts-ignore
process.on('unhandledRejection', function (reason) {
console.error('Unhandled Promise Rejection: ', reason);
});

View file

@ -25,7 +25,6 @@ exports.assign = function assign(destination, source) {
*/
exports.load = function (modulePaths, resultCallback, options) {
// @ts-ignore
const webFrame = require('electron').webFrame;
const path = require('path');
@ -49,7 +48,6 @@ exports.load = function (modulePaths, resultCallback, options) {
}
// Error handler
// @ts-ignore
process.on('uncaughtException', function (error) {
onUnexpectedError(error, enableDeveloperTools);
});
@ -164,7 +162,6 @@ function parseURLQueryArgs() {
*/
function registerDeveloperKeybindings(disallowReloadKeybinding) {
// @ts-ignore
const ipc = require('electron').ipcRenderer;
const extractKey = function (e) {
@ -203,7 +200,6 @@ function registerDeveloperKeybindings(disallowReloadKeybinding) {
function onUnexpectedError(error, enableDeveloperTools) {
// @ts-ignore
const ipc = require('electron').ipcRenderer;
if (enableDeveloperTools) {

View file

@ -6,7 +6,7 @@
//@ts-check
'use strict';
// @ts-ignore
// @ts-expect-error
const pkg = require('../package.json');
const path = require('path');
const os = require('os');
@ -33,4 +33,4 @@ function getDefaultUserDataPath(platform) {
}
exports.getAppDataPath = getAppDataPath;
exports.getDefaultUserDataPath = getDefaultUserDataPath;
exports.getDefaultUserDataPath = getDefaultUserDataPath;

View file

@ -401,9 +401,9 @@ suite('Paths (Node Implementation)', () => {
];
resolveTests.forEach((test) => {
const resolve = test[0];
//@ts-ignore
//@ts-expect-error
test[1].forEach((test) => {
//@ts-ignore
//@ts-expect-error
const actual = resolve.apply(null, test[0]);
let actualAlt;
const os = resolve === path.win32.resolve ? 'win32' : 'posix';
@ -579,9 +579,9 @@ suite('Paths (Node Implementation)', () => {
];
relativeTests.forEach((test) => {
const relative = test[0];
//@ts-ignore
//@ts-expect-error
test[1].forEach((test) => {
//@ts-ignore
//@ts-expect-error
const actual = relative(test[0], test[1]);
const expected = test[2];
const os = relative === path.win32.relative ? 'win32' : 'posix';

View file

@ -107,7 +107,7 @@ function parseTest(fileName: string): ITest {
return { content, assertions };
}
// @ts-ignore
// @ts-expect-error
function executeTest(fileName: string, parseFunc: IParseFunc): void {
const { content, assertions } = parseTest(fileName);
const actual = parseFunc(content);

View file

@ -54,7 +54,7 @@ export class BrowserClipboardService implements IClipboardService {
}
readFindText(): string {
// @ts-ignore
// @ts-expect-error
return undefined;
}

View file

@ -20,12 +20,10 @@ import { assertIsDefined } from 'vs/base/common/types';
import { Schemas } from 'vs/base/common/network';
function es5ClassCompat(target: Function): any {
///@ts-ignore
///@ts-expect-error
function _() { return Reflect.construct(target, arguments, this.constructor); }
Object.defineProperty(_, 'name', Object.getOwnPropertyDescriptor(target, 'name')!);
///@ts-ignore
Object.setPrototypeOf(_, target);
///@ts-ignore
Object.setPrototypeOf(_.prototype, target.prototype);
return _;
}

View file

@ -20,7 +20,6 @@ export interface IRPCProtocol {
assertRegistered(identifiers: ProxyIdentifier<any>[]): void;
}
// @ts-ignore
export class ProxyIdentifier<T> {
public static count = 0;
_proxyIdentifierBrand: void;

View file

@ -155,7 +155,7 @@ async function runTestsInBrowser(testModules, browserType) {
});
try {
// @ts-ignore
// @ts-expect-error
await page.evaluate(modules => loadAndRun(modules), testModules);
} catch (err) {
console.error(err);