Merge pull request #3449 from Microsoft/typePredicateASI
Don't consume 'is' keyword if there is a preceding line terminator
This commit is contained in:
commit
6490d67509
5 changed files with 40 additions and 1 deletions
|
@ -1903,7 +1903,7 @@ module ts {
|
||||||
|
|
||||||
function parseTypeReferenceOrTypePredicate(): TypeReferenceNode | TypePredicateNode {
|
function parseTypeReferenceOrTypePredicate(): TypeReferenceNode | TypePredicateNode {
|
||||||
let typeName = parseEntityName(/*allowReservedWords*/ false, Diagnostics.Type_expected);
|
let typeName = parseEntityName(/*allowReservedWords*/ false, Diagnostics.Type_expected);
|
||||||
if (typeName.kind === SyntaxKind.Identifier && token === SyntaxKind.IsKeyword) {
|
if (typeName.kind === SyntaxKind.Identifier && token === SyntaxKind.IsKeyword && !scanner.hasPrecedingLineBreak()) {
|
||||||
nextToken();
|
nextToken();
|
||||||
let node = <TypePredicateNode>createNode(SyntaxKind.TypePredicate, typeName.pos);
|
let node = <TypePredicateNode>createNode(SyntaxKind.TypePredicate, typeName.pos);
|
||||||
node.parameterName = <Identifier>typeName;
|
node.parameterName = <Identifier>typeName;
|
||||||
|
|
7
tests/baselines/reference/typePredicateASI.js
Normal file
7
tests/baselines/reference/typePredicateASI.js
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
//// [typePredicateASI.ts]
|
||||||
|
interface I {
|
||||||
|
foo(callback: (a: any, b: any) => void): I
|
||||||
|
is(): boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
//// [typePredicateASI.js]
|
14
tests/baselines/reference/typePredicateASI.symbols
Normal file
14
tests/baselines/reference/typePredicateASI.symbols
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
=== tests/cases/conformance/expressions/typeGuards/typePredicateASI.ts ===
|
||||||
|
interface I {
|
||||||
|
>I : Symbol(I, Decl(typePredicateASI.ts, 0, 0))
|
||||||
|
|
||||||
|
foo(callback: (a: any, b: any) => void): I
|
||||||
|
>foo : Symbol(foo, Decl(typePredicateASI.ts, 0, 13))
|
||||||
|
>callback : Symbol(callback, Decl(typePredicateASI.ts, 1, 8))
|
||||||
|
>a : Symbol(a, Decl(typePredicateASI.ts, 1, 19))
|
||||||
|
>b : Symbol(b, Decl(typePredicateASI.ts, 1, 26))
|
||||||
|
>I : Symbol(I, Decl(typePredicateASI.ts, 0, 0))
|
||||||
|
|
||||||
|
is(): boolean;
|
||||||
|
>is : Symbol(is, Decl(typePredicateASI.ts, 1, 46))
|
||||||
|
}
|
14
tests/baselines/reference/typePredicateASI.types
Normal file
14
tests/baselines/reference/typePredicateASI.types
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
=== tests/cases/conformance/expressions/typeGuards/typePredicateASI.ts ===
|
||||||
|
interface I {
|
||||||
|
>I : I
|
||||||
|
|
||||||
|
foo(callback: (a: any, b: any) => void): I
|
||||||
|
>foo : (callback: (a: any, b: any) => void) => I
|
||||||
|
>callback : (a: any, b: any) => void
|
||||||
|
>a : any
|
||||||
|
>b : any
|
||||||
|
>I : I
|
||||||
|
|
||||||
|
is(): boolean;
|
||||||
|
>is : () => boolean
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
interface I {
|
||||||
|
foo(callback: (a: any, b: any) => void): I
|
||||||
|
is(): boolean;
|
||||||
|
}
|
Loading…
Reference in a new issue