Repository: TypeScript
Issue: No Quick Fix support to implement an interface when internal package "types" point to source files 
Labels: Bug,Help Wanted

### Demo Repo

https://github.com/akwodkiewicz/ts-no-quick-fix

### Which of the following problems are you reporting?

Something else more complicated which I'll explain in more detail

### Demonstrate the defect described above with a code sample.

```
import { contract } from "foobar-contracts";
import { RpcService } from "rpc-lib";

class Server implements RpcService<typeof contract> {}
//    ^^^^^^
```

Implementing the `RpcService<typeof contract>` interface in the service is suggested as a Quick Fix in VSCode if the `foobar-contracts`' `package.json#types` point to `d.ts` files, **but not when `package.json#types` points to `.ts` source files.**


### Run `tsc --showConfig` and paste its output here

## faulty-app
```
{
    "compilerOptions": {
        "module": "nodenext",
        "moduleResolution": "nodenext",
        "lib": [
            "esnext"
        ],
        "outDir": "./dist",
        "isolatedModules": true,
        "experimentalDecorators": true,
        "strict": true,
        "noImplicitReturns": true,
        "noImplicitOverride": true,
        "noUnusedLocals": true,
        "noUnusedParameters": true,
        "noEmitOnError": true,
        "skipLibCheck": true,
        "allowSyntheticDefaultImports": true,
        "esModuleInterop": true,
        "resolveJsonModule": true,
        "useUnknownInCatchVariables": false,
        "noUncheckedIndexedAccess": true,
        "verbatimModuleSyntax": false
    },
    "files": [
        "./src/app.ts"
    ],
    "include": [
        "src"
    ],
    "exclude": [
        "dist"
    ]
}
```

## foobar-contract
```
{
    "compilerOptions": {
        "module": "nodenext",
        "moduleResolution": "nodenext",
        "lib": [
            "esnext"
        ],
        "outDir": "./dist",
        "declaration": true,
        "declarationDir": "./dist",
        "isolatedModules": true,
        "experimentalDecorators": true,
        "strict": true,
        "noImplicitReturns": true,
        "noImplicitOverride": true,
        "noUnusedLocals": true,
        "noUnusedParameters": true,
        "noEmitOnError": true,
        "skipLibCheck": true,
        "allowSyntheticDefaultImports": true,
        "esModuleInterop": true,
        "resolveJsonModule": true,
        "useUnknownInCatchVariables": false,
        "noUncheckedIndexedAccess": true,
        "verbatimModuleSyntax": false
    },
    "files": [
        "./src/contract.ts",
        "./src/index.ts"
    ],
    "include": [
        "src"
    ],
    "exclude": [
        "dist",
        "dist"
    ]
}
```

### rpc-lib
```
{
    "compilerOptions": {
        "target": "es2022",
        "module": "nodenext",
        "moduleResolution": "nodenext",
        "lib": [
            "esnext"
        ],
        "outDir": "./dist",
        "declaration": true,
        "declarationDir": "./dist",
        "isolatedModules": true,
        "experimentalDecorators": true,
        "strict": true,
        "noImplicitReturns": true,
        "noImplicitOverride": true,
        "noUnusedLocals": true,
        "noUnusedParameters": true,
        "noEmitOnError": true,
        "skipLibCheck": true,
        "allowSyntheticDefaultImports": true,
        "esModuleInterop": true,
        "resolveJsonModule": true,
        "useUnknownInCatchVariables": false,
        "noUncheckedIndexedAccess": true,
        "verbatimModuleSyntax": false
    },
    "files": [
        "./src/index.ts"
    ],
    "include": [
        "src"
    ],
    "exclude": [
        "dist",
        "dist"
    ]
}
```

### Run `tsc --traceResolution` and paste its output here

Will provide separately (the comment is too long)

### Paste the `package.json` of the *importing* module, if it exists

```
{
  "name": "faulty-app",
  "type": "commonjs",
  "main": "./dist/app.js",
  "scripts": {
    "build": "rm -rf dist && tsc"
  },
  "dependencies": {
    "foobar-contracts": "workspace:*",
    "rpc-lib": "workspace:*"
  },
  "devDependencies": {
    "typescript": "5.2.2"
  }
}
```

### Paste the `package.json` of the *target* module, if it exists

```
{
  "name": "foobar-contracts",
  "type": "commonjs",
  "main": "./dist/index.js",
  "types": "./src/index.ts", // <- this causes the issue, "./dist/index.d.ts" works fine
  "scripts": {
    "build": "rm -rf dist && tsc"
  },
  "devDependencies": {
    "rpc-lib": "workspace:*",
    "typescript": "5.2.2"
  },
  "peerDependencies": {
    "rpc-lib": "workspace:*"
  }
}
```

### Any other comments can go here

Some more info:


### Visual Studio Code

Version: 1.85.1
Commit: 0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2
Date: 2023-12-13T09:48:16.874Z
Electron: 25.9.7
ElectronBuildId: 25551756
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Darwin arm64 23.1.0

-----



It's important to notice that it seems that the compiler manages to find the errors with the `.ts` files, it's just that the IDE experience is degraded.

Why is it even important to use the source files in `package.json#types`?

If we were able to **not** rely on the declaration files, we would be able to easily skip some build processes for operations like linting with ESLint and the `@typescript-eslint` plugin where one package depends on some other internal packages.

The types are already in the source code -- why do we need to emit d.ts files specifically?

I'll be glad to provide more information about the "whys" if necessary, I'm trying to figure out the best DX for a TS monorepo that is gradually migrating from the old `moduleResolution: Node` to modern equivalents and it might be the case I am not making the best decisions here.