Reputation: 788
I am trying to migrate my Meteor-React project to TypeScript. I have a .tsx file:
import { withTracker } from 'meteor/react-meteor-data';
class Header extends React.Component<any,any> {
...
}
export default withTracker(() => {
return {
...
};
})(Header);
But I am getting the error, even though the site renders correctly:
Module ''meteor/react-meteor-data'' has no exported member 'withTracker'.
Running versions:
Local package version is up-to-date: [email protected]
Local package version is up-to-date: [email protected]
Local package version is up-to-date: barbatus:[email protected]
Local package version is up-to-date: barbatus:[email protected]
Local package version is up-to-date: barbatus:[email protected]
Local package version is up-to-date: [email protected]
Local package version is up-to-date: [email protected]
Local package version is up-to-date: [email protected]
Local package version is up-to-date: [email protected]
Local package version is up-to-date: [email protected]
Local package version is up-to-date: [email protected]
Thank you for your help.
Upvotes: 2
Views: 575
Reputation: 9680
The react-meteor-data
package does not contain type information. This repository contains types for the old createContainer
, but the repo has not been updated with withTracker
.
I have solved this by including a .d.ts
file somewhere in the project with the following declaration:
declare module 'meteor/react-meteor-data' {
import * as React from 'react';
type RMDComponentConstructor<P> = React.ComponentClass<P> | React.StatelessComponent<P>
export function withTracker<InP, D, OutP extends (InP & D)>(
options: (props: InP) => D | {getMeteorData: (props: InP) => D, pure?: boolean}):
(reactComponent: RMDComponentConstructor<OutP>) => RMDComponentConstructor<InP>;
}
Upvotes: 2