V
V
Vadim2018-10-30 16:15:32
Angular
Vadim, 2018-10-30 16:15:32

How to assign type to Observable in Angular 6/Rxjs 6?

Good afternoon, I'm moving a project from Angular 4.3 to Angular 6 and there was a problem with Observables.

Cannot use namespace 'Observable' as a type.
When trying to specify what the method should return, how can this be fixed?
public postMethod(url: string, params: any, session: string = null): Observable<any> {
// do something
  }

I am using this assembly , package.json is the following
"dependencies": {
    "@angular/animations": "^6.1.9",
    "@angular/cdk": "~6.2.1",
    "@angular/common": "^6.1.9",
    "@angular/compiler": "^6.1.9",
    "@angular/core": "^6.1.9",
    "@angular/forms": "^6.1.9",
    "@angular/platform-browser": "^6.1.9",
    "@angular/platform-browser-dynamic": "^6.1.9",
    "@angular/platform-server": "^6.1.9",
    "@angular/router": "^6.1.9",
    "@angular/material": "~6.4.7",
    "@angularclass/hmr": "~2.1.3",
    "core-js": "^2.5.7",
    "http-server": "^0.11.1",
    "ie-shim": "^0.1.0",
    "reflect-metadata": "^0.1.12",
    "rxjs": "~6.3.3",
    "zone.js": "^0.8.26",
    "xlsx": "~0.14.0",
    "font-awesome": "^4.7.0",
    "hammerjs": "^2.0.8"
  },
  "devDependencies": {
    "@angular-devkit/build-optimizer": "^0.6.8",
    "@angular/cli": "^6.0.8",
    "@angular/compiler-cli": "^6.0.6",
    "@angular/flex-layout": "~6.0.0-beta.18",
    "@angular/language-service": "^6.0.6",
    "@compodoc/compodoc": "^1.1.3",
    "@ngtools/webpack": "^6.0.8",
    "@types/hammerjs": "^2.0.36",
    "@types/jasmine": "^2.8.9",
    "@types/node": "~10.11.5",
    "@types/uglify-js": "^3.0.2",
    "@types/webpack": "^4.4.2",
    "add-asset-html-webpack-plugin": "^2.1.3",
    "angular2-template-loader": "^0.6.2",
    "assets-webpack-plugin": "^3.8.4",
    "awesome-typescript-loader": "^5.2.0",
    "codelyzer": "^4.3.0",
    "copy-webpack-plugin": "^4.5.1",
    "cross-env": "^5.2.0",
    "css-loader": "^0.28.11",
    "exports-loader": "^0.7.0",
    "expose-loader": "^0.7.5",
    "file-loader": "^1.1.11",
    "find-root": "^1.1.0",
    "gh-pages": "^1.2.0",
    "html-webpack-plugin": "^3.2.0",
    "imports-loader": "^0.8.0",
    "istanbul-instrumenter-loader": "^3.0.1",
    "jasmine-core": "^3.1.0",
    "karma": "^2.0.4",
    "karma-chrome-launcher": "^2.2.0",
    "karma-coverage": "^1.1.2",
    "karma-jasmine": "^1.1.2",
    "karma-mocha-reporter": "^2.2.5",
    "karma-remap-coverage": "^0.1.5",
    "karma-sourcemap-loader": "^0.3.7",
    "karma-webpack": "^3.0.0",
    "mini-css-extract-plugin": "^0.4.0",
    "node-sass": "^4.9.0",
    "npm-run-all": "^4.1.3",
    "optimize-js-plugin": "^0.0.4",
    "parse5": "^5.0.0",
    "protractor": "^5.3.2",
    "raw-loader": "^0.5.1",
    "rimraf": "^2.6.2",
    "rxjs-tslint": "^0.1.5",
    "sass-loader": "^7.0.3",
    "script-ext-html-webpack-plugin": "^2.0.1",
    "source-map-loader": "^0.2.3",
    "string-replace-loader": "^2.1.1",
    "style-loader": "^0.21.0",
    "to-string-loader": "^1.1.5",
    "ts-node": "^7.0.0",
    "tslib": "^1.9.3",
    "tslint": "^5.10.0",
    "tslint-loader": "^3.6.0",
    "typedoc": "^0.11.1",
    "typescript": "^2.9.2",
    "uglifyjs-webpack-plugin": "^1.2.6",
    "url-loader": "^1.0.1",
    "webpack": "^4.12.0",
    "webpack-cli": "^3.0.8",
    "webpack-dev-middleware": "^3.1.3",
    "webpack-dev-server": "^3.1.4",
    "webpack-inline-manifest-plugin": "^4.0.1",
    "webpack-merge": "^4.1.3"
  }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
msdosx86, 2018-12-02
@msdosx86

There is clearly a problem in the import of Observable'a

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question