Skip to content

vite+vue3+ts项目中,.vue文件内的TS不报错! #467

@bestime

Description

@bestime

Related plugins

Describe the bug

有这么一段代码,编译不会报错,奇葩的是,运行时浏览器不报错,必须要try catch才行。

// 这个数据可能从一个未知的地方来(来源不重要)
const a:any = {}
console.log(a.b.c.d.e.f.g)

然而这个项目也许是别人的,又或许数据来源变了,导致数据结构发生了变化,项目中又有多处这种潜在问题,又无法一一排查,如何能让这个代码在浏览器中直接抛错(试了js、和非vue文件引用的TS浏览器会抛错)而且本来也应该抛错

Reproduction

Steps to reproduce

System Info

普通浏览器

Used Package Manager

npm

Logs

npm run dev

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions