Can we autocomplete variables/objects for JS?
So I have an JSON file that in the build process then will be parsed to the complex JS object and will be set to the "settings" variable.
e.g.
File:
{"userSettings" : {"defaultTimeout" : 10000, "defaultNode" : "basicNode"}}
So the variable use will be:
let resultTimeout = this.settings.userSettings.defaultTimeout + 1000;
So can we somehow get this file parsed so in development the whole structure of the object will be autocompleted?
Because right now I have to look into the file each time to provide the needed structure to use in the code development...
Please sign in to leave a comment.
This should work if the JSON is explicitly required in your code, like
But if the file is only loaded in runtime (received through the ajax call, etc.), there is no way for the IDE to resolve the keys during static code analysis. You can let the IDE know what your runtime data looks like using JSDoc annotations. See https://youtrack.jetbrains.com/issue/WEB-17419#comment=27-1058451, https://intellij-support.jetbrains.com/hc/en-us/community/posts/206349469-disable-unresolved-variable-on-json-object-received-by-ajax-call for possible workarounds