tsdjs / tsd

Check TypeScript type definitions
MIT License
2.36k stars 68 forks source link

Add support for self-referencing #194

Open RebeccaStevens opened 1 year ago

RebeccaStevens commented 1 year ago

I can't seem to get self-referencing to work with tsd. Here's the basics of my setup.

// my-test.test-d.ts
import { expectType } from "tsd";

import { foo } from "my-package";      // <-- tsd cannot resolve either of these imports,
import { bar } from "my-package/bar";  // <-- but typescript itself can.

// ...
// package.json
{
  "name": "my-package",
  "type": "module",
  "exports": {
    ".": {
      "development": "./src/index.ts",
      "types": "./dist/index.d.mts",
      "import": "./dist/index.mjs",
    },
    "./bar": {
      "development": "./src/bar.ts",
      "types": "./dist/bar.d.mts",
      "import": "./dist/bar.mjs",
    }
  }
}
// tsconfig.json
{
  "compilerOptions": {
    "strict": true,
    "customConditions": ["development"] // If tsd is to run on the compiled .d.ts files, then tsd probably need to be configure NOT to use this (all other tools do need it)
  }
}