-
Notifications
You must be signed in to change notification settings - Fork 118
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
Typescript documentation, test or demo case #64
Comments
I know this is not what you're requesting, but check if this file helps in any way: https://github.com/joaonuno/tree-model-js/blob/master/types/tree-model-tests.ts |
Hey @Kevin-at-Navigram, thanks for opening the issue. Would you prefer existing (and some more ??) readme examples to be also available in typescript? Just as a quickstart, this is how you create simple tree (copied from tests file): interface TestModel {
name: string;
}
const tree = new TreeModel({});
const root = tree.parse<TestModel>({ name: 'a', children: [{ name: 'b' }, { name: 'c' }] }); It is also possible to type the input object (to parse) itself, instead of providing the generic type to const data : TreeModel.Model<TestModel> = { name: 'a', children: [{ name: 'b' }, { name: 'c' }] };
const root = tree.parse(data); |
He, I really appreciate this quick feedback. I did actually use the tests.ts file as a reference, but I thought it would be a nice addition to the website and documentation. I've added it myself to the readme: |
Since about a year, your project has Typescript support using a types.d.ts file.
Now, I was wondering if you could provide some basic info on how to set up a simple tree with a few nodes. I'm no expert with Typescript myself so I was looking for some documentation, but I found very little. Perhaps that @bendtherules can chip in as he was part of the original implementation team.
The text was updated successfully, but these errors were encountered: