nuejs / www

Content for nuejs.org
34 stars 31 forks source link

React isn't using plain JS as FAQ claims #11

Closed oplik0 closed 12 months ago

oplik0 commented 1 year ago

The FAQ states that Nue is like React, Svelte and SvelteKit in being written in plain JS and not TypeScript. While the latter two have moved to JSDoc based type checking (using TypeScript, and from my understanding also for the internals and not just the public API surface like Nue currently does), React isn't using plain JavaScript but rather Flow - Facebook's statically typed JS variant. Every file annotated with @flow in a comment is using Flow syntax, which, like TypeScript, is a superset of JS that uses type annotations in a very similar way (note that it also allows for typing in comments but React isn't doing so - their source code can't run directly inside JS runtimes)

For an example (random file from react source that's using Flow annotation) see: https://github.com/facebook/react/blob/a5fc797db14c6e05d4d5c4dbb22a0dd70d41f5d5/packages/react/src/ReactLazy.js#L45-L52

export type LazyComponent<T, P> = {
  $$typeof: symbol | number,
  _payload: P,
  _init: (payload: P) => T,
};

function lazyInitializer<T>(payload: Payload<T>): T {
  if (payload._status === Uninitialized) {
tipiirai commented 12 months ago

Thanks. Good point! I came to this PR too late since this issue has already been addressed. So I'm closing this one.