Skip to content

Commit 808503a

Browse files
committed
fix: type dist again
1 parent 04382eb commit 808503a

File tree

7 files changed

+197
-192
lines changed

7 files changed

+197
-192
lines changed

package.json

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "2.0.1",
44
"main": "lib/index.js",
55
"module": "lib/es/index.js",
6-
"types": "types/index.d.ts",
6+
"types": "index.d.ts",
77
"repository": {
88
"type": "git",
99
"url": "https://github.com/4Catalyzer/react-context-toolbox.git"
@@ -16,11 +16,15 @@
1616
"testonly": "jest",
1717
"test:types": "dtslint types",
1818
"build:es": "babel src -d lib/es --env-name esm --ignore **/__tests__ ",
19-
"build:lib": "babel src -d lib --ignore **/__tests__ --delete-dir-on-start ",
20-
"build": "npm run build:lib && npm run build:es && cpy types/index.d.ts lib/types",
19+
"build:lib":
20+
"babel src -d lib --ignore **/__tests__ --delete-dir-on-start ",
21+
"build":
22+
"npm run build:lib && npm run build:es && cpy types/*.d.ts lib && cpy types/*.d.ts lib/es",
2123
"prepublishOnly": "yarn run build",
22-
"lint": "eslint . && prettier --list-different --ignore-path .eslintignore '**/*.{json,css,md}'",
23-
"format": "eslint . --fix && prettier --write --ignore-path .eslintignore '**/*.{json,css,md}'",
24+
"lint":
25+
"eslint . && prettier --list-different --ignore-path .eslintignore '**/*.{json,css,md}'",
26+
"format":
27+
"eslint . --fix && prettier --write --ignore-path .eslintignore '**/*.{json,css,md}'",
2428
"precommit": "lint-staged"
2529
},
2630
"publishConfig": {
@@ -32,28 +36,19 @@
3236
"trailingComma": "all"
3337
},
3438
"lint-staged": {
35-
"*.js": [
36-
"eslint --fix",
37-
"git add"
38-
],
39+
"*.js": ["eslint --fix", "git add"],
3940
"*.{json,css,md}": [
4041
"prettier --write --ignore-path .eslintignore",
4142
"git add"
4243
]
4344
},
4445
"jest": {
45-
"roots": [
46-
"<rootDir>/test"
47-
],
46+
"roots": ["<rootDir>/test"],
4847
"testEnvironment": "jsdom",
49-
"setupFiles": [
50-
"<rootDir>/test/index.js"
51-
]
48+
"setupFiles": ["<rootDir>/test/index.js"]
5249
},
5350
"release": {
54-
"extends": [
55-
"@4c/semantic-release-config"
56-
],
51+
"extends": ["@4c/semantic-release-config"],
5752
"pkgRoot": "lib"
5853
},
5954
"devDependencies": {

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export { mapContextToProps } from './mapContextToProps';
2+
export { forwardRef } from './forwardRef';

types/forwardRef.d.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// TypeScript Version: 3.0
2+
3+
declare module 'react-context-toolbox/forwardRef' {
4+
import * as React from 'react';
5+
6+
interface ForwardRefOptions<TProps> {
7+
displayName?: string;
8+
propTypes?: React.ValidationMap<TProps>;
9+
defaultProps?: Partial<TProps>;
10+
allowFallback?: boolean;
11+
}
12+
13+
function forwardRef<TRef, TProps>(
14+
renderFn: (
15+
props: TProps & { children?: React.ReactNode },
16+
ref: React.Ref<TRef> | null,
17+
) => React.ReactElement<any> | null,
18+
options?: ForwardRefOptions<TProps>,
19+
): React.ForwardRefExoticComponent<
20+
React.PropsWithRef<TProps> & React.RefAttributes<TRef>
21+
>;
22+
23+
export default forwardRef;
24+
}

types/index.d.ts

Lines changed: 4 additions & 171 deletions
Original file line numberDiff line numberDiff line change
@@ -1,175 +1,8 @@
11
// TypeScript Version: 3.0
22

3-
declare module 'react-context-toolbox/forwardRef' {
4-
import * as React from 'react';
3+
declare module 'react-context-toolbox' {
4+
import mapContextToProps from 'react-context-toolbox/mapContextToProps';
5+
import forwardRef from 'react-context-toolbox/forwardRef';
56

6-
interface ForwardRefOptions<TProps> {
7-
displayName?: string;
8-
propTypes?: React.ValidationMap<TProps>;
9-
defaultProps?: Partial<TProps>;
10-
allowFallback?: boolean;
11-
}
12-
13-
function forwardRef<TRef, TProps>(
14-
renderFn: (
15-
props: TProps & { children?: React.ReactNode },
16-
ref: React.Ref<TRef> | null,
17-
) => React.ReactElement<any> | null,
18-
options?: ForwardRefOptions<TProps>,
19-
): React.ForwardRefExoticComponent<
20-
React.PropsWithRef<TProps> & React.RefAttributes<TRef>
21-
>;
22-
23-
export default forwardRef;
24-
}
25-
26-
declare module 'react-context-toolbox/mapContextToProps' {
27-
import * as React from 'react';
28-
29-
type ElementType = React.ComponentType<any> | keyof JSX.IntrinsicElements;
30-
31-
type Omit<T, U> = Pick<T, Exclude<keyof T, keyof U>>;
32-
33-
type GetProps<C> = C extends React.ComponentType<infer P> ? P : never;
34-
35-
interface ContextInjectedComponent<TComponent, TInjectedProps, TExtraProps>
36-
extends React.ForwardRefExoticComponent<
37-
Omit<GetProps<TComponent>, TInjectedProps> & TExtraProps
38-
> {}
39-
40-
// Single Context
41-
function mapContextToProps<TComponent, TContext, TContextProps, TOwnProps>(
42-
context: React.Context<TContext> | [React.Context<TContext>],
43-
mapToProps: (ctxValue: TContext, props: TOwnProps) => TContextProps,
44-
Component: TComponent,
45-
): ContextInjectedComponent<TComponent, TContextProps, TOwnProps>;
46-
function mapContextToProps<TContext, TContextProps, TOwnProps>(
47-
context: React.Context<TContext> | [React.Context<TContext>],
48-
mapToProps: (ctxValue: TContext, props: TOwnProps) => TContextProps,
49-
): <TComponent>(
50-
component: TComponent,
51-
) => ContextInjectedComponent<TComponent, TContextProps, TOwnProps>;
52-
53-
// 2 Contexts
54-
function mapContextToProps<
55-
TComponent,
56-
TContext1,
57-
TContext2,
58-
TContextProps,
59-
TOwnProps
60-
>(
61-
context: [React.Context<TContext1>, React.Context<TContext2>],
62-
mapToProps: (
63-
c1: TContext1,
64-
c2: TContext2,
65-
props: TOwnProps,
66-
) => TContextProps,
67-
Component: TComponent,
68-
): ContextInjectedComponent<TComponent, TContextProps, TOwnProps>;
69-
function mapContextToProps<TContext1, TContext2, TContextProps, TOwnProps>(
70-
context: [React.Context<TContext1>, React.Context<TContext2>],
71-
mapToProps: (
72-
c1: TContext1,
73-
c2: TContext2,
74-
props: TOwnProps,
75-
) => TContextProps,
76-
): <TComponent>(
77-
component: TComponent,
78-
) => ContextInjectedComponent<TComponent, TContextProps, TOwnProps>;
79-
80-
// 3 Contexts
81-
function mapContextToProps<
82-
TComponent,
83-
TContext1,
84-
TContext2,
85-
TContext3,
86-
TContextProps,
87-
TOwnProps
88-
>(
89-
context: [
90-
React.Context<TContext1>,
91-
React.Context<TContext2>,
92-
React.Context<TContext3>
93-
],
94-
mapToProps: (
95-
c1: TContext1,
96-
c2: TContext2,
97-
c3: TContext3,
98-
props: TOwnProps,
99-
) => TContextProps,
100-
Component: TComponent,
101-
): ContextInjectedComponent<TComponent, TContextProps, TOwnProps>;
102-
function mapContextToProps<
103-
TContext1,
104-
TContext2,
105-
TContext3,
106-
TContextProps,
107-
TOwnProps
108-
>(
109-
context: [
110-
React.Context<TContext1>,
111-
React.Context<TContext2>,
112-
React.Context<TContext3>
113-
],
114-
mapToProps: (
115-
c1: TContext1,
116-
c2: TContext2,
117-
c3: TContext3,
118-
props: TOwnProps,
119-
) => TContextProps,
120-
): <TComponent>(
121-
component: TComponent,
122-
) => ContextInjectedComponent<TComponent, TContextProps, TOwnProps>;
123-
124-
// 4 Contexts
125-
function mapContextToProps<
126-
TComponent,
127-
TContext1,
128-
TContext2,
129-
TContext3,
130-
TContext4,
131-
TContextProps,
132-
TOwnProps
133-
>(
134-
context: [
135-
React.Context<TContext1>,
136-
React.Context<TContext2>,
137-
React.Context<TContext3>,
138-
React.Context<TContext4>
139-
],
140-
mapToProps: (
141-
c1: TContext1,
142-
c2: TContext2,
143-
c3: TContext3,
144-
c4: TContext4,
145-
props: TOwnProps,
146-
) => TContextProps,
147-
Component: TComponent,
148-
): ContextInjectedComponent<TComponent, TContextProps, TOwnProps>;
149-
function mapContextToProps<
150-
TContext1,
151-
TContext2,
152-
TContext3,
153-
TContext4,
154-
TContextProps,
155-
TOwnProps
156-
>(
157-
context: [
158-
React.Context<TContext1>,
159-
React.Context<TContext2>,
160-
React.Context<TContext3>,
161-
React.Context<TContext4>
162-
],
163-
mapToProps: (
164-
c1: TContext1,
165-
c2: TContext2,
166-
c3: TContext3,
167-
c4: TContext4,
168-
props: TOwnProps,
169-
) => TContextProps,
170-
): <TComponent>(
171-
component: TComponent,
172-
) => ContextInjectedComponent<TComponent, TContextProps, TOwnProps>;
173-
174-
export default mapContextToProps;
7+
export { mapContextToProps, forwardRef };
1758
}

0 commit comments

Comments
 (0)