Comments (6)
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.
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.
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.
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.
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.
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)
- `T extends infer I1 extends { K: infer I2 }` infers I2 to unknown HOT 7
- Wrong type narrowing on union type. HOT 2
- Document link for reference types and path
- object with `?:` property type, spread last --> allowed (but shouldn't) HOT 3
- Add a flag to require JS object literals to be initialized with all declared members HOT 4
- Type inference lost after spreading array with `ArrayLike` HOT 1
- Regular Expression finds HOT 4
- "This comparison appears to be unintentional" and control flow analysis with a variable updated in lambda HOT 4
- Classes static generic function return `any` type. HOT 2
- Is assignment not allowed here? HOT 2
- Editor changes overload resolution based on syntax HOT 6
- TS cache corruption leads to "error TS2590: Expression produces a union type that is too complex to represent" HOT 1
- Type alias circularly references itself (5.4 regression) HOT 1
- error TS2385: Overload signatures must all be public, private or protected. HOT 2
- `export type * ...` statements in `.d.ts` files do not work (5.4 regression) HOT 4
- HTMLFormElement disallows symbol keys HOT 6
- TypeScript language service cannot find subclass references/implementation of mixin methods
- when using ts.getJSDocTags, the value of @type is not returned. Is there any solution? HOT 2
- Compiler allows narrower method signature than implemented interface HOT 7
- Allow overload signatures to have different access levels HOT 3
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 typescript.