我有這種型別:
export type ICfnOutput = {
ENDPOINTS: {
[key in `${keyof typeof MSERVICES}_ENDPOINT`]: string
},
USER_POOL_CLIENT_ID: string,
amplifyClientUrl: string,
USER_POOL_ID: string
}
當我運行命令時:
eslint . --ext .ts
我收到以下錯誤:
error Parsing error: Type expected
.eslintrc.json
{
"env": {
"node": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {}
}
我正在使用 eslint v8.21.0
,我該如何避免這種情況,或者我應該忽略它并添加一個忽略命令,因為這似乎是一個 eslint 問題
代碼作業正常只是當我 lint eslint 將其視為錯誤時。
uj5u.com熱心網友回復:
在評論中解決:
我看到并仔細檢查,問題是打字稿版本,我使用的是 aws cdk,顯然默認安裝打字稿 v3.9.7。—伍海克
模板文字型別是在 TypeScript 4.1 中引入的,因此 ESLint 正確地標記了這種語法是意外的。
通過使用Typescript-ESLint Playground進行除錯很有幫助。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/527584.html
標籤:打字稿埃斯林特模板字符串
上一篇:如何遍歷節點樹并修改其結構和值