Skip to content

Commit d8417e8

Browse files
jedmaotimdorr
andcommitted
Defer to rollup TS plugin to build types (#3564)
* Defer to rollup TS plugin to build types * index.ts -> redux.js, redux.d.ts * Only output one copy of the types. This also puts them back into the types path. However, I don't know how to have them output as a single file bundle to match our other outputs. * Remove the move Co-authored-by: Tim Dorr <[email protected]>
1 parent 9e71b4c commit d8417e8

14 files changed

+23
-35
lines changed

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
.DS_Store
2-
*.log
31
node_modules
2+
3+
coverage
4+
45
dist
56
lib
67
es
7-
coverage
88
types
99

1010
website/translated_docs

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,13 @@
3939
"format": "prettier --write \"{src,test}/**/*.{js,ts}\" index.d.ts \"**/*.md\"",
4040
"format:check": "prettier --list-different \"{src,test}/**/*.{js,ts}\" index.d.ts \"**/*.md\"",
4141
"lint": "eslint --ext js,ts src test",
42+
"check-types": "tsc --noEmit",
4243
"pretest": "npm run build",
4344
"test": "jest",
4445
"test:watch": "npm test -- --watch",
4546
"test:cov": "npm test -- --coverage",
46-
"build": "npm run build-types && rollup -c",
47+
"build": "rollup -c",
4748
"prepare": "npm run clean && npm run check-types && npm run format:check && npm run lint && npm test",
48-
"build-types": "tsc --emitDeclarationOnly",
49-
"check-types": "tsc --noEmit",
5049
"examples:lint": "eslint --ext js,ts examples",
5150
"examples:test": "cross-env CI=true babel-node examples/testAll.js"
5251
},

rollup.config.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { terser } from 'rollup-plugin-terser'
66

77
import pkg from './package.json'
88

9+
const noDeclarationFiles = { compilerOptions: { declaration: false } };
10+
911
export default [
1012
// CommonJS
1113
{
@@ -19,7 +21,7 @@ export default [
1921
nodeResolve({
2022
extensions: ['.ts']
2123
}),
22-
typescript(),
24+
typescript({ useTsconfigDeclarationDir: true }),
2325
babel()
2426
]
2527
},
@@ -36,7 +38,7 @@ export default [
3638
nodeResolve({
3739
extensions: ['.ts']
3840
}),
39-
typescript(),
41+
typescript({ tsconfigOverride: noDeclarationFiles }),
4042
babel()
4143
]
4244
},
@@ -52,7 +54,7 @@ export default [
5254
replace({
5355
'process.env.NODE_ENV': JSON.stringify('production')
5456
}),
55-
typescript(),
57+
typescript({ tsconfigOverride: noDeclarationFiles }),
5658
babel({
5759
exclude: 'node_modules/**'
5860
}),
@@ -80,7 +82,7 @@ export default [
8082
nodeResolve({
8183
extensions: ['.ts']
8284
}),
83-
typescript(),
85+
typescript({ tsconfigOverride: noDeclarationFiles }),
8486
babel({
8587
exclude: 'node_modules/**'
8688
}),
@@ -103,7 +105,7 @@ export default [
103105
nodeResolve({
104106
extensions: ['.ts']
105107
}),
106-
typescript(),
108+
typescript({ tsconfigOverride: noDeclarationFiles }),
107109
babel({
108110
exclude: 'node_modules/**'
109111
}),

test/typescript/actionCreators.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
Dispatch,
55
bindActionCreators,
66
ActionCreatorsMapObject
7-
} from 'redux'
7+
} from '../..'
88

99
interface AddTodoAction extends Action {
1010
text: string

test/typescript/actions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Action as ReduxAction } from 'redux'
1+
import { Action as ReduxAction } from '../..'
22

33
namespace FSA {
44
interface Action<P> extends ReduxAction {

test/typescript/compose.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { compose } from 'redux'
1+
import { compose } from '../..'
22

33
// adapted from DefinitelyTyped/compose-function
44

test/typescript/dispatch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Dispatch, AnyAction } from 'redux'
1+
import { Dispatch } from '../..'
22

33
/**
44
* Default Dispatch type accepts any object with `type` property.

test/typescript/enhancers.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
import {
2-
StoreEnhancer,
3-
Action,
4-
AnyAction,
5-
Reducer,
6-
createStore,
7-
PreloadedState
8-
} from 'redux'
1+
import { StoreEnhancer, Action, AnyAction, Reducer, createStore } from '../..'
92

103
interface State {
114
someField: 'string'

test/typescript/injectedDispatch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Dispatch, Action } from 'redux'
1+
import { Dispatch, Action } from '../..'
22

33
interface Component<P> {
44
props: P

test/typescript/middleware.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ import {
22
Middleware,
33
MiddlewareAPI,
44
applyMiddleware,
5-
StoreEnhancer,
65
createStore,
76
Dispatch,
87
Reducer,
98
Action,
109
AnyAction
11-
} from 'redux'
10+
} from '../..'
1211

1312
/**
1413
* Logger middleware doesn't add any extra types to dispatch, just logs actions

test/typescript/reducers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Reducer, Action, combineReducers, ReducersMapObject } from 'redux'
1+
import { Reducer, Action, combineReducers, ReducersMapObject } from '../..'
22

33
/**
44
* Simple reducer definition with no action shape checks.

test/typescript/replaceReducer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { combineReducers, createStore } from 'redux'
1+
import { combineReducers, createStore } from '../..'
22

33
/**
44
* verify that replaceReducer maintains strict typing if the new types change

test/typescript/store.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ import {
44
Reducer,
55
Action,
66
StoreEnhancer,
7-
StoreCreator,
8-
StoreEnhancerStoreCreator,
97
Unsubscribe,
108
Observer,
119
ExtendState
12-
} from 'redux'
10+
} from '../..'
1311
import 'symbol-observable'
1412

1513
type State = {

test/typescript/tsconfig.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
"compilerOptions": {
33
"lib": ["es2017", "dom"],
44
"strict": true,
5-
"baseUrl": "../..",
6-
"paths": {
7-
"redux": ["types/index.d.ts"]
8-
}
5+
"baseUrl": "../.."
96
}
107
}

0 commit comments

Comments
 (0)