简体   繁体   中英

TS2339: Property 'first' does not exist on type 'Observable<boolean>'

I have a basic shell Angular6,.NET Core 2 app that I am trying to run. Angular 6 was updated from Angular 4 and that update didn't seem to go very smoothly. Some errors were TS property optionality related which I was able to sort.

This, however, is causing much grief.

Says the error is in: ./ClientApp/boot.server.ts:26:29 boot.server.ts 26-29 are:

        return new Promise<RenderResult>((resolve, reject) => {
        zone.onError.subscribe((errorInfo: any) => reject(errorInfo));
        appRef.isStable.first(isStable => isStable).subscribe(() => {
            // Because 'onStable' fires before 'onError', we have to delay slightly before
            // completing the request in case there's an error to report
            setImmediate(() => {
                resolve({
                    html: state.renderToString()
                });
                moduleRef.destroy();
            });
        });
    });

the .first call is where it's breaking.

my package.json file looks like this:

{
  "name": "TestApp",
  "private": true,
  "version": "0.0.0",
  "scripts": {
    "test": "karma start ClientApp/test/karma.conf.js"
  },
  "devDependencies": {
    "@angular/animations": "6.0.2",
    "@angular/common": "6.0.2",
    "@angular/compiler": "6.0.2",
    "@angular/compiler-cli": "6.0.2",
    "@angular/core": "6.0.2",
    "@angular/forms": "6.0.2",
    "@angular/http": "6.0.2",
    "@angular/platform-browser": "6.0.2",
    "@angular/platform-browser-dynamic": "6.0.2",
    "@angular/platform-server": "6.0.2",
    "@angular/router": "6.0.2",
    "@ngtools/webpack": "6.0.3",
    "@types/chai": "4.1.3",
    "@types/jasmine": "2.8.7",
    "@types/webpack-env": "1.13.6",
    "angular2-router-loader": "0.3.5",
    "angular2-template-loader": "0.6.2",
    "aspnet-prerendering": "^3.0.1",
    "aspnet-webpack": "^2.0.1",
    "awesome-typescript-loader": "5.0.0",
    "bootstrap": "4.1.1",
    "chai": "4.1.2",
    "css": "2.2.3",
    "css-loader": "0.28.11",
    "es6-shim": "0.35.3",
    "event-source-polyfill": "0.0.12",
    "expose-loader": "0.7.5",
    "extract-text-webpack-plugin": "3.0.2",
    "file-loader": "1.1.11",
    "html-loader": "0.5.5",
    "isomorphic-fetch": "2.2.1",
    "jasmine-core": "3.1.0",
    "jquery": "3.3.1",
    "json-loader": "0.5.7",
    "karma": "2.0.2",
    "karma-chai": "0.1.0",
    "karma-chrome-launcher": "2.2.0",
    "karma-cli": "1.0.1",
    "karma-jasmine": "1.1.2",
    "karma-webpack": "3.0.0",
    "preboot": "6.0.0-beta.4",
    "raw-loader": "0.5.1",
    "reflect-metadata": "0.1.12",
    "rxjs": "6.1.0",
    "style-loader": "0.21.0",
    "to-string-loader": "1.1.5",
    "typescript": "2.8.3",
    "url-loader": "1.0.1",
    "webpack": "4.8.3",
    "webpack-hot-middleware": "2.22.2",
    "webpack-merge": "4.1.2",
    "zone.js": "0.8.26",
    "popper.js": "^1.14.3"
  },
  "dependencies": {
    "@angular/cli": "^6.0.3"
  }
}

tsconfig.json

{
  "compilerOptions": {
    "module": "es2015",
    "moduleResolution": "node",
    "target": "es5",
    "sourceMap": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "skipDefaultLibCheck": true,
    "skipLibCheck": true, // Workaround for https://github.com/angular/angular/issues/17863. Remove this if you upgrade to a fixed version of Angular.
    "strict": true,
    "strictPropertyInitialization": false, // resolution for error TS2564
    "lib": [ "es6", "dom" ],
    "types": [ "webpack-env" ]
  },
  "exclude": [ "bin", "node_modules" ],
  "atom": { "rewriteTsconfig": false }
}

running.. Node 9.11.1

any help/direction is much appreciated!

If you ctrl-click the import statement

import 'rxjs/add/operator/first';

it will take you to first.d.ts which contains only

import 'rxjs-compat/add/operator/first';

So the solution is to also add rxjs-compat to your package.json , the same version as rxjs .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM