TypeScript Lab: DOM and Node Library Map
Planned
LAB 009 — TypeScript Toolchain
Separate browser APIs from Node APIs in compiler configuration.
TypeScript Lab: DOM and Node Library Map
Compiler libraries and type packages determine which platform APIs TypeScript recognizes.
Compiler libraries and type packages determine which platform APIs TypeScript recognizes.
Objective & Explanation
What the project should make visible and why the concept matters.Objective
Separate browser APIs from Node APIs in compiler configuration.
Explanation
Compiler libraries and type packages determine which platform APIs TypeScript recognizes.
Project Plan
Structure, technologies, data boundary, and source connection.Build Instructions
Build only the focused behavior, then use the visual layer to inspect it.Install TypeScript locally and initialize the compiler configuration.
- Implement only the concept shown in the code example.
- Compile the TypeScript and load the browser page.
Change one input or action and confirm the visible result changes for the expected reason.
Code & Configuration
Starter configuration plus the focused implementation example.const browserElement: HTMLElement = document.body;
const nodeVersion: string = process.version;
console.log(browserElement.tagName);
console.log(nodeVersion);package.json
{
"type": "module",
"scripts": { "build": "tsc" },
"devDependencies": { "typescript": "^7.0.2" }
}tsconfig.json
{
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
"target": "ES2022",
"module": "ES2022",
"lib": ["ES2022", "DOM"],
"strict": true,
"sourceMap": true
},
"include": ["src/**/*.ts"]
}Expected Visual Result
The output is the proof that the concept is working.The browser should visibly demonstrate: separate browser APIs from Node APIs in compiler configuration.
Data: None