【发布时间】:2021-12-31 14:05:19
【问题描述】:
我有 MySql2 数据库配置功能
const db = mysql.createConnection({
host: process.env['SQL_HOST'],
user: process.env['SQL_USER'],
password: process.env['SQL_PASSWORD'],
});
我收到此错误:
No overload matches this call.
Overload 1 of 2, '(connectionUri: string): Connection', gave the following error.
Argument of type '{ host: string | undefined; user: string | undefined; password: string | undefined; }' is not assignable to parameter of type 'string'.
Overload 2 of 2, '(config: ConnectionOptions): Connection', gave the following error.
Argument of type '{ host: string | undefined; user: string | undefined; password: string | undefined; }' is not assignable to parameter of type 'ConnectionOptions' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
Types of property 'user' are incompatible.
Type 'string | undefined' is not assignable to type 'string'.
Type 'undefined' is not assignable to type 'string'.
有人遇到这个错误吗?
【问题讨论】:
标签: mysql node.js typescript