0

I have been trying to write constants in one file and using it on another file in ReactNative. But found that VSCode is not able to suggest the values of one hash object when importing with module.export = {} structure, but it is working fine when I'm using export const ... model. I totally got confused by this.

For eg:

// file one
const someObject = {
    cValueOne: 1,
    cValueTwo: 2
};

module.exports = {
    someObject,
}


// file two

export const someObject = {
    cValueOne: 1,
    cValueTwo: 2
};

I can import both of them in another file as follows:

// usage file

import {
     someObject,
} from '.../path/.../constants';


let a = someObject.cValueOne;

If I'm writing the file one modal export, then VSCode is not suggesting the values of someObject where if it is done as in file two, then VSCode is able to suggest it.

What could be the reason?

Swalah Amani
  • 1
  • 1
  • 2

1 Answers1

1

Welcome to the Stackoverflow community first.

I understand that this was your first Question on Stackoverflow, and I appreciate you doing that.

But You can find your answers in a previous thread which has a lot of discussions and answers already given, that would be more helpful to you.

Here's the link: Difference between "module.exports" and "exports" in the CommonJs Module System

Happy Coding!

Regards
Ashutosh Kumar

Ashutosh Kumar
  • 830
  • 7
  • 19
  • Thank you @ashutoshkumar for answering my question and sharing the link. But what about the VSCode suggestion part? – Swalah Amani May 21 '20 at 10:57
  • @SwalahAmani ok! So I was trying to reproduce your problem on the Visual Studio Code, and I did everything exactly as stated above, but I was able to get suggestions for both the cases. – Ashutosh Kumar May 21 '20 at 11:28