I'm new to Node.JS and VSCode.
I'm coding Firestore Cloud Function. I want to use a constant file to help me make sure I don't make type-errors.
I have followed the suggestion here. But the VSCode code helper doesn't show the constants I have defined there.
In constants.js
:
function define(name, value) {
Object.defineProperty(exports, name, {
value: value,
enumerable: true
});
}
define('kFieldName', 'name');
define('kFieldAge', 'age');
Then in index.js
:
var constants = require("./constants");
exports.createUserDocuments = functions
.runWith({ memory: "128MB", timeoutSeconds: 30 })
.auth.user().onCreate((user) => {
// As I type constants.kFieldName here code helper does not show the corresponding definitions
});
What I hope to see is as I type the keyword such as constants.kField
then the Code Helper should show suggestions kFieldName
and kFieldAge
just like in Android Studio.
How do I make VSCode's code helper to show the definitions I wrote in constants.js
?
Is it because I miss something in regards to exports and importing the files?
Thank you!