为何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
相关产品推荐
相关产品推荐

