Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

237
Views
How to reference a type declaration file for Javascript in another folder?

I am trying to write typescript declaration files for my Javascript files, but wishing to store them in a separate folder:

src/
  types/
    foo.d.ts
  foo.js
// foo.d.ts
export function foo(bar): number
// foo.js
export const foo = bar => bar.length
// The type suggestion when calling foo from another file 
foo() //(alias) const foo: (bar: any) => any

Now when I import and call foo in other files, the type suggestion doesn't work. When I do something like this before, I had to put the .d.ts file in the same directory as the JS file. I tried adding /// <reference/> but it didn't help or I have done it incorrectly. I am not trying to export the declaration files, and it is purely for helping me during development. How can I do this?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!