Cherry-pick PR #38228 into release-3.9 (#38350)

Component commits:
956ac2132a Allowed comment directives to be multiline

12749c9291 Added tests, and perhaps fixed a test runner bug?

99bb366fd6 I think it's going to need a consistent variable to loop over

a21477d6ac Used dynamically computed indexes in verifies

992441d9b8 Added multiline tests

199d256ba2 Increased flexibility for multiline comment parsing

65a7587432 Undid a couple of formatting changes; removed backslashes from multiline regexp

036a4ae922 Merge branch 'master'

b620104be2 Merge branch 'master' of https://github.com/microsoft/TypeScript into multiline-comment-directives

Co-authored-by: Orta Therox <orta.therox@gmail.com>
This commit is contained in:
TypeScript Bot
2020-05-06 13:11:45 -07:00
committed by GitHub
parent 90570dfe09
commit e261cdd2f6
13 changed files with 767 additions and 208 deletions

View File

@@ -0,0 +1,53 @@
// @filename: a.ts
export const texts: string[] = [];
/**
@ts-ignore */
texts.push(100);
/**
@ts-expect-error */
texts.push(100);
/**
@ts-expect-error */
texts.push("100");
// @filename: b.tsx
// @jsx: react
// @libFiles: react.d.ts,lib.d.ts
import * as React from "react";
export function MyComponent(props: { foo: string }) {
return <div />;
}
let x = (
<div>
{/*
@ts-ignore */}
<MyComponent foo={100} />
{/*@ts-ignore*/}
<MyComponent foo={100} />
{/*
@ts-expect-error */}
<MyComponent foo={100} />
{/*
// @ts-expect-error */}
<MyComponent foo={100} />
{/*
* @ts-expect-error */}
<MyComponent foo={100} />
{/*@ts-expect-error*/}
<MyComponent foo={100} />
{/*
@ts-expect-error */}
<MyComponent foo={"hooray"} />
</div>
);

View File

@@ -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';