Working on an existing typescript project. VS Code.
Create a new file in the server directory and get unique errors just on that file
this:
let path = require('path')
gives me the ole:
Cannot redeclare block-scoped variable 'path'.
whereas this is OK:
import * as path from "path"
Funnily enough, this
let fs = require('fs')
on its own also gives the same error,
but if I include the import * as path from "path"
above then that error goes away without touching it! Internal node modules are treated differently!
In many other files in the same project the
let fs = require('fs')
Gives no error at all
What is going on typescript?
I had a similar problem 2.5 years ago, and seems TS is still the same mystery box of configuration BS, now made even more opaque by VSC.
cannot redeclare block scoped variable (typescript)
this file is OK!
but in another file exact same code has the little squigglies!
but this magical combination is OK: