How to modify variable js type through a js function
Answered
for example:
let arr=[]
arr.push({name:1})
I want to add [{name: 1}] jstype for arr
Make arr[0].<caret> will completion name property
Which extension point should I use?
Please sign in to leave a comment.
Hi,
I'm sorry, but your use case is unclear. Do you want to add `{name: 1}` to array automatically? If yes, then how? By invoking something?
Or is it only about completing name, when such an object with name property exists in array (no adding is needed).
Yes, but i don't know which api to invoke
Hi,
I still don't understand which option you mean. I gave you two options to choose from, and you answered "yes".
Please describe the use case in detail (it is required when creating any topic on the forum).
option 1 , In short, I want to add additional JSType for qualified JSExpression
Hi,
If you want to insert an element to the array, then you can do it by modifying code PSI. See:
https://plugins.jetbrains.com/docs/intellij/modifying-psi.html
Sorry, my English is not good,I found a similar code https://github.com/tomblachut/svelte-intellij/blob/599259a5cb861475cb1cbbd42d5ef7bd6c96805d/src/main/java/dev/blachut/svelte/lang/SvelteFrameworkHandler.kt, and I will try to program