'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?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source