Just starting out with Typescript. Made a simple project with a single index.ts file which i want to utilize node-fetch
. So my code looks like
index.ts
var fetch = require('node-fetch');
fetch("https://www.google.com")
When running tsc index.ts
i get the following
../../../../.nvm/versions/node/v10.14.0/lib/node_modules/typescript/lib/lib.dom.d.ts:17778:18 - error TS2300: Duplicate identifier 'fetch'.
My understanding
Looks like the typescript module installed globally includes types for fetch. I have two questions with regards to this
Questions
- a) How can I make it so that
tsc
only looks at my current directory downards for types? - b) If i do nothing, what directories is
tsc
looking in in order to determines types? - c) Any obvious flaws to my approach a) worth mentioning?
EDIT: I've also added https://www.npmjs.com/package/@types/node-fetch in hope it will take precedence but no joy