gpt4 book ai didi

angular - @ ngx-translate/core中的错误-错误TS1086 : An accessor cannot be declared in an ambient context in Angular 8

转载 作者:行者123 更新时间:2023-12-03 13:44:42 26 4
gpt4 key购买 nike

我正在使用Angular 8并使用ngx-translate实现国际化(i18n)。我使用了以下库。

  • “@ ngx-translate/core”:“^ 13.0.0”,
  • “@ ngx-translate/http-loader”:“^ 6.0.0”。

  • 在运行这个 Angular 项目时,我遇到了这个错误。
    请帮助我解决此错误。
    这是完整的错误:
    ERROR in node_modules/@ngx-translate/core/lib/translate.directive.d.ts:14:9 - error TS1086: An accessor cannot be declared in an ambient context.

    node_modules/@ngx-translate/core/lib/translate.directive.d.ts:15:9 - error TS1086: An accessor cannot be declared in an ambient context.
    node_modules/@ngx-translate/core/lib/translate.service.d.ts:49:9 - error TS1086: An accessor cannot be declared in an ambient context.
    node_modules/@ngx-translate/core/lib/translate.service.d.ts:56:9 - error TS1086: An accessor cannot be declared in an ambient context.
    node_modules/@ngx-translate/core/lib/translate.service.d.ts:63:9 - error TS1086: An accessor cannot be declared in an ambient context.
    node_modules/@ngx-translate/core/lib/translate.service.d.ts:67:9 - error TS1086: An accessor cannot be declared in an ambient context.
    node_modules/@ngx-translate/core/lib/translate.service.d.ts:68:9 - error TS1086: An accessor cannot be declared in an ambient context.
    node_modules/@ngx-translate/core/lib/translate.service.d.ts:72:9 - error TS1086: An accessor cannot be declared in an ambient context.
    node_modules/@ngx-translate/core/lib/translate.service.d.ts:73:9 - error TS1086: An accessor cannot be declared in an ambient context.
    node_modules/@ngx-translate/core/lib/translate.service.d.ts:77:9 - error TS1086: An accessor cannot be declared in an ambient context.
    node_modules/@ngx-translate/core/lib/translate.service.d.ts:78:9 - error TS1086: An accessor cannot be declared in an ambient context.
    node_modules/@ngx-translate/core/lib/translate.service.d.ts:82:9 - error TS1086: An accessor cannot be declared in an ambient context.
    node_modules/@ngx-translate/core/lib/translate.service.d.ts:83:9 - error TS1086: An accessor cannot be declared in an ambient context.

    这是我的package.json
    {
    "name": "ng-i18n",
    "version": "0.0.0",
    "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
    },
    "private": true,
    "dependencies": {
    "@angular/animations": "~8.2.14",
    "@angular/common": "~8.2.14",
    "@angular/compiler": "~8.2.14",
    "@angular/core": "~8.2.14",
    "@angular/forms": "~8.2.14",
    "@angular/platform-browser": "~8.2.14",
    "@angular/platform-browser-dynamic": "~8.2.14",
    "@angular/router": "~8.2.14",
    "@ngx-translate/core": "^13.0.0",
    "@ngx-translate/http-loader": "^6.0.0",
    "bootstrap": "^4.0.0",
    "jquery": "^3.5.1",
    "rxjs": "~6.4.0",
    "tslib": "^1.10.0",
    "zone.js": "~0.9.1"
    },
    "devDependencies": {
    "@angular-devkit/build-angular": "~0.803.28",
    "@angular/cli": "~8.3.28",
    "@angular/compiler-cli": "~8.2.14",
    "@angular/language-service": "~8.2.14",
    "@types/node": "~8.9.4",
    "@types/jasmine": "~3.3.8",
    "@types/jasminewd2": "~2.0.3",
    "codelyzer": "^5.0.0",
    "jasmine-core": "~3.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.1.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.4.0",
    "protractor": "~7.0.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.15.0",
    "typescript": "~3.5.3"
    }
    }

    最佳答案

    更新
    由于最近发布了angular 11,因此请检查答案是否仍与更新的软件包一致。跟踪ngx-translate的演变。

    旧答案
    将其降级到12.1.2版对我有用。
    只需在您的终端中执行npm i @ngx-translate/core@12.1.2
    现在,我正在使用theese软件包,并且一切正常:

  • angular/core@8.3.29
  • ngx-translate-cache@9.0.2
  • ngx-translate/http-loader@6.0.0
  • ngx-translate/core@12.1.2
  • 关于angular - @ ngx-translate/core中的错误-错误TS1086 : An accessor cannot be declared in an ambient context in Angular 8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63132590/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com