Skip to content

Commit d9834cd

Browse files
committed
Update types
1 parent f121d94 commit d9834cd

File tree

3 files changed

+13
-21
lines changed

3 files changed

+13
-21
lines changed

src/index.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import { Platform } from 'react-native';
99
import NativeRNCImageEditor from './NativeRNCImageEditor';
1010
import type { Spec } from './NativeRNCImageEditor';
11+
import type { ImageCropData } from './types.ts';
1112

1213
const LINKING_ERROR =
1314
`The package '@react-native-community/image-editor' doesn't seem to be linked. Make sure: \n\n` +
@@ -23,16 +24,6 @@ const RNCImageEditor: Spec = NativeRNCImageEditor
2324
},
2425
});
2526

26-
type ImageCropDataFromSpec = Parameters<Spec['cropImage']>[1];
27-
28-
export interface ImageCropData
29-
extends Omit<ImageCropDataFromSpec, 'resizeMode'> {
30-
resizeMode?: 'contain' | 'cover' | 'stretch';
31-
// ^^^ codegen doesn't support union types yet
32-
// so to provide more type safety we override the type here
33-
format?: 'png' | 'jpeg' | 'webp'; // web only
34-
}
35-
3627
class ImageEditor {
3728
/**
3829
* Crop the image specified by the URI param. If URI points to a remote

src/index.web.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
1-
import type { Spec } from './NativeRNCImageEditor';
2-
3-
type ImageCropDataFromSpec = Parameters<Spec['cropImage']>[1];
4-
5-
export interface ImageCropData
6-
extends Omit<ImageCropDataFromSpec, 'resizeMode'> {
7-
resizeMode?: 'contain' | 'cover' | 'stretch';
8-
// ^^^ codegen doesn't support union types yet
9-
// so to provide more type safety we override the type here
10-
format?: 'png' | 'jpeg' | 'webp'; // web only
11-
}
1+
import type { ImageCropData } from './types.ts';
122

133
function drawImage(
144
img: HTMLImageElement,

src/types.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type { Spec } from './NativeRNCImageEditor.ts';
2+
3+
type ImageCropDataFromSpec = Parameters<Spec['cropImage']>[1];
4+
5+
export interface ImageCropData
6+
extends Omit<ImageCropDataFromSpec, 'resizeMode' | 'format'> {
7+
format?: 'png' | 'jpeg' | 'webp';
8+
resizeMode?: 'contain' | 'cover' | 'stretch';
9+
// ^^^ codegen doesn't support union types yet
10+
// so to provide more type safety we override the type here
11+
}

0 commit comments

Comments
 (0)