Skip to content

Defer to rollup TS plugin to build types #3564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.DS_Store
*.log
node_modules

coverage

dist
lib
es
coverage
types

website/translated_docs
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,13 @@
"format": "prettier --write \"{src,test}/**/*.{js,ts}\" index.d.ts \"**/*.md\"",
"format:check": "prettier --list-different \"{src,test}/**/*.{js,ts}\" index.d.ts \"**/*.md\"",
"lint": "eslint --ext js,ts src test",
"check-types": "tsc --noEmit",
"pretest": "npm run build",
"test": "jest",
"test:watch": "npm test -- --watch",
"test:cov": "npm test -- --coverage",
"build": "npm run build-types && rollup -c",
"build": "rollup -c",
"prepare": "npm run clean && npm run check-types && npm run format:check && npm run lint && npm test",
"build-types": "tsc --emitDeclarationOnly",
"check-types": "tsc --noEmit",
"examples:lint": "eslint --ext js,ts examples",
"examples:test": "cross-env CI=true babel-node examples/testAll.js"
},
Expand Down
12 changes: 7 additions & 5 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { terser } from 'rollup-plugin-terser'

import pkg from './package.json'

const noDeclarationFiles = { compilerOptions: { declaration: false } };

export default [
// CommonJS
{
Expand All @@ -19,7 +21,7 @@ export default [
nodeResolve({
extensions: ['.ts']
}),
typescript(),
typescript({ useTsconfigDeclarationDir: true }),
babel()
]
},
Expand All @@ -36,7 +38,7 @@ export default [
nodeResolve({
extensions: ['.ts']
}),
typescript(),
typescript({ tsconfigOverride: noDeclarationFiles }),
babel()
]
},
Expand All @@ -52,7 +54,7 @@ export default [
replace({
'process.env.NODE_ENV': JSON.stringify('production')
}),
typescript(),
typescript({ tsconfigOverride: noDeclarationFiles }),
babel({
exclude: 'node_modules/**'
}),
Expand Down Expand Up @@ -80,7 +82,7 @@ export default [
nodeResolve({
extensions: ['.ts']
}),
typescript(),
typescript({ tsconfigOverride: noDeclarationFiles }),
babel({
exclude: 'node_modules/**'
}),
Expand All @@ -103,7 +105,7 @@ export default [
nodeResolve({
extensions: ['.ts']
}),
typescript(),
typescript({ tsconfigOverride: noDeclarationFiles }),
babel({
exclude: 'node_modules/**'
}),
Expand Down
2 changes: 1 addition & 1 deletion test/typescript/actionCreators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
Dispatch,
bindActionCreators,
ActionCreatorsMapObject
} from 'redux'
} from '../..'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. This could have caused a number of problems for people working on the code!


interface AddTodoAction extends Action {
text: string
Expand Down
2 changes: 1 addition & 1 deletion test/typescript/actions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Action as ReduxAction } from 'redux'
import { Action as ReduxAction } from '../..'

namespace FSA {
interface Action<P> extends ReduxAction {
Expand Down
2 changes: 1 addition & 1 deletion test/typescript/compose.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { compose } from 'redux'
import { compose } from '../..'

// adapted from DefinitelyTyped/compose-function

Expand Down
2 changes: 1 addition & 1 deletion test/typescript/dispatch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Dispatch, AnyAction } from 'redux'
import { Dispatch } from '../..'

/**
* Default Dispatch type accepts any object with `type` property.
Expand Down
9 changes: 1 addition & 8 deletions test/typescript/enhancers.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import {
StoreEnhancer,
Action,
AnyAction,
Reducer,
createStore,
PreloadedState
} from 'redux'
import { StoreEnhancer, Action, AnyAction, Reducer, createStore } from '../..'

interface State {
someField: 'string'
Expand Down
2 changes: 1 addition & 1 deletion test/typescript/injectedDispatch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Dispatch, Action } from 'redux'
import { Dispatch, Action } from '../..'

interface Component<P> {
props: P
Expand Down
3 changes: 1 addition & 2 deletions test/typescript/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ import {
Middleware,
MiddlewareAPI,
applyMiddleware,
StoreEnhancer,
createStore,
Dispatch,
Reducer,
Action,
AnyAction
} from 'redux'
} from '../..'

/**
* Logger middleware doesn't add any extra types to dispatch, just logs actions
Expand Down
2 changes: 1 addition & 1 deletion test/typescript/reducers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Reducer, Action, combineReducers, ReducersMapObject } from 'redux'
import { Reducer, Action, combineReducers, ReducersMapObject } from '../..'

/**
* Simple reducer definition with no action shape checks.
Expand Down
2 changes: 1 addition & 1 deletion test/typescript/replaceReducer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { combineReducers, createStore } from 'redux'
import { combineReducers, createStore } from '../..'

/**
* verify that replaceReducer maintains strict typing if the new types change
Expand Down
4 changes: 1 addition & 3 deletions test/typescript/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ import {
Reducer,
Action,
StoreEnhancer,
StoreCreator,
StoreEnhancerStoreCreator,
Unsubscribe,
Observer,
ExtendState
} from 'redux'
} from '../..'
import 'symbol-observable'

type State = {
Expand Down
5 changes: 1 addition & 4 deletions test/typescript/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
"compilerOptions": {
"lib": ["es2017", "dom"],
"strict": true,
"baseUrl": "../..",
"paths": {
"redux": ["types/index.d.ts"]
}
"baseUrl": "../.."
}
}