How can I make Emmet use className instead of class in .tsx files
Hi!
As the title already explains I do have the following scenario when I type something like this in a .tsx file:div.hello and press tab, it auto completes to <div class="hello"></div>
This however is wrong in React projects and I wonder if there is a setting where I can change that behaviour so the autocomplete uses className instead of class.
Thanks in advance!
Please sign in to leave a comment.
Unfortunately I failed to reproduce the issue. Do you have a sample project you can share that reproduces it?
Expanding Emmet in JSX context is based on the framework detection. It currently uses the same logic as the tsc compiler. We don't hardcode anything specific to react/preact/solid or other libraries, but instead use the typings and configuration.
There are several major cases:
jsxImportSource" flag in tsconfig/jsconfig or it is a pragma in the file e.g./** @jsxImportSource solid-js */. In this case IDE builds "virtual" importimport("solid-js/jsx-runtime").JSX.IntrinsicElementsand we use elements inside of IntrinsicElements type as tags with the corresponding attributes. The part "jsx-runtime" is defined by "jsx" property according to the compiler implementation (see https://www.typescriptlang.org/tsconfig#jsxImportSource).jsxFactoryin tsconfig/jsconfig or@jsxpragma e.g./** @jsx h */. In this case IDE tries to resolve locally the symbol with the name "h" in the scope of the file, and if it exists IDE builds "virtual" import likeimport("preact").JSX.IntrinsicElementsbase on the location of the "h" symbol.jsxImportSourceandjsxFactoryIDE tries to resolve global namespace "JSX.IntrinsicElements".react.d.tstypings and the "JSX.IntrinsicElements" namespace from there.Hi!
I was not able to resolve this issue unfortunately, I tried enabling the
jsxImportSourceflag however emmet still autocompletes toclassinstead ofclassName.I do have a Vite project with tsx and everything is working correctly otherwise. Is there any info I can provide to identitfy what causes this behaviour?
I've create this sample project .
Steps to reproduce the issue:
1. Go to app.tsx
2. Type
div.something3. See it getting autocompleted to
<div class="something"></div>Thank you for sharing the project. Regrettably I didn't manage to reproduce the issue:
What IDE version do you use?