Change ingore diagonstic comment to // @ts-ignore

This commit is contained in:
Mohamed Hegazy 2017-03-22 16:23:21 -07:00
parent e408cad618
commit db6c96967c
23 changed files with 46 additions and 38 deletions

View File

@ -1,4 +1,4 @@
/// <reference path="types.ts"/>
/// <reference path="types.ts"/>
/// <reference path="performance.ts" />
namespace ts {

View File

@ -3484,7 +3484,7 @@
"category": "Message",
"code": 90018
},
"Suppress this error message.": {
"Ignore this error message.": {
"category": "Message",
"code": 90019
},

View File

@ -1,10 +1,10 @@
/// <reference path="sys.ts" />
/// <reference path="sys.ts" />
/// <reference path="emitter.ts" />
/// <reference path="core.ts" />
namespace ts {
const emptyArray: any[] = [];
const suppressDiagnosticCommentRegEx = /(^\s*$)|(^\s*\/\/\/?\s*(@ts-suppress)?)/;
const ignoreDiagnosticCommentRegEx = /(^\s*$)|(^\s*\/\/\/?\s*(@ts-ignore)?)/;
export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName = "tsconfig.json"): string {
while (true) {
@ -926,7 +926,7 @@ namespace ts {
}
/**
* Skip errors if previous line start with '// @ts-suppress' comment, not counting non-empty non-comment lines
* Skip errors if previous line start with '// @ts-ignore' comment, not counting non-empty non-comment lines
*/
function shouldReportDiagnostic(diagnostic: Diagnostic) {
const { file, start } = diagnostic;
@ -934,13 +934,13 @@ namespace ts {
let { line } = computeLineAndCharacterOfPosition(lineStarts, start);
while (line > 0) {
const previousLineText = file.text.slice(lineStarts[line - 1], lineStarts[line]);
const result = suppressDiagnosticCommentRegEx.exec(previousLineText);
const result = ignoreDiagnosticCommentRegEx.exec(previousLineText);
if (!result) {
// non-empty line
return true;
}
if (result[3]) {
// @ts-suppress
// @ts-ignore
return false;
}
line--;

View File

@ -1,4 +1,4 @@
//
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -1,4 +1,4 @@
/* @internal */
/* @internal */
namespace ts.codefix {
registerCodeFix({
errorCodes: getApplicableDiagnosticCodes(),
@ -12,12 +12,12 @@ namespace ts.codefix {
.map(d => allDiagnostcs[d].code);
}
function getSuppressCommentLocationForLocation(sourceFile: SourceFile, position: number, newLineCharacter: string) {
let { line } = getLineAndCharacterOfPosition(sourceFile, position);
function getIgnoreCommentLocationForLocation(sourceFile: SourceFile, position: number, newLineCharacter: string) {
const { line } = getLineAndCharacterOfPosition(sourceFile, position);
const lineStartPosition = getStartPositionOfLine(line, sourceFile);
const startPosition = getFirstNonSpaceCharacterPosition(sourceFile.text, lineStartPosition);
// First try to see if we can put the '// @ts-suppress' on the previous line.
// First try to see if we can put the '// @ts-ignore' on the previous line.
// We need to make sure that we are not in the middle of a string literal or a comment.
// We also want to check if the previous line holds a comment for a node on the next line
// if so, we do not want to separate the node from its comment if we can.
@ -27,7 +27,7 @@ namespace ts.codefix {
if (!tokenLeadingCommnets || !tokenLeadingCommnets.length || tokenLeadingCommnets[0].pos >= startPosition) {
return {
span: { start: startPosition, length: 0 },
newText: `// @ts-suppress${newLineCharacter}`
newText: `// @ts-ignore${newLineCharacter}`
};
}
}
@ -35,7 +35,7 @@ namespace ts.codefix {
// If all fails, add an extra new line immediatlly before the error span.
return {
span: { start: position, length: 0 },
newText: `${position === startPosition ? "" : newLineCharacter}// @ts-suppress${newLineCharacter}`
newText: `${position === startPosition ? "" : newLineCharacter}// @ts-ignore${newLineCharacter}`
};
}
@ -47,10 +47,10 @@ namespace ts.codefix {
}
return [{
description: getLocaleSpecificMessage(Diagnostics.Suppress_this_error_message),
description: getLocaleSpecificMessage(Diagnostics.Ignore_this_error_message),
changes: [{
fileName: sourceFile.fileName,
textChanges: [getSuppressCommentLocationForLocation(sourceFile, span.start, newLineCharacter)]
textChanges: [getIgnoreCommentLocationForLocation(sourceFile, span.start, newLineCharacter)]
}]
},
{

View File

@ -1,4 +1,4 @@
/* @internal */
/* @internal */
namespace ts.codefix {
registerCodeFix({
errorCodes: [Diagnostics.Property_0_does_not_exist_on_type_1.code],

View File

@ -4,15 +4,15 @@ var x = 0;
>x : Symbol(x, Decl(a.js, 1, 3))
/// @ts-suppress
/// @ts-ignore
x();
>x : Symbol(x, Decl(a.js, 1, 3))
/// @ts-suppress
/// @ts-ignore
x();
>x : Symbol(x, Decl(a.js, 1, 3))
/// @ts-suppress
/// @ts-ignore
x(
>x : Symbol(x, Decl(a.js, 1, 3))
@ -21,7 +21,7 @@ x(
// @ts-suppress
// @ts-ignore
// come comment
// some other comment
@ -32,7 +32,7 @@ x();
// @ts-suppress: no call signature
// @ts-ignore: no call signature
x();
>x : Symbol(x, Decl(a.js, 1, 3))

View File

@ -5,17 +5,17 @@ var x = 0;
>0 : 0
/// @ts-suppress
/// @ts-ignore
x();
>x() : any
>x : number
/// @ts-suppress
/// @ts-ignore
x();
>x() : any
>x : number
/// @ts-suppress
/// @ts-ignore
x(
>x( 2, 3) : any
>x : number
@ -28,7 +28,7 @@ x(
// @ts-suppress
// @ts-ignore
// come comment
// some other comment
@ -40,7 +40,7 @@ x();
// @ts-suppress: no call signature
// @ts-ignore: no call signature
x();
>x() : any
>x : number

View File

@ -5,6 +5,7 @@
"module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */
// "lib": [], /* Specify library files to be included in the compilation: */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */

View File

@ -5,6 +5,7 @@
"module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */
// "lib": [], /* Specify library files to be included in the compilation: */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */

View File

@ -5,6 +5,7 @@
"module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */
// "lib": [], /* Specify library files to be included in the compilation: */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
"jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */

View File

@ -5,6 +5,7 @@
"module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */
// "lib": [], /* Specify library files to be included in the compilation: */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */

View File

@ -5,6 +5,7 @@
"module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */
"lib": ["es5","es2015.promise"], /* Specify library files to be included in the compilation: */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */

View File

@ -5,6 +5,7 @@
"module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */
// "lib": [], /* Specify library files to be included in the compilation: */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */

View File

@ -5,6 +5,7 @@
"module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */
"lib": ["es5","es2015.core"], /* Specify library files to be included in the compilation: */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */

View File

@ -5,6 +5,7 @@
"module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */
// "lib": [], /* Specify library files to be included in the compilation: */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */

View File

@ -6,20 +6,20 @@
var x = 0;
/// @ts-suppress
/// @ts-ignore
x();
/// @ts-suppress
/// @ts-ignore
x();
/// @ts-suppress
/// @ts-ignore
x(
2,
3);
// @ts-suppress
// @ts-ignore
// come comment
// some other comment
@ -29,5 +29,5 @@ x();
// @ts-suppress: no call signature
// @ts-ignore: no call signature
x();

View File

@ -10,5 +10,5 @@
// Disable checking for next line
verify.rangeAfterCodeFix(`var x = "";
// @ts-suppress
// @ts-ignore
x = 1;`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0);

View File

@ -13,6 +13,6 @@
// Disable checking for next line
verify.rangeAfterCodeFix(`"test \\
";
// @ts-suppress
// @ts-ignore
x = 1;`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0);

View File

@ -12,6 +12,6 @@
// Disable checking for next line
verify.rangeAfterCodeFix(`/** comment */
// @ts-suppress
// @ts-ignore
x = 1;`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0);

View File

@ -12,6 +12,6 @@
////}
// Disable checking for next line
verify.rangeAfterCodeFix(`// @ts-suppress
verify.rangeAfterCodeFix(`// @ts-ignore
f(x());`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0);

View File

@ -12,6 +12,6 @@
////}
// Disable checking for next line
verify.rangeAfterCodeFix(`// @ts-suppress
verify.rangeAfterCodeFix(`// @ts-ignore
x();`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0);

View File

@ -14,6 +14,6 @@
// Disable checking for next line
verify.rangeAfterCodeFix(`f(
// @ts-suppress
// @ts-ignore
x());`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0);