小编Mik*_* S.的帖子

抑制 Angular 语言服务 VSCode 扩展的“strictTemplates in angularCompilerOptions”通知

由于我们将代码库升级到 Angular 11,我在 VSCode 中收到了这条消息:

某些语言功能不可用。要访问所有功能,请strictTemplatesangularCompilerOptions.

来源:Angular 语言服务(扩展)

带有“打开 tsconfig.json”的链接,如下所示:

上述文本的可视化

我期待启用此功能并享受新功能。但我想抽出时间来做和测试这个。就目前而言,VSCode 中的弹出窗口一直不断出现,这很烦人和分心。

我如何(现在)抑制此消息,最好是针对我当前的工作区?


  • Angular 语言服务 ( angular.ng-template) v11.2.3
  • Windows 10 上的 Visual Studio Code 1.53.2 版

visual-studio-code angular angular-language-service

20
推荐指数
3
解决办法
7067
查看次数

联合类型允许错误分配所用类型的属性

我在理解 TS 中的联合时遇到问题,为什么下面的分配是有效的?我认为这将只是为有效const a = {a:12}{a:123,b:23}{a:12,b:12,c:123}

type abcd =
    | {
        a: number;
      }
    | {
        a: number;
        b: number;
      }
    | {
        a: number;
        b: number;
        c: number;
      };

const a: abcd = {
    a:123,
    c:234
};
Run Code Online (Sandbox Code Playgroud)

游乐场链接

如果我更改csomethingElse

const a: abcd = {
    a:123,
    somethingElse:234 // Error on this line
};
Run Code Online (Sandbox Code Playgroud)

它给了我:

输入'{一个:数字;别的东西:数字;}' 不能分配给类型 'abcd'。对象字面量只能指定已知属性,并且类型“abcd”中不存在“somethingElse”。(2322)

typescript

5
推荐指数
1
解决办法
67
查看次数

仅当 Rxjs 轮询上的某些属性发生更改时才调度 NgRx 操作

我有一个像这样的 Rxjs 轮询效果:

updateProductData$ = createEffect(() =>
  this.actions$.pipe(
    ofType(fromActions.loadProduct),
    switchMap(_) =>
      this.http.get('endpoint').pipe(
        delay(1000),
        repeat(),
        switchMap((data) => [
          fromActions.updateFoo({foo: data.foo}),
          fromActions.updateBar({bar: data.bar}),
        ])
      )
    )
  );

Run Code Online (Sandbox Code Playgroud)

我怎样才能派遣updateFooupdateBar仅当data.foodata.bar分别改变?

我可以通过使用来改进这一点distinctUntilChanged,这样做的话data.stuff,如果发生变化,动作不会触发,但是,当任何一个动作发生变化时,这两个动作仍然会调度。

...
     repeat(),
     distinctUntileChanged((prev, curr) => prev.foo === curr.foo && prev.bar === curr.bar) // works but it fires both actions when either one changes
     switchMap((data) => [
       fromActions.updateFoo({foo: data.foo}),
       fromActions.updateBar({bar: data.bar}),
     ])
Run Code Online (Sandbox Code Playgroud)

我希望派遣updateFoodata.foo的变化和updateBar何时data.bar改变,知道data …

rxjs ngrx angular

5
推荐指数
0
解决办法
75
查看次数