TypeScript/tests/cases/conformance/directives/ts-ignore.ts
Orta ffde92349d
Added @ts-expect-error to @ts-ignore directives (#36014)
* Added @ts-expect-error to @ts-ignore directives

Similar to `// @ts-ignore`, but will itself cause a new error diagnostic if it does not cause an existing diagnostic to be ignored.

Technical summary:
1. The scanner will now keep track of `CommentDirective`s it comes across: both `@ts-expect-error` and `@ts-ignore`
2. During type checking, the program will turn those directives into a map keying them by line number
3. For each diagnostic, if it's preceded by a directive, that directive is marked as "used"
4. All `@ts-expect-error` directives not marked as used generate a new diagnostic error

* Renamed to getDiagnosticsWithPrecedingDirectives per suggestion

* Added JSDoc comment I thought I did already

Co-authored-by: Orta <orta.therox+github@gmail.com>
2020-03-05 10:37:36 -05:00

16 lines
370 B
TypeScript

// @ts-ignore with additional commenting
var invalidCommentedFancy: number = 'nope';
// @ts-ignore with additional commenting
var validCommentedFancy: string = 'nope';
// @ts-ignore
var invalidCommentedPlain: number = 'nope';
// @ts-ignore
var validCommentedPlain: string = 'nope';
var invalidPlain: number = 'nope';
var validPlain: string = 'nope';