-
Notifications
You must be signed in to change notification settings - Fork 0
typescript collections #18
Comments
报错报错: 无法重新声明块级作用域变量
|
Vue.js
interface commit {
commit: (info: string, payload?: any) => void
}
export const doSomething: (commit: commit) => void = ({ commit }) => {
commit('doWhatYouWant')
} |
Node.js
yarn add @types/node -D 在安装 {
"compilerOptions":{
+ "types": [
+ "node"
+ ]
}
}
const http = require('http')
import { ServerResponse, ServerRequest } from 'http'
const PORT = process.env.PORT || 8800
const server = http.createServer((req: ServerResponse, res: ServerRequest) => {
// ...
})
server.listen(PORT) |
|
类型别名 ——
|
使用技巧
定义时
确定类型,而在运行时
确定类型。泛型的出现允许我们跟踪函数内的变量类型信息。注:在泛型的类型未确定时,不能调用有关参数的属性(即泛型约束)。
The text was updated successfully, but these errors were encountered: