diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 1522fb1f2e..0000000000 --- a/index.d.ts +++ /dev/null @@ -1,31 +0,0 @@ -export { default as createNextState } from 'immer' -export { - Action, - ActionCreator, - AnyAction, - Middleware, - Reducer, - Store, - StoreEnhancer, - combineReducers, - compose -} from 'redux' -export { default as createSelector } from 'selectorator' - -export { - configureStore, - ConfigureStoreOptions, - getDefaultMiddleware -} from './src/configureStore' -export { - createAction, - getType, - PayloadAction, - PayloadActionCreator -} from './src/createAction' -export { createReducer } from './src/createReducer' -export { createSlice, CreateSliceOptions, Slice } from './src/createSlice' -export { - default as createSerializableStateInvariantMiddleware, - isPlain -} from './src/serializableStateInvariantMiddleware' diff --git a/package.json b/package.json index a60e3b257f..6bb5820a78 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "main": "dist/redux-starter-kit.cjs.js", "module": "dist/redux-starter-kit.esm.js", "unpkg": "dist/redux-starter-kit.umd.js", + "types": "dist/typings.d.ts", "author": "Mark Erikson ", "license": "MIT", "devDependencies": { @@ -45,7 +46,6 @@ }, "files": [ "dist", - "index.d.ts", "src" ], "dependencies": { diff --git a/rollup.config.js b/rollup.config.js index 3dd26f573e..c028eb6016 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -20,7 +20,7 @@ export default [ plugins: [ babel({ extensions, - exclude: 'node_modules/**' + exclude }), resolve({ extensions diff --git a/src/configureStore.ts b/src/configureStore.ts index de779d8719..6477e8418d 100644 --- a/src/configureStore.ts +++ b/src/configureStore.ts @@ -14,7 +14,7 @@ import { } from 'redux' import { composeWithDevTools } from 'redux-devtools-extension' import thunk, { ThunkDispatch, ThunkMiddleware } from 'redux-thunk' -import createSerializableStateInvariantMiddleware from './serializableStateInvariantMiddleware' +import { createSerializableStateInvariantMiddleware } from './serializableStateInvariantMiddleware' import isPlainObject from './isPlainObject' diff --git a/src/index.ts b/src/index.ts index 59cc10f77e..3f31fa3293 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,24 +1,5 @@ -export { combineReducers, compose } from 'redux' -export { default as createNextState } from 'immer' -export { default as createSelector } from 'selectorator' - -export { configureStore, getDefaultMiddleware } from './configureStore' -export { createAction, getType } from './createAction' -export { createReducer } from './createReducer' -export { createSlice } from './createSlice' -export { - default as createSerializableStateInvariantMiddleware, - isPlain -} from './serializableStateInvariantMiddleware' - -// Unfortunately, Babel's TypeScript plugin doesn't let us re-export -// types using the `export { ... } from` syntax. Because it compiles -// modules, independently, it has no way of knowing whether an identifier -// refers to a type or value, and thus cannot strip the type re-exports -// out of the generated JS. -// -// https://github.com/babel/babel/issues/8361 -// -// As a workaround, the root of this repository contains an `index.d.ts` -// that contains all type re-exports. Whenever adding a new public function -// or type, remember to export it in `index.d.ts` as well. +export * from './configureStore' +export * from './createAction' +export * from './createReducer' +export * from './createSlice' +export * from './serializableStateInvariantMiddleware' diff --git a/src/serializableStateInvariantMiddleware.test.ts b/src/serializableStateInvariantMiddleware.test.ts index 4d5b3188e0..76129fd521 100644 --- a/src/serializableStateInvariantMiddleware.test.ts +++ b/src/serializableStateInvariantMiddleware.test.ts @@ -1,7 +1,8 @@ import { Reducer } from 'redux' import { configureStore } from './configureStore' -import createSerializableStateInvariantMiddleware, { +import { + createSerializableStateInvariantMiddleware, findNonSerializableValue } from './serializableStateInvariantMiddleware' diff --git a/src/serializableStateInvariantMiddleware.ts b/src/serializableStateInvariantMiddleware.ts index a6f519a655..bdd0a4a832 100644 --- a/src/serializableStateInvariantMiddleware.ts +++ b/src/serializableStateInvariantMiddleware.ts @@ -101,7 +101,7 @@ export interface SerializableStateInvariantMiddlewareOptions { * * @param options Middleware options. */ -export default function createSerializableStateInvariantMiddleware( +export function createSerializableStateInvariantMiddleware( options: SerializableStateInvariantMiddlewareOptions = {} ): Middleware { const { isSerializable = isPlain } = options diff --git a/src/typings.ts b/src/typings.ts new file mode 100644 index 0000000000..92ed425ed3 --- /dev/null +++ b/src/typings.ts @@ -0,0 +1,15 @@ +export { + Action, + ActionCreator, + AnyAction, + Middleware, + Reducer, + Store, + StoreEnhancer, + combineReducers, + compose +} from 'redux' +export { default as createNextState } from 'immer' +export { default as createSelector } from 'selectorator' + +export * from '.' diff --git a/tsconfig.json b/tsconfig.json index 77a0ef6200..f3718bd130 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,14 +1,17 @@ { "compilerOptions": { "allowSyntheticDefaultImports": true, + "emitDeclarationOnly": true, "esModuleInterop": true, + "declaration": true, "module": "es2015", "moduleResolution": "node", - "noEmit": true, "noUnusedLocals": true, "noUnusedParameters": true, + "outDir": "dist", "strict": true, "target": "es2018" }, - "include": ["src"] + "include": ["src"], + "exclude": ["src/*.test.ts"] } diff --git a/type-tests/files/tsconfig.json b/type-tests/files/tsconfig.json index b9f3329600..e2da8a5654 100644 --- a/type-tests/files/tsconfig.json +++ b/type-tests/files/tsconfig.json @@ -8,7 +8,7 @@ "target": "es2018", "baseUrl": "../..", "paths": { - "redux-starter-kit": ["index.d.ts"] + "redux-starter-kit": ["dist/typings.d.ts"] } } }