【发布时间】:2018-08-12 01:22:49
【问题描述】:
使用 vue.js 时出现 Typescript 类型转换错误
export interface User {
id: number
uuid: string
email: string
name: string
role: number
}
let myObject: User
let otherObject: any
myObject = otherObject as User
错误代码
http://eslint.org/docs/rules/ Parsing error: Unexpected token, expected ";"
46 | let otherObject: any
47 | // values are assigned to them, and...
> 48 | myObject = otherObject as User //
src\components\modal\LoginModal.vue:81:31
myObject = otherObject as User
使用的ide是vscode
我不知道为什么会出现这个错误。
这是.. 使用 typescript 和 tslint 版本
版本:typescript 2.7.2,tslint 5.9.1
【问题讨论】:
-
已解决。我将其更改为 .ts 而不是 .vue 扩展名。像这样...github.com/ducksoupdev/vue-webpack-typescript/tree/master/…
标签: typescript vue.js vuejs2