mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Allowed comment directives to be multiline
This commit is contained in:
+30
-14
File diff suppressed because one or more lines are too long
@@ -474,7 +474,7 @@ namespace ts {
|
||||
export function createCommentDirectivesMap(sourceFile: SourceFile, commentDirectives: CommentDirective[]): CommentDirectivesMap {
|
||||
const directivesByLine = createMapFromEntries(
|
||||
commentDirectives.map(commentDirective => ([
|
||||
`${getLineAndCharacterOfPosition(sourceFile, commentDirective.range.pos).line}`,
|
||||
`${getLineAndCharacterOfPosition(sourceFile, commentDirective.range.end).line}`,
|
||||
commentDirective,
|
||||
]))
|
||||
);
|
||||
|
||||
@@ -1,24 +1,51 @@
|
||||
tests/cases/conformance/directives/ts-expect-error.ts(4,1): error TS2578: Unused '@ts-expect-error' directive.
|
||||
tests/cases/conformance/directives/ts-expect-error.ts(10,1): error TS2578: Unused '@ts-expect-error' directive.
|
||||
tests/cases/conformance/directives/ts-expect-error.ts(13,5): error TS2322: Type '"nope"' is not assignable to type 'number'.
|
||||
tests/cases/conformance/directives/ts-expect-error.ts(8,1): error TS2578: Unused '@ts-expect-error' directive.
|
||||
tests/cases/conformance/directives/ts-expect-error.ts(11,1): error TS2578: Unused '@ts-expect-error' directive.
|
||||
tests/cases/conformance/directives/ts-expect-error.ts(21,1): error TS2578: Unused '@ts-expect-error' directive.
|
||||
tests/cases/conformance/directives/ts-expect-error.ts(24,1): error TS2578: Unused '@ts-expect-error' directive.
|
||||
tests/cases/conformance/directives/ts-expect-error.ts(28,1): error TS2578: Unused '@ts-expect-error' directive.
|
||||
tests/cases/conformance/directives/ts-expect-error.ts(31,5): error TS2322: Type '"nope"' is not assignable to type 'number'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/directives/ts-expect-error.ts (3 errors) ====
|
||||
==== tests/cases/conformance/directives/ts-expect-error.ts (6 errors) ====
|
||||
// @ts-expect-error additional commenting
|
||||
var invalidCommentedFancy: number = 'nope';
|
||||
var invalidCommentedFancySingle: number = 'nope';
|
||||
|
||||
/*
|
||||
@ts-expect-error additional commenting */
|
||||
var invalidCommentedFancyMulti: number = 'nope';
|
||||
|
||||
// @ts-expect-error additional commenting
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2578: Unused '@ts-expect-error' directive.
|
||||
var validCommentedFancy: string = 'nope';
|
||||
var validCommentedFancySingle: string = 'nope';
|
||||
|
||||
/* @ts-expect-error additional commenting */
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2578: Unused '@ts-expect-error' directive.
|
||||
var validCommentedFancyMulti: string = 'nope';
|
||||
|
||||
// @ts-expect-error
|
||||
var invalidCommentedPlain: number = 'nope';
|
||||
var invalidCommentedPlainSingle: number = 'nope';
|
||||
|
||||
/*
|
||||
@ts-expect-error */
|
||||
var invalidCommentedPlainMulti: number = 'nope';
|
||||
|
||||
// @ts-expect-error
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2578: Unused '@ts-expect-error' directive.
|
||||
var validCommentedPlain: string = 'nope';
|
||||
var validCommentedPlainSingle: string = 'nope';
|
||||
|
||||
/* @ts-expect-error */
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2578: Unused '@ts-expect-error' directive.
|
||||
var validCommentedPlainMulti1: string = 'nope';
|
||||
|
||||
/*
|
||||
@ts-expect-error */
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2578: Unused '@ts-expect-error' directive.
|
||||
var validCommentedPlainMulti2: string = 'nope';
|
||||
|
||||
var invalidPlain: number = 'nope';
|
||||
~~~~~~~~~~~~
|
||||
|
||||
@@ -1,15 +1,33 @@
|
||||
//// [ts-expect-error.ts]
|
||||
// @ts-expect-error additional commenting
|
||||
var invalidCommentedFancy: number = 'nope';
|
||||
var invalidCommentedFancySingle: number = 'nope';
|
||||
|
||||
/*
|
||||
@ts-expect-error additional commenting */
|
||||
var invalidCommentedFancyMulti: number = 'nope';
|
||||
|
||||
// @ts-expect-error additional commenting
|
||||
var validCommentedFancy: string = 'nope';
|
||||
var validCommentedFancySingle: string = 'nope';
|
||||
|
||||
/* @ts-expect-error additional commenting */
|
||||
var validCommentedFancyMulti: string = 'nope';
|
||||
|
||||
// @ts-expect-error
|
||||
var invalidCommentedPlain: number = 'nope';
|
||||
var invalidCommentedPlainSingle: number = 'nope';
|
||||
|
||||
/*
|
||||
@ts-expect-error */
|
||||
var invalidCommentedPlainMulti: number = 'nope';
|
||||
|
||||
// @ts-expect-error
|
||||
var validCommentedPlain: string = 'nope';
|
||||
var validCommentedPlainSingle: string = 'nope';
|
||||
|
||||
/* @ts-expect-error */
|
||||
var validCommentedPlainMulti1: string = 'nope';
|
||||
|
||||
/*
|
||||
@ts-expect-error */
|
||||
var validCommentedPlainMulti2: string = 'nope';
|
||||
|
||||
var invalidPlain: number = 'nope';
|
||||
|
||||
@@ -18,12 +36,25 @@ var validPlain: string = 'nope';
|
||||
|
||||
//// [ts-expect-error.js]
|
||||
// @ts-expect-error additional commenting
|
||||
var invalidCommentedFancy = 'nope';
|
||||
var invalidCommentedFancySingle = 'nope';
|
||||
/*
|
||||
@ts-expect-error additional commenting */
|
||||
var invalidCommentedFancyMulti = 'nope';
|
||||
// @ts-expect-error additional commenting
|
||||
var validCommentedFancy = 'nope';
|
||||
var validCommentedFancySingle = 'nope';
|
||||
/* @ts-expect-error additional commenting */
|
||||
var validCommentedFancyMulti = 'nope';
|
||||
// @ts-expect-error
|
||||
var invalidCommentedPlain = 'nope';
|
||||
var invalidCommentedPlainSingle = 'nope';
|
||||
/*
|
||||
@ts-expect-error */
|
||||
var invalidCommentedPlainMulti = 'nope';
|
||||
// @ts-expect-error
|
||||
var validCommentedPlain = 'nope';
|
||||
var validCommentedPlainSingle = 'nope';
|
||||
/* @ts-expect-error */
|
||||
var validCommentedPlainMulti1 = 'nope';
|
||||
/*
|
||||
@ts-expect-error */
|
||||
var validCommentedPlainMulti2 = 'nope';
|
||||
var invalidPlain = 'nope';
|
||||
var validPlain = 'nope';
|
||||
|
||||
@@ -1,23 +1,46 @@
|
||||
=== tests/cases/conformance/directives/ts-expect-error.ts ===
|
||||
// @ts-expect-error additional commenting
|
||||
var invalidCommentedFancy: number = 'nope';
|
||||
>invalidCommentedFancy : Symbol(invalidCommentedFancy, Decl(ts-expect-error.ts, 1, 3))
|
||||
var invalidCommentedFancySingle: number = 'nope';
|
||||
>invalidCommentedFancySingle : Symbol(invalidCommentedFancySingle, Decl(ts-expect-error.ts, 1, 3))
|
||||
|
||||
/*
|
||||
@ts-expect-error additional commenting */
|
||||
var invalidCommentedFancyMulti: number = 'nope';
|
||||
>invalidCommentedFancyMulti : Symbol(invalidCommentedFancyMulti, Decl(ts-expect-error.ts, 5, 3))
|
||||
|
||||
// @ts-expect-error additional commenting
|
||||
var validCommentedFancy: string = 'nope';
|
||||
>validCommentedFancy : Symbol(validCommentedFancy, Decl(ts-expect-error.ts, 4, 3))
|
||||
var validCommentedFancySingle: string = 'nope';
|
||||
>validCommentedFancySingle : Symbol(validCommentedFancySingle, Decl(ts-expect-error.ts, 8, 3))
|
||||
|
||||
/* @ts-expect-error additional commenting */
|
||||
var validCommentedFancyMulti: string = 'nope';
|
||||
>validCommentedFancyMulti : Symbol(validCommentedFancyMulti, Decl(ts-expect-error.ts, 11, 3))
|
||||
|
||||
// @ts-expect-error
|
||||
var invalidCommentedPlain: number = 'nope';
|
||||
>invalidCommentedPlain : Symbol(invalidCommentedPlain, Decl(ts-expect-error.ts, 7, 3))
|
||||
var invalidCommentedPlainSingle: number = 'nope';
|
||||
>invalidCommentedPlainSingle : Symbol(invalidCommentedPlainSingle, Decl(ts-expect-error.ts, 14, 3))
|
||||
|
||||
/*
|
||||
@ts-expect-error */
|
||||
var invalidCommentedPlainMulti: number = 'nope';
|
||||
>invalidCommentedPlainMulti : Symbol(invalidCommentedPlainMulti, Decl(ts-expect-error.ts, 18, 3))
|
||||
|
||||
// @ts-expect-error
|
||||
var validCommentedPlain: string = 'nope';
|
||||
>validCommentedPlain : Symbol(validCommentedPlain, Decl(ts-expect-error.ts, 10, 3))
|
||||
var validCommentedPlainSingle: string = 'nope';
|
||||
>validCommentedPlainSingle : Symbol(validCommentedPlainSingle, Decl(ts-expect-error.ts, 21, 3))
|
||||
|
||||
/* @ts-expect-error */
|
||||
var validCommentedPlainMulti1: string = 'nope';
|
||||
>validCommentedPlainMulti1 : Symbol(validCommentedPlainMulti1, Decl(ts-expect-error.ts, 24, 3))
|
||||
|
||||
/*
|
||||
@ts-expect-error */
|
||||
var validCommentedPlainMulti2: string = 'nope';
|
||||
>validCommentedPlainMulti2 : Symbol(validCommentedPlainMulti2, Decl(ts-expect-error.ts, 28, 3))
|
||||
|
||||
var invalidPlain: number = 'nope';
|
||||
>invalidPlain : Symbol(invalidPlain, Decl(ts-expect-error.ts, 12, 3))
|
||||
>invalidPlain : Symbol(invalidPlain, Decl(ts-expect-error.ts, 30, 3))
|
||||
|
||||
var validPlain: string = 'nope';
|
||||
>validPlain : Symbol(validPlain, Decl(ts-expect-error.ts, 14, 3))
|
||||
>validPlain : Symbol(validPlain, Decl(ts-expect-error.ts, 32, 3))
|
||||
|
||||
|
||||
@@ -1,22 +1,50 @@
|
||||
=== tests/cases/conformance/directives/ts-expect-error.ts ===
|
||||
// @ts-expect-error additional commenting
|
||||
var invalidCommentedFancy: number = 'nope';
|
||||
>invalidCommentedFancy : number
|
||||
var invalidCommentedFancySingle: number = 'nope';
|
||||
>invalidCommentedFancySingle : number
|
||||
>'nope' : "nope"
|
||||
|
||||
/*
|
||||
@ts-expect-error additional commenting */
|
||||
var invalidCommentedFancyMulti: number = 'nope';
|
||||
>invalidCommentedFancyMulti : number
|
||||
>'nope' : "nope"
|
||||
|
||||
// @ts-expect-error additional commenting
|
||||
var validCommentedFancy: string = 'nope';
|
||||
>validCommentedFancy : string
|
||||
var validCommentedFancySingle: string = 'nope';
|
||||
>validCommentedFancySingle : string
|
||||
>'nope' : "nope"
|
||||
|
||||
/* @ts-expect-error additional commenting */
|
||||
var validCommentedFancyMulti: string = 'nope';
|
||||
>validCommentedFancyMulti : string
|
||||
>'nope' : "nope"
|
||||
|
||||
// @ts-expect-error
|
||||
var invalidCommentedPlain: number = 'nope';
|
||||
>invalidCommentedPlain : number
|
||||
var invalidCommentedPlainSingle: number = 'nope';
|
||||
>invalidCommentedPlainSingle : number
|
||||
>'nope' : "nope"
|
||||
|
||||
/*
|
||||
@ts-expect-error */
|
||||
var invalidCommentedPlainMulti: number = 'nope';
|
||||
>invalidCommentedPlainMulti : number
|
||||
>'nope' : "nope"
|
||||
|
||||
// @ts-expect-error
|
||||
var validCommentedPlain: string = 'nope';
|
||||
>validCommentedPlain : string
|
||||
var validCommentedPlainSingle: string = 'nope';
|
||||
>validCommentedPlainSingle : string
|
||||
>'nope' : "nope"
|
||||
|
||||
/* @ts-expect-error */
|
||||
var validCommentedPlainMulti1: string = 'nope';
|
||||
>validCommentedPlainMulti1 : string
|
||||
>'nope' : "nope"
|
||||
|
||||
/*
|
||||
@ts-expect-error */
|
||||
var validCommentedPlainMulti2: string = 'nope';
|
||||
>validCommentedPlainMulti2 : string
|
||||
>'nope' : "nope"
|
||||
|
||||
var invalidPlain: number = 'nope';
|
||||
|
||||
@@ -1,14 +1,32 @@
|
||||
// @ts-expect-error additional commenting
|
||||
var invalidCommentedFancy: number = 'nope';
|
||||
var invalidCommentedFancySingle: number = 'nope';
|
||||
|
||||
/*
|
||||
@ts-expect-error additional commenting */
|
||||
var invalidCommentedFancyMulti: number = 'nope';
|
||||
|
||||
// @ts-expect-error additional commenting
|
||||
var validCommentedFancy: string = 'nope';
|
||||
var validCommentedFancySingle: string = 'nope';
|
||||
|
||||
/* @ts-expect-error additional commenting */
|
||||
var validCommentedFancyMulti: string = 'nope';
|
||||
|
||||
// @ts-expect-error
|
||||
var invalidCommentedPlain: number = 'nope';
|
||||
var invalidCommentedPlainSingle: number = 'nope';
|
||||
|
||||
/*
|
||||
@ts-expect-error */
|
||||
var invalidCommentedPlainMulti: number = 'nope';
|
||||
|
||||
// @ts-expect-error
|
||||
var validCommentedPlain: string = 'nope';
|
||||
var validCommentedPlainSingle: string = 'nope';
|
||||
|
||||
/* @ts-expect-error */
|
||||
var validCommentedPlainMulti1: string = 'nope';
|
||||
|
||||
/*
|
||||
@ts-expect-error */
|
||||
var validCommentedPlainMulti2: string = 'nope';
|
||||
|
||||
var invalidPlain: number = 'nope';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user