vite-plugin-solid icon indicating copy to clipboard operation
vite-plugin-solid copied to clipboard

Remove `@babel/preset-typescript`

Open lxsmnsyc opened this issue 1 year ago • 4 comments

  • Option typescript is unused by the majority I believe
  • typescript parsing can be bypassed by parserOpts.plugin = ['typescript'], you can see an example here: https://github.com/lxsmnsyc/solid-styled/blob/main/packages/vite/src/index.ts#L66-L69
  • typescript preset performs the TS-to-JS compilation, I don't think we want this

lxsmnsyc avatar Mar 20 '23 09:03 lxsmnsyc

I didn't write this plugin so I can't speak to it. But assuming we don't do the TS conversion the expectation is the downstream tool does? Can we make that assumption. I'm open to this if we know Vite will just handle this for the files we process. I wonder if there are any other implications. I trust you if you've tested this.

ryansolid avatar Mar 21 '23 17:03 ryansolid

The transform step in the link I gave is actually based on what Prefresh does in their Vite plugin: https://github.com/preactjs/prefresh/blob/main/packages/vite/src/index.js#L27-L34

so if anything, they have tested this more realistically. It works as I've tested. My only concern really here is if anyone actually uses the typescript option in the plugin, in which case we can just recommend users to install @babel/preset-typescript on their own.

lxsmnsyc avatar Mar 22 '23 03:03 lxsmnsyc

Hi. I actually use typescript option for this:

solid({
    typescript: {
        allowDeclareFields: true,
    },
})

Otherwise, my build fails because declare is not allowed without that setting

4:42:58 PM [vite] Internal server error: /home/eptadot/source/md-web-widgets-elec-2024/assets/stimulus/controllers/Form/CandidateCollectionController/index.tsx: The 'declare' modifier is only allowed when the 'allowDeclareFields' option of @babel/plugin-transform-typescript or @babel/preset-typescript is enabled.
  23 |      
> 24 |     declare readonly nameValue: string;

Can I use declare without that setting after removing @babel/preset-typescript? I suppose yes but I want to be sure.

Eptagone avatar Jan 18 '24 22:01 Eptagone

yes you can. The new setup just enables Babel to understand TypeScript syntax.

lxsmnsyc avatar Jan 19 '24 01:01 lxsmnsyc