https://github.com/mdecker-mobilecomputing/typescript_grundlagen
Some files with simple examples for programming with TypeScript.
https://github.com/mdecker-mobilecomputing/typescript_grundlagen
basics typescript
Last synced: 11 months ago
JSON representation
Some files with simple examples for programming with TypeScript.
- Host: GitHub
- URL: https://github.com/mdecker-mobilecomputing/typescript_grundlagen
- Owner: MDecker-MobileComputing
- License: bsd-3-clause
- Created: 2019-01-12T17:23:35.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-11-12T09:07:39.000Z (over 1 year ago)
- Last Synced: 2025-01-05T21:08:45.585Z (over 1 year ago)
- Topics: basics, typescript
- Language: TypeScript
- Homepage:
- Size: 43.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Grundlagen TypeScript #
This Git repository contains [some files](beispiele/) to demonstrate the basic usage of
the programming language [TypeScript](https://www.typescriptlang.org).
TypeScript is a language by Microsoft, which extends JavaScript (i.e. it is a superset of JavaScript) and can be transpiled to JavaScript, so it can be
executed in web browsers.
However, the TypeScript files contained in this repositry are to be executed with [Node.js](https://nodejs.org/en/about/) after transpilation.
----
## Transpiling to JavaScript ##
To transpile a TypeScript file to JavaScript, you need to install [TypeScript](https://www.npmjs.com/package/typescript) first:
````
npm install -g typescript
````
On Linux and MacOS you have to prepend a `sudo` in front of this command.
After this a TypeScript file can be transpiled by calling the program `tsc`, e.g.:
````
tsc Variablen.ts
````
If no syntax errors are found, then this will produce a file named `Variablen.js`.
This file can then be executed as follows:
````
node Variablen.ts
````
As default `tsc` will generate JavaScript of version ES3, but you can change this using
the option `--target`, e.g.:
````
tsc --target es6 Variablen.ts
````
----
## Executiong with `ts-node` ##
You can also use [ts-node](https://www.npmjs.com/package/ts-node) to execute TypeScript files without
explicit transpilition to JavaScript.
For this package `ts-node` has to be installed after package `typescript` was installed:
````
npm install -g ts-node
````
Again, on Linux and MacOS you have to prepend a `sudo` in front of this command.
After this you can execute a TypeScript file "directly", e.g.:
````
ts-node Variablen.ts
````
----
## License ##
See the [LICENSE file](LICENSE.md) for license rights and limitations (BSD 3-Clause License)
for the files in this repository.