8000 Merge pull request #3449 from Microsoft/typePredicateASI · johnangularjs/TypeScript@6490d67 · GitHub
[go: up one dir, main page]

Skip to content
< 8000 /react-partial>

Commit 6490d67

Browse files
committed
Merge pull request microsoft#3449 from Microsoft/typePredicateASI
Don't consume 'is' keyword if there is a preceding line terminator
2 parents ce2d914 + 75ed565 commit 6490d67

File tree

5 files changed

+40
-1
lines changed

5 files changed

+40
-1
lines changed

src/compiler/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1903,7 +1903,7 @@ module ts {
19031903

19041904
function parseTypeReferenceOrTypePredicate(): TypeReferenceNode | TypePredicateNode {
19051905
let typeName = parseEntityName(/*allowReservedWords*/ false, Diagnostics.Type_expected);
1906-
if (typeName.kind === SyntaxKind.Identifier && token === SyntaxKind.IsKeyword) {
1906+
if (typeName.kind === SyntaxKind.Identifier && token === SyntaxKind.IsKeyword && !scanner.hasPrecedingLineBreak()) {
19071907
nextToken();
19081908
let node = <TypePredicateNode>createNode(SyntaxKind.TypePredicate, typeName.pos);
19091909
node.parameterName = <Identifier>typeName;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//// [typePredicateASI.ts]
2+
interface I {
3+
foo(callback: (a: any, b: any) => void): I
4+
is(): boolean;
5+
}
6+
7+
//// [typePredicateASI.js]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
=== tests/cases/conformance/expressions/typeGuards/typePredicateASI.ts ===
2+
interface I {
3+
>I : Symbol(I, Decl(typePredicateASI.ts, 0, 0))
4+
5+
foo(callback: (a: any, b: any) => void): I
6+
>foo : Symbol(foo, Decl(typePredicateASI.ts, 0, 13))
7+
>callback : Symbol(callback, Decl(typePredicateASI.ts, 1, 8))
8+
>a : Symbol(a, Decl(typePredicateASI.ts, 1, 19))
9+
>b : Symbol(b, Decl(typePredicateASI.ts, 1, 26))
10+
>I : Symbol(I, Decl(typePredicateASI.ts, 0, 0))
11+
12+
is(): boolean;
13+
>is : Symbol(is, Decl(typePredicateASI.ts, 1, 46))
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
=== tests/cases/conformance/expressions/typeGuards/typePredicateASI.ts ===
2+
interface I {
3+
>I : I
4+
5+
foo(callback: (a: any, b: any) => void): I
6+
>foo : (callback: (a: any, b: any) => void) => I
7+
>callback : (a: any, b: any) => void
8+
>a : any
9+
>b : any
10+
>I : I
11+
12+
is(): boolean;
13+
>is : () => boolean
14+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
interface I {
2+
foo(callback: (a: any, b: any) => void): I
3+
is(): boolean;
4+
}

0 commit comments

Comments
 (0)
0