Skip to content

Commit e24a794

Browse files
Merge pull request #15323 from Mikejo5000/mikejo-br30
Update tsconfig for articles on compiling TypeScript
2 parents 337e5de + 5627626 commit e24a794

2 files changed

Lines changed: 64 additions & 64 deletions

File tree

docs/javascript/compile-typescript-code-nuget.md

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Compile and build TypeScript code using NuGet
33
description: Add TypeScript support to your Visual Studio projects by using the NuGet package for portability across different platforms and environments.
4-
ms.date: 5/15/2025
4+
ms.date: 4/27/2026
55
ms.topic: how-to
66
author: "mikejo5000"
77
ms.author: "mikejo"
@@ -51,19 +51,25 @@ If Visual Studio is installed, then the node.exe bundled with it will automatica
5151
Use the following example, which shows a simple *tsconfig.json* file.
5252

5353
```json
54-
{
55-
"compilerOptions": {
56-
"noImplicitAny": false,
57-
"noEmitOnError": true,
58-
"removeComments": false,
59-
"sourceMap": true,
60-
"target": "es5",
61-
"outDir": "wwwroot/js"
62-
},
63-
"include": [
64-
"scripts/**/*"
65-
]
66-
}
54+
{
55+
"compileOnSave": true,
56+
"compilerOptions": {
57+
"noImplicitAny": false,
58+
"noEmitOnError": true,
59+
"removeComments": false,
60+
"sourceMap": true,
61+
"target": "ES6",
62+
"rootDir": "./scripts",
63+
"outDir": "wwwroot/js"
64+
},
65+
"include": [
66+
"scripts/**/*"
67+
],
68+
"exclude": [
69+
"node_modules",
70+
"wwwroot"
71+
]
72+
}
6773
```
6874

6975
In this example:
@@ -92,16 +98,6 @@ If Visual Studio is installed, then the node.exe bundled with it will automatica
9298

9399
Source map files are required for debugging.
94100

95-
1. If you want to compile every time you save the project, use the *compileOnSave* option in *tsconfig.json*.
96-
97-
```json
98-
{
99-
"compileOnSave": true,
100-
"compilerOptions": {
101-
}
102-
}
103-
```
104-
105101
For an example of using gulp with the Task Runner to build your app, see [ASP.NET Core and TypeScript](https://www.typescriptlang.org/docs/handbook/asp-net-core.html).
106102

107103
If you run into issues where Visual Studio is using a version of Node.js or a third-party tool that is different than what the version you expected, you may need to set the path for Visual Studio to use. Choose **Tools** > **Options**. Under **Projects and solutions**, choose **Web Package Management** > **External Web Tools**.

docs/javascript/tutorial-aspnet-with-typescript.md

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -92,24 +92,25 @@ Visual Studio opens your new project.
9292
1. Open `tsconfig.json` and replace the default code with the following code:
9393

9494
```json
95-
{
96-
"compileOnSave": true,
97-
"compilerOptions": {
98-
"noImplicitAny": false,
99-
"noEmitOnError": true,
100-
"removeComments": false,
101-
"sourceMap": true,
102-
"target": "ES6",
103-
"outDir": "wwwroot/js"
104-
},
105-
"include": [
106-
"scripts/**/*"
107-
],
108-
"exclude": [
109-
"node_modules",
110-
"wwwroot"
111-
]
112-
}
95+
{
96+
"compileOnSave": true,
97+
"compilerOptions": {
98+
"noImplicitAny": false,
99+
"noEmitOnError": true,
100+
"removeComments": false,
101+
"sourceMap": true,
102+
"target": "ES6",
103+
"rootDir": "./scripts",
104+
"outDir": "wwwroot/js"
105+
},
106+
"include": [
107+
"scripts/**/*"
108+
],
109+
"exclude": [
110+
"node_modules",
111+
"wwwroot"
112+
]
113+
}
113114
```
114115

115116
The *outDir* option specifies the output folder for the plain JavaScript files that the TypeScript compiler transpiles.
@@ -127,28 +128,31 @@ Visual Studio opens your new project.
127128
1. Open `app.ts` and add the following TypeScript code.
128129

129130
```ts
130-
function TSButton() {
131-
let name: string = "Fred";
132-
document.getElementById("ts-example").innerHTML = greeter(user);
133-
}
134-
135-
class Student {
136-
fullName: string;
137-
constructor(public firstName: string, public middleInitial: string, public lastName: string) {
138-
this.fullName = firstName + " " + middleInitial + " " + lastName;
139-
}
140-
}
141-
142-
interface Person {
143-
firstName: string;
144-
lastName: string;
145-
}
146-
147-
function greeter(person: Person) {
148-
return "Hello, " + person.firstName + " " + person.lastName;
149-
}
150-
151-
let user = new Student("Fred", "M.", "Smith");
131+
function TSButton() {
132+
let name: string = "Fred";
133+
const element = document.getElementById("ts-example");
134+
if (element) {
135+
element.innerHTML = greeter(user);
136+
}
137+
}
138+
139+
class Student {
140+
fullName: string;
141+
constructor(public firstName: string, public middleInitial: string, public lastName: string) {
142+
this.fullName = firstName + " " + middleInitial + " " + lastName;
143+
}
144+
}
145+
146+
interface Person {
147+
firstName: string;
148+
lastName: string;
149+
}
150+
151+
function greeter(person: Person) {
152+
return "Hello, " + person.firstName + " " + person.lastName;
153+
}
154+
155+
let user = new Student("Fred", "M.", "Smith");
152156
```
153157

154158
Visual Studio provides IntelliSense support for your TypeScript code.

0 commit comments

Comments
 (0)