学无先后,达者为师

网站首页 前端文档 正文

TS2339: property ‘of‘ does not exist on type ‘typeof Observable‘ - rxjs@6.2.2

作者:� 杰尼龟 更新时间: 2022-02-14 前端文档

两种方法

问题

TS2339: property ‘of’ does not exist on type ‘typeof Observable’ - rxjs@6.2.2

方法

方法1

找到tsconfig.json

/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "moduleResolution": "node",
    "importHelpers": true,
    "target": "es2015",
    "module": "es2020",
    "lib": [
      "es2018",
      "dom"
    ]
  },
  "angularCompilerOptions": {
    "enableI18nLegacyMessageIdFormat": false,
    "strictInjectionParameters": true,
    "strictInputAccessModifiers": true,
    "strictTemplates": true
  }
}

“strict”: true,改为 “strict”: false,

方法2

import {AbstractControl, FormControl, FormGroup} from '@angular/forms';
import {of} from 'rxjs';
Observable.of() 改为 of()
加一层 pipe()
  return of(valid ? null : {mobile: true}).pipe(
  func();
 );

原文链接:https://blog.csdn.net/weixin_45124380/article/details/115917222

栏目分类
最近更新