-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8daac14
commit ffb9585
Showing
12 changed files
with
140 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 0 additions & 18 deletions
18
tests/baselines/reference/declarationEmitThisPredicates02.errors.txt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 0 additions & 18 deletions
18
tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName02.errors.txt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
tests/baselines/reference/thisPredicateInObjectLiteral.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
thisPredicateInObjectLiteral.ts(10,28): error TS2526: A 'this' type is available only in a non-static member of a class or interface. | ||
|
||
|
||
==== thisPredicateInObjectLiteral.ts (1 errors) ==== | ||
// Should be OK | ||
const foo2 = { | ||
isNumber(): this is { b: string } { | ||
return true; | ||
}, | ||
}; | ||
|
||
// Still an error | ||
const foo3 = { | ||
isNumber(x: any): x is this { | ||
~~~~ | ||
!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. | ||
return true; | ||
}, | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
//// [tests/cases/compiler/thisPredicateInObjectLiteral.ts] //// | ||
|
||
//// [thisPredicateInObjectLiteral.ts] | ||
// Should be OK | ||
const foo2 = { | ||
isNumber(): this is { b: string } { | ||
return true; | ||
}, | ||
}; | ||
|
||
// Still an error | ||
const foo3 = { | ||
isNumber(x: any): x is this { | ||
return true; | ||
}, | ||
}; | ||
|
||
|
||
//// [thisPredicateInObjectLiteral.js] | ||
"use strict"; | ||
// Should be OK | ||
var foo2 = { | ||
isNumber: function () { | ||
return true; | ||
}, | ||
}; | ||
// Still an error | ||
var foo3 = { | ||
isNumber: function (x) { | ||
return true; | ||
}, | ||
}; |
28 changes: 28 additions & 0 deletions
28
tests/baselines/reference/thisPredicateInObjectLiteral.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//// [tests/cases/compiler/thisPredicateInObjectLiteral.ts] //// | ||
|
||
=== thisPredicateInObjectLiteral.ts === | ||
// Should be OK | ||
const foo2 = { | ||
>foo2 : Symbol(foo2, Decl(thisPredicateInObjectLiteral.ts, 1, 5)) | ||
|
||
isNumber(): this is { b: string } { | ||
>isNumber : Symbol(isNumber, Decl(thisPredicateInObjectLiteral.ts, 1, 14)) | ||
>b : Symbol(b, Decl(thisPredicateInObjectLiteral.ts, 2, 25)) | ||
|
||
return true; | ||
}, | ||
}; | ||
|
||
// Still an error | ||
const foo3 = { | ||
>foo3 : Symbol(foo3, Decl(thisPredicateInObjectLiteral.ts, 8, 5)) | ||
|
||
isNumber(x: any): x is this { | ||
>isNumber : Symbol(isNumber, Decl(thisPredicateInObjectLiteral.ts, 8, 14)) | ||
>x : Symbol(x, Decl(thisPredicateInObjectLiteral.ts, 9, 13)) | ||
>x : Symbol(x, Decl(thisPredicateInObjectLiteral.ts, 9, 13)) | ||
|
||
return true; | ||
}, | ||
}; | ||
|
43 changes: 43 additions & 0 deletions
43
tests/baselines/reference/thisPredicateInObjectLiteral.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
//// [tests/cases/compiler/thisPredicateInObjectLiteral.ts] //// | ||
|
||
=== thisPredicateInObjectLiteral.ts === | ||
// Should be OK | ||
const foo2 = { | ||
>foo2 : { isNumber(): this is { b: string; }; } | ||
> : ^^^^^^^^^^^^^^ ^^^ | ||
>{ isNumber(): this is { b: string } { return true; },} : { isNumber(): this is { b: string; }; } | ||
> : ^^^^^^^^^^^^^^ ^^^ | ||
|
||
isNumber(): this is { b: string } { | ||
>isNumber : () => this is { b: string; } | ||
> : ^^^^^^ | ||
>b : string | ||
> : ^^^^^^ | ||
|
||
return true; | ||
>true : true | ||
> : ^^^^ | ||
|
||
}, | ||
}; | ||
|
||
// Still an error | ||
const foo3 = { | ||
>foo3 : { isNumber(x: any): x is this; } | ||
> : ^^^^^^^^^^^ ^^ ^^^ ^^^ | ||
>{ isNumber(x: any): x is this { return true; },} : { isNumber(x: any): x is this; } | ||
> : ^^^^^^^^^^^ ^^ ^^^ ^^^ | ||
|
||
isNumber(x: any): x is this { | ||
>isNumber : (x: any) => x is this | ||
> : ^ ^^ ^^^^^ | ||
>x : any | ||
> : ^^^ | ||
|
||
return true; | ||
>true : true | ||
> : ^^^^ | ||
|
||
}, | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// @strict: true | ||
|
||
// Should be OK | ||
const foo2 = { | ||
isNumber(): this is { b: string } { | ||
return true; | ||
}, | ||
}; | ||
|
||
// Still an error | ||
const foo3 = { | ||
isNumber(x: any): x is this { | ||
return true; | ||
}, | ||
}; |