You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

为何TypeScript中pl.Datetime返回父类pl.DataType而非子类?

Node.js Polars 类型不匹配问题

以下代码会触发 TypeScript 类型错误:

import * as pl from "nodejs-polars"

const foo: pl.Datetime = pl.Datetime("ms")

错误提示为:

Property 'timeUnit' is missing in type 'DataType' but required in type 'Datetime'.

实际调用 pl.Datetime("ms") 时,返回的是父类型 pl.DataType,而非预期的子类 pl.Datetime,这导致了类型不匹配的问题。

内容的提问来源于stack exchange,提问作者scarf

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.16 08:29:52