Skip to content

Commit 5327b47

Browse files
huntiemeta-codesync[bot]
authored andcommitted
Relocate manual .d.ts definitions under types_DEPRECATED/ (#57513)
Summary: Pull Request resolved: #57513 See [**RFC0894: Removing deep imports from react-native**](react-native-community/discussions-and-proposals#894) **Changes** Rename the hand-written `types/` directory to `types_DEPRECATED/` and consolidate the co-located `.d.ts` declarations beneath it. - This is a pure relocation with **no change** to the public type surface. The package `"exports"` map is updated so that every `types` condition resolves to the new location (`.` → `./types_DEPRECATED/index.d.ts`, `./Libraries/*` → `./types_DEPRECATED/Libraries/*.d.ts`) — consumers resolve the exact same types and runtime modules through the same import specifiers. - Relative imports between the moved declarations, and the references from the moved `types/` files into `Libraries/`, were rewritten so the type graph continues to resolve. **Downsides** Risk of structural code drift if/when source modules in `Libraries/` move around. **Counterpoint**: The aim here is to feature-lock the legacy JS API and remove deep `Libraries/` imports by projects. Changelog: [Internal] Differential Revision: D110602194
1 parent 22cfb5c commit 5327b47

99 files changed

Lines changed: 229 additions & 212 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/react-native/__typetests__/tsconfig.legacy.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "https://json.schemastore.org/tsconfig",
33
// Legacy variant: Opts into the `"react-native-legacy-deep-imports"` export
44
// condition so `react-native` and `react-native/Libraries/*` resolve to the
5-
// hand-written types in `types/`.
5+
// hand-written types in `types_DEPRECATED/`.
66
"extends": "./tsconfig.json",
77
"compilerOptions": {
88
"customConditions": ["react-native-legacy-deep-imports"]

packages/react-native/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929
"main": "./index.js",
3030
"exports": {
3131
".": {
32-
"react-native-legacy-deep-imports": "./types/index.d.ts",
32+
"react-native-legacy-deep-imports": "./types_DEPRECATED/index.d.ts",
3333
"types": "./types_generated/index.d.ts",
3434
"default": "./index.js"
3535
},
3636
"./Libraries/*": {
37-
"react-native-legacy-deep-imports": "./Libraries/*.d.ts",
37+
"react-native-legacy-deep-imports": "./types_DEPRECATED/Libraries/*.d.ts",
3838
"types": null,
3939
"default": "./Libraries/*.js"
4040
},
@@ -128,7 +128,7 @@
128128
"src",
129129
"!src/private/testing",
130130
"third-party-podspecs",
131-
"types",
131+
"types_DEPRECATED",
132132
"types_generated",
133133
"!**/__docs__/**",
134134
"!**/__fixtures__/**",
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
* @format
8+
*/
9+
10+
// From @react-native/js-polyfills
11+
12+
type ErrorHandlerCallback = (error: any, isFatal?: boolean) => void;
13+
14+
export interface ErrorUtils {
15+
setGlobalHandler: (callback: ErrorHandlerCallback) => void;
16+
getGlobalHandler: () => ErrorHandlerCallback;
17+
}

packages/react-native/src/types/globals.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @format
88
*/
99

10-
import type {ErrorUtils} from '../../Libraries/vendor/core/ErrorUtils';
10+
import type {ErrorUtils} from './ErrorUtils';
1111

1212
declare global {
1313
interface NodeRequire {

packages/react-native/types/index.d.ts

Lines changed: 0 additions & 165 deletions
This file was deleted.

packages/react-native/Libraries/ActionSheetIOS/ActionSheetIOS.d.ts renamed to packages/react-native/types_DEPRECATED/Libraries/ActionSheetIOS/ActionSheetIOS.d.ts

File renamed without changes.

packages/react-native/Libraries/Alert/Alert.d.ts renamed to packages/react-native/types_DEPRECATED/Libraries/Alert/Alert.d.ts

File renamed without changes.

packages/react-native/Libraries/Animated/Animated.d.ts renamed to packages/react-native/types_DEPRECATED/Libraries/Animated/Animated.d.ts

File renamed without changes.

packages/react-native/Libraries/Animated/Easing.d.ts renamed to packages/react-native/types_DEPRECATED/Libraries/Animated/Easing.d.ts

File renamed without changes.

packages/react-native/Libraries/Animated/useAnimatedColor.d.ts renamed to packages/react-native/types_DEPRECATED/Libraries/Animated/useAnimatedColor.d.ts

File renamed without changes.

0 commit comments

Comments
 (0)