diff options
author | Kyle K <kylek389@gmail.com> | 2023-04-02 20:30:49 -0500 |
---|---|---|
committer | Kyle K <kylek389@gmail.com> | 2023-04-02 20:30:49 -0500 |
commit | 1c420ebf6e53af11c66434c01c6749f292b75044 (patch) | |
tree | 52f50923bb8232317b744591d1864f99835fdf22 /tsapp1 | |
parent | 35b6225e63cc978483b7485c9e3890dc75133a56 (diff) | |
download | jsexamples-1c420ebf6e53af11c66434c01c6749f292b75044.tar.gz jsexamples-1c420ebf6e53af11c66434c01c6749f292b75044.tar.bz2 jsexamples-1c420ebf6e53af11c66434c01c6749f292b75044.zip |
add minimal example of TypeScript project
Diffstat (limited to 'tsapp1')
-rw-r--r-- | tsapp1/package.json | 13 | ||||
-rw-r--r-- | tsapp1/src/user.ts | 17 | ||||
-rw-r--r-- | tsapp1/tsconfig.json | 11 |
3 files changed, 41 insertions, 0 deletions
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/**/*"] +} |