#VScode TSC fails to give errors for undefined variables

50 messages · Page 1 of 1 (latest)

vague gulch
severe sigil
#

looks like it's been declared to ts, do you have any excess d.ts files for example?

#

maybe check Right Click > Go to Definition

hollow cove
#

or perhaps vscode is missing a tsconfig

vague gulch
vague gulch
vague gulch
severe sigil
#

or anything else related?

vague gulch
#

Yes, refrences are there. wait one

#

Also another weird thing is that ts server things i am redeclaring imports from libs? when the original imports it refers to are in different files

severe sigil
hollow cove
#

are the files missing imports and exports?

severe sigil
#

do you have esm imports/exports there

hollow cove
#

*do the files have no imports and no exports

vague gulch
#

I am using the default tsconfig, "noImplicitAny" set to true

#

wait one

#

Ok so the redclaration is a topic for another thread, i will get the info you asked in a second

vague gulch
severe sigil
#

if you're doing this in node, then you should already have imports/exports between everything?

vague gulch
#

I was using commonjs before this

#

module.exports/require

severe sigil
#

those still are imports/exports, just not esm imports/exports

vague gulch
#

I though you were refering to esm imports/exports only as imports/exports

severe sigil
#

just to be clear, you can still use cjs with ts, just that ts imports/exports look like esm imports/exports

vague gulch
#

Right.

vague gulch
hollow cove
#

anything

#

if there are no imports and exports, TS thinks the file isn't a module

#

and so all its variables are implicitly global

vague gulch
#

the file giving the issue has both

hollow cove
#

ah

#

weird, if it has either exports or imports it shouldn't have an issue

vague gulch
#

i changed the only file defining path and fs from cjs to esm and them seemed to reolve the issue

#

although i would like to understand it

#

Is there a tsconfig option to disable this?

severe sigil
#

it's not exactly that you changed to esm, it's that you changed to the esm-like ts imports/exports which ts sees and understands is a module

lunar root
# vague gulch module.exports/require

i think there's some confusion going on here but if by this message you meant you were literally writing stuff like require() and module.exports = in your .ts files then there "are no imports and exports" according to TS

#

so the file wasn't being treated as a module

#

if you instead were writing import ... and export ... statements and letting tsc compile them down to require() and module.exports = , then that's different story

lunar root
vague gulch
#

Yeah, I mentioned it above, some of my files still had those as I was shifting from js to ts.

lunar root
#

ah, it wasn't clear if "changing from cjs to esm" meant you were changing the module setting in the compiler or rewriting your code manually

vague gulch
#

Well I learned a nice thing today, about non module stuff being set to global

lunar root
unkempt kestrel