2016-01-20 53 views
0

尝试在ASP.NET 5应用程序中使用打字稿创建反应组件。 那代码是好的:无法创建打字稿+反应模块

class AppRoot extends React.Component<{}, {}> { 
    constructor(props: any) { 
     super(); 
    } 

    render() { 
     return (
      <div>test</div> 
     ); 
    } 
} 

但是那是不行的:

module Pages { 

export class AppRoot extends React.Component<{}, {}> { 
    constructor(props: any) { 
     super(); 
    } 

    render() { 
     return (
      <div>test</div> 
     ); 
    } 
} 

} 

错误:

ScriptEngineException: Error: ../Scripts/Pages/AppRoot.tsx: Unexpected  token (5:7) 
3 | ///// <reference path="./interfaces.d.ts"/> 
4 | 
> 5 | module Pages { 
|^
6 | 

哪些错误与他,现在可好? = | 谢谢。

回答

0

module Pages {

这本来编译后。即运行时JavaScript不应包含*module*。也许你忘了将TypeScript编译为JavaScript。