Firebase Functions 6.0.1的TypeScript导入及UserRecord类型获取
Firebase Functions 6.0.1 中 TypeScript 导入语法及 UserRecord 类型的正确用法
可以继续使用 TypeScript 的
import语法,只是6.x版本的模块结构与3.x不同,需要调整导入路径。核心 functions 模块的正确导入方式:
// 指定v1版本(推荐,避免版本迭代导致的兼容问题) import * as functions from "firebase-functions/v1"; // 或不指定版本(会使用默认的最新稳定版本) import * as functions from "firebase-functions";注意:需确保项目配置支持ES模块,比如在
package.json中设置"type": "module",或在tsconfig.json中将module选项配置为ESNext/Node16等兼容ES模块的值。UserRecord 类型的正确导入方式:
6.x版本不再通过内部lib/providers/auth路径暴露类型,需从公开的auth子模块导入:// 指定v1版本 import { UserRecord } from "firebase-functions/v1/auth"; // 或不指定版本 import { UserRecord } from "firebase-functions/auth";
内容的提问来源于stack exchange,提问作者jmc42
相关产品推荐
相关产品推荐

