3

What are you trying to do?

I want to use @angular/cdk (source) to make a modal draggable as seen in their tutorial

Reproduction

npm i @angular/cdk

then when I import the module in my file xxx.module.ts :

import { DragDropModule } from '@angular/cdk/drag-drop';

I immediately obtain a list of error messages :

ERROR in node_modules/@angular/cdk/bidi/dir.d.ts(26,9): error TS1086: An accessor cannot be declared in an ambient context.

error console

Environment

Here is my package.json :

{
  "name": "libertchan",
  "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/cdk": "^9.0.0",
    "@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",
    "@ng-bootstrap/ng-bootstrap": "^5.2.1",
    "bootstrap": "^4.4.1",
    "rxjs": "~6.4.0",
    "tslib": "^1.10.0",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.803.19",
    "@angular/cli": "~8.3.19",
    "@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": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.15.0",
    "typescript": "~3.5.3"
  }
}
Boris BELLOC
  • 196
  • 1
  • 4
  • 15
  • 3
    Does this answer your question? [error TS1086: An accessor cannot be declared in an ambient context in Angular 9](https://stackoverflow.com/questions/60131331/error-ts1086-an-accessor-cannot-be-declared-in-an-ambient-context-in-angular-9) – cyr_x Feb 13 '20 at 16:22
  • Thanks for link, I found the solution. The problem was because I was using TypeScript 3.5 and the latest version of the CDK requires TypeScript 3.7. Angular 8 can't use TS3.7 so I also needed to upgrade to Angular 9 – Boris BELLOC Feb 14 '20 at 15:54

1 Answers1

1

Found the answer : the problem was because I was using TypeScript 3.5 and the latest version of the CDK requires TypeScript 3.7.

Angular 8 can't use TypeScript 3.7 so I also needed to upgrade to Angular 9.

Boris BELLOC
  • 196
  • 1
  • 4
  • 15