Fixed a mistake in the narrowingDestructuring test (#52411)

This commit is contained in:
Mateusz Burzyński 2023-01-25 19:50:29 +01:00 committed by GitHub
parent a311e25305
commit 45c246f28c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 9 deletions

View File

@ -34,10 +34,11 @@ function func3<T extends { kind: "a", a: string } | { kind: "b", b: number }>(t:
function farr<T extends [number, string, string] | [string, number, number]>(x: T) {
const [head, ...tail] = x;
if (x[0] === 'number') {
if (typeof x[0] === 'number') {
const [head, ...tail] = x;
}
}
}
//// [narrowingDestructuring.js]
var __rest = (this && this.__rest) || function (s, e) {
@ -83,7 +84,7 @@ function func3(t) {
}
function farr(x) {
var head = x[0], tail = x.slice(1);
if (x[0] === 'number') {
if (typeof x[0] === 'number') {
var head_1 = x[0], tail_1 = x.slice(1);
}
}

View File

@ -136,7 +136,7 @@ function farr<T extends [number, string, string] | [string, number, number]>(x:
>tail : Symbol(tail, Decl(narrowingDestructuring.ts, 34, 16))
>x : Symbol(x, Decl(narrowingDestructuring.ts, 33, 77))
if (x[0] === 'number') {
if (typeof x[0] === 'number') {
>x : Symbol(x, Decl(narrowingDestructuring.ts, 33, 77))
>0 : Symbol(0)
@ -146,3 +146,4 @@ function farr<T extends [number, string, string] | [string, number, number]>(x:
>x : Symbol(x, Decl(narrowingDestructuring.ts, 33, 77))
}
}

View File

@ -135,16 +135,18 @@ function farr<T extends [number, string, string] | [string, number, number]>(x:
>tail : [string, string] | [number, number]
>x : [number, string, string] | [string, number, number]
if (x[0] === 'number') {
>x[0] === 'number' : boolean
if (typeof x[0] === 'number') {
>typeof x[0] === 'number' : boolean
>typeof x[0] : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>x[0] : string | number
>x : [number, string, string] | [string, number, number]
>0 : 0
>'number' : "number"
const [head, ...tail] = x;
>head : "number"
>head : number
>tail : [string, string] | [number, number]
>x : [number, string, string] | [string, number, number]
}
}

View File

@ -33,7 +33,7 @@ function func3<T extends { kind: "a", a: string } | { kind: "b", b: number }>(t:
function farr<T extends [number, string, string] | [string, number, number]>(x: T) {
const [head, ...tail] = x;
if (x[0] === 'number') {
if (typeof x[0] === 'number') {
const [head, ...tail] = x;
}
}
}