From 1c420ebf6e53af11c66434c01c6749f292b75044 Mon Sep 17 00:00:00 2001 From: Kyle K Date: Sun, 2 Apr 2023 20:30:49 -0500 Subject: add minimal example of TypeScript project --- tsapp1/package.json | 13 +++++++++++++ tsapp1/src/user.ts | 17 +++++++++++++++++ tsapp1/tsconfig.json | 11 +++++++++++ 3 files changed, 41 insertions(+) create mode 100644 tsapp1/package.json create mode 100644 tsapp1/src/user.ts create mode 100644 tsapp1/tsconfig.json diff --git a/tsapp1/package.json b/tsapp1/package.json new file mode 100644 index 0000000..525339a --- /dev/null +++ b/tsapp1/package.json @@ -0,0 +1,13 @@ +{ + "name": "tsapp1", + "version": "1.0.0", + "main": "index.js", + "license": "MIT", + "dependencies": { + "typescript": "^5.0.3" + }, + "scripts": { + "build": "yarn run -T tsc --build --verbose", + "start": "node ./dist/user.js" + } +} diff --git a/tsapp1/src/user.ts b/tsapp1/src/user.ts new file mode 100644 index 0000000..353fd44 --- /dev/null +++ b/tsapp1/src/user.ts @@ -0,0 +1,17 @@ +interface User { + name: string; + id: number; +} + +class UserAccount { + name: string; + id: number; + + constructor(name: string, id: number) { + this.name = name; + this.id = id; + } +} + +const user: User = new UserAccount("Kyle", 1); +console.log("username is %s and userid is %d", user.name, user.id); \ No newline at end of file diff --git a/tsapp1/tsconfig.json b/tsapp1/tsconfig.json new file mode 100644 index 0000000..4a8596c --- /dev/null +++ b/tsapp1/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "outDir": "./dist", + "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ + "module": "commonjs", /* Specify what module code is generated. */ + "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ + "strict": true, /* Enable all strict type-checking options. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */ + }, + "include": ["./src/**/*"] +} -- cgit v1.2.3