@observable/@action + interface build error
See original GitHub issuewhat did I do:
- create an empty react project with create-react-app --script-version=react-scripts-ts mobxtest and add deps: mobx & mobx-react
- add a intf.ts in src dir:
export interface ITest { // if ITest is a class, build passed
a?: string
}
export class A { // if A is an interface, build passed
}
- add a Store.ts in src dir:
import { action, observable } from 'mobx'
import { ITest } from './intf'
export class Store {
@observable public t: ITest // can't work with @observable
@observable public testData: string = ''
@action.bound
public test(iTest: ITest) { // can't work with @action.bound
return this.testData = iTest.toString()
}
@action
public test2 = (iTest: ITest) => { // can't work with @action
return this.testData = iTest.toString()
}
}
export const store = new Store()
- use store in App.tsx
import * as React from 'react';
import './App.css';
import { observer } from 'mobx-react'
import logo from './logo.svg';
import { store } from './store'
@observer
class App extends React.Component {
public render() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h1 className="App-title">Welcome to React</h1>
</header>
{store.testData} // use store
</div>
);
}
}
export default App;
- tsc compile success, but build with webpack report error:
'./intf' does not contain an export named 'ITest'
interface from file contains classes can’t work with @observable or @action
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Error with Actions observable in @ngrx/effects using ...
Error TS2345: Argument of type 'Actions' is not assignable to parameter of type 'Observable<Action>'. Types of property 'lift' are incompatible.
Read more >Troubleshooting · redux-observable
Usually this means you're not returning an observable from one or more of your Epics. Often this is just a missing return ....
Read more >Type definition of Epic<T = Action,S,D = any> is wrong? #392
I think Type definitions of redux-observable is wrong. export declare interface Epic<T extends Action, S, D = any> { (action$: ...
Read more >Create an observable data action - Commerce | Dynamics 365
The IObservableAction interface returns an AsyncResult class that provides additional data including the status and error properties of the data ...
Read more >Angular Basics: Introduction to Observables (RxJS)—Part 2
The subscriber class implements the observer interface. Therefore, a subscriber object has the next , error and complete methods.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@rainmanhhh I don’t see any error in the codesandbox you’ve linked. Please provide a better reproduction
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or questions.