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
}