jsoneditor icon indicating copy to clipboard operation
jsoneditor copied to clipboard

node.path property of onEditable missing in TypeScript definitions

Open MichaelPanwenjie opened this issue 2 years ago • 5 comments

The above solution is failed in angular 14 image

can you tell me how to implement custom_fields_editable in angular 14? very thanks.

Originally posted by @MichaelPanwenjie in https://github.com/josdejong/jsoneditor/issues/1377#issuecomment-1243374267

MichaelPanwenjie avatar Sep 12 '22 08:09 MichaelPanwenjie

the defination is 👍 as below: public onEditable: (node: JsonEditorTreeNode | {}) => boolean | { field: boolean, value: boolean };

node maybe {} sometimes, then it can not write as this: this.editorOptions.onEditable = function(node) {
if (!node.path) { // this line error return false; } };

image

Can you help me, thanks again!

MichaelPanwenjie avatar Sep 12 '22 08:09 MichaelPanwenjie

I guess the type definitions are not up to date with the actual code, I think they come from definitely typed?

So as a solution, it would be great if someone can create a PR to fix the TypeScript definitions. For the time being you can create up to date type definitions yourself, or add a line // @ts-ignore above it as a temporary workaround.

josdejong avatar Sep 12 '22 13:09 josdejong

I use switch "(( <any > node).field)" instead, it works now. Thanks a lot!

MichaelPanwenjie avatar Sep 12 '22 13:09 MichaelPanwenjie

👍

josdejong avatar Sep 12 '22 13:09 josdejong

Leaving this open for now, help would be welcome to fix the type definitions.

josdejong avatar Sep 12 '22 13:09 josdejong