diff --git a/05_typescript/agenda.md b/05_typescript/agenda.md index fab089e..df5ccd4 100644 --- a/05_typescript/agenda.md +++ b/05_typescript/agenda.md @@ -452,7 +452,7 @@ Projekte & optionale Übungen #### Tag 27 -- **Exkurs: Vite vs Gulp** +- **Exkurs: Gulp Build Prozess** - **SASS 7 on 1 mit Bootstrap 6** - **Projektfinalisierung Express + REST API** - Einführung in Typescript @@ -483,6 +483,7 @@ Projekte & optionale Übungen - type statement vs interface - Type Assertion with as and <> - Typescript "more Types" +- Interface, as statement **Übungen:** @@ -494,11 +495,11 @@ Projekte & optionale Übungen **Inhalt:** -- Typescript "more Types" - - Interface, as statement, literale -- Typescript Narrowing with Guards +- Typescript literale, Narrowing with Guards - truthiness, equality, in-operator, type-predicate - TS Funktionen und Objekte +- **Exkurs: Vite vs Gulp** +- **Produktmanager Refactoring mit Bootstrap 6** **Übungen:** diff --git a/05_typescript/uebungen/u04_without-any/src/main.ts b/05_typescript/uebungen/u04_without-any/src/main.ts index c2a5b6c..39c44d1 100644 --- a/05_typescript/uebungen/u04_without-any/src/main.ts +++ b/05_typescript/uebungen/u04_without-any/src/main.ts @@ -1,6 +1,12 @@ -const processData = (input: number): number => { - return input * 2; +// const processData = (input: T): T | number => { +// return Number(input) * 2; +// }; + +// let result = processData('100'); + +const processData = (input: string | number): number => { + return Number(input) * 2; }; -let result = processData(100); -console.log(result); +let result = processData('100'); +console.log(processData(100)); diff --git a/05_typescript/uebungen/u05_type-annotations/assets/js/bundle.js b/05_typescript/uebungen/u05_type-annotations/assets/js/bundle.js new file mode 100644 index 0000000..8e82bea --- /dev/null +++ b/05_typescript/uebungen/u05_type-annotations/assets/js/bundle.js @@ -0,0 +1,29 @@ +(() => { + // src/main.ts + { + const firstName = "Max"; + const getFullName = (firstName2, lastName) => { + return `${firstName2} ${lastName}`; + }; + const sumNumbers = (numbers2) => { + let sum = 0; + for (const number of numbers2) { + sum += number; + } + return sum; + }; + const sumNumbers2 = (numbers2) => { + return numbers2.reduce((a, b) => a + b, 0); + }; + const fullName = getFullName(firstName, "Mustermann"); + const numbers = [10, 20, 30]; + const total = sumNumbers(numbers); + console.log(`${fullName}: Die Summe der Zahlen betr\xE4gt ${total}.`); + console.time("forOf"); + console.log(sumNumbers([10, 20, 30, 40, 50, 60, 70, 80, 1, 2, 3, 45])); + console.timeEnd("forOf"); + console.time("reduce"); + console.log(sumNumbers2([10, 20, 30, 40, 50, 60, 70, 80, 1, 2, 3, 45])); + console.timeEnd("reduce"); + } +})(); diff --git a/05_typescript/uebungen/u05_type-annotations/src/main.ts b/05_typescript/uebungen/u05_type-annotations/src/main.ts index b72b5ed..9fd9f08 100644 --- a/05_typescript/uebungen/u05_type-annotations/src/main.ts +++ b/05_typescript/uebungen/u05_type-annotations/src/main.ts @@ -1,3 +1,42 @@ +{ + // Die Type Annotation : string legt fest, dass die Variable Text enthält. + const firstName: string = 'Max'; + + // Die Parameter und der Rückgabewert sind jeweils vom Typ string. + const getFullName = (firstName: string, lastName: string): string => { + return `${firstName} ${lastName}`; + }; + + // number[] ist ein Array aus Zahlen; die Funktion gibt eine Zahl zurück. + const sumNumbers = (numbers: number[]): number => { + let sum: number = 0; + + for (const number of numbers) { + sum += number; + } + return sum; + }; + + const sumNumbers2 = (numbers: number[]): number => { + return numbers.reduce((a, b) => a + b, 0); + }; + + const fullName: string = getFullName(firstName, 'Mustermann'); + + const numbers: number[] = [10, 20, 30]; + const total: number = sumNumbers(numbers); + + console.log(`${fullName}: Die Summe der Zahlen beträgt ${total}.`); + + console.time('forOf'); + console.log(sumNumbers([10, 20, 30, 40, 50, 60, 70, 80, 1, 2, 3, 45])); + console.timeEnd('forOf'); + + console.time('reduce'); + console.log(sumNumbers2([10, 20, 30, 40, 50, 60, 70, 80, 1, 2, 3, 45])); + console.timeEnd('reduce'); +} + // TODO: Deklariere eine Variable, um den Namen einer Person zu speichern, und gib ihn explizit als String ein. // TODO: Deklariere eine Funktion, die zwei Parameter, firstName und lastName, beide vom Typ String, benötigt und einen verketteten vollständigen Namen (ebenfalls vom Typ String) zurückgibt. diff --git a/05_typescript/uebungen/u06_optional-properties/assets/js/bundle.js b/05_typescript/uebungen/u06_optional-properties/assets/js/bundle.js new file mode 100644 index 0000000..f20b22f --- /dev/null +++ b/05_typescript/uebungen/u06_optional-properties/assets/js/bundle.js @@ -0,0 +1,16 @@ +(() => { + // src/main.ts + { + const printBookDetails = (book) => { + console.log(`Titel: ${book.title}`); + console.log(`Autor: ${book.author}`); + if (book.yearPublished !== void 0) { + console.log(`Erscheinungsjahr: ${book.yearPublished}`); + } else { + console.log("Erscheinungsjahr: unbekannt"); + } + }; + printBookDetails({ title: "The TypeScript Handbook", author: "Dan Vanderkam" }); + printBookDetails({ title: "Clean Code", author: "Robert C. Martin", yearPublished: 2008 }); + } +})(); diff --git a/05_typescript/uebungen/u06_optional-properties/package-lock.json b/05_typescript/uebungen/u06_optional-properties/package-lock.json new file mode 100644 index 0000000..eb60944 --- /dev/null +++ b/05_typescript/uebungen/u06_optional-properties/package-lock.json @@ -0,0 +1,500 @@ +{ + "name": "06_optional-properties", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "06_optional-properties", + "version": "1.0.0", + "license": "ISC", + "devDependencies": { + "esbuild": "^0.28.2" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.2.tgz", + "integrity": "sha512-XExcO+dvLKvVtNTibSTBej1NCAbaGhWn9Ww1ZPx80qsahhPFe/8jgWP0IchNe0F3HwkU7n8ejhH8bjonqht8mQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.28.2.tgz", + "integrity": "sha512-kXXoiPVVGQcnIYGOeaovwOURpniDBpSq4A03qkQ+BMQqtGG6HYap3xne9C1O1yo4TR3qxlCX5IqqmX6fFo2Lqg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.28.2.tgz", + "integrity": "sha512-5YfKeeI8qWfBZIX+u2xZC3Zlb3Os/gLS2sbEKM+I4ZOcsWmHS2WLysCcQZDAFRslDUU5Oiq44gf6PYN1vGwG5A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.28.2.tgz", + "integrity": "sha512-O387ite7SzUyCcy3JQX4P4bLtEA7bLLkx+esve5JHnyYfNTxcVpXZo9jhdB0lTKN44gztELTdU7nS8Nr16Fs1Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.28.2.tgz", + "integrity": "sha512-n4KqkOQrraxHJcgjM1RvwbigfQKIKJVpM7xp+KsxiyUSrRdIXnt73VhrPAx0fV44hgfmIVKjxMN9J1t5jySVkw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.28.2.tgz", + "integrity": "sha512-uq6suIWYP37qzGddBKPw5QEQPi6HiLGsO7UmkpfyaYNQ3D+rN6w6WfwH+nuqcGXWvawGwxOEroO4YGnFh95azw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.28.2.tgz", + "integrity": "sha512-n+I0BTSRIoy+d6RPKnEVwql5UwBJolytvY4mAOIEJorKlqgPII8ix6slVVrfZ5Tnj7glIZvloylbB/EJPMWEXw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.28.2.tgz", + "integrity": "sha512-78XJTJkvPs0kz2w61301PJjXl4g7q3JqiYMZ/M/yVI73EHBrCRTgkhu9oqG7vPqq+a/yadEW8aD+agKlk5xrmg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.28.2.tgz", + "integrity": "sha512-XlDnu2q5yoqems+xay6wSAcg9DDD7K9RLKZEBOMZm3ckNpJBvOX20tSfby8KfrrhINDyv9V2YVZKY/SpoGJI8w==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.28.2.tgz", + "integrity": "sha512-pW4AC0P3it8c7do9MVM4p51FzHzdM/TZrerurgRcHJ2WTa1VQ1CIq18xncfpBJw4ojkiZZrKW2yIBWBP92j6Ug==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.28.2.tgz", + "integrity": "sha512-CYbnj78HsIeA+DhgUKgFCfvNsTHFhMMrinUrMZpDXJXKN8T3XViTZ/+wtHeVxEWY8ewSzTFN+nRmSwO2tZaLUQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.28.2.tgz", + "integrity": "sha512-buwkd8nsph4R+ajRvw0qM5Hja/TXQow3ptzWO2EbG/cqcIkHloRrdlBtQlshyYGTNFvfkfJ5tpPLVkY4DtsPfQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.28.2.tgz", + "integrity": "sha512-ZVykbDyk7519VwiNb9Lcj9m8XM6v5V9uKPvrEMkkEedVewf+0itkhahp4HDpgERXhwLRpWFypsGbG/J8s0QjJA==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.28.2.tgz", + "integrity": "sha512-CAXl+Dtd9UUuJd8pKKdwh6MLm3MUMiqMPmhZ3tTSXPqfyQ3vDl6R5hZdZ/kYojK4ofXtdfSv1tFq8XzWx3heNQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.28.2.tgz", + "integrity": "sha512-GeXCej4IQtU1B+QlDV8W/RRvbzI3O/Stss+/bCXv4lZls5WGRtu2a+3JkA3i4qIUlMXpcHebWpF8AkJhATowuA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.28.2.tgz", + "integrity": "sha512-3H1weTYZPxt/WOhByszQZybS9w5lKzUn1FDMsgEChbHWQwHYQQRfBxgCcZvPhjHfKyJjIievvMmEUawJrdY9Dg==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.28.2.tgz", + "integrity": "sha512-4xTZr1FUmSoQW4XIWmit3tzQrUTZM+N3P0XV8xROKYF50XfI7xeO90+1bZvNwxIufQ9hDQVRJH5YhgPVF8A/HQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.28.2.tgz", + "integrity": "sha512-sSATRjPeDBg3pdgHoQfoYBob11Kk1FGa9lui5RIHZCoCkJa9QKlvl3/vKz2usCmYYjs7ymJR/2Nnsqe+Hjt5nw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.28.2.tgz", + "integrity": "sha512-lqnzCV+mM0gIADaKihiCg6ifgfU2L3h5E33rNQBN1Y4MaVGnzryzmvvf7UHxprpQdE8hpqLolJ9Rl+SkIRDpyw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.28.2.tgz", + "integrity": "sha512-AL2qJILH7lNjrDmCQDvdxMfAUIv8KMNZOvrwAQ8i8//ntL9FflhOyMJ8OZSMBb8/AWXe3/5v5S20y3zCoZWKoQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.28.2.tgz", + "integrity": "sha512-QtiuPytchRyC4rwUKhexJdQKvDuZ6hWloi3igqPQNUJCS1/v9EiO3UTOXR6A3FoMo4fnAKbWJdqaIwhOzh8qEw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.28.2.tgz", + "integrity": "sha512-WkhYDmpTjLvGlScA1rwjRUmhl4k8oXR3cIbtqWmELgU/dFeHHlEllxDvdWcNJV9rbzCexB5vz8gtNewWLgCT7Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.28.2.tgz", + "integrity": "sha512-GPMSkTOtMnv2U2F8gxe4Io6qmVs+YKyp832Etqqxr0hFngmXQ3rzwytelm3GIn7T4VviRUlf3sOgBOiTdvaf7g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.28.2.tgz", + "integrity": "sha512-PIhhEkE9uPBleRBrQEJpUn7MBnibZzbGzYWPmY3x+YoVg/95zbjB4CxPPOQ8l5tYYM4mMaCthF8/1DIfBQQyWQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.28.2.tgz", + "integrity": "sha512-YmJbfTlvU7Sdn9BB+4PRES4oB6pxgS37MAONj+hBr/cpXS1aBPKXxNnDbu+QCWPj0o9dgyxeq79g6c5P8KeuYA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.28.2.tgz", + "integrity": "sha512-5ebpxr3nWMzrL/rnUI755Jkuee0bHL/Gq0WTF9lvcpv73wAp5eu8MfBUgWK9bhWvZjj7yX8etf/8tI8Ney695g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/esbuild": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.2.tgz", + "integrity": "sha512-HKVLS8dvII+xoKW9kmqxbRKrnWEXfJJr/FZhhJmiqIB0e053QNYFqOBouTMO/k5sID4MvCiUCvv8b9M4h32wIA==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.28.2", + "@esbuild/android-arm": "0.28.2", + "@esbuild/android-arm64": "0.28.2", + "@esbuild/android-x64": "0.28.2", + "@esbuild/darwin-arm64": "0.28.2", + "@esbuild/darwin-x64": "0.28.2", + "@esbuild/freebsd-arm64": "0.28.2", + "@esbuild/freebsd-x64": "0.28.2", + "@esbuild/linux-arm": "0.28.2", + "@esbuild/linux-arm64": "0.28.2", + "@esbuild/linux-ia32": "0.28.2", + "@esbuild/linux-loong64": "0.28.2", + "@esbuild/linux-mips64el": "0.28.2", + "@esbuild/linux-ppc64": "0.28.2", + "@esbuild/linux-riscv64": "0.28.2", + "@esbuild/linux-s390x": "0.28.2", + "@esbuild/linux-x64": "0.28.2", + "@esbuild/netbsd-arm64": "0.28.2", + "@esbuild/netbsd-x64": "0.28.2", + "@esbuild/openbsd-arm64": "0.28.2", + "@esbuild/openbsd-x64": "0.28.2", + "@esbuild/openharmony-arm64": "0.28.2", + "@esbuild/sunos-x64": "0.28.2", + "@esbuild/win32-arm64": "0.28.2", + "@esbuild/win32-ia32": "0.28.2", + "@esbuild/win32-x64": "0.28.2" + } + } + } +} diff --git a/05_typescript/uebungen/u06_optional-properties/package.json b/05_typescript/uebungen/u06_optional-properties/package.json index bf98b04..466b6ce 100644 --- a/05_typescript/uebungen/u06_optional-properties/package.json +++ b/05_typescript/uebungen/u06_optional-properties/package.json @@ -9,5 +9,8 @@ "keywords": [], "author": "", "license": "ISC", - "type": "module" + "type": "module", + "devDependencies": { + "esbuild": "^0.28.2" + } } diff --git a/05_typescript/uebungen/u06_optional-properties/src/main.ts b/05_typescript/uebungen/u06_optional-properties/src/main.ts index 9a8d28a..d1de605 100644 --- a/05_typescript/uebungen/u06_optional-properties/src/main.ts +++ b/05_typescript/uebungen/u06_optional-properties/src/main.ts @@ -1,7 +1,31 @@ -// Step 1: Define the Book object type +{ + // Step 1: Define the Book object type + interface Book { + title: string; + author: string; + yearPublished?: number; + } -// Step 2: Implement the function to print book details + // type Book = { + // title: string; + // author: string; + // yearPublished?: number; + // }; -// Test cases to verify your code implementation (comment out the code below to remove the initial errors) -printBookDetails({ title: 'The TypeScript Handbook', author: 'Dan Vanderkam' }); -printBookDetails({ title: 'Clean Code', author: 'Robert C. Martin', yearPublished: 2008 }); + // Step 2: Implement the function to print book details + + const printBookDetails = (book: Book): void => { + console.log(`Titel: ${book.title}`); + console.log(`Autor: ${book.author}`); + + if (book.yearPublished !== undefined) { + console.log(`Erscheinungsjahr: ${book.yearPublished}`); + } else { + console.log('Erscheinungsjahr: unbekannt'); + } + }; + + // Test cases to verify your code implementation (comment out the code below to remove the initial errors) + printBookDetails({ title: 'The TypeScript Handbook', author: 'Dan Vanderkam' }); + printBookDetails({ title: 'Clean Code', author: 'Robert C. Martin', yearPublished: 2008 }); +} diff --git a/05_typescript/uebungen/u07_union-types/assets/js/bundle.js b/05_typescript/uebungen/u07_union-types/assets/js/bundle.js new file mode 100644 index 0000000..5c59e6e --- /dev/null +++ b/05_typescript/uebungen/u07_union-types/assets/js/bundle.js @@ -0,0 +1,34 @@ +(() => { + // src/main.ts + { + const processInput = (input) => { + let mReturn = input; + switch (typeof input) { + case "string": + mReturn = input.toUpperCase(); + break; + case "number": + mReturn = input * input; + break; + case "boolean": + mReturn = input ? "Yes" : "No"; + break; + } + return mReturn; + }; + const processInput2 = (input) => { + if (typeof input === "string") { + return input.toUpperCase(); + } else if (typeof input === "number") { + return input * input; + } else if (typeof input === "boolean") { + return input ? "Yes" : "No"; + } + return input; + }; + console.log(processInput("example")); + console.log(processInput(7)); + console.log(processInput(true)); + console.log(processInput(false)); + } +})(); diff --git a/05_typescript/uebungen/u07_union-types/src/main.ts b/05_typescript/uebungen/u07_union-types/src/main.ts index 84c25ef..a221ac9 100644 --- a/05_typescript/uebungen/u07_union-types/src/main.ts +++ b/05_typescript/uebungen/u07_union-types/src/main.ts @@ -1,10 +1,41 @@ { const processInput = (input: string | number | boolean): string | number => { + let mReturn = input; // TODO: Implement logic here to handle different types of input // - If the input is a string, return the string in uppercase // - If the input is a number, return the square of the number // - If the input is a boolean, return "Yes" if true, otherwise "No" + switch (typeof input) { + case 'string': + mReturn = input.toUpperCase(); + break; + case 'number': + mReturn = input * input; + break; + case 'boolean': + mReturn = input ? 'Yes' : 'No'; + break; + } + // Placeholder return statement to be replaced + return mReturn; + }; + + const processInput2 = (input: string | number | boolean): string | number => { + // TODO: Implement logic here to handle different types of input + // - If the input is a string, return the string in uppercase + if (typeof input === 'string') { + // Handle the case where input is a string + return input.toUpperCase(); + // - If the input is a number, return the square of the number + } else if (typeof input === 'number') { + // Handle the case where input is a number + return input * input; + // - If the input is a boolean, return "Yes" if true, otherwise "No" + } else if (typeof input === 'boolean') { + // Handle the case where input is a boolean + return input ? 'Yes' : 'No'; + } // Placeholder return statement to be replaced return input; }; diff --git a/05_typescript/uebungen/u08_type-aliase/assets/js/bundle.js b/05_typescript/uebungen/u08_type-aliase/assets/js/bundle.js new file mode 100644 index 0000000..e6f39b7 --- /dev/null +++ b/05_typescript/uebungen/u08_type-aliase/assets/js/bundle.js @@ -0,0 +1,27 @@ +(() => { + // src/main.ts + { + let printPersonDetails = function(person2) { + const { name, age, isActive } = person2; + const status = isActive ? "Active" : "Inactive"; + console.log(`Name: ${name}, Age: ${age}, Status: ${status}`); + }, handleResponse = function(status) { + switch (status) { + case "success": + console.log("Operation successful"); + break; + case "failure": + console.log("Operation failed"); + break; + case "pending": + console.log("Operation pending"); + break; + } + }; + const person = { name: "Alice", age: 30, isActive: true }; + printPersonDetails(person); + handleResponse("success"); + handleResponse("failure"); + handleResponse("pending"); + } +})(); diff --git a/05_typescript/uebungen/u08_type-aliase/src/main.ts b/05_typescript/uebungen/u08_type-aliase/src/main.ts index fd40786..5a7171b 100644 --- a/05_typescript/uebungen/u08_type-aliase/src/main.ts +++ b/05_typescript/uebungen/u08_type-aliase/src/main.ts @@ -1,26 +1,52 @@ -// Step 1: Define a type alias 'Person' for an object type with the following properties: -// - name: a string -// - age: a number -// - isActive: a boolean +{ + // Step 1: Define a type alias 'Person' for an object type with the following properties: + // - name: a string + // - age: a number + // - isActive: a boolean + type Person = { + name: string; + age: number; + isActive: boolean; + }; -// Step 2: Define a type alias 'ResponseStatus' for a union type that includes the following string literals: -// - "success" -// - "failure" -// - "pending" + // Step 2: Define a type alias 'ResponseStatus' for a union type that includes the following string literals: + // - "success" + // - "failure" + // - "pending" + type ResponseStatus = 'success' | 'failure' | 'pending'; -// Step 3: Implement a function 'printPersonDetails' that takes a parameter of type 'Person' -// - The function should print out the person's name, age, and activity status ("Active" or "Inactive" based on the isActive property). + // Step 3: Implement a function 'printPersonDetails' that takes a parameter of type 'Person' + // - The function should print out the person's name, age, and activity status ("Active" or "Inactive" based on the isActive property). + function printPersonDetails(person: Person): void { + const { name, age, isActive } = person; + const status = isActive ? 'Active' : 'Inactive'; + console.log(`Name: ${name}, Age: ${age}, Status: ${status}`); + } -// Step 4: Implement a function 'handleResponse' that takes a parameter of type 'ResponseStatus' -// - The function should print different messages based on the value of the 'ResponseStatus' ("Operation successful", "Operation failed", "Operation pending"). + // Step 4: Implement a function 'handleResponse' that takes a parameter of type 'ResponseStatus' + // - The function should print different messages based on the value of the 'ResponseStatus' ("Operation successful", "Operation failed", "Operation pending"). + function handleResponse(status: ResponseStatus): void { + switch (status) { + case 'success': + console.log('Operation successful'); + break; + case 'failure': + console.log('Operation failed'); + break; + case 'pending': + console.log('Operation pending'); + break; + } + } -// Test cases to verify your code implementation (comment out the code below to remove the initial errors) + // Test cases to verify your code implementation (comment out the code below to remove the initial errors) -// Create an object of type 'Person' and pass it to 'printPersonDetails' -const person = { name: 'Alice', age: 30, isActive: true }; -printPersonDetails(person); // => Name: Alice, Age: 30, Status: Active + // Create an object of type 'Person' and pass it to 'printPersonDetails' + const person: Person = { name: 'Alice', age: 30, isActive: true }; + printPersonDetails(person); // => Name: Alice, Age: 30, Status: Active -// Pass different 'ResponseStatus' values to 'handleResponse' -handleResponse('success'); // => "Operation successful" -handleResponse('failure'); // => "Operation failed" -handleResponse('pending'); // => "Operation pending" + // Pass different 'ResponseStatus' values to 'handleResponse' + handleResponse('success'); // => "Operation successful" + handleResponse('failure'); // => "Operation failed" + handleResponse('pending'); // => "Operation pending" +} diff --git a/05_typescript/uebungen/u09_interfaces/assets/js/bundle.js b/05_typescript/uebungen/u09_interfaces/assets/js/bundle.js new file mode 100644 index 0000000..e2b4b79 --- /dev/null +++ b/05_typescript/uebungen/u09_interfaces/assets/js/bundle.js @@ -0,0 +1,18 @@ +(() => { + // src/main.ts + { + const printEmployeeDetails = ({ name, age, employeeId }) => { + console.log(`Name: ${name}`); + console.log(`Age: ${age}`); + console.log(`Employee ID: ${employeeId}`); + }; + const printDisplayDetails = (display2) => { + console.log(`Resolution: ${display2.resolution}`); + console.log(`Size: ${display2.size}`); + }; + const employee = { name: "Bob", age: 40, employeeId: 12345 }; + printEmployeeDetails(employee); + const display = { resolution: "4K", size: 27 }; + printDisplayDetails(display); + } +})(); diff --git a/05_typescript/uebungen/u09_interfaces/src/main.ts b/05_typescript/uebungen/u09_interfaces/src/main.ts index 9bb1fbf..f9fc797 100644 --- a/05_typescript/uebungen/u09_interfaces/src/main.ts +++ b/05_typescript/uebungen/u09_interfaces/src/main.ts @@ -1,27 +1,47 @@ -// Step 1: Define an interface 'Person' with the following properties: -// - name: a string -// - age: a number +{ + // Step 1: Define an interface 'Person' with the following properties: + // - name: a string + // - age: a number + interface Person { + name: string; + age: number; + } -// Step 2: Extend the 'Person' interface to create an 'Employee' interface with an additional property: -// - employeeId: a number + // Step 2: Extend the 'Person' interface to create an 'Employee' interface with an additional property: + // - employeeId: a number + interface Employee extends Person { + employeeId: number; + } + // Step 3: Implement a function 'printEmployeeDetails' that takes a parameter of type 'Employee' + // - The function should print out the employee's name, age, and employeeId. + const printEmployeeDetails = ({ name, age, employeeId }: Employee) => { + console.log(`Name: ${name}`); + console.log(`Age: ${age}`); + console.log(`Employee ID: ${employeeId}`); + }; -// Step 3: Implement a function 'printEmployeeDetails' that takes a parameter of type 'Employee' -// - The function should print out the employee's name, age, and employeeId. + // Step 4: Declare the 'Display' interface with a property: + // - resolution: a string + interface Display { + resolution: string; + } + // Step 5: Add a new property 'size: number' to the 'Display' interface using declaration merging + interface Display { + size: number; + } + // Step 6: Implement a function 'printDisplayDetails' that takes a parameter of type 'Display' + // - The function should print out the display's resolution and size. + const printDisplayDetails = (display: Display) => { + console.log(`Resolution: ${display.resolution}`); + console.log(`Size: ${display.size}`); + }; + // Test cases to verify your code implementation (comment out the code below to remove the initial errors) -// Step 4: Declare the 'Display' interface with a property: -// - resolution: a string + // Create an 'Employee' object and pass it to 'printEmployeeDetails' + const employee = { name: 'Bob', age: 40, employeeId: 12345 }; + printEmployeeDetails(employee); // => Name: Bob, Age: 40, Employee ID: 12345 -// Step 5: Add a new property 'size: number' to the 'Display' interface using declaration merging - -// Step 6: Implement a function 'printDisplayDetails' that takes a parameter of type 'Display' -// - The function should print out the display's resolution and size. - -// Test cases to verify your code implementation (comment out the code below to remove the initial errors) - -// Create an 'Employee' object and pass it to 'printEmployeeDetails' -const employee = { name: 'Bob', age: 40, employeeId: 12345 }; -printEmployeeDetails(employee); // => Name: Bob, Age: 40, Employee ID: 12345 - -// Create a 'Display' object and pass it to 'printDisplayDetails' -const display = { resolution: '4K', size: 27 }; -printDisplayDetails(display); // => Resolution: 4K, Size: 27 + // Create a 'Display' object and pass it to 'printDisplayDetails' + const display = { resolution: '4K', size: 27 }; + printDisplayDetails(display); // => Resolution: 4K, Size: 27 +} diff --git a/05_typescript/unterricht/tag29/01_ts-types/src/01_primitive-types.ts b/05_typescript/unterricht/tag29/01_ts-types/src/01_primitive-types.ts index c23e358..51f267d 100644 --- a/05_typescript/unterricht/tag29/01_ts-types/src/01_primitive-types.ts +++ b/05_typescript/unterricht/tag29/01_ts-types/src/01_primitive-types.ts @@ -18,6 +18,26 @@ let scores: number[] = [10, 20, 30, 40]; let moreScores: Array = [50, 60, 70]; + // Bigint (2020) + let bigNumber: bigint = 9007199254740992n; + + console.log(Number.MAX_SAFE_INTEGER); // => 9007199254740991 + console.log(bigNumber); + + // Symbol + const id: symbol = Symbol(123); + const id2: symbol = Symbol(123); + + console.log(id === id2); // => false + console.log(123 === 123); // => true + + // Funktionen + const multiply = (a: number, b: number): number => { + return a * b; + }; + + console.log(multiply(2, 4)); // => 8 + // nicht Grundtypen let listItems: Node[] = Array.from(document.querySelectorAll('li')); let listItems2: NodeListOf = document.querySelectorAll('li'); @@ -31,6 +51,7 @@ randomValue = "Now I'm a string!"; randomValue = { name: 'TypeScript' }; // randomValue.doSomething(); // No error, even though `doSomething` doesn't exist. + // randomValue(); // no error const $on = (elOrAr: Node | Node[], type: string, fn: EventListener) => { if (Array.isArray(elOrAr)) { @@ -51,23 +72,4 @@ $on($$('ul li'), 'click', (e: Event) => { console.log('click'); }); - - // Funktionen - const multiply = (a: number, b: number): number => { - return a * b; - }; - - // Bigint - let bigNumber: bigint = 9007199254740992n; - - console.log(Number.MAX_SAFE_INTEGER); // => 9007199254740991 - console.log(bigNumber); - - // Symbol - const id: symbol = Symbol(123); - const id2: symbol = Symbol(123); - - console.log(id === id2); // => false - - console.log(multiply(2, 4)); // => 8 } diff --git a/05_typescript/unterricht/tag29/01_ts-types/src/07_type-as-statement.ts b/05_typescript/unterricht/tag29/01_ts-types/src/07_type-as-statement.ts index fab9ad7..54ba6a8 100644 --- a/05_typescript/unterricht/tag29/01_ts-types/src/07_type-as-statement.ts +++ b/05_typescript/unterricht/tag29/01_ts-types/src/07_type-as-statement.ts @@ -1,4 +1,4 @@ -// Type Assertions verwenden - mit "as" statement festen Datentyp zuweisen +// Type Assertions verwenden - mit "as" statement und "<>" Operator festen Datentyp zuweisen { const h1El: HTMLHeadingElement | null = document.querySelector('h1'); diff --git a/05_typescript/unterricht/tag30/01_ts-types/assets/img/what-is-ts.webp b/05_typescript/unterricht/tag30/01_ts-types/assets/img/what-is-ts.webp new file mode 100644 index 0000000..d329dbb Binary files /dev/null and b/05_typescript/unterricht/tag30/01_ts-types/assets/img/what-is-ts.webp differ diff --git a/05_typescript/unterricht/tag30/01_ts-types/assets/js/01_type-literale.js b/05_typescript/unterricht/tag30/01_ts-types/assets/js/01_type-literale.js new file mode 100644 index 0000000..8afef30 --- /dev/null +++ b/05_typescript/unterricht/tag30/01_ts-types/assets/js/01_type-literale.js @@ -0,0 +1,2 @@ +(() => { +})(); diff --git a/05_typescript/unterricht/tag30/01_ts-types/index.html b/05_typescript/unterricht/tag30/01_ts-types/index.html new file mode 100644 index 0000000..b118e5f --- /dev/null +++ b/05_typescript/unterricht/tag30/01_ts-types/index.html @@ -0,0 +1,30 @@ + + + + + + TypeScript - Grundlagen + + + + + + + + + + + +
+
+

TypeScript - Grundlagen

+

+ TypeScript ist eine von Microsoft entwickelte Skriptsprache, die auf den Vorschlägen zum ECMAScript-6-Standard + basiert und statische Typisierung zu JavaScript hinzufügt. Sprachkonstrukte von TypeScript, wie Klassen, + Vererbung, Module und anonyme Funktionen, wurden auch in ECMAScript 6 übernommen. +

+ TypeScript Kreisdiagramm +
+
+ + diff --git a/05_typescript/unterricht/tag30/01_ts-types/package-lock.json b/05_typescript/unterricht/tag30/01_ts-types/package-lock.json new file mode 100644 index 0000000..93e05a3 --- /dev/null +++ b/05_typescript/unterricht/tag30/01_ts-types/package-lock.json @@ -0,0 +1,499 @@ +{ + "name": "01_ts-types", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "01_ts-types", + "version": "1.0.0", + "devDependencies": { + "esbuild": "^0.28.2" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.2.tgz", + "integrity": "sha512-XExcO+dvLKvVtNTibSTBej1NCAbaGhWn9Ww1ZPx80qsahhPFe/8jgWP0IchNe0F3HwkU7n8ejhH8bjonqht8mQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.28.2.tgz", + "integrity": "sha512-kXXoiPVVGQcnIYGOeaovwOURpniDBpSq4A03qkQ+BMQqtGG6HYap3xne9C1O1yo4TR3qxlCX5IqqmX6fFo2Lqg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.28.2.tgz", + "integrity": "sha512-5YfKeeI8qWfBZIX+u2xZC3Zlb3Os/gLS2sbEKM+I4ZOcsWmHS2WLysCcQZDAFRslDUU5Oiq44gf6PYN1vGwG5A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.28.2.tgz", + "integrity": "sha512-O387ite7SzUyCcy3JQX4P4bLtEA7bLLkx+esve5JHnyYfNTxcVpXZo9jhdB0lTKN44gztELTdU7nS8Nr16Fs1Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.28.2.tgz", + "integrity": "sha512-n4KqkOQrraxHJcgjM1RvwbigfQKIKJVpM7xp+KsxiyUSrRdIXnt73VhrPAx0fV44hgfmIVKjxMN9J1t5jySVkw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.28.2.tgz", + "integrity": "sha512-uq6suIWYP37qzGddBKPw5QEQPi6HiLGsO7UmkpfyaYNQ3D+rN6w6WfwH+nuqcGXWvawGwxOEroO4YGnFh95azw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.28.2.tgz", + "integrity": "sha512-n+I0BTSRIoy+d6RPKnEVwql5UwBJolytvY4mAOIEJorKlqgPII8ix6slVVrfZ5Tnj7glIZvloylbB/EJPMWEXw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.28.2.tgz", + "integrity": "sha512-78XJTJkvPs0kz2w61301PJjXl4g7q3JqiYMZ/M/yVI73EHBrCRTgkhu9oqG7vPqq+a/yadEW8aD+agKlk5xrmg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.28.2.tgz", + "integrity": "sha512-XlDnu2q5yoqems+xay6wSAcg9DDD7K9RLKZEBOMZm3ckNpJBvOX20tSfby8KfrrhINDyv9V2YVZKY/SpoGJI8w==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.28.2.tgz", + "integrity": "sha512-pW4AC0P3it8c7do9MVM4p51FzHzdM/TZrerurgRcHJ2WTa1VQ1CIq18xncfpBJw4ojkiZZrKW2yIBWBP92j6Ug==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.28.2.tgz", + "integrity": "sha512-CYbnj78HsIeA+DhgUKgFCfvNsTHFhMMrinUrMZpDXJXKN8T3XViTZ/+wtHeVxEWY8ewSzTFN+nRmSwO2tZaLUQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.28.2.tgz", + "integrity": "sha512-buwkd8nsph4R+ajRvw0qM5Hja/TXQow3ptzWO2EbG/cqcIkHloRrdlBtQlshyYGTNFvfkfJ5tpPLVkY4DtsPfQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.28.2.tgz", + "integrity": "sha512-ZVykbDyk7519VwiNb9Lcj9m8XM6v5V9uKPvrEMkkEedVewf+0itkhahp4HDpgERXhwLRpWFypsGbG/J8s0QjJA==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.28.2.tgz", + "integrity": "sha512-CAXl+Dtd9UUuJd8pKKdwh6MLm3MUMiqMPmhZ3tTSXPqfyQ3vDl6R5hZdZ/kYojK4ofXtdfSv1tFq8XzWx3heNQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.28.2.tgz", + "integrity": "sha512-GeXCej4IQtU1B+QlDV8W/RRvbzI3O/Stss+/bCXv4lZls5WGRtu2a+3JkA3i4qIUlMXpcHebWpF8AkJhATowuA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.28.2.tgz", + "integrity": "sha512-3H1weTYZPxt/WOhByszQZybS9w5lKzUn1FDMsgEChbHWQwHYQQRfBxgCcZvPhjHfKyJjIievvMmEUawJrdY9Dg==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.28.2.tgz", + "integrity": "sha512-4xTZr1FUmSoQW4XIWmit3tzQrUTZM+N3P0XV8xROKYF50XfI7xeO90+1bZvNwxIufQ9hDQVRJH5YhgPVF8A/HQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.28.2.tgz", + "integrity": "sha512-sSATRjPeDBg3pdgHoQfoYBob11Kk1FGa9lui5RIHZCoCkJa9QKlvl3/vKz2usCmYYjs7ymJR/2Nnsqe+Hjt5nw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.28.2.tgz", + "integrity": "sha512-lqnzCV+mM0gIADaKihiCg6ifgfU2L3h5E33rNQBN1Y4MaVGnzryzmvvf7UHxprpQdE8hpqLolJ9Rl+SkIRDpyw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.28.2.tgz", + "integrity": "sha512-AL2qJILH7lNjrDmCQDvdxMfAUIv8KMNZOvrwAQ8i8//ntL9FflhOyMJ8OZSMBb8/AWXe3/5v5S20y3zCoZWKoQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.28.2.tgz", + "integrity": "sha512-QtiuPytchRyC4rwUKhexJdQKvDuZ6hWloi3igqPQNUJCS1/v9EiO3UTOXR6A3FoMo4fnAKbWJdqaIwhOzh8qEw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.28.2.tgz", + "integrity": "sha512-WkhYDmpTjLvGlScA1rwjRUmhl4k8oXR3cIbtqWmELgU/dFeHHlEllxDvdWcNJV9rbzCexB5vz8gtNewWLgCT7Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.28.2.tgz", + "integrity": "sha512-GPMSkTOtMnv2U2F8gxe4Io6qmVs+YKyp832Etqqxr0hFngmXQ3rzwytelm3GIn7T4VviRUlf3sOgBOiTdvaf7g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.28.2.tgz", + "integrity": "sha512-PIhhEkE9uPBleRBrQEJpUn7MBnibZzbGzYWPmY3x+YoVg/95zbjB4CxPPOQ8l5tYYM4mMaCthF8/1DIfBQQyWQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.28.2.tgz", + "integrity": "sha512-YmJbfTlvU7Sdn9BB+4PRES4oB6pxgS37MAONj+hBr/cpXS1aBPKXxNnDbu+QCWPj0o9dgyxeq79g6c5P8KeuYA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.28.2.tgz", + "integrity": "sha512-5ebpxr3nWMzrL/rnUI755Jkuee0bHL/Gq0WTF9lvcpv73wAp5eu8MfBUgWK9bhWvZjj7yX8etf/8tI8Ney695g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/esbuild": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.2.tgz", + "integrity": "sha512-HKVLS8dvII+xoKW9kmqxbRKrnWEXfJJr/FZhhJmiqIB0e053QNYFqOBouTMO/k5sID4MvCiUCvv8b9M4h32wIA==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.28.2", + "@esbuild/android-arm": "0.28.2", + "@esbuild/android-arm64": "0.28.2", + "@esbuild/android-x64": "0.28.2", + "@esbuild/darwin-arm64": "0.28.2", + "@esbuild/darwin-x64": "0.28.2", + "@esbuild/freebsd-arm64": "0.28.2", + "@esbuild/freebsd-x64": "0.28.2", + "@esbuild/linux-arm": "0.28.2", + "@esbuild/linux-arm64": "0.28.2", + "@esbuild/linux-ia32": "0.28.2", + "@esbuild/linux-loong64": "0.28.2", + "@esbuild/linux-mips64el": "0.28.2", + "@esbuild/linux-ppc64": "0.28.2", + "@esbuild/linux-riscv64": "0.28.2", + "@esbuild/linux-s390x": "0.28.2", + "@esbuild/linux-x64": "0.28.2", + "@esbuild/netbsd-arm64": "0.28.2", + "@esbuild/netbsd-x64": "0.28.2", + "@esbuild/openbsd-arm64": "0.28.2", + "@esbuild/openbsd-x64": "0.28.2", + "@esbuild/openharmony-arm64": "0.28.2", + "@esbuild/sunos-x64": "0.28.2", + "@esbuild/win32-arm64": "0.28.2", + "@esbuild/win32-ia32": "0.28.2", + "@esbuild/win32-x64": "0.28.2" + } + } + } +} diff --git a/05_typescript/unterricht/tag30/01_ts-types/package.json b/05_typescript/unterricht/tag30/01_ts-types/package.json new file mode 100644 index 0000000..0d8bea6 --- /dev/null +++ b/05_typescript/unterricht/tag30/01_ts-types/package.json @@ -0,0 +1,14 @@ +{ + "name": "01_ts-types", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "ts": "npx esbuild \"src/*.ts\" --watch --bundle --outdir=\"assets/js\" --loader:.ts=ts" + }, + "keywords": [], + "type": "module", + "devDependencies": { + "esbuild": "^0.28.2" + } +} diff --git a/05_typescript/unterricht/tag30/01_ts-types/src/01_type-literale.ts b/05_typescript/unterricht/tag30/01_ts-types/src/01_type-literale.ts new file mode 100644 index 0000000..4dca0ba --- /dev/null +++ b/05_typescript/unterricht/tag30/01_ts-types/src/01_type-literale.ts @@ -0,0 +1 @@ +// Literal