Click here to Skip to main content
15,888,085 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying to create an application using Typescript(1.7.5) and AMD module. I have added reference to r.js and requirejs.js. below is my TS code:

javscript
export module TestNs {
    export class TestClass {
        public fn(): void{
            debugger;
        }
    }
}


here is my aspx page to call "fn()":


ASP.NET
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TypeScriptPage.aspx.cs" Inherits="WebApplication1.TypeScriptPage" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div id="div1">
        </div>
        <script src="Scripts/r.js"></script>
        <script src="Scripts/require.js"></script>
        <script src="Scripts/TypeScriptBegin.js"></script>
        <script type="text/javascript">

            var testObj = new TestNs.TestClass();
            testObj.fn();

        </script>
    </form>
</body>
</html>


but I am getting below errors:

TestNS is undefined

"JavaScript runtime error: Mismatched anonymous define() module: function (require, exports)"


however when I remove "export" keyword, above code works fine. I am new to Typescript and requirejs. Can anyone point out what I am doing wrong and how to fix this?

thanks in advance.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900