Git Product home page Git Product logo

Comments (6)

RyanCavanaugh avatar RyanCavanaugh commented on May 3, 2024 9

Remember when everyone said Flow was better because it wasn't adding transpiles-to-runtime stuff like enum and namespace to JS? TypeScript remembers 👴

from typescript.

nmain avatar nmain commented on May 3, 2024 1

Over time, JSX has proven to quite useful for a variety of scenarios. The React transform requires nothing more than a createElement-like function, and for other use cases there are many other popular transforms. It's been used in React, React-like, other not-at-all-like React VDOM-based systems, and systems that emit HTML strings, raw DOM elements, and others. Everyone wanted a reasonable template-ish syntax for making HTML-likes in Javascript, and JSX filled that need well.

By contrast, these changes are much more React-specific. component enforces a very specific signature. hook goes down the rabbit-hole of "the rules of hooks" as defined by React.

from typescript.

RyanCavanaugh avatar RyanCavanaugh commented on May 3, 2024 1

In all seriousness though, it doesn't seem that problematic to parse component as an alias for function in TSX files only under jsx: preserve (which would leave component in the emitted JSX file) or noEmit, and otherwise skip all the Meta-specific rules that Flow infers on it.

As far as I understand, their component-to-function compiler doesn't need any type annotations to do the right thing.

from typescript.

MartinJohns avatar MartinJohns commented on May 3, 2024

but the new component syntax has the potential to unify how things are done

Unless this syntax is supported by JSX I can't see this happening at all.

And until today I always thought flow is a type checker. TIL.

from typescript.

snarbies avatar snarbies commented on May 3, 2024

I don't see the appeal either, but couldn't one react the same way to JSX itself? It's also a special syntax for react that has to be transpiled.

from typescript.

Josh-Cena avatar Josh-Cena commented on May 3, 2024

The component syntax's advantage does not lie in its sugar; it's more about giving code semantics and allowing stricter type checks like return type being ReactNode, parameters being readonly, etc. This benefit can trickle down to other linters like eslint-plugin-react where they can enforce proper hook calls, etc. (totally understand if TypeScript doesn't want to take on this kind of checking)

from typescript.

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.