-
Notifications
You must be signed in to change notification settings - Fork 795
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
bug: unable to use jsxImportSource
for Stencil JSX types with newer versions of TypeScript.
#6180
Comments
jsxImportSource
for Stencil JSX types with newer versions of TypeScript.
I think it shouldn't be difficult to add an additional export path to enable this. Contributions are welcome! |
I did a small exploration and I got types from Here's a patch to diff --git a/node_modules/@stencil/core/jsx-runtime.d.ts b/node_modules/@stencil/core/jsx-runtime.d.ts
new file mode 100644
index 0000000..aaa3332
--- /dev/null
+++ b/node_modules/@stencil/core/jsx-runtime.d.ts
@@ -0,0 +1 @@
+export type * from "./internal/index.js";
diff --git a/node_modules/@stencil/core/jsx-runtime.js b/node_modules/@stencil/core/jsx-runtime.js
new file mode 100644
index 0000000..afc2712
--- /dev/null
+++ b/node_modules/@stencil/core/jsx-runtime.js
@@ -0,0 +1,2 @@
+// No JSX runtime to export here, but jsx-runtime.d.ts exports JSX types.
+export {} Or basically, I simply added these two files: This is // No JSX runtime to export here, but jsx-runtime.d.ts exports JSX types.
export {} This is export type * from "./internal/index.js"; I am now able to use the I only tested type definitions in my case, but I think that the |
I've made a repo where I've gotten a stencil app with https://github.com/trusktr/stenciljs-core-issue-6181-jsxImportSource Note this depends on an unpublished version of In the meantime, to understand the needed changes and what is left to fix,
When toggling from |
Prerequisites
Stencil Version
4.26.0
Current Behavior
The
@stencil/core
package does not have a@stencil/core/jsx-runtime
export path (or similarjsx-runtime
path), making it not possible to use with TypeScript'sjsxImportSource
option.Expected Behavior
Updated Stencil to work with newer TypeScript.
System Info
Steps to Reproduce
In any TypeScript project (doesn't matter if it is a React project, etc), try to put this at the top of a
.tsx
file to tell TypeScript to load JSX types for anyJSX
expressions from@stencil/core
:/* @jsxImportSource @stencil/core */
You'll get an error like
where
/jsx-runtime
is the conventional postfix that TypeScript appends to the path.Code Reproduction URL
no URL yet
Additional Information
Without this feature, it is not possible to write Stencil components inside any other application that uses non-stencil JSX types.
The purpose of
jsxImportSource
is to allow for different files to use different JSX types. This makes it possible to, for example, compile certain files with one flavor of JSX (f.e. Solid.js JSX) and other files with Stencil JSX.Solution
The fix is likely easy: just create an empty
jsx-runtime.js
file at the root of the package, along with ajsx-runtime.d.ts
file at the root of the package that re-exports theJSX
type.The text was updated successfully, but these errors were encountered: