Typescript types broken using `withColumn`/`withColumns`/`select` methods
Have you tried latest version of polars?
- [yes]
What version of polars are you using?
"nodejs-polars": "~0.18.0",
What operating system are you using polars on?
Mac OS Sequoia 15.3.2
What node version are you using
20.17.0
Describe your bug.
Typescript types are not correctly managed by built-in methods.
What are the steps to reproduce the behavior?
Example using withColumn
Example using select
What is the actual behavior?
As seen in the screenshots above, the types are completely wrong in both cases but in slightly different ways. withColumn totally breaks all the types, whereas select just doesn't reflect the updated types ('new_age' is missing).
What is the expected behavior?
Types should be correctly set/inferred by polars' built-in methods.
@scarf005 Would you know how to fix this? Thx
@Bidek56 the issue is due to Expressions (pl.col) not being generic.
also, it'd be very hard (if not impossible) to infer correct type as we have no info on what age is before withColumn/select is called:
const age = pl.col("age")
// ^? const c: pl.Expr<{ "age": pl.Series<unknown> }>
const mul = pl.col("age").mul(2)
// ^? const mul: pl.Expr<{ "age": pl.Series<unknown> }>
@Bidek56 the issue is due to Expressions (pl.col) not being generic.
also, it'd be very hard (if not impossible) to infer correct type as we have no info on what
ageis before withColumn/select is called:const age = pl.col("age") // ^? const c: pl.Expr<{ "age": pl.Series
}> const mul = pl.col("age").mul(2) // ^? const mul: pl.Expr<{ "age": pl.Series
}>
I see, thank you. Would there be any way to extend the API to pass on the required type data perhaps?
Also, any guidance on where I should be looking in the repo for this stuff? Would be keen to experiment :)
This is the line of code.
Hey! Is this solved?