Skip to content
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?]: Solid Start parses every TypeScript file as TSX #1655

Open
2 tasks done
AFatNiBBa opened this issue Oct 21, 2024 · 0 comments
Open
2 tasks done

[Bug?]: Solid Start parses every TypeScript file as TSX #1655

AFatNiBBa opened this issue Oct 21, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@AFatNiBBa
Copy link

AFatNiBBa commented Oct 21, 2024

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

I have a TypeScript dependency (Not transpiled) that uses the alternative cast syntax (<any>{} instead of {} as any), which is allowed in ".ts" files but not in ".tsx".
When I import that dependency it throws a syntax error because EVERY file is interpreted as TSX

Expected behavior 🤔

Normal ".ts" files should NOT behave as ".tsx"

Steps to reproduce 🕹

Steps:

  1. Create a new bare Solid Start project with TypeScript (npm init solid)
  2. Go inside the "src" directory and create a file named "a.ts" containing export default <any>{};
  3. Add this (↓) to "app.tsx"
import a from "./a";
console.log(a);

You'll get an error like this one
image

Context 🔦

I tried specifying the extensions option in the config, but here it's being added instead of overriding the default one

import { defineConfig } from "@solidjs/start/config";

export default defineConfig({
    extensions: [ "jsx", "tsx" ]
});

I suggest changing that line into

const extensions = start.extensions || DEFAULT_EXTENSIONS;

Or even better, this one into

const DEFAULT_EXTENSIONS = ["jsx", "tsx"];

Note

This is just a partial suggestion, since I noticed that doing this has the side effect of breaking ".ts" API routes

Your environment 🌎

I don't know what command you are talking about, sorry (Luckily, I don't think it matters anyway)

System:
  OS: Windows 11
  CPU: (16) x64
Binaries:
  Node: v22.8.0
  npm: 10.8.2
npmPackages:
  @solidjs/start@1.0.9
  solid-js@1.9.2
  vinxi@0.4.3
@AFatNiBBa AFatNiBBa added the bug Something isn't working label Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant