首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >环境上下文中的“const”初始值设定项必须是字符串或数字文本或文本枚举引用

环境上下文中的“const”初始值设定项必须是字符串或数字文本或文本枚举引用
EN

Stack Overflow用户
提问于 2021-01-03 04:09:06
回答 2查看 576关注 0票数 0

只需将Nativescript升级到版本7并得到下面的错误,不确定为什么nativescript会抛出这个错误。

这是我的package.json:

代码语言:javascript
复制
"dependencies": {
    "@angular/animations": "^10.2.4",
    "@angular/common": "^10.2.4",
    "@angular/compiler": "^10.2.4",
    "@angular/core": "^10.2.4",
    "@angular/forms": "^10.2.4",
    "@angular/platform-browser": "^10.2.4",
    "@angular/platform-browser-dynamic": "^10.2.4",
    "@angular/router": "^10.2.4",
    "@nativescript/angular": "^10.1.7",
    "@nativescript/core": "^7.1.0",
    "@nativescript/webpack": "^4.0.0",
    "@nstudio/nativescript-cardview": "^2.0.1",
    "@types/jest": "^24.0.18",
    "base-64": "^0.1.0",
    "js-base64": "^2.5.2",
    "nativescript-admob": "^4.0.0",
    "nativescript-clipboard": "^2.0.0",
    "nativescript-drop-down": "^5.0.6",
    "nativescript-pdf-view": "^2.4.3",
    "nativescript-permissions": "^1.3.11",
    "nativescript-plugin-firebase": "^10.6.3",
    "nativescript-theme-core": "^1.0.6",
    "nativescript-toast": "^2.0.0",
    "nativescript-ui-calendar": "^7.0.2",
    "nativescript-ui-listview": "^9.0.4",
    "nativescript-ui-sidedrawer": "^9.0.3",
    "reflect-metadata": "~0.1.12",
    "rxjs": "^6.4.0",
    "zone.js": "^0.10.3"
  },
  "devDependencies": {
    "@angular-devkit/schematics": "^10.2.1",
    "@angular/cli": "^10.2.1",
    "@angular/compiler-cli": "^10.2.4",
    "@nativescript/android": "7.0.1",
    "@nativescript/schematics": "^10.1.0",
    "@nativescript/types": "^7.0.4",
    "@ngtools/webpack": "^10.2.1",
    "@schematics/angular": "^10.2.1",
    "@schematics/update": "^0.11.4",
    "node-sass": "^4.13.1",
    "typescript": "^3.9.7"
  },

我也尝试了TypeScript4,但是产生了更多的错误。

任何人在下面遇到这个问题:

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2021-01-11 02:07:23

确保您的tsconfig.json包含

代码语言:javascript
复制
"skipLibCheck": true

如果你正在生成一个新的项目,但是在更新过程中没有被添加,那么它看起来是默认的。添加它为我解决了这个问题,现在我可以毫无问题地编译应用程序了。

下面是我的tsconfig文件的一个示例:

代码语言:javascript
复制
{
  "compilerOptions": {
    "module": "esnext",
    "target": "es2017",
    "moduleResolution": "node",
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "noEmitHelpers": true,
    "noEmitOnError": true,
    "skipLibCheck": true,
    "resolveJsonModule": true,
    "esModuleInterop": true,
    "lib": [
      "es2017",
      "dom"
    ],
    "baseUrl": ".",
    "paths": {
      "~/*": [
        "src/*"
      ]
    }
  },
  "exclude": [
    "node_modules",
    "platforms"
  ]
}
票数 1
EN

Stack Overflow用户

发布于 2021-01-11 02:22:41

这是一个Nativescript错误。该解决方案在5天前实施,但自11天以来就没有新的版本。在此期间,您可以自己修复它。以下是解决方案:https://github.com/NativeScript/NativeScript/pull/9136/commits/619fd49186f58d4d11d0554458af1210108c89d1

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65543585

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档