由于我们将代码库升级到 Angular 11,我在 VSCode 中收到了这条消息:
某些语言功能不可用。要访问所有功能,请
strictTemplates在angularCompilerOptions.来源:Angular 语言服务(扩展)
带有“打开 tsconfig.json”的链接,如下所示:
我期待启用此功能并享受新功能。但我想抽出时间来做和测试这个。就目前而言,VSCode 中的弹出窗口一直不断出现,这很烦人和分心。
我如何(现在)抑制此消息,最好是针对我当前的工作区?
angular.ng-template) v11.2.3我在理解 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)
如果我更改c为somethingElse:
const a: abcd = {
a:123,
somethingElse:234 // Error on this line
};
Run Code Online (Sandbox Code Playgroud)
它给了我:
输入'{一个:数字;别的东西:数字;}' 不能分配给类型 'abcd'。对象字面量只能指定已知属性,并且类型“abcd”中不存在“somethingElse”。(2322)
我有一个像这样的 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)
我怎样才能派遣updateFoo和updateBar仅当data.foo或data.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)
我希望派遣updateFoo时data.foo的变化和updateBar何时data.bar改变,知道data …