Difference between revisions of "Typescript"
From MgmtWiki
(→Add to ASP.NET project) |
(→Add to ASP.NET project) |
||
Line 16: | Line 16: | ||
# Add>New Item>TypeScript JSON Configuration File (Do Not change its name) | # Add>New Item>TypeScript JSON Configuration File (Do Not change its name) | ||
## in tsconfig.json change target library to a current version, like "target": "es2015" | ## in tsconfig.json change target library to a current version, like "target": "es2015" | ||
− | ## and add this line "outDir": "wwwroot/js" | + | ## and add this line "outDir": "wwwroot/js" which will force the output from the ts compilation to that dir |
# Add>New Item> TypeScript File (Name it anything - say add.ts, we assume you are starting with no JS, so call it site.js) | # Add>New Item> TypeScript File (Name it anything - say add.ts, we assume you are starting with no JS, so call it site.js) | ||
+ | ## Since we used an existing file this is already in the _Layout.cshtml <script src="~/js/site.js" asp-append-version="true"></script> | ||
==References== | ==References== |
Revision as of 19:26, 3 November 2021
Full Title or Meme
A superscript of JavaScript that adds strong typing and other aids for good programming practice.
Context
JavaScript was becoming more than just a scripting language in 2019 with object-oriented features like asynchronous calls but without strong typing or other features of monder programming languages. since it seemed unlikely that strong typing would ever be included in javascript, typescript was created to add other features that supported good programming practices.
Examples
Add to ASP.NET project
- Add>New Item>TypeScript JSON Configuration File (Do Not change its name)
- in tsconfig.json change target library to a current version, like "target": "es2015"
- and add this line "outDir": "wwwroot/js" which will force the output from the ts compilation to that dir
- Add>New Item> TypeScript File (Name it anything - say add.ts, we assume you are starting with no JS, so call it site.js)
- Since we used an existing file this is already in the _Layout.cshtml <script src="~/js/site.js" asp-append-version="true"></script>