In VSCode when exporting functions: “Individual declarations must be all exported or all local”

I recently upgraded to Visual Studio Code 0.5.0 and some new errors cropped up that weren’t there before.

I have a bunch of functions that are declared locally and then exported. Since the upgrade, however, hovering over each of the local function names produces the error Individual declarations in merged declaration functionName must be all exported or all local.

This is an example local function that is exported.

var testParamsCreatorUpdater = function (lTestParams, creatorID){
    lTestParams.creator = creatorID;
    return lTestParams;
module.exports.testParamsCreatorUpdater = testParamsCreatorUpdater;

I realize I can change this to…

module.exports.testParamsCreatorUpdater = function (lTestParams, creatorID){
    lTestParams.creator = creatorID;
    return lTestParams;

And prepend module.exports. to every testParamsCreatorUpdater() call.

But why is the first snippet wrong? As I understand it, require() makes everything in the module.exports object available to whatever required it.

I had this issue in Webstorm , I Restarted it and it went away

I think at a JavaScript level it cannot differentiate between:

var testParamsCreatorUpdater = ...


module.exports.testParamsCreatorUpdater = ...

as the names are the same. I got the exact same error (leading me to this post) in TypeScript when I tried this:

import { AuditService } from '../services/audit.service';
import { Audit } from '../models/audit.model';

    selector: 'audit',
    templateUrl: './audit.component.html',
export class Audit {
    constructor(private auditService: AuditService) {

So TypeScript did not like that I imported a module called Audit and exported a class also called Audit.

You are exporting a variable in this file which is imported in the same file module (locally).

I think it’s related to the feature of merged declaration for TypeScript ref. I have not done the detailed research for Typescript but it seems that it can include Javascript in the Typescript file.

Read More:   D3 javascript Difference between foreach and each

I guess the way testParamsCreatorUpdater was declared in the Javascript was detected to be error by VSCode because it thinks the two declarations cannot be merged.

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Similar Posts