Skip to content

Commit e1a22a2

Browse files
committed
revert(revert): ⏪ revert split types changes
1 parent fc07bd3 commit e1a22a2

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"url": "git+https://github.com/timelessco/renderlesskit-react-tailwind.git"
1919
},
2020
"license": "MIT",
21-
"author": "Navin Moorthy <navin@timeless.co>",
21+
"author": "Timeless <hello@timeless.co>",
2222
"sideEffects": false,
2323
"main": "dist/cjs/index.js",
2424
"module": "dist/esm/index.js",
@@ -37,6 +37,7 @@
3737
"build:cjs": "cross-env BABEL_ENV=cjs babel src --extensions .ts,.tsx -d dist/cjs --source-maps",
3838
"build:esm": "cross-env BABEL_ENV=esm babel src --extensions .ts,.tsx -d dist/esm --source-maps",
3939
"build:types": "tsc --emitDeclarationOnly --project tsconfig.prod.json",
40+
"check-types": "yarn build:types && yarn tsd",
4041
"commit": "gacp",
4142
"contributors:add": "all-contributors add",
4243
"contributors:generate": "all-contributors generate",
@@ -53,7 +54,7 @@
5354
"release:github": "conventional-github-releaser -p angular && git push",
5455
"storybook": "cross-env DEBUG=true start-storybook -p 6006",
5556
"test": "jest --config ./jest.config.ts --no-cache",
56-
"typecheck": "tsc --noEmit --project tsconfig.prod.json && tsd"
57+
"tsd": "tsd"
5758
},
5859
"commitlint": {
5960
"extends": [

src/toast/ToastBar.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from "react";
22
import { cx } from "@renderlesskit/react";
33

44
import { useTheme } from "../theme";
5-
// import { Split } from "../utils/types";
5+
import { Split } from "../utils/types";
66
import { isFunction, objectKeys } from "../utils";
77
import { useHover, useMediaQuery } from "../hooks";
88
import { Toast, ToastPlacement, useToasts, useToastsReturnType } from "./index";
@@ -34,7 +34,7 @@ export type ToastsContainerProps = {
3434

3535
export const ToastsContainer = (props: ToastsContainerProps) => {
3636
const { toasts, placement, updateHeight, calculateOffset } = props;
37-
const [side, position] = placement.split("-") as any;
37+
const [side, position] = placement.split("-") as Split<typeof placement, "-">;
3838

3939
const [isMobile] = useMediaQuery("(max-width: 640px)");
4040
const { hoverProps, isHovered } = useHover();
@@ -113,7 +113,7 @@ export const StackableToast = (props: StackableToastProps) => {
113113
);
114114

115115
const isToastVisible = visible;
116-
const [side, position] = placement.split("-") as any;
116+
const [side, position] = placement.split("-") as Split<typeof placement, "-">;
117117
const sortedIndex = toastsLength - (index + 1);
118118
const clampedIndex =
119119
sortedIndex > visibleToasts ? visibleToasts : sortedIndex;

src/utils/types.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ export type AnyString = string & { ignore?: any };
4545

4646
export type Dict<T = any> = Record<string, T>;
4747

48-
// export type Split<T, K extends string> = T extends `${infer P1}${K}${infer P2}`
49-
// ? [P1, ...Split<P2, K>]
50-
// : [T];
48+
export type Split<T, K extends string> = T extends `${infer P1}${K}${infer P2}`
49+
? [P1, ...Split<P2, K>]
50+
: [T];
5151

5252
export type DeepPartial<T> = {
5353
[P in keyof T]?: DeepPartial<T[P]>;

0 commit comments

Comments
 (0)