Git Product home page Git Product logo

Comments (9)

Boshen avatar Boshen commented on June 26, 2024

It should be analyzed in the transformer.

from oxc.

overlookmotel avatar overlookmotel commented on June 26, 2024

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.

Boshen avatar Boshen commented on June 26, 2024

Nope, it's not part of the spec so it can't go into the AST.

from oxc.

overlookmotel avatar overlookmotel commented on June 26, 2024

But it is part of the TS spec, no? https://www.typescriptlang.org/docs/handbook/jsx.html#configuring-jsx

from oxc.

Boshen avatar Boshen commented on June 26, 2024

That's not an AST spec, it's just documentation 😅

from oxc.

overlookmotel avatar overlookmotel commented on June 26, 2024

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.

overlookmotel avatar overlookmotel commented on June 26, 2024

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.

Boshen avatar Boshen commented on June 26, 2024

You can save them into Trivias if you really want to parse them from the parser.

from oxc.

Boshen avatar Boshen commented on June 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.