Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace UserConfig typedef with a subpath export (#3460) #3562

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

noelforte
Copy link

This is a minimum viable patch that starts work on #3460. Notably, this change removes the requirement of maxNodeModuleJsDepth in tsconfig.json for TS packages that want to import UserConfig API, as mentioned in the mega TS issue.

Since modifying the functionality of exports, imports, and declarations will involve some cleanup, removal and renaming, further work is probably something best left to the next major release.

I've removed the @typedef comment from Eleventy.js, since adding a types subpath export makes exporting it from Eleventy's main file redundant. If backwards compatiblity is needed, then something like this will implement the fuctionality offered by the subpath export:

 /**
  * Eleventy’s programmatic API
  * @module 11ty/eleventy/Eleventy
  *
+ * This line is required for IDE autocomplete in config files
+ * @typedef {import('./UserConfig').default} UserConfig
  */

Also note, declaring ./src/UserConfig.js as a "types" export will still block it from being directly consumed (see #3460), since "." is the only pathname that has a "import/require" key. It's therefore only possible to import it as a type, either from Typescript or from JSDoc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant