5

The TypeScript compiler is reporting errors in the react-redux typings file, even though I have excluded the typings directory in tsconfig.

TypeScript version: 1.8.10

Here are the errors I'm getting

ERROR in /home/me/dev/proj/typings/main/ambient/react-redux/index.d.ts (64,16): error TS2314: Generic type 'Dispatch' requires 1 type argument(s).

ERROR in /home/me/dev/proj/typings/main/ambient/react-redux/index.d.ts (68,21): error TS2314: Generic type 'ActionCreator' requires 1 type argument(s).

ERROR in /home/me/dev/proj/typings/main/ambient/react-redux/index.d.ts (95,13): error TS2314: Generic type 'Store' requires 1 type argument(s).

typings.json:

{
    "ambientDependencies": {
        "es6-shim": "registry:dt/es6-shim#0.31.2+20160602141504",
        "material-ui": "registry:dt/material-ui#0.15.0+20160602140214",
        "query-string": "registry:dt/query-string#3.0.0+20160331065456",
        "react": "github:DefinitelyTyped/DefinitelyTyped/react/react.d.ts#f407264835650f5f38d4bb2c515a79e7a835916b",
        "react-addons-css-transition-group": "registry:dt/react-addons-css-transition-group#0.14.0+20160316155526",
        "react-addons-transition-group": "registry:dt/react-addons-transition-group#0.14.0+20160417134118",
        "react-dom": "github:DefinitelyTyped/DefinitelyTyped/react/react-dom.d.ts#ca5bfe76d2d9bf6852cbc712d9f3e0047c93486e",
        "react-redux": "registry:dt/react-redux#4.4.0+20160501125835",
        "react-tap-event-plugin": "registry:dt/react-tap-event-plugin#0.0.0+20160226083632",
        "require": "registry:dt/require#2.1.20+20160316155526",
        "socket.io-client": "registry:dt/socket.io-client#1.4.4+20160317120654"
    }, 
    "dependencies": {
        "es6-promise": "registry:npm/es6-promise#3.0.0+20160211003958",
        "radium": "registry:npm/radium#0.16.6+20160310030142",
        "redux-thunk": "registry:npm/redux-thunk#2.0.0+20160525185520",
        "webpack": "registry:npm/webpack#1.12.9+20160418172948"
    }
}

tsconfig.json:

{
    "version": "1.8.10",
    "compileOnSave": false,
    "compilerOptions": {
        "module": "commonjs",
        "target": "es5",
        "jsx": "react",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true
    },
    "exclude": [
        "node_modules",
        "typings"
    ]
}

Why is it reporting errors from an excluded directory? How can I eliminate these errors?

Update:

As Mike suggested in his answer, the problem is that the react-redux definitions are using the dt definitions for redux, and not the ones that ship with redux. Installing the dt defintions for redux does indeed take these errors away, but this is not an option for me since my own code uses the generic types defined in the definitions file that ships with redux.

So my real question is this: How can I stop TypeScript from reporting errors in files from the typings directory? I thought that setting 'typings' as one of the exclude directories would stop this, but it doesn't.

1 Answer 1

3

It looks like the dt definitions for react-redux have a dependency on the dt definitions for redux, these differ from the ones bundled with the redux npm module, which it looks like you may be relying on.

Installing the ambient (global) definitions of redux from dt should resolve the issue.

typings install dt~redux --global --save

The TS typing space is messy.

The fact that when you install dt type definitions for react-redux it strips any dependencies forcing you to install each yourself makes things that bit more confusing.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for your answer. Yes, you are right, but unfortunately your suggested solution is not an option for me. See the update in my question
Btw, the given command to install redux typings from the dt repository didn't work for me, I needed >typings install redux --ambient.
It sounds like you're using a pre 1.0 version of the typings lib github.com/typings/typings#updating-from-0x-to-10. As for your updated question, I think I'd just update your code to use the dt typings for redux, otherwise you'll not have typings for react-redux or any other redux lib typings which depend on the dt redux typings.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.