Skip to content

元组一章 #229

@guda-art

Description

@guda-art

也可以只赋值其中一项:

let tom: [string, number];
tom[0] = 'Tom';

编译时不报错, 也能通过类型检查, 但是tom[0]是undefined,, 所以运行时会报错
ts-node .ts或node .js都会报错

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