You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ks...@apache.org on 2019/01/29 16:26:29 UTC
[arrow] branch master updated: ARROW-4395: [JS] Fix ts-node error
running bin/arrow2csv
This is an automated email from the ASF dual-hosted git repository.
kszucs pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new eedda2f ARROW-4395: [JS] Fix ts-node error running bin/arrow2csv
eedda2f is described below
commit eedda2fb5fc88d57e5d72719a8d98662aba6334d
Author: ptaylor <pa...@me.com>
AuthorDate: Tue Jan 29 17:25:58 2019 +0100
ARROW-4395: [JS] Fix ts-node error running bin/arrow2csv
`ts-node` type-checking is inaccurate, because it only checks files that are touched by node's `require()` calls, leading to errors like this:
```sh
$ cat test/data/cpp/stream/simple.arrow | ./bin/arrow2csv.js
/home/ptaylor/dev/arrow/js/node_modules/ts-node/src/index.ts:228
return new TSError(diagnosticText, diagnosticCodes)
^
TSError: тип Unable to compile TypeScript:
src/vector/map.ts(25,57): error TS2345: Argument of type 'Field<T[string | number | symbol]>[]' is not assignable to parameter of type 'Field<T[keyof T]>[]'.
Type 'Field<T[string | number | symbol]>' is not assignable to type 'Field<T[keyof T]>'.
Type 'T[string] | T[number] | T[symbol]' is not assignable to type 'T[keyof T]'.
Type 'T[symbol]' is not assignable to type 'T[keyof T]'.
Type 'DataType<Type, any>' is not assignable to type 'T[keyof T]'.
Type 'symbol' is not assignable to type 'keyof T'.
Type 'symbol' is not assignable to type 'string | number'.
```
The solution is to update ts-node and run it in transpile-only mode.
Closes https://issues.apache.org/jira/browse/ARROW-4395
Author: ptaylor <pa...@me.com>
Author: Paul Taylor <pa...@me.com>
Closes #3504 from trxcllnt/js/fix-tsnode-typecheck and squashes the following commits:
066327f0 <Paul Taylor> Merge branch 'master' into js/fix-tsnode-typecheck
89b2a7cc <ptaylor> fix ts-node error running bin/arrow2csv
---
js/bin/arrow2csv.js | 3 ++-
js/src/vector/map.ts | 2 +-
js/src/vector/struct.ts | 2 +-
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/js/bin/arrow2csv.js b/js/bin/arrow2csv.js
index afd5973..0e446fa 100755
--- a/js/bin/arrow2csv.js
+++ b/js/bin/arrow2csv.js
@@ -21,7 +21,8 @@ const Path = require(`path`);
const here = Path.resolve(__dirname, '../');
const tsnode = require.resolve(`ts-node/register`);
const arrow2csv = Path.join(here, `src/bin/arrow2csv.ts`);
+const env = { ...process.env, TS_NODE_TRANSPILE_ONLY: `true` };
require('child_process').spawn(`node`, [
`-r`, tsnode, arrow2csv, ...process.argv.slice(2)
-], { cwd: here, env: process.env, stdio: `inherit` });
+], { cwd: here, env, stdio: `inherit` });
diff --git a/js/src/vector/map.ts b/js/src/vector/map.ts
index 060b9ee..27c51a6 100644
--- a/js/src/vector/map.ts
+++ b/js/src/vector/map.ts
@@ -22,7 +22,7 @@ import { DataType, Map_, Struct } from '../type';
export class MapVector<T extends { [key: string]: DataType } = any> extends BaseVector<Map_<T>> {
public asStruct() {
- return Vector.new(this.data.clone(new Struct(this.type.children)));
+ return Vector.new(this.data.clone(new Struct<T>(this.type.children)));
}
// @ts-ignore
private _rowProxy: Row<T>;
diff --git a/js/src/vector/struct.ts b/js/src/vector/struct.ts
index ca228ff..4ad57ff 100644
--- a/js/src/vector/struct.ts
+++ b/js/src/vector/struct.ts
@@ -22,7 +22,7 @@ import { DataType, Map_, Struct } from '../type';
export class StructVector<T extends { [key: string]: DataType } = any> extends BaseVector<Struct<T>> {
public asMap(keysSorted: boolean = false) {
- return Vector.new(this.data.clone(new Map_(this.type.children, keysSorted)));
+ return Vector.new(this.data.clone(new Map_<T>(this.type.children, keysSorted)));
}
// @ts-ignore
private _rowProxy: Row<T>;