Skip to content

Commit dc3b736

Browse files
committed
fix: Add global AbortSignal to fix the build-types command
1 parent a89df86 commit dc3b736

4 files changed

Lines changed: 35 additions & 3 deletions

File tree

‎packages/react-native/ReactNativeApi.d.ts‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<b0c8c41e65758fde472ddf1c5b106a27>>
7+
* @generated SignedSource<<3d7835eb88d765da6d5de7f92764d0af>>
88
*
99
* This file was generated by scripts/js-api/build-types/index.js.
1010
*/
@@ -1113,6 +1113,13 @@ declare type add = typeof add
11131113
declare function addChangeListener(
11141114
listener: (preferences: AppearancePreferences) => void,
11151115
): EventSubscription
1116+
declare type AddEventListenerOptions = Readonly<
1117+
EventListenerOptions & {
1118+
once?: boolean
1119+
passive?: boolean
1120+
signal?: AbortSignal
1121+
}
1122+
>
11161123
declare class Alert {
11171124
static alert(
11181125
title: null | string | undefined,
@@ -1874,7 +1881,11 @@ declare type DevMenuStatic = {
18741881
declare type DevSettings = typeof DevSettings
18751882
declare type diffClamp = typeof diffClamp
18761883
declare class Dimensions {
1877-
static addEventListener(type: "change", handler: Function): EventSubscription
1884+
static addEventListener(
1885+
type: "change",
1886+
handler: Function,
1887+
options?: Pick<AddEventListenerOptions, "once" | "signal">,
1888+
): EventSubscription
18781889
static get(dim: string): DisplayMetrics | DisplayMetricsAndroid
18791890
static set(dims: Readonly<DimensionsPayload>): void
18801891
}
@@ -2116,6 +2127,9 @@ declare class EventEmitter<
21162127
declare type EventEmitter_2<T> = (
21172128
handler: ($$PARAM_0$$: T) => Promise<void> | void,
21182129
) => EventSubscription
2130+
declare type EventListenerOptions = {
2131+
readonly capture?: boolean
2132+
}
21192133
declare type EventName = (() => string) | string
21202134
declare interface EventSubscription {
21212135
remove(): void
@@ -5816,7 +5830,7 @@ export {
58165830
DeviceInfo, // 0f5a517b
58175831
DeviceInfoConstants, // 279e7858
58185832
DimensionValue, // b163a381
5819-
Dimensions, // 980ef68c
5833+
Dimensions, // 03d31826
58205834
DimensionsPayload, // 653bc26c
58215835
DisplayMetrics, // 1dc35cef
58225836
DisplayMetricsAndroid, // 872e62eb

‎scripts/js-api/build-types/buildApiSnapshot.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,12 @@ async function generateConfigFiles(tempDirectory: string) {
303303
adjustedApiExtractorConfig,
304304
);
305305

306+
// copy ambient global declarations
307+
await fs.copyFile(
308+
path.join(__dirname, 'templates', 'globals.d.ts'),
309+
path.join(tempDirectory, 'globals.d.ts'),
310+
);
311+
306312
// generate basic package.json
307313
const packageJSON = {name: 'react-native'};
308314
await fs.writeFile(

‎scripts/js-api/build-types/templates/api-extractor.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"compiler": {
66
"overrideTsconfig": {
77
"$schema": "http://json.schemastore.org/tsconfig",
8+
"files": ["${typegen_directory}/globals.d.ts"],
89
"compilerOptions": {
910
"lib": ["es2020"],
1011
"types": [],
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
// Ambient web globals referenced by the public API that are not part of the
9+
// "es2020" lib used by api-extractor. Declared here so that api-extractor
10+
// resolves them as globals and leaves references to them untouched.
11+
declare class AbortSignal {}

0 commit comments

Comments
 (0)