Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create experimental TS types #37403

Merged
merged 2 commits into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions packages/react-native/Libraries/StyleSheet/StyleSheetTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type FlexAlignType =
| 'stretch'
| 'baseline';

type DimensionValue =
export type DimensionValue =
| number
| 'auto'
| `${number}%`
Expand Down Expand Up @@ -79,15 +79,9 @@ export interface FlexStyle {
| undefined;
left?: DimensionValue | undefined;
margin?: DimensionValue | undefined;
marginBlock?: DimensionValue | undefined;
marginBlockEnd?: DimensionValue | undefined;
marginBlockStart?: DimensionValue | undefined;
marginBottom?: DimensionValue | undefined;
marginEnd?: DimensionValue | undefined;
marginHorizontal?: DimensionValue | undefined;
marginInline?: DimensionValue | undefined;
marginInlineEnd?: DimensionValue | undefined;
marginInlineStart?: DimensionValue | undefined;
marginLeft?: DimensionValue | undefined;
marginRight?: DimensionValue | undefined;
marginStart?: DimensionValue | undefined;
Expand All @@ -100,14 +94,8 @@ export interface FlexStyle {
overflow?: 'visible' | 'hidden' | 'scroll' | undefined;
padding?: DimensionValue | undefined;
paddingBottom?: DimensionValue | undefined;
paddingBlock?: DimensionValue | undefined;
paddingBlockEnd?: DimensionValue | undefined;
paddingBlockStart?: DimensionValue | undefined;
paddingEnd?: DimensionValue | undefined;
paddingHorizontal?: DimensionValue | undefined;
paddingInline?: DimensionValue | undefined;
paddingInlineEnd?: DimensionValue | undefined;
paddingInlineStart?: DimensionValue | undefined;
paddingLeft?: DimensionValue | undefined;
paddingRight?: DimensionValue | undefined;
paddingStart?: DimensionValue | undefined;
Expand Down
101 changes: 101 additions & 0 deletions packages/react-native/types/experimental.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/

/**
* These are types for things that are present for New Architecture enabled apps
* which is currently considered experimental.
*
* To load the types declared here in an actual project, there are three ways.
*
* 1. If your `tsconfig.json` already has a `"types"` array in the `"compilerOptions"` section,
* is to add `"react-native/types/experimental"` to the `"types"` array.
*
* 2. Alternatively, a specific import syntax can to be used from a typescript file.
* This module does not exist in reality, which is why the {} is important:
*
* ```ts
* import {} from 'react-native/types/experimental'
* ```
*
* 3. It is also possible to include it through a triple-slash reference:
*
* ```ts
* /// <reference types="react-native/types/experimental" />
* ```
*
* Either the import or the reference only needs to appear once, anywhere in the project.
*/

import {DimensionValue} from 'react-native/Libraries/StyleSheet/StyleSheetTypes';

export {};

declare module '.' {
export interface FlexStyle {
/**
* Equivalent to `marginVertical`
*/
marginBlock?: DimensionValue | undefined;

/**
* Equivalent to `marginBottom`
*/
marginBlockEnd?: DimensionValue | undefined;

/**
* Equivalent to `marginTop`
*/
marginBlockStart?: DimensionValue | undefined;

/**
* Equivalent to `marginHorizontal`
*/
marginInline?: DimensionValue | undefined;

/**
* Equivalent to `marginEnd`
*/
marginInlineEnd?: DimensionValue | undefined;

/**
* Equivalent to `marginStart`
*/
marginInlineStart?: DimensionValue | undefined;

/**
* Equivalent to `paddingVertical`
*/
paddingBlock?: DimensionValue | undefined;

/**
* Equivalent to `paddingBottom`
*/
paddingBlockEnd?: DimensionValue | undefined;

/**
* Equivalent to `paddingTop`
*/
paddingBlockStart?: DimensionValue | undefined;

/**
* Equivalent to `paddingHorizontal`
*/
paddingInline?: DimensionValue | undefined;

/**
* Equivalent to `paddingEnd`
*/
paddingInlineEnd?: DimensionValue | undefined;

/**
* Equivalent to `paddingStart`
*/
paddingInlineStart?: DimensionValue | undefined;
}
}