के साथ प्रतिक्रिया-राउटर का उपयोग करना मैं टाइपस्क्रिप्ट पर एक छोटे से प्रतिक्रिया ऐप को पोर्ट करने का प्रयास कर रहा हूं।टाइपस्क्रिप्ट
मुझे प्रतिक्रिया-राउटर के साथ समस्याएं आ रही हैं। मैं निश्चित रूप से से नवीनतम परिभाषाओं टाइप है, लेकिन निम्नलिखित कोड मुझे त्रुटियों देता है:
var routes:Router.Route = (
<Route name="root" path="/" handler={MyApp}>
<Route path="dashboard" handler={MyDash} />
<DefaultRoute handler={SomeSection} />
<NotFoundRoute handler={NotFoundPage} />
</Route>
);
Router.run(routes, function (Handler:React.Component<any, any>) {
React.render(<Handler/>, document.body);
});
ये संकलन त्रुटियों मैं कर रहे हैं:
js/app.tsx(31,3): error TS2605: JSX element type 'Component<RouteProp, any>' is not a constructor function for JSX elements.
Property 'render' is missing in type 'Component<RouteProp, any>'.
js/app.tsx(32,5): error TS2605: JSX element type 'Component<RouteProp, any>' is not a constructor function for JSX elements.
js/app.tsx(47,5): error TS2605: JSX element type 'Component<DefaultRouteProp, any>' is not a constructor function for JSX elements.
Property 'render' is missing in type 'Component<DefaultRouteProp, any>'.
js/app.tsx(49,5): error TS2605: JSX element type 'Component<NotFoundRouteProp, any>' is not a constructor function for JSX elements.
Property 'render' is missing in type 'Component<NotFoundRouteProp, any>'.
js/app.tsx(53,20): error TS2345: Argument of type '(Handler: Component<any, any>) => void' is not assignable to parameter of type '(Handler: RouteClass, state: RouterState) => void'.
Types of parameters 'Handler' and 'Handler' are incompatible.
Type 'Component<any, any>' is not assignable to type 'RouteClass'.
js/app.tsx(54,17): error TS2604: JSX element type 'Handler' does not have any construct or call signatures.
react- का एक सेट को प्रारंभ करने के लिए सही तरीका क्या है टाइपस्क्रिप्ट का उपयोग कर राउटर मार्ग?
(मैं स्पष्ट करना चाहिए कि मैं एक रात टाइपप्रति निर्माण जो --jsx react
झंडा
मैं एक ही मुद्दा था और यह एक हो सकता है टाइपस्क्रिप्ट के टीएसएक्स समर्थन के साथ समस्या: [टाइपस्क्रिप्ट/3 9 28] (https://github.com/Microsoft/TypeScript/issues/3928)। मैंने वहां एक समान सवाल पूछा, और उन्होंने इस मुद्दे को फिर से खोल दिया। – Nathan
उस @ नाथन के लिए धन्यवाद! – theycallmemorty