exported commonjs-function recognized as global function, others not?

Well the intellisense is borking up at one specific function, at most other functions it is showing the correct menu:


"insert const {...}  = require(...)" and "insert import {....}" - yet a very similar named function the context menu isn't showing up. Instead of that it shows "introduce local variable".


When I specify code highlighting I discover it considers the non working function to be a "global function"; yet I cannot find any reason why it would consider this (In a new project it actually works). I've tried clearing the cache/restarting already multiple times, but it keeps coming to the same conclusion. If I rightclick go to declaration it actually finds the implementation... Even without me importing that file (and it obviously fails during run).


Offending file - importing serverError works, serverReturnError doesn't. - Not sure how useful this is due to the fact it only happens in this specific project (which I cannot really share in public).

// @flow

function serverReturnError(res: ResponseTy, err: ErrorTy): void {
if (err.name === 'ForbiddenError') {
return res.forbidden({message: "Not enough rights", name: "Forbidden"});
} else if (err.name === 'UsageError') {
if (err.code === 'E_UNIQUE') {
err.detail.removed = (!!err.detail.removed:any);
return res.status(409).json({name: err.code, message: err.message, details: err.detail});
} else if (err.code === 'SESSION_FAULTY') {
return res.status(401).json({name: err.code, message: err.message});
} else if (err.code !== 'E_INVALID_CRITERIA') {
return res.status(400).json({name: err.code || err.name, message: err.message, details: err.detail});
} else if (err.name === 'AuthenticateFailure') {
return res.status(401).json({name: err.name, message: err.message});
} else if (err.name === 'InvalidOperation') {
return res.status(409).json({name: err.name, message: err.message});
} else if (err.name === 'NotFound') {
return res.status(404).json({name: err.name, message: err.message});
} if (err.name === 'AdapterError') {
return res.status(500).json({name: err.name, message: ''});
return res.status(500).json({name: err.name, message: ''});

module.exports = {
serverReturnError: serverReturnError,
serverError: serverReturnError,

Is there any better way I can debug why webstorm thinks the way it thinks?

1 comment
Comment actions Permalink

We can hardly help unfortunately unless we have a project the issue can be reproduced with.... Check if this 'global function` is defined elsewhere in your project, try disabling direct dependencies one by one to see if any of them is causing the issue, etc.


Please sign in to leave a comment.