Skip to content

Commit 5c048ae

Browse files
committed
feat: improve TypeScript configuration and add type definitions
This commit enhances the TypeScript build configuration by: - Adding type declaration generation for the library - Configuring declaration output directory - Adding type definitions for ImageViewer and Gallery components - Updating package.json to include types in exports
1 parent 5b67492 commit 5c048ae

File tree

4 files changed

+38
-22
lines changed

4 files changed

+38
-22
lines changed

package.json

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"source": "./src/index.tsx",
66
"main": "./lib/commonjs/index.js",
77
"module": "./lib/module/index.js",
8+
"types": "./lib/typescript/src/index.d.ts",
89
"exports": {
910
".": {
1011
"import": {
@@ -187,25 +188,12 @@
187188
"source": "src",
188189
"output": "lib",
189190
"targets": [
190-
[
191-
"commonjs",
192-
{
193-
"esm": true
194-
}
195-
],
196-
[
197-
"module",
198-
{
199-
"esm": true
200-
}
201-
],
202-
[
203-
"typescript",
204-
{
205-
"project": "tsconfig.build.json",
206-
"esm": true
207-
}
208-
]
191+
["commonjs", {"configFile": "./babel.config.js"}],
192+
["module", {"configFile": "./babel.config.js"}],
193+
["typescript", {
194+
"project": "tsconfig.build.json",
195+
"tsc": "./node_modules/.bin/tsc"
196+
}]
209197
]
210198
},
211199
"create-react-native-library": {

src/index.d.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import type { ImageStyle, ImageSourcePropType, ViewStyle } from 'react-native';
2+
3+
export interface ImageViewerProps {
4+
source: ImageSourcePropType;
5+
imageStyle?: ImageStyle;
6+
}
7+
8+
export interface GalleryProps {
9+
data: ImageSourcePropType[];
10+
style?: ViewStyle;
11+
imageStyle?: ImageStyle;
12+
containerStyle?: ViewStyle;
13+
contentContainerStyle?: ViewStyle;
14+
backdropColor?: string;
15+
}
16+
17+
export { default as ImageViewer } from './ImageViewer';
18+
export { default } from './Gallery';

tsconfig.build.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
{
22
"extends": "./tsconfig",
3-
"exclude": ["example", "lib"]
4-
}
3+
"compilerOptions": {
4+
"declaration": true,
5+
"declarationDir": "lib/typescript",
6+
"emitDeclarationOnly": true,
7+
"noEmit": false
8+
},
9+
"exclude": ["**/__tests__", "**/*.test.ts", "example"]
10+
}

tsconfig.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,9 @@
2626
"strict": true,
2727
"target": "ESNext",
2828
"verbatimModuleSyntax": true,
29-
}
29+
"declaration": true,
30+
"declarationDir": "./lib/typescript"
31+
},
32+
"include": ["src"],
33+
"exclude": ["example", "lib", "node_modules"]
3034
}

0 commit comments

Comments
 (0)