Comments (9)
It should be analyzed in the transformer.
from oxc.
Would it not be useful to add a pragmas
field to Program
and populate it in the parser, like with Hashbang
? I imagine other tools might find this info useful as its meaningful information for interpreting the AST (broadly equivalent to an import React from "whatever";
statement).
from oxc.
Nope, it's not part of the spec so it can't go into the AST.
from oxc.
But it is part of the TS spec, no? https://www.typescriptlang.org/docs/handbook/jsx.html#configuring-jsx
from oxc.
That's not an AST spec, it's just documentation 😅
from oxc.
OK, true! But what's the difference? Spec and config are both things which are present in the source text, and alter the meaning of the code.
Therefore I feel it's better to store that useful info in AST. And we have to parse it somewhere, so might as well parse it in the parser. But I don't feel strongly about it - say no one more time, and I'll shut up!
from oxc.
PS It'd also be faster to find these comments in parser while parsing comments anyway, rather than searching through all comments again later.
from oxc.
You can save them into Trivias
if you really want to parse them from the parser.
from oxc.
In #3553
The lines in https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsxComplexSignatureHasApplicabilityError.tsx
// @strict: true
// @jsx: react
// @skipLibCheck: true
are compiler settings for the test file, they aren't pragmas.
In tsx files, the prgrama
/** @jsxImportSource preact */
<Foo />
produces
import {jsx as _jsx} from 'preact/jsx-runtime';
_jsx(Foo, {});
which is working as intended.
from oxc.
Related Issues (20)
- missing source map when swapping (re-ordering) ast nodes HOT 1
- Add custom `Serializer` impl for `TSModuleBlock` HOT 1
- Remove `span` field from `BindingPattern` HOT 7
- When should `ScopeFlags::StrictMode` be set? HOT 1
- feat(linter): unicorn/no-negation-in-equality-check
- feat(linter): eslint-plugin-unicorn/no-useless-undefined
- Transform binding should including oxc_transform, like esbuild `tranform` api.
- Parser accepts trailing comma for ParenthesizedExpression, SequenceExpression
- proposal: `@oxc/jest` package HOT 4
- Replace `NormalList` and `SeparatedList` trait implementation with `parseDelimitedList` and `parseList`
- Remove special case for `BindingPattern` in `GetSpan` codegen
- JSDoc is missing when using `isolatedDeclaration` HOT 1
- Incorrect "fix" for `no-useless-spread`
- parser: failed to parse parameter name `accessor`
- isolatedDeclaration errors don't include line numbers
- isolatedDeclaration can't infer type for negative number literals
- isolatedDeclaration strips docstrings
- isolatedDeclaration emits excess parentheses in union types HOT 2
- isolatedDeclaration panics when it encounters a private constructor
- isolatedDeclarations drops type parameters of methods
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 oxc.