Currently, I am in the process of diving into TypeScript and Angular. As I write my code down, I encounter various challenges along the way.
**app.ts**
import { LikeComponent } from "./like.component";
let component = new LikeComponent(10,true);
component.onClick();
console.log(`likescount: ${component.likesCount}, isSelect: ${component.isSelected}`);
**like.component.ts**
export class LikeComponent
{
constructor(public likesCount: number,public isSelected: boolean) {
}
onClick() {
this.likesCount += (this.isSelected) ? 1: -1;
this.isSelected = !this.isSelected;
}
}
During this learning journey, I faced an error which presented itself as https://i.sstatic.net/BDcUZ.png
My current folder structure looks like this
https://i.sstatic.net/uYCJJ.png
In an attempt to resolve the issue, I added the following code snippet in tsconfig.js but unfortunately, it did not yield any positive results
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "es2015",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}
Upon executing 'tsc like.component.cs', I encountered an error stating 'cannot run external module unless--module is provided'.
tsc --version : 1.0.3.0