bug: Preact typing doesn't work if using non-legacy TypeScript moduleResolution #9494
Open
2 of 6 tasks
Labels
0 - new
New issues that need assignment.
ArcGIS Maps SDK for JavaScript
Issues logged by ArcGIS SDK for JavaScript team members.
bug
Bug reports for broken functionality. Issues should include a reproduction of the bug.
calcite-components
Issues specific to the @esri/calcite-components package.
estimate - 3
A day or two of work, likely requires updates to tests.
impact - p3 - not time sensitive
User set priority impact status of p3 - not time sensitive
p - low
Issue is non core or affecting less that 10% of people using the library
spike
Issues that need quick investigations for time estimations, prioritization, or a quick assessment.
Milestone
Check existing issues
Actual Behavior
Calcite provides typings for Preact.
However, these work only if using legacy TypeScript moduleResolution setting
"Node"
Expected Behavior
Using modern moduleResolution like
"Node16"
or"Bundler"
should work.Without this, you can't use the package.json's
"exports"
fieldReproduction Sample
https://github.com/Esri/calcite-components-examples/tree/main/preact-typescript
Reproduction Steps
Clone this folder: https://github.com/Esri/calcite-components-examples/tree/main/preact-typescript
In tsconfig on this line, replace the legacy module resolution with a modern one:
See error anywhere where calcite elements are used in JSX
Property 'calcite-icon' does not exist on type 'JSX.IntrinsicElements'.ts(2339)
Reproduction Version
2.8.5
Relevant Info
The issue is likely because the preact typings generated by Calcite reference a
"preact/src/jsx"
file which is not included in Preact's package.json's"exports"
field:calcite-design-system/packages/calcite-components/support/preact.ts
Line 26 in 9b4c3ee
Note, because of TypeScript limitation, this might be not possible to solve without opening a PR in Preact to add this to their package.json's exports:
With the above line, Calcite's typings seem to work again
Regression?
No response
Priority impact
impact - p3 - not time sensitive
Impact
I tried to add Preact typings to arcgis-web-components, but faced an issue.
When I looked at how typings work in Calcite, I noticed that Calcite's Preact typings don't work with newer TypeScript module resolution setting.
Calcite package
Esri team
ArcGIS Maps SDK for JavaScript
The text was updated successfully, but these errors were encountered: