How is IntelliJi detecting objects attributes



I have this Nodejs express code...'/user', async (req, res) =>
console.log("save user");
if(AccessManager.checkAccess(req, res, ["user_edit"]))
const session = req.session;
if (session && session.user)
const user = req.body.user;

await dbCon.queryDB(`BEGIN`, null);

await dbCon.queryDB(
`INSERT INTO users (sso, name, language, active, last_update_date, last_update_by)
VALUES ($1, $2, $3, $4, NOW(), $5)
ON CONFLICT (sso) DO UPDATE SET name = $2, language = $3, active = $4, last_update_date = NOW(), last_update_by = $5`,
[user.sso,, user.language,, session.user.sso]);

Intelliji is here giving a warning

"unresolved variable sso" for the user.sso as the first insert value

but not for name, language and active.

Why are these attributes ok, but sso not? I would understand if it would find no attributes because its coming from a JSON object from the POST body, or if it doesn't care about all. But only one is not ok that's what I don't understand.


评论操作 固定链接

The IDE indeed can't resolve the fields using static code analysis as this data is only available in runtime; so it tries 'week' resolving - props are resolved from the project index by name only. You must have the name, etc. fields defined somewhere in your code and/or libraries...

 You can let the IDE know what your runtime data looks like using JSDoc annotations -this would help to avoid this `weak` resolving. See, for possible workarounds