小编Mic*_*ens的帖子

res.body 的 TypeScript 类型注释

我正在为我的应用程序使用打字稿node.js。我想说的res.body是类型personne。我试过这个:

router.post('/',(req: Request, res: Response) => {
   const defunt:PersoneModel = res.(<PersoneModel>body);
}
Run Code Online (Sandbox Code Playgroud)

我有这个模型:

export type PersoneModel = mongoose.Document & {
  nom: String,
  prenom: String,
}
Run Code Online (Sandbox Code Playgroud)

你能帮助我吗?

谢谢你。

javascript node.js express typescript

21
推荐指数
2
解决办法
2万
查看次数

类型“Dispatch&lt;RootState&gt;”不可分配给类型“Dispatch&lt;AnyAction&gt;”

你好,我正在尝试使用 Angular 来使用 redux。但当我尝试运行我的角度应用程序时,出现此错误消息:

ERROR in node_modules/@angular-redux/store/lib/src/components/ng-redux.d.ts(10,31): error TS2420: Class 'NgRedux<RootState>' incorrectly implements interface 'ObservableStore<RootState>'.
  Types of property 'dispatch' are incompatible.
    Type 'Dispatch<RootState>' is not assignable to type 'Dispatch<AnyAction>'.
      Type 'RootState' is not assignable to type 'AnyAction'.
node_modules/@angular-redux/store/lib/src/components/ng-redux.d.ts(37,33): error TS2344: Type 'RootState' does not satisfy the constraint 'Action<any>'.
node_modules/@angular-redux/store/lib/src/components/root-store.d.ts(18,24): error TS2344: Type 'RootState' does not satisfy the constraint 'Action<any>'.
node_modules/redux-observable/index.d.ts(32,56): error TS2344: Type 'S' does not satisfy the constraint 'Dispatch<AnyAction>'.
Run Code Online (Sandbox Code Playgroud)

我的减速机:

export default function reducer(state= {
  persones: [],
  selectedPersone: {}, …
Run Code Online (Sandbox Code Playgroud)

javascript redux redux-observable angular angular-redux

5
推荐指数
0
解决办法
1986
查看次数