mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-14 19:16:17 -06:00
Test:type predicate uses correct index to report errors
This commit is contained in:
parent
8ae7c6c227
commit
a59f77ffb4
7
tests/baselines/reference/thisTypeInTypePredicate.js
Normal file
7
tests/baselines/reference/thisTypeInTypePredicate.js
Normal file
@ -0,0 +1,7 @@
|
||||
//// [thisTypeInTypePredicate.ts]
|
||||
declare function filter<S>(f: (this: void, x: any) => x is S): S[];
|
||||
const numbers = filter<number>((x): x is number => 'number' == typeof x)
|
||||
|
||||
|
||||
//// [thisTypeInTypePredicate.js]
|
||||
var numbers = filter(function (x) { return 'number' == typeof x; });
|
||||
18
tests/baselines/reference/thisTypeInTypePredicate.symbols
Normal file
18
tests/baselines/reference/thisTypeInTypePredicate.symbols
Normal file
@ -0,0 +1,18 @@
|
||||
=== tests/cases/conformance/types/thisType/thisTypeInTypePredicate.ts ===
|
||||
declare function filter<S>(f: (this: void, x: any) => x is S): S[];
|
||||
>filter : Symbol(filter, Decl(thisTypeInTypePredicate.ts, 0, 0))
|
||||
>S : Symbol(S, Decl(thisTypeInTypePredicate.ts, 0, 24))
|
||||
>f : Symbol(f, Decl(thisTypeInTypePredicate.ts, 0, 27))
|
||||
>this : Symbol(this, Decl(thisTypeInTypePredicate.ts, 0, 31))
|
||||
>x : Symbol(x, Decl(thisTypeInTypePredicate.ts, 0, 42))
|
||||
>x : Symbol(x, Decl(thisTypeInTypePredicate.ts, 0, 42))
|
||||
>S : Symbol(S, Decl(thisTypeInTypePredicate.ts, 0, 24))
|
||||
>S : Symbol(S, Decl(thisTypeInTypePredicate.ts, 0, 24))
|
||||
|
||||
const numbers = filter<number>((x): x is number => 'number' == typeof x)
|
||||
>numbers : Symbol(numbers, Decl(thisTypeInTypePredicate.ts, 1, 5))
|
||||
>filter : Symbol(filter, Decl(thisTypeInTypePredicate.ts, 0, 0))
|
||||
>x : Symbol(x, Decl(thisTypeInTypePredicate.ts, 1, 32))
|
||||
>x : Symbol(x, Decl(thisTypeInTypePredicate.ts, 1, 32))
|
||||
>x : Symbol(x, Decl(thisTypeInTypePredicate.ts, 1, 32))
|
||||
|
||||
23
tests/baselines/reference/thisTypeInTypePredicate.types
Normal file
23
tests/baselines/reference/thisTypeInTypePredicate.types
Normal file
@ -0,0 +1,23 @@
|
||||
=== tests/cases/conformance/types/thisType/thisTypeInTypePredicate.ts ===
|
||||
declare function filter<S>(f: (this: void, x: any) => x is S): S[];
|
||||
>filter : <S>(f: (this: void, x: any) => x is S) => S[]
|
||||
>S : S
|
||||
>f : (this: void, x: any) => x is S
|
||||
>this : void
|
||||
>x : any
|
||||
>x : any
|
||||
>S : S
|
||||
>S : S
|
||||
|
||||
const numbers = filter<number>((x): x is number => 'number' == typeof x)
|
||||
>numbers : number[]
|
||||
>filter<number>((x): x is number => 'number' == typeof x) : number[]
|
||||
>filter : <S>(f: (this: void, x: any) => x is S) => S[]
|
||||
>(x): x is number => 'number' == typeof x : (this: void, x: any) => x is number
|
||||
>x : any
|
||||
>x : any
|
||||
>'number' == typeof x : boolean
|
||||
>'number' : "number"
|
||||
>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"
|
||||
>x : any
|
||||
|
||||
@ -0,0 +1,2 @@
|
||||
declare function filter<S>(f: (this: void, x: any) => x is S): S[];
|
||||
const numbers = filter<number>((x): x is number => 'number' == typeof x)
|
||||
Loading…
x
Reference in New Issue
Block a user