Where should I place custom .d.ts files?

Use paths instead of typeRoots

  • https://github.com/Microsoft/TypeScript/issues/22217#issuecomment-369783776
  • https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping

“typeRoots” is meant for global code. i.e. something that is
declared in the global namespace, and you want to include it. For
modules, they have their own scope, all you need is path mapping..
something like:

{
    "compilerOptions": {
        "target": "es2017",
        "baseUrl": "./",
        "paths": {
            "*": [ "src/client/@custom_types/*"]
        }
    },
    "exclude": [ "node_modules", "src/client/@custom_types", ... ]
}

Note: baseUrl is required with paths, and you probably also want to add the dir to exclude.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)