I have two files, index.ts and app.ts. The index.ts file defines two objects, profile and person. profile is not exported, but it is logged to the console using console.log(profile["age"]) and console.log(profile["education@"]). person is exported as the default export.
In app.ts, I import person using import person from "./index.js"; and log person.name to the console using console.log(person.name);. I compile the TypeScript code using tsc and then run the resulting JavaScript code using node app.js.
index.ts
const profile = {
name : "Noman..",
age : 25,
"education@": "BSSEs",
}
const person = {
name : "Noman",
age : 24,
"education@": "BSSE",
}
console.log(profile["age"]);
console.log(profile["education@"]);
export default person;
app.ts
import person from "./index.js";
console.log(person.name);
The output is
My question is, why am I seeing console.log output for profile properties in my app.js output even though I have not exported the profile object from index.ts? Also, how can I prevent this console output from appearing in my app.js output?
I have two files,
index.tsandapp.ts. Theindex.tsfile defines two objects,profile and person. profile is not exported, but it is logged to the console usingconsole.log(profile["age"])andconsole.log(profile["education@"]). person is exported as the default export.In app.ts, I import person using import person from
"./index.js";and logperson.nameto the console usingconsole.log(person.name);. I compile the TypeScript code using tsc and then run the resulting JavaScript code using node app.js.index.ts
app.ts
The output is
My question is, why am I seeing
console.logoutput for profile properties in myapp.jsoutput even though I have not exported the profile object fromindex.ts? Also, how can I prevent this console output from appearing in myapp.jsoutput?