我在 express typescript 中为应用程序使用什么类型
what type do I use for app in express typescript
我在 index.ts 中导出控制器,有人知道我在第 7 行将 app
作为参数传递时使用什么类型吗?
import userController from "./userController.js"
import getController from "./getController.js"
import productController from "./productController.js"
const exportArr = [userController, getController, productController]
export default (app: any) => {
exportArr.forEach(controller => controller(app))
}
确保安装快速类型 npm install @types/express
并在 .ts 文件中 import {Application} from 'express'
您的代码如下所示:
import { Application } from "express";
import userController from "./userController.js"
import getController from "./getController.js"
import productController from "./productController.js"
const exportArr = [userController, getController, productController]
export default (app: Application) => {
exportArr.forEach(controller => controller(app))
}
我在 index.ts 中导出控制器,有人知道我在第 7 行将 app
作为参数传递时使用什么类型吗?
import userController from "./userController.js"
import getController from "./getController.js"
import productController from "./productController.js"
const exportArr = [userController, getController, productController]
export default (app: any) => {
exportArr.forEach(controller => controller(app))
}
确保安装快速类型 npm install @types/express
并在 .ts 文件中 import {Application} from 'express'
您的代码如下所示:
import { Application } from "express";
import userController from "./userController.js"
import getController from "./getController.js"
import productController from "./productController.js"
const exportArr = [userController, getController, productController]
export default (app: Application) => {
exportArr.forEach(controller => controller(app))
}