-
-
Notifications
You must be signed in to change notification settings - Fork 561
Description
Describe the bug
Issue
If you try to import TanStackFormController in a Lit component project where tsconfig moduleResolution is set to "nodenext" or "node16", the types don't work.
Cause
This is because in the index.ts of lit-form, TanStackFormController is exported using a relative file path:
export { TanStackFormController } from './tanstack-form-controller'Relative (extension-less) file paths often have downstream issues in consuming repos. For widest compatibility, libraries should use explicit file path export/imports. TS recommends setting moduleResolution to "nodenext" or "node16" for libraries, which will also enable compiler checking to ensure .js file extensions are present.
Suggested solution
Add the .js file extension to library exports. In this case:
export { TanStackFormController } from './tanstack-form-controller.js'Your minimal, reproducible example
https://codesandbox.io/p/devbox/lucid-christian-mn2vg6?file=%2Fsrc%2Findex.ts%3A4%2C49
Steps to reproduce
See this forked Lit form example: https://codesandbox.io/p/devbox/lucid-christian-mn2vg6?file=%2Fsrc%2Findex.ts%3A4%2C49
tsconfig.json moduleResolution and module have been set to "NodeNext". Notice that in index.ts, #form is now typed as any.
Expected behavior
#form = new TanStackFormController(this, {
defaultValues: {
employees: [] as Employee[],
},
})#form should be properly typed.
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
- OS: MacOS
TanStack Form adapter
lit-form
TanStack Form version
v1.3.2
TypeScript version
v5.6.2
Additional context
No response