Skip to content

tuple一章实际会报错 #33

Closed
Closed
@yinsang

Description

@yinsang
let xcatliu: [string, number];
xcatliu[0] = 'Xcat Liu';
xcatliu[1] = 25;

这里实际会报错【在赋值前使用了变量“xcatliu”。】
tsc -v 3.2.2

越界的元素中对越界元素的报错定义也有所不同了:

let xcatliu: [string, number];
xcatliu = ['Xcat Liu', 25];
xcatliu.push('http://xcatliu.com/');
xcatliu.push(true);

类型“true”的参数不能赋给类型“string | number”的参数。新版的ts没有Type 'boolean' is not assignable to type 'number'.这样的对应了。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions