Skip to content

Commit

Permalink
[flow] Remove bom, cssom, dom, stream from bundled libdefs
Browse files Browse the repository at this point in the history
Summary:
Changelog: [lib] Since the last version, most of the bundled libdefs will no longer be maintained and shipped with Flow. Going forward, they should be downloaded from flow-typed. Starting from this version, we will also no longer ship a set of precise typing definition for jsx intrinsics. To maintain the same behavior as before, you should have a `flow-typed.config.json` in the root of your project with the following content:
```
{
  "env": ["node", "dom", "bom", "intl", "cssom", "indexeddb", "serviceworkers", "webassembly", "jsx"]
}
```

Reviewed By: jbrown215

Differential Revision: D70409195

fbshipit-source-id: 483f214a71d11f3f98cf2e077fe4a88f49e2c5d6
  • Loading branch information
SamChou19815 authored and facebook-github-bot committed Feb 28, 2025
1 parent 632778a commit 9f2fcb8
Show file tree
Hide file tree
Showing 23 changed files with 162 additions and 6,151 deletions.
575 changes: 0 additions & 575 deletions lib/bom.js

This file was deleted.

555 changes: 0 additions & 555 deletions lib/cssom.js

This file was deleted.

4,471 changes: 0 additions & 4,471 deletions lib/dom.js

This file was deleted.

127 changes: 0 additions & 127 deletions lib/streams.js

This file was deleted.

2 changes: 1 addition & 1 deletion newtests/lsp/queries/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ module.exports = (suite(
[
[
'telemetry/rage',
'{Focused: 8,LSP adapter state: Connected,.monitor_log,.log}',
'{Focused: 4,LSP adapter state: Connected,.monitor_log,.log}',
],
],
[...lspIgnoreStatusAndCancellation],
Expand Down
4 changes: 4 additions & 0 deletions tests/arrows/arrows.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ function selectBestEffortImageForWidth(
return images.find(image => image.width >= maxPixelWidth) ||
images[images.length - 1];
}

declare class Image {
width: number
}
244 changes: 1 addition & 243 deletions tests/autocomplete_from_m_to_q/autocomplete_from_m_to_q.exp

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions tests/component_syntax/component_syntax.exp
Original file line number Diff line number Diff line change
Expand Up @@ -3196,13 +3196,12 @@ References:
Error --------------------------------------------------------------------------------------------------- refs.js:105:23

Cannot create `GenericRef1` element because in property `ref`: [incompatible-type]
- Either `HTMLElement` [1] is not a subtype of object type [2]. Class instances are not subtypes of object types;
consider rewriting object type [2] as an interface.
- Or `HTMLElement` [1] is incompatible with function type [3]. Non-callable objects are not compatible with functions.
- Either number [1] is incompatible with object type [2].
- Or number [1] is incompatible with function type [3].

refs.js:105:23
105| <GenericRef1 ref={new HTMLElement()} />; // error
^^^^^^^^^^^^^^^^^ [1]
105| <GenericRef1 ref={1} />; // error
^ [1]

References:
<BUILTINS>/react.js:113:5
Expand Down
2 changes: 1 addition & 1 deletion tests/component_syntax/refs.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ import * as React from 'react';

<GenericRef1 ref={(r: string | null) => {}} />; // ok
<GenericRef1 ref={(r: number | null) => {}} />; // ok
<GenericRef1 ref={new HTMLElement()} />; // error
<GenericRef1 ref={1} />; // error
<GenericRef2 ref={(r: Array<Array<Array<string>>> | null) => {}} />; // ok
<GenericRef2 ref={(r: Array<Array<Array<number>>> | null) => {}} />; // ok
<GenericRef2 ref={(r: string | null) => {}} />; // error
Expand Down
54 changes: 30 additions & 24 deletions tests/declare_namespace/declare_namespace.exp
Original file line number Diff line number Diff line change
Expand Up @@ -471,48 +471,54 @@ Cannot resolve name `React`. [cannot-resolve-name]

Error --------------------------------------------------------------------------------- type_only_react_namespace.js:5:3

Cannot cast `new HTMLAnchorElement()` to `Node` because: [incompatible-cast]
- Either `HTMLAnchorElement` [1] is incompatible with `React.Element` [2].
- Or `HTMLAnchorElement` [1] is incompatible with `React.Portal` [3].
- Or property `@@iterator` is missing in `HTMLAnchorElement` [1] but exists in `$Iterable` [4].
Cannot cast `Array` to `Node` because: [incompatible-cast]
- Either class `Array` [1] is incompatible with `React.Element` [2].
- Or class `Array` [1] is incompatible with `React.Portal` [3].
- Or property `@@iterator` is missing in class `Array` [1] but exists in `$Iterable` [4].

type_only_react_namespace.js:5:3
5| new HTMLAnchorElement() as React.Node; // error
^^^^^^^^^^^^^^^^^^^^^^^ [1]
5| Array as React.Node; // error
^^^^^

References:
<BUILTINS>/core.js:946:15
946| declare class Array<T> extends $ReadOnlyArray<T> {
^^^^^ [1]
<BUILTINS>/react.js:21:5
21| | React$Element<any>
^^^^^^^^^^^^^^^^^^ [2]
21| | React$Element<any>
^^^^^^^^^^^^^^^^^^ [2]
<BUILTINS>/react.js:22:5
22| | React$Portal
^^^^^^^^^^^^ [3]
22| | React$Portal
^^^^^^^^^^^^ [3]
<BUILTINS>/react.js:23:5
23| | Iterable<?React$Node>;
^^^^^^^^^^^^^^^^^^^^^ [4]
23| | Iterable<?React$Node>;
^^^^^^^^^^^^^^^^^^^^^ [4]


Error -------------------------------------------------------------------------------- type_only_react_namespace.js:12:3

Cannot cast `new HTMLAnchorElement()` to `Node` because: [incompatible-cast]
- Either `HTMLAnchorElement` [1] is incompatible with `React.Element` [2].
- Or `HTMLAnchorElement` [1] is incompatible with `React.Portal` [3].
- Or property `@@iterator` is missing in `HTMLAnchorElement` [1] but exists in `$Iterable` [4].
Cannot cast `Array` to `Node` because: [incompatible-cast]
- Either class `Array` [1] is incompatible with `React.Element` [2].
- Or class `Array` [1] is incompatible with `React.Portal` [3].
- Or property `@@iterator` is missing in class `Array` [1] but exists in `$Iterable` [4].

type_only_react_namespace.js:12:3
12| new HTMLAnchorElement() as React.Node; // error
^^^^^^^^^^^^^^^^^^^^^^^ [1]
12| Array as React.Node; // error
^^^^^

References:
<BUILTINS>/core.js:946:15
946| declare class Array<T> extends $ReadOnlyArray<T> {
^^^^^ [1]
<BUILTINS>/react.js:21:5
21| | React$Element<any>
^^^^^^^^^^^^^^^^^^ [2]
21| | React$Element<any>
^^^^^^^^^^^^^^^^^^ [2]
<BUILTINS>/react.js:22:5
22| | React$Portal
^^^^^^^^^^^^ [3]
22| | React$Portal
^^^^^^^^^^^^ [3]
<BUILTINS>/react.js:23:5
23| | Iterable<?React$Node>;
^^^^^^^^^^^^^^^^^^^^^ [4]
23| | Iterable<?React$Node>;
^^^^^^^^^^^^^^^^^^^^^ [4]


Error ----------------------------------------------------------------------------------------------- typing_test.js:7:1
Expand Down
4 changes: 2 additions & 2 deletions tests/declare_namespace/type_only_react_namespace.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<div />; // ok
React; // error
1 as React.Node;
new HTMLAnchorElement() as React.Node; // error
Array as React.Node; // error
}
{
const React = require('react');
<div /> as React.Node; // ok
React; // error
1 as React.Node;
new HTMLAnchorElement() as React.Node; // error
Array as React.Node; // error
}
30 changes: 15 additions & 15 deletions tests/global_this/global_this.exp
Original file line number Diff line number Diff line change
Expand Up @@ -69,28 +69,28 @@ References:

Error ----------------------------------------------------------------------------------------------------- test.js:10:1

Cannot cast `HTMLElement` to `Node` because: [incompatible-cast]
- Either class `HTMLElement` [1] is incompatible with `React.Element` [2].
- Or class `HTMLElement` [1] is incompatible with `React.Portal` [3].
- Or property `@@iterator` is missing in class `HTMLElement` [1] but exists in `$Iterable` [4].
Cannot cast `Array` to `Node` because: [incompatible-cast]
- Either class `Array` [1] is incompatible with `React.Element` [2].
- Or class `Array` [1] is incompatible with `React.Portal` [3].
- Or property `@@iterator` is missing in class `Array` [1] but exists in `$Iterable` [4].

test.js:10:1
10| HTMLElement as globalThis.React.Node; // error
^^^^^^^^^^^
10| Array as globalThis.React.Node; // error
^^^^^

References:
<BUILTINS>/dom.js:2092:15
2092| declare class HTMLElement extends Element {
^^^^^^^^^^^ [1]
<BUILTINS>/core.js:946:15
946| declare class Array<T> extends $ReadOnlyArray<T> {
^^^^^ [1]
<BUILTINS>/react.js:21:5
21| | React$Element<any>
^^^^^^^^^^^^^^^^^^ [2]
21| | React$Element<any>
^^^^^^^^^^^^^^^^^^ [2]
<BUILTINS>/react.js:22:5
22| | React$Portal
^^^^^^^^^^^^ [3]
22| | React$Portal
^^^^^^^^^^^^ [3]
<BUILTINS>/react.js:23:5
23| | Iterable<?React$Node>;
^^^^^^^^^^^^^^^^^^^^^ [4]
23| | Iterable<?React$Node>;
^^^^^^^^^^^^^^^^^^^^^ [4]



Expand Down
2 changes: 1 addition & 1 deletion tests/global_this/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ window.myGlobal as globalThis.Opaque; // ok: this is weird, but TS also supports
window.myGlobal as empty; // error
globalThis.myGlobal as empty; // error

HTMLElement as globalThis.React.Node; // error
Array as globalThis.React.Node; // error
7 changes: 6 additions & 1 deletion tests/new_merge_diff/new_merge_diff.exp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ Error --------------------------------------------------------------------------
Invalid trivially recursive definition of exports. [recursive-definition]


Error ---------------------------------------------------------------------------------- recursive_module_cycle_B.js:0:1

Invalid trivially recursive definition of exports. [recursive-definition]


Error ------------------------------------------------------------------------------------------ recursive_types.js:1:14

Invalid type annotation for `x`. It contains a reference [1] to the binding being declared. [recursive-definition]
Expand Down Expand Up @@ -169,7 +174,7 @@ Invalid trivially recursive definition of object type. [recursive-definition]



Found 15 errors
Found 16 errors

Only showing the most relevant union/intersection branches.
To see all branches, re-run Flow with --show-all-branches
8 changes: 4 additions & 4 deletions tests/quick_start/quick_start.exp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Quick start.
Expect no errors.
No errors!

The Flow server is currently in lazy mode and is only checking 7/8 files.
The Flow server is currently in lazy mode and is only checking 3/4 files.
To learn more, visit flow.org/en/docs/lang/lazy-modes

Change @flow file, expect error.
Expand All @@ -27,13 +27,13 @@ References:

Found 1 error

The Flow server is currently in lazy mode and is only checking 8/8 files.
The Flow server is currently in lazy mode and is only checking 4/4 files.
To learn more, visit flow.org/en/docs/lang/lazy-modes

Make file @noflow, expect error to go away.
No errors!

The Flow server is currently in lazy mode and is only checking 7/7 files.
The Flow server is currently in lazy mode and is only checking 3/3 files.
To learn more, visit flow.org/en/docs/lang/lazy-modes

Revert file, expect error again.
Expand All @@ -54,7 +54,7 @@ References:

Found 1 error

The Flow server is currently in lazy mode and is only checking 8/8 files.
The Flow server is currently in lazy mode and is only checking 4/4 files.
To learn more, visit flow.org/en/docs/lang/lazy-modes

Done!
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ Quick start.
Expect no errors.
No errors!

The Flow server is currently in lazy mode and is only checking 7/9 files.
The Flow server is currently in lazy mode and is only checking 3/5 files.
To learn more, visit flow.org/en/docs/lang/lazy-modes

Change @flow file with dependency on a @flow file, expect no error.
No errors!

The Flow server is currently in lazy mode and is only checking 9/9 files.
The Flow server is currently in lazy mode and is only checking 5/5 files.
To learn more, visit flow.org/en/docs/lang/lazy-modes

Done!
Loading

0 comments on commit 9f2fcb8

Please sign in to comment.