Skip to content

Namespace imports are incompatible with verbatimModuleSyntax #2190

@mrcaidev

Description

@mrcaidev

Describe the bug

If verbatimModuleSyntax is set to true in tsconfig.json, namespace imports would crash the whole app. For example:

import { JSX } from "solid-js";

I am aware that this is more like an issue on TypeScript side, and I do find a relevant issue #52461 there. In this issue, TypeScript members suggest a particular way to export namespaces, and the failure of other ways is an expected behavior.

Currently, I can solve this by turning off verbatimModuleSyntax to stop my app from crashing. But I'm wondering if this can be avoided on SolidJS side? That is, modifying the style in which namespaces are exported, so that they can become compatible with verbatimModuleSyntax.

Your Example Website or App

https://codesandbox.io/p/devbox/importing-jsx-with-tsconfig-verbatimmodulesyntax-62pnqn

Steps to Reproduce the Bug or Issue

  1. The app is functioning normally.
  2. Import JSX on line 1: import { createSignal, JSX } from "solid-js";.
  3. Refresh the page.
  4. The app crashes.

Expected behavior

Namespace imports should work along well with "verbatimModuleSyntax": true.

Screenshots or Videos

image

Platform

  • OS: Linux (CodeSandbox Devbox)
  • Browser: Microsoft Edge (CodeSandbox Devbox)
  • Version: 1.8.17

Additional context

Log:

11:39:11 PM [vite] Error when evaluating SSR module /home/mrcaidev/cinema/src/routes/index.tsx?pick=default&pick=$css: failed to import "solid-js"
|- SyntaxError: [vite] The requested module 'solid-js' does not provide an export named 'JSX'
    at analyzeImportedModDifference (file:///home/mrcaidev/cinema/node_modules/.pnpm/vite@5.3.1_@types+node@20.14.2_terser@5.31.1/node_modules/vite/dist/node/chunks/dep-BcXSligG.js:52490:15)
    at nodeImport (file:///home/mrcaidev/cinema/node_modules/.pnpm/vite@5.3.1_@types+node@20.14.2_terser@5.31.1/node_modules/vite/dist/node/chunks/dep-BcXSligG.js:53497:5)
    at async ssrImport (file:///home/mrcaidev/cinema/node_modules/.pnpm/vite@5.3.1_@types+node@20.14.2_terser@5.31.1/node_modules/vite/dist/node/chunks/dep-BcXSligG.js:53349:16)
    at async eval (/home/mrcaidev/cinema/src/components/ui/button.tsx:5:31)
    at async instantiateModule (file:///home/mrcaidev/cinema/node_modules/.pnpm/vite@5.3.1_@types+node@20.14.2_terser@5.31.1/node_modules/vite/dist/node/chunks/dep-BcXSligG.js:53408:5)

Metadata

Metadata

Assignees

No one assigned

    Labels

    typescriptrelating to typescript or types

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions