由于Ngrx版本导致Angular项目中出现错误

时间:2019-01-14 23:01:11

标签: angular rxjs ngrx

我删除了node_modules并重新安装。但是我仍然遇到错误。请让我知道我在做什么错。

检查更新的版本。 我的节点版本是8.12.0 我的NPM版本是6.4.1

下面是我面临的错误

ERROR in node_modules/@ngrx/store/src/store.d.ts(30,31): error TS2304: Cannot find name 'Extract'.
node_modules/@ngrx/store/src/store_module.d.ts(23,154): error TS2315: Type 'ModuleWithProviders' is not generic.
node_modules/@ngrx/store/src/store_module.d.ts(24,178): error TS2315: Type 'ModuleWithProviders' is not generic.
node_modules/@ngrx/store/src/store_module.d.ts(25,171): error TS2315: Type 'ModuleWithProviders' is not generic.

Below is package.json file

  "dependencies": {
    "@angular/animations": "^6.0.0",
    "@angular/common": "^6.0.0",
    "@angular/compiler": "^6.0.0",
    "@angular/core": "^6.0.0",
    "@angular/forms": "^6.0.0",
    "@angular/http": "^6.0.0",
    "@angular/platform-browser": "^6.0.0",
    "@angular/platform-browser-dynamic": "^6.0.0",
    "@angular/router": "^6.0.0",
    "@ngrx/effects": "^7.0.0",
    "@ngrx/store": "^7.0.0",
    "bootstrap": "^4.1.0",
    "core-js": "^2.5.4",
    "rxjs": "^6.1.0",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular/compiler-cli": "^6.0.0",
    "@angular-devkit/build-angular": "~0.6.0",
    "typescript": "~2.7.2",
    "@angular/cli": "~6.0.0",
    "@angular/language-service": "^6.0.0",
    "@types/jasmine": "~2.8.6",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "angular-in-memory-web-api": "0.6.0",
    "codelyzer": "~4.2.1",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~1.7.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~1.4.2",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.3.0",
    "ts-node": "~5.0.1",
    "tslint": "~5.9.1"
  }
}

1 个答案:

答案 0 :(得分:1)

此处提到此错误:https://github.com/ngrx/platform/issues/1488

它指出private async void btnSearch_Click(object sender, EventArgs e) { this.gridLog.DataSource = null; this.Cursor = Cursors.WaitCursor; if (this.btnSearch.Text.ToLower().Contains("load")) { this.btnSearch.Text = "Cancel"; this.btnSearch.ForeColor = Color.White; this.btnSearch.BackColor = Color.Red; //get params to pass /* snip */ this.cancellationTokenSource = new CancellationTokenSource(); List<DocLog> list = await DocLog.FindForLocationAsync(docType, subType, days, currLocation.ID, cancellationTokenSource.Token); gridLog.DataSource = new BindingList<DocLog>( list ); this.btnSearch.Text = "Load Data..."; this.btnSearch.ForeColor = Color.Black; this.btnSearch.BackColor = Color.FromArgb(225, 225, 225); } else { CancelSearch(); this.btnSearch.Text = "Load Data..."; this.btnSearch.ForeColor = Color.Black; this.btnSearch.BackColor = Color.FromArgb(225, 225, 225); } this.Cursor = Cursors.Default; } private void CancelSearch() { this.cancellationTokenSource?.Cancel(); } public async static Task<List<DocLog>> FindForLocationAsync(string DocType, string SubType, int? LastXDays, Guid LocationID, CancellationToken cancellationToken) { List<DocLog> dll = new List<DocLog>(); using (SqlConnection sqlConnection = new SqlConnection(Helper.GetConnectionString())) using (SqlCommand sqlCommand = sqlConnection.CreateCommand()) { await sqlConnection.OpenAsync(cancellationToken).ConfigureAwait(false); sqlCommand.CommandText = (LastXDays == null) ? "DocLogGetAllForLocation" : "DocLogGetAllForLocationLastXDays"; sqlCommand.CommandType = System.Data.CommandType.StoredProcedure; sqlCommand.Parameters.Add("@DocType", SqlDbType.NVarChar, 30).Value = DocType.Trim(); sqlCommand.Parameters.Add("@SubType", SqlDbType.NVarChar, 30).Value = SubType.Trim(); sqlCommand.Parameters.Add("@LocationID", SqlDbType.UniqueIdentifier).Value = LocationID; if (LastXDays != null) { sqlCommand.Parameters.Add("@NumberOfDays", SqlDbType.Int).Value = LastXDays; } using( SqlDataReader sqlDataReader = await sqlCommand.ExecuteReaderAsync(cancellationToken).ConfigureAwait(false) ) { while (await sqlDataReader.ReadAsync(cancellationToken).ConfigureAwait(false)) { if (cancellationToken.IsCancellationRequested) break; DocLog dl = readData(sqlDataReader); dll.Add(dl); } } } return dll; }

上面定义的项目正在使用TypeScript 2.7.2。

考虑升级您的TypeScript版本。

(我也在这里回复:https://app.pluralsight.com/library/courses/angular-ngrx-getting-started/discussion