mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
Fixed a mistake in the narrowingDestructuring test (#52411)
This commit is contained in:
parent
a311e25305
commit
45c246f28c
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user