Comments (3)
Looking at the generated tokens,
<span foo:hi='bar'></span>
produces
Location Label Raw contextualKeyword scopeDepth isType identifierRole jsxRole shadowsGlobal isAsyncOperation contextId rhsEndIndex isExpression numNullishCoalesceStarts numNullishCoalesceEnds isOptionalChainStart isOptionalChainEnd subscriptStartIndex nullishStartIndex
1:1-1:2 jsxTagStart < 0 0 0 0 0
1:2-1:6 jsxName span 0 0 0 0
1:7-1:10 jsxName foo 0 0 0 0
1:10-1:11 : : 0 0 0 0
1:11-1:13 name hi 0 0 0 0
1:13-1:14 = = 0 0 0 0
1:14-1:19 string 'bar' 0 0 0 0
1:19-1:20 jsxTagEnd > 0 0 0 0
1:20-1:21 jsxTagStart < 0 0 0 0
1:21-1:22 / / 0 0 0 0
1:22-1:26 jsxName span 0 0 0 0
1:26-1:27 jsxTagEnd > 0 0 0 0
2:1-2:1 eof 0 0 0 0
So a quick fix would just be to run through tokens, and when you find jsxName
followed by :
and name
, combine those two into the jsxName value, and remove those two tokens.
from sucrase.
So far, this needs JSXTransformer.ts to have this inserted at line 420:
} else if (this.tokens.matches4(tt.jsxName, tt.colon, tt.name, tt.eq)) {
Still not sure what to put in there though. I tried adding the two strings, and the linter said string concatenation is bad, so...
from sucrase.
Actually the tokenizer would probably be a better place.
from sucrase.
Related Issues (20)
- Incorrect elision of `import {}` with TS transform disabled HOT 1
- TypeScript type-only re-exports not always properly elided
- TypeScript automatic named export elision incorrectly happens for re-export
- Incorrect elision of named import if typings of a callback function contains a parameter with the same name HOT 1
- Sucrase SyntaxError - (7:3) HOT 2
- jest.mock hoisting breaks when using @jest/globals
- Option to just compile JSX to object literal HOT 2
- Unexpected output from an exported mergeable enum HOT 2
- glob lib dependency, depends on Inflight lib which is now introducing a security vulnerability HOT 2
- Exporting declaration after function invocation misses semi
- Empty template spans break sourcemaps HOT 1
- Dont remove `export interface` , instead rename it to something else. HOT 4
- support absolute import with baseUrl HOT 1
- Is Sucrase support targeting ES3? HOT 1
- Certain syntax errors have poor position recovery
- Using --project switch incorrectly outputs to include base folder name
- Using --project switch breaks when `tsconfig.json` does not specify `outDir`
- When specifying a folder to compile, empty js files are output for `.d.ts` declaration files
- tsconfig.json parsing using JSON.parse which does not support all features that tsc does
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sucrase.