constantin-p / cp-react-tree-table

A fast, efficient tree table component for ReactJS.
https://constantin.software/cp-react-tree-table
MIT License
94 stars 27 forks source link

No exports for Column API and Props #17

Closed altavir closed 5 years ago

altavir commented 5 years ago

I am not sure, I am doing everything correctly, but It is not seem to be possible to programmatically create a Column, or its props, or props for TreeTable. Probably, when using from pure JS it does not matter since you use dynamic object creation and it does not care for those types, but there should be some problems with TS similar to what I see with Kotlin-JS.

constantin-p commented 5 years ago

Hi @altavir,

Can you run the typescript demo from demo-ts/demo-ts and reproduce the error?

From demo-ts branch:

cd demo-ts
yarn
yarn start

If the demo is not working can you share a project where I can reproduce the error ?

altavir commented 5 years ago

I do not use TypeScript, so it does not help me. The problem is that in your example JSX cheats the type system. You do not have import for Column, yet you use it in the code as a tag. I believe under the hood, TS just creates dynamic reference based on tag name. It won't work it you are writing type-safe program.

The same situation is with Props classes. They are not accessible outside your module, so I can't create or manipulate them. In JSX you do not explicitly create them, but I do not understand how you can work with them without JSX. The types are presented in typing, but are not exported.

I have very little experience with JS/TS, so maybe I am doing something wrong.

constantin-p commented 5 years ago

Hi @altavir,

Column is a static field to TreeTable. Both the documentation and the demo refer to it as TreeTable.Column (JSX, docs).

I've updated the typescript demo with an example written without JSX. Can you please try this one and tell me if you can reproduce the error?

It would be really helpful to have a sample project where I can reproduce the errors, otherwise I can only guess the cause.

NOTE: Is TypeScript used by Kotlin-JS in any form? If not, how is Kotlin-JS inferring types?

altavir commented 5 years ago

Kotlin-JS uses TS bindings to generate its own bindings. Your example still uses non-type-safe creation for properties, but there is a workaround. After I used converted TS bindings (from your d.ts) instead of my old manual ones, I do not get errors anymore. I still see only blanck page, but I think that now the problem is in that I do something wrong with React, not with the library.