I like to use the import
statement only for importing actual functionality in a file, and I rely on my tsconfig
to include all necessary types.
Here is an example of a reducer in my application:
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);
}
I have defined State
in custom_types/typings.d.ts
, and have included custom_types
in
tsconfig.compileOptions.typeRoots
. This setup works well for me.
The Action
is currently undefined. Even though I could add Action
in the import
statement, since it is used solely for typing purposes, I would rather include it through my tsconfig
.
I have attempted various ways to globally include @ngrx
typings:
- Adding
@ngrx/store
totypeRoots
- Adding
@ngrx/store/index.d.ts
totypeRoots
- Adding
import '@ngrx/store'
tocustom_types/typings.d.ts
However, the compiler keeps indicating that Action
is undefined.
What is the best way to globally include all @ngrx
typings in my project?