javascript - 在通常放置 var 的地方使用 type 关键字是什么?

标签 javascript typescript redux

type StoreCreator = (reducer: Reducer, preloadedState: ?State) => Store

我从来没有遇到过这个。什么类型的?

作为一个不相关的跟进,什么是 ?State

最佳答案

type 用于 typescript 中的类型别名。例如:

type StringOrNumber = string | number;  

A type alias serves as an alias for the type specified in the type alias declaration. Unlike an interface declaration, which always introduces a named object type, a type alias declaration can introduce a name for any kind of type, including primitive, union, and intersection types.

在这里您可以找到文档:https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#3.10

关于javascript - 在通常放置 var 的地方使用 type 关键字是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38877424/

相关文章:

javascript - 无法让 spyOn 测试正常工作 - Angular

javascript - 如何在 jQuery 中使用 mousedown 控制计时器?

javascript - 与无效合并运算符相反

javascript - jQuery 中的 .bind ('click' ) 和 .click() 有什么区别?

typescript - 如何在 Aurelia Validation 中为给定的 customRule 创建自定义方法

reactjs - 如何在 ASP.NET Core React/Redux 模板项目中更新我的 React 版本?

javascript - 使用 componentWillRecieveProps 调用类组件的 api

reactjs - array.includes() 不是函数

javascript - 回调函数未按预期工作

javascript - “你接受条款和条件吗?”关于登录表单例份验证 MVC3