Angular 如何从通常为非';t全局加载?
我喜欢使用Angular 如何从通常为非';t全局加载?,angular,typescript,ngrx,Angular,Typescript,Ngrx,我喜欢使用import仅在文件中包含实际功能,而使用我的tsconfig包含所有必要的类型 以下是我的应用程序中的一个示例: import { createReducer } from '@ngrx/store'; const initialState: State = ['a', 'b', 'c', 'd']; const reducer = createReducer( initialState, ); export function appReducer(state: State
import
仅在文件中包含实际功能,而使用我的tsconfig
包含所有必要的类型
以下是我的应用程序中的一个示例:
import { createReducer } from '@ngrx/store';
const initialState: State = ['a', 'b', 'c', 'd'];
const reducer = createReducer(
initialState,
);
export function appReducer(state: State, action: Action): State {
return reducer(state, action);
}
我在custom\u types/typings.d.ts
中声明了State
,并在tsconfig.compileOptions.typeRoots中包含了custom\u types
。这个很好用
操作
未定义。我可以在import
语句中包含Action
,但由于它只用于输入,而不用于功能,因此我更希望通过我的tsconfig
包含它
我尝试以几种方式在全球范围内包括@ngrx
打字:
- 将
@ngrx/store
添加到typeroot
- 将
@ngrx/store/index.d.ts
添加到typeroot
- 添加
import'@ngrx/store'
到custom\u type/typings.d.ts
但是编译器继续说,操作
是未定义的
如何在我的项目中全局包含所有@ngrx
打字?在自定义类型/全局类型中。d.ts
:
type Action=import(“@ngrx/store”)。操作
或
从“@ngrx/store”导入*作为存储
宣布全球{
类型Action=store.Action
}