Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JS] Strong typing for builders #32086

Open
asfimport opened this issue Jun 5, 2022 · 0 comments
Open

[JS] Strong typing for builders #32086

asfimport opened this issue Jun 5, 2022 · 0 comments

Comments

@asfimport
Copy link

I've been obfuscating the builder types in my application to clear the editor issue highlights. However, it seems that the root cause is the way the StructRowProxy type is created. It seems that instead of or | the type is created with {}&{}, and this causes the editor to complain.

Let's look at an example.

interface ValueType extends arrow.TypeMap {
  time: arrow.TimestampMillisecond,
  value: arrow.Float64,
}
type Value = {
  time: number,
  value: number,
}
const children: (arrow.Field<arrow.DateMillisecond> | arrow.Field<arrow.Float64>)[] = [
  new arrow.Field('time', new arrow.TimestampMillisecond()),
  new arrow.Field('value', new arrow.Float64()),
]
const valueDataType: arrow.Struct<any> = new arrow.Struct<ValueType>(children) // forcing the Struct type here - without it the error message is the same and will just show <any> instead of <ValueType>
const builder: arrow.StructBuilder<ValueType, null | undefined> = arrow.makeBuilder({ type: valueDataType, nullValues: [null, undefined] })
...
const add = (value: Value) => builder.append(value)
/*
Argument of type 'Value' is not assignable to parameter of type 'StructRowProxy<ValueType>'.
  Type 'Value' is missing the following properties from type 'StructRow<ValueType>': toArray, toJSON, [kRowIndex], [kParent], [Symbol.iterator]
*/

To prevent editor error highlights, I have to obfuscate the builder type.

const builder: arrow.Builder = arrow.makeBuilder({ type: valueDataType, nullValues: [null, undefined] })

Reporter: Teodor Kostov

Note: This issue was originally created as ARROW-16750. Please see the migration documentation for further details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant