You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched for existing issues that already report this problem, without success.
Stencil Version
4.12.0
Current Behavior
It appears that the TypeScript definitions for JSX support in Stencil are not completely correct, and are causing issue when used with third-party tools (like @typescript-eslint)
Expected Behavior
JSX.Element type is resolved correctly
System Info
System: node 20.11.0
Platform: darwin (23.2.0)
CPU Model: Apple M1 Pro (10 cpus)
Compiler: /Users/mak13180/site/esri/arcgis-web-components/node_modules/@stencil/core/compiler/stencil.js
Build: 1705333241
Stencil: 4.10.0 🍪
TypeScript: 5.3.3
Rollup: 2.42.3
Parse5: 7.1.2
jQuery: 4.0.0-pre
Terser: 5.26.0
Steps to Reproduce
I made a small reproduction case based on the JSX typings in Stencil: source
See the error on line 16
Further, see that see that typescript compiler resolves the type as "error":
out.mp4
This is because TypeScript is hardcoded to look for Element type/interface in the JSX namespace
In the above demo, uncomment line 8 (not present in Stencil's typings), and see how the typescript compiler now correctly resolves the JSX type, and also the typescript-eslint error is resolved
After debugging typescript-eslint and reading TypeScript source code, it appears that TypeScript is hardcoded to look for JSX.Element type/interface, rather than look at the return type of the jsxFactory:
Prerequisites
Stencil Version
4.12.0
Current Behavior
It appears that the TypeScript definitions for JSX support in Stencil are not completely correct, and are causing issue when used with third-party tools (like @typescript-eslint)
Expected Behavior
JSX.Element type is resolved correctly
System Info
System: node 20.11.0 Platform: darwin (23.2.0) CPU Model: Apple M1 Pro (10 cpus) Compiler: /Users/mak13180/site/esri/arcgis-web-components/node_modules/@stencil/core/compiler/stencil.js Build: 1705333241 Stencil: 4.10.0 🍪 TypeScript: 5.3.3 Rollup: 2.42.3 Parse5: 7.1.2 jQuery: 4.0.0-pre Terser: 5.26.0Steps to Reproduce
I made a small reproduction case based on the JSX typings in Stencil: source
See the error on line 16
Further, see that see that typescript compiler resolves the type as "error":
out.mp4
This is because TypeScript is hardcoded to look for Element type/interface in the JSX namespace
In the above demo, uncomment line 8 (not present in Stencil's typings), and see how the typescript compiler now correctly resolves the JSX type, and also the typescript-eslint error is resolved
Code Reproduction URL
anytyped value."type Element = VNodein JSX namespace: ESLint Playground - Example 2: "'Fragment' cannot be used as a JSX component.Its return type 'VNode | VNode[]' is not a valid JSX element."
Additional Information
For reference, here are examples of
Elementsinterface/type being included in the JSX element in other popular libraries:After debugging typescript-eslint and reading TypeScript source code, it appears that TypeScript is hardcoded to look for JSX.Element type/interface, rather than look at the return type of the jsxFactory:
(TS 3.7 source)
out.mp4