I'm building a website using ASP.NET CORE with MVC, Razor and Bootstrap. I've started working with Typescript to deal with all my JavaScript, but now I'm stumbling upon an issue to which I can't find a solution. I think my approach is wrong, so I'd like to sketch my situation in a couple of requirements in the hope that someone can point me into the right direction:
- In each Razor view I'd like to be able to use a Typescript class as sort of a 'ViewModel' to deal with all the JS for that specific view.
- From within TypeScript I want to be able to import my own classes, such as my Form class to deal with form input and Ajax calls, and my Modal class to deal with showing Modals to the user.
- In my Typescript classes I'd like to be able to use classes from other third parties such as Bootstrap Notify(@types/bootstrap-notify).
I've tried CommonJS and AMD with moduleResolution set to 'node', but this gives me an issue where I keep getting errors that 'define is not defined'. I've looked this up and this got me looking into Require.js. Made an attempt with this, but ended up giving me issues with not being able to do any imports in Typescript.
I see that my description might be rather vague, so the issue all comes down to this:
TL/DR: What is the recommended solution for working with Typescript with export/import and third party typings when using it in an ASP.NET Core Web project with Razor and Bootstrap in Visual Studio?