Skip to content

Commit f2cf05b

Browse files
lunaleapsLuna Wei
authored andcommitted
🤖 Merge PR DefinitelyTyped#65485 [react-native] Add experimental types by @lunaleaps
* [react-native] Add experimental types * Remove exports --------- Co-authored-by: Luna Wei <[email protected]>
1 parent 7c00b12 commit f2cf05b

File tree

3 files changed

+117
-0
lines changed

3 files changed

+117
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import * as React from 'react';
2+
3+
import {
4+
View,
5+
StyleSheet,
6+
} from 'react-native';
7+
8+
import {} from 'react-native/types/experimental';
9+
10+
function TestExperimentalStyleSheetProps() {
11+
return (
12+
<>
13+
<View style={styles.experimental} />
14+
<View style={{marginInline: 2, marginInlineEnd: 3, marginBlock: 3}} />
15+
</>
16+
);
17+
}
18+
19+
const styles = StyleSheet.create({
20+
experimental: {
21+
paddingBlock: 3,
22+
paddingInline: 2,
23+
}
24+
})

types/react-native/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"files": [
1919
"index.d.ts",
2020
"test/animated.tsx",
21+
"test/experimental.tsx",
2122
"test/fabric-component-sample.ts",
2223
"test/globals.tsx",
2324
"test/index.tsx",
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/**
2+
* These are types for things that are present for New Architecture enabled apps
3+
* which is currently considered experimental.
4+
*
5+
* To load the types declared here in an actual project, there are three ways.
6+
*
7+
* 1. If your `tsconfig.json` already has a `"types"` array in the `"compilerOptions"` section,
8+
* is to add `"react-native/types/experimental"` to the `"types"` array.
9+
*
10+
* 2. Alternatively, a specific import syntax can to be used from a typescript file.
11+
* This module does not exist in reality, which is why the {} is important:
12+
*
13+
* ```ts
14+
* import {} from 'react-native/types/experimental'
15+
* ```
16+
*
17+
* 3. It is also possible to include it through a triple-slash reference:
18+
*
19+
* ```ts
20+
* /// <reference types="react-native/types/experimental" />
21+
* ```
22+
*
23+
* Either the import or the reference only needs to appear once, anywhere in the project.
24+
*/
25+
26+
import {DimensionValue} from '../Libraries/StyleSheet/StyleSheetTypes';
27+
28+
export {};
29+
30+
declare module '.' {
31+
export interface FlexStyle {
32+
/**
33+
* Equivalent to `marginVertical`
34+
*/
35+
marginBlock?: DimensionValue | undefined;
36+
37+
/**
38+
* Equivalent to `marginBottom`
39+
*/
40+
marginBlockEnd?: DimensionValue | undefined;
41+
42+
/**
43+
* Equivalent to `marginTop`
44+
*/
45+
marginBlockStart?: DimensionValue | undefined;
46+
47+
/**
48+
* Equivalent to `marginHorizontal`
49+
*/
50+
marginInline?: DimensionValue | undefined;
51+
52+
/**
53+
* Equivalent to `marginEnd`
54+
*/
55+
marginInlineEnd?: DimensionValue | undefined;
56+
57+
/**
58+
* Equivalent to `marginStart`
59+
*/
60+
marginInlineStart?: DimensionValue | undefined;
61+
62+
/**
63+
* Equivalent to `paddingVertical`
64+
*/
65+
paddingBlock?: DimensionValue | undefined;
66+
67+
/**
68+
* Equivalent to `paddingBottom`
69+
*/
70+
paddingBlockEnd?: DimensionValue | undefined;
71+
72+
/**
73+
* Equivalent to `paddingTop`
74+
*/
75+
paddingBlockStart?: DimensionValue | undefined;
76+
77+
/**
78+
* Equivalent to `paddingHorizontal`
79+
*/
80+
paddingInline?: DimensionValue | undefined;
81+
82+
/**
83+
* Equivalent to `paddingEnd`
84+
*/
85+
paddingInlineEnd?: DimensionValue | undefined;
86+
87+
/**
88+
* Equivalent to `paddingStart`
89+
*/
90+
paddingInlineStart?: DimensionValue | undefined;
91+
}
92+
}

0 commit comments

Comments
 (0)