Description
From @benjie at #44501 (comment):
Hello, your beta announcements are asking for feedback on this feature. First of all - I'm super excited about this! Great work!
One thing I was really looking forward to in Node.js exports/ESM support was having example files that import from the library itself - this way we can just say import { foo } from "my-module"
rather than import { foo } from ".." /* TODO: replace this with "my-module" */
- makes it much easier for users to copy/paste examples whilst keeping the examples co-located inside the package.
Node.js supports this "self-referencing" behaviour; however TypeScript doesn't seem to understand how to import this in module:"nodenext"
mode - a could not find a declaration file for module 'my-module'
error is raised.
I've prepared a minimal reproduction here with js
folder working using Node.js and analogous ts
folder which is not working with TypeScript (won't compile):
https://github.com/benjie/typescript-self-referencing-issue
TSConfig:
{
"compilerOptions": {
"lib": ["es2021"],
"module": "nodenext",
"target": "es2021",
"strict": true,
"rootDir": "src",
"declaration": true,
"declarationDir": "dist",
"outDir": "dist"
},
"include": ["src"],
"exclude": ["dist"]
}
TypeScript version 4.6.0-dev.20211110
Maybe this relates to #46212?
Thanks for your hard work on TypeScript ❤️
Originally posted by @benjie in #44501 (comment)