问题描述
我是NGXS的新手,找不到我的问题的答案。
是否可以在NGXS中强烈键入选择器,以便intellisense在Visual Studio Code中起作用,并且可以在编译时捕获错误?
解决方法
是的,您需要使用state token之类的东西。
基本原理是您需要在选择器中使用键入的内容,而不键入字符串,例如:
@Select(TODOS_STATE_TOKEN) good$: Observable<TodosStateModel>;
// Uncomment the next line,it won't compile
// @Select(TODOS_STATE_TOKEN) bad$: Observable<string[]>;
// this is typed as any still
@Select(TODOS_STATE_TOKEN) any$;