Skip to content

Commit f2b5975

Browse files
committed
compile to .d.ts to fix type errors on some environments
1 parent 715b56c commit f2b5975

12 files changed

+2641
-22
lines changed

Diff for: .gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
node_modules/
1+
node_modules/
2+
lib/

Diff for: example/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"react": "~16.11.0",
1414
"react-dom": "~16.11.0",
1515
"react-native": "https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz",
16-
"react-native-fast-toast": "file:../",
16+
"react-native-fast-toast": "^2.1.0",
1717
"react-native-web": "~0.11.7"
1818
},
1919
"devDependencies": {

Diff for: example/yarn.lock

+4-2
Original file line numberDiff line numberDiff line change
@@ -4397,8 +4397,10 @@ react-native-appearance@~0.3.3:
43974397
invariant "^2.2.4"
43984398
use-subscription "^1.0.0"
43994399

4400-
"react-native-fast-toast@file:..":
4401-
version "1.1.2"
4400+
react-native-fast-toast@^2.1.0:
4401+
version "2.1.0"
4402+
resolved "https://registry.yarnpkg.com/react-native-fast-toast/-/react-native-fast-toast-2.1.0.tgz#9f26b4c82346922459dc8f3edbf91f9abfba2be0"
4403+
integrity sha512-hXveRJolqg0SEuYab7wcm/5xyVYEsYkzBm/Sw79/emqzKgB6aCFusplbCPK7cO9nlfvE5xTmzi8xcI9MbPvTfQ==
44024404

44034405
react-native-safe-area-context@~3.0.7:
44044406
version "3.0.7"

Diff for: index.ts

-3
This file was deleted.

Diff for: package.json

+27-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,38 @@
11
{
22
"name": "react-native-fast-toast",
3-
"version": "2.0.0",
4-
"main": "index.ts",
3+
"version": "2.1.1",
4+
"main": "lib/commonjs/index.js",
5+
"module": "lib/module/index.js",
6+
"types": "lib/typescript/index.d.ts",
7+
"react-native": "lib/module/index.js",
8+
"files": [
9+
"src",
10+
"lib"
11+
],
512
"license": "MIT",
613
"author": {
714
"name": "Alireza Rezania",
815
"email": "[email protected]"
916
},
17+
"homepage": "https://github.com/arnnis/react-native-fast-toast#readme",
1018
"devDependencies": {
19+
"@react-native-community/bob": "^0.16.2",
1120
"@types/react": "^16.9.49",
12-
"@types/react-native": "^0.63.15"
21+
"@types/react-native": "^0.63.15",
22+
"typescript": "^4.0.3"
23+
},
24+
"@react-native-community/bob": {
25+
"source": "src",
26+
"output": "lib",
27+
"targets": [
28+
[
29+
"commonjs",
30+
{
31+
"copyFlow": true
32+
}
33+
],
34+
"module",
35+
"typescript"
36+
]
1337
}
1438
}

Diff for: src/hook/context.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import React from "react";
22

3-
type Toast = React.RefObject<
4-
import("react-native-fast-toast").default
5-
>["current"];
3+
type Toast = React.RefObject<import("../toast-container").default>["current"];
64

75
const ToastContext = React.createContext(null as Toast);
86

Diff for: src/hook/useToast.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useContext } from "react";
1+
import { useContext } from "react";
22
import ToastContext from "./context";
33

44
const useToast = () => useContext(ToastContext);

Diff for: src/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export { default } from "./toast-container";
2+
export { default as ToastProvider } from "./hook/provider";
3+
export { default as useToast } from "./hook/useToast";

Diff for: src/toast-container.tsx

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import React, { Component } from "react";
2-
import { View, StyleSheet, Dimensions, ViewStyle, KeyboardAvoidingView, Platform } from "react-native";
2+
import {
3+
StyleSheet,
4+
Dimensions,
5+
ViewStyle,
6+
KeyboardAvoidingView,
7+
Platform,
8+
} from "react-native";
39
import Toast, { ToastOptions, ToastProps } from "./toast";
410

511
const dims = Dimensions.get("window");
@@ -77,9 +83,10 @@ class ToastContainer extends Component<Props, State> {
7783

7884
return (
7985
<KeyboardAvoidingView
80-
behavior={Platform.OS === 'ios' ? 'position' : undefined}
86+
behavior={Platform.OS === "ios" ? "position" : undefined}
8187
style={[styles.container, style]}
82-
pointerEvents="box-none">
88+
pointerEvents="box-none"
89+
>
8390
{toasts.map((toast) => (
8491
<Toast key={toast.id} {...this.props} {...toast} />
8592
))}

Diff for: src/toast.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ const Toast: FC<ToastProps> = ({
108108
}
109109
}
110110

111-
const animationStyle: Animated.WithAnimatedValue<StyleProp<ViewStyle>> = {
111+
const animationStyle = {
112112
opacity: animation,
113113
transform: [
114114
{

Diff for: tsconfig.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"compilerOptions": {
3+
"baseUrl": ".",
4+
"allowUnreachableCode": false,
5+
"allowUnusedLabels": false,
6+
"esModuleInterop": true,
7+
"forceConsistentCasingInFileNames": true,
8+
"jsx": "react",
9+
"lib": ["esnext"],
10+
"module": "esnext",
11+
"moduleResolution": "node",
12+
"noFallthroughCasesInSwitch": true,
13+
"noImplicitReturns": true,
14+
"noImplicitUseStrict": false,
15+
"noStrictGenericChecks": false,
16+
"noUnusedLocals": true,
17+
"noUnusedParameters": true,
18+
"resolveJsonModule": true,
19+
"skipLibCheck": true,
20+
"strict": true,
21+
"target": "esnext",
22+
"isolatedModules": true,
23+
},
24+
"include": ["src/**/*"]
25+
}

0 commit comments

Comments
 (0)