Typescript-react-starter: Problems with StoreState

Created on 23 Aug 2018  路  8Comments  路  Source: microsoft/TypeScript-React-Starter

\TypeScript-React-Starter\src*index.tsx* has problem with const store = createStore

Error '(12,27): Expected 4 type arguments, but got 1.'

Most helpful comment

Thanks James! See updated working version below:

import * as React from 'react';
import * as ReactDOM from 'react-dom';

import Hello from './containers/Hello';
import { Provider } from 'react-redux';
import { createStore } from 'redux';
import { enthusiasm } from './reducers/index';
import { StoreState } from './types/index';

import './index.css';

import { EnthusiasmAction } from './actions/index';

const store = createStore(enthusiasm, {
enthusiasmLevel: 1,
languageName: 'TypeScript'
});

ReactDOM.render(

,
document.getElementById('root') as HTMLElement
);

Cheers

All 8 comments

Saw that issue before I kept digging, and I'm wondering if a) that's the correct solution and the tutorial needs to be updated or b) the individual accidentally closed the issue when making their comment and the tutorial still needs to be updated with the correct solution.

I tried solution from #140, but doesn't work unless I'm missing something...
see original error and updated/modified version attached

27-08-18 10 10 59 am
27-08-18 10 10 24 am

@a455047 you have IStoreState instead of just keeping StoreState. I think that might fix one of the errors.

Thanks James! See updated working version below:

import * as React from 'react';
import * as ReactDOM from 'react-dom';

import Hello from './containers/Hello';
import { Provider } from 'react-redux';
import { createStore } from 'redux';
import { enthusiasm } from './reducers/index';
import { StoreState } from './types/index';

import './index.css';

import { EnthusiasmAction } from './actions/index';

const store = createStore(enthusiasm, {
enthusiasmLevel: 1,
languageName: 'TypeScript'
});

ReactDOM.render(

,
document.getElementById('root') as HTMLElement
);

Cheers

The solution above works for me but I thought using any was a no no?

What's the current state of this solution? Working through a broken demo is discouraging.

You can just wait for https://github.com/facebook/create-react-app/pull/4837 to be finished and just use TypeScript natively with CRA 2.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  7Comments

BenjaminWatts picture BenjaminWatts  路  6Comments

Yang09701194 picture Yang09701194  路  7Comments

Lxxyx picture Lxxyx  路  9Comments

painreign picture painreign  路  6Comments