Currently, I am in the process of integrating a TypeScript project into a VS2015 MVC 5 project (which is based on ASP.NET 4, specifically not asp.net 5 or asp.net 6 - only the MVC portion is version 5). All aspects of my query pertain solely to this target environment; hence, generalized advice on TypeScript, node.js, and module loaders will not be applicable.
The task would be easier with ASP.NET Core, but that is not the challenge at hand. Resources providing examples and guidance tend to steer clear of or offer limited information when it comes to ASP.NET 4 MVC 5 due to its complexity. The exact difficulties and obstacles remain unspecified by most individuals.
To compound matters, navigating the TypeScript documentation is akin to sifting through Open Source Documentation: you typically hit a dead end after one issue, leading to a never-ending cycle of problem-solving.
I value diverse viewpoints, but what I seek is concrete experiential knowledge - the approach that has demonstrably proved effective for a production team.
Below are the specific concerns that must be addressed and configured to function within the framework of a functioning, medium-sized ASP.NET 4 MVC 5 line-of-business application:
Configuration of TypeScript in Visual Studio, including installation details (typically done via node) and ensuring compatibility with Tools/options - TypeScript settings.
Determining between browser-style testing (often manual TDD workflow) or node.js testing (automated), which must be decided upfront to avoid further troubleshooting. For our purposes, we've selected browser-based testing using PhantomJS with WallabyJs.
Implementation of NPM @types/library-name: intended to populate a node_modules directory with both library-name and library-name.d.ts files based on package.json's @Types references. However, this requires the package.json to contain references for both @types/library-name and library-name to function correctly in my setup with VS 2015 Enterprise v3 and ASP.NET 4 MVC 5. Despite specifying versions manually, the lookup procedure seems somewhat suspect. It is uncertain whether the @types method suits ASP.NET 4 MVC 5, leaving me clueless about alternative corrections. At present, @Types is the recommended choice for handling TypeScript.
Selecting the appropriate ECMAScript version: es6 may be too advanced, while es2015 appears more suitable, albeit potentially linked to other issues. Although these designations appear interchangeable, they can be specified in two separate locations. I have opted for es2015 in tools/options/typescript, recognizing that any misconfiguration among the three settings could lead to problems.
Deciding on a module system: CommonJS caters to node and automated testing, with VS development testing being server-side automated exclusively, and UI tests requiring manual intervention. AMD or RequireJS may be viable options for VS, although their implementation introduces additional workflows, maintenance requirements, and complexities specific to ASP.NET. Leveraging ASP.NET bundling and triple-slash references might work post-library integration into node-modules, warranting full path usage within import statements. This process is cumbersome, involving significant trial and error. Nonetheless, resolving this particular aspect could unlock solutions to the broader question.
Various minor issues may arise throughout this endeavor. Those experienced in this field will have successfully tackled all aforementioned challenges along with others.
I am seeking comprehensive instructions encompassing all mentioned issues derived from an operational TypeScript application within an ASP.NET 4 MVC 5 setting for browser-based unit/behavior testing in VS 2015. Individuals who have navigated this process firsthand will grasp the significance of such insights.
Your attention and input are greatly appreciated.