SlideShare a Scribd company logo
1 of 24
TypeScript 3.X: Was war. Was kommt!
Johannes Dienst
Autoimport Declaration Files
2 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
Autoimport Modules
3 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
Refactoring
4 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
Quickfixes
5 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
The never type (1)
class PseudoAbstractClass {
pseudoAbstractMethod(): never {
throw new Error();
}
}
// Leads to error:
// Class 'SubClass' incorrectly extends base class 'PseudoAbstractClass'
class SubClass extends PseudoAbstractClass {
pseudoAbstractMethod() {
return 42;
}
}
6 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
The never Type (2)
• The never type is the bottom type of the type hierarchy
• It signals that a method does not return
• The compiler uses it mostly to prevent errors
const foo = () => { throw new Error()};
let bar = foo();
bar. // no suggestions
7 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
Control-Flow Analysis (1) – Determine type
function notNullTest(x: string | null) {
if (x === null) {
return;
}
x; // type of x is string in remainder of function
}
function test(title: any) {
if (typeof title == 'string') {
// Property 'filter' does not exist on type 'string'.
title.filter((t) => t == 'foo');
}
}
8 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
Control-Flow Analysis (2) – Prevent compile errors
if (false) {
// @ts-ignore: Unreachable code error
console.log("hello");
}
9 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
Control-Flow Analysis (3) - NoImplicitAny
// Parameter 'title' implicitly has an 'any' type.
function implicitAny(title) {
title.filter();
}
// No error
function implicitAny(title: { filter: () => void; }) {
title.filter();
}
10 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
Control-Flow Analysis (4) – Type widening
const c1 = 1; // Type 1
const c2 = c1; // Type 1
const c3 = "abc"; // Type "abc"
const c4 = true; // Type true
const c5 = (42) ? 1 : "abc"; // Type 1 | "abc"
let v1 = 1; // Type number
let v2 = c2; // Type number
let v3 = c3; // Type string
let v4 = c4; // Type boolean
let v5 = c5; // Type number | string
11 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
Control-Flow Analysis (5) – Generics
let x: Promise<string> = new Promise(resolve => {
// resolve(10); ~~ Error!
resolve("10");
});
let fun1: <T>(x: T) => T = y => y;
// Leads to errors, because y is of type T
let fun2: <T>(x: T) => T = y => y() + y.foo.bar;
type A = <T, U>(x: T, y: U) => [T, U];
type B = <S>(x: S, y: S) => [S, S];
function fun3(a: A, b: B) {
// a = b; // Error
b = a; // Ok
return b;
}
12 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
Control-Flow Analysis (6) – Definite Assignment Operator
let x: number;
console.log(x); // Error: Variable is used before assignment
let y!: number;
console.log(y); // No Error
13 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
Control-Flow Analysis (7) – Fixed length Arrays
let anArray: [number, number] = [27, 42];
// Error: Type [number, number, number]
// not assignable to [number, number]
anArray = [1, 2, 3];
14 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
Class based Mixins (1)
type Constructor<T = {}> = new(...args: any[]) => T;
function Tagged<T extends Constructor>(Base: T) {
return class extends Base {
_tag: string;
constructor(...args: any[]) {
super(...args);
this._tag = "";
}
}
}
15 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
Class based Mixins (2)
class Developer {
constructor(public name: string, language: string) {}
}
class DevOpsGuy extends Tagged(Developer) {
operating_system: string;
}
let devopsguy = new DevOpsGuy("Joe", "Doe");
devopsguy._tag = "The chosen one";
devopsguy.operating_system = "Linux";
16 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
Class based Mixins (3)
const WithSoundBite = <T extends Constructor<Developer>>(Base: T) =>
class extends Base {
getSoundBite(): string {
return `${this.language} is the best!`;
}
}
class SoundBiter extends WithSoundBite(Developer) { }
let sB = new SoundBiter("Jane", "Dane");
sB.getSoundBite();
17 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
Decorators (1)
• A decorator is a function with the following signature
function dec(target: any, propertyKey: any, descriptor: any) { }
• Applicable to classes, methods and parameters
18 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
Decorators (2) – Example https://github.com/awerlang/es-decorators
const serialized = new WeakMap();
export function serializable() {
return function (target: any) {
target.prototype.toJSON = function () {
const map = serialized.get(target.prototype);
const props = Object.keys(map);
return props.reduce((previous, key) => {
previous[map[key]] = this[key];
return previous;
}, {});
}
}
}
19 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
Decorators (3) – Example https://github.com/awerlang/es-decorators
export function serialize(name?: string) {
return function (target, propertyKey) {
let map = serialized.get(target);
if (!map) {
map = {};
serialized.set(target, map);
}
map[propertyKey] = name || propertyKey;
}
}
20 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
Decorators (4) – Example https://github.com/awerlang/es-decorators
@serializable()
class Person {
constructor(name: string) {
this._name = name;
}
private _name: string;
@serialize()
get name() {
return this._name;
}
}
const p = new Person('Johannes');
console.log(JSON.stringify(p));
21 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
Async / Await (1)
function delay(milliseconds: number) {
return new Promise<void>(resolve => {
setTimeout(resolve, milliseconds);
});
}
async function dramaticWelcome() {
console.log("Hello");
for (let i = 0; i < 3; i++) {
await delay(500);
console.log(".");
}
console.log("World!");
}
22 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
Async / Await (2)
async function* g() {
yield 1;
await delay(100);
yield* [2, 3];
yield* (async function *() {
await delay(100);
yield 4;
})();
}
async function fun() {
for await (const x of g()) {
console.log(x);
}
}
23 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
I love working with smart people and being challenged.
I also like working on stuff that‘s relevant.
That‘s my adrenaline shot.
Anders Hejlsberg
DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst

More Related Content

What's hot

What's hot (20)

C# programs
C# programsC# programs
C# programs
 
Assignment9
Assignment9Assignment9
Assignment9
 
Type Casting in C++
Type Casting in C++Type Casting in C++
Type Casting in C++
 
C++ Overview PPT
C++ Overview PPTC++ Overview PPT
C++ Overview PPT
 
C formatted and unformatted input and output constructs
C  formatted and unformatted input and output constructsC  formatted and unformatted input and output constructs
C formatted and unformatted input and output constructs
 
Few Operator used in c++
Few Operator used in c++Few Operator used in c++
Few Operator used in c++
 
Matlab Functions
Matlab FunctionsMatlab Functions
Matlab Functions
 
Introduction To Algorithm [2]
Introduction To Algorithm [2]Introduction To Algorithm [2]
Introduction To Algorithm [2]
 
01. introduction to C++
01. introduction to C++01. introduction to C++
01. introduction to C++
 
Verilog Tasks and functions
Verilog Tasks and functionsVerilog Tasks and functions
Verilog Tasks and functions
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
 
Basic operators in matlab
Basic operators in matlabBasic operators in matlab
Basic operators in matlab
 
Getting Started with C++
Getting Started with C++Getting Started with C++
Getting Started with C++
 
User Defined Functions in C Language
User Defined Functions   in  C LanguageUser Defined Functions   in  C Language
User Defined Functions in C Language
 
Assignment8
Assignment8Assignment8
Assignment8
 
operators and expressions in c++
 operators and expressions in c++ operators and expressions in c++
operators and expressions in c++
 
Cs211 module 1_2015
Cs211 module 1_2015Cs211 module 1_2015
Cs211 module 1_2015
 
Java 8
Java 8Java 8
Java 8
 
Pointers in C language
Pointers  in  C languagePointers  in  C language
Pointers in C language
 
Code optimisation presnted
Code optimisation presntedCode optimisation presnted
Code optimisation presnted
 

Similar to Type Script 3.x - Was war. Was kommt!

Modern c++ (C++ 11/14)
Modern c++ (C++ 11/14)Modern c++ (C++ 11/14)
Modern c++ (C++ 11/14)Geeks Anonymes
 
Mercury: A Functional Review
Mercury: A Functional ReviewMercury: A Functional Review
Mercury: A Functional ReviewMark Cheeseman
 
Composing an App with Free Monads (using Cats)
Composing an App with Free Monads (using Cats)Composing an App with Free Monads (using Cats)
Composing an App with Free Monads (using Cats)Hermann Hueck
 
Functional programming-advantages
Functional programming-advantagesFunctional programming-advantages
Functional programming-advantagesSergei Winitzki
 
Make sure to make a copy of the Google Doc for this lab into.pdf
Make sure to make a copy of the Google Doc for this lab into.pdfMake sure to make a copy of the Google Doc for this lab into.pdf
Make sure to make a copy of the Google Doc for this lab into.pdfadityastores21
 
Automatic Task-based Code Generation for High Performance DSEL
Automatic Task-based Code Generation for High Performance DSELAutomatic Task-based Code Generation for High Performance DSEL
Automatic Task-based Code Generation for High Performance DSELJoel Falcou
 
Lecture 5: Functional Programming
Lecture 5: Functional ProgrammingLecture 5: Functional Programming
Lecture 5: Functional ProgrammingEelco Visser
 
data Structure Lecture 1
data Structure Lecture 1data Structure Lecture 1
data Structure Lecture 1Teksify
 
(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...
(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...
(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...Phil Calçado
 
Kotlin Developer Starter in Android projects
Kotlin Developer Starter in Android projectsKotlin Developer Starter in Android projects
Kotlin Developer Starter in Android projectsBartosz Kosarzycki
 
Kotlin Developer Starter in Android - STX Next Lightning Talks - Feb 12, 2016
Kotlin Developer Starter in Android - STX Next Lightning Talks - Feb 12, 2016Kotlin Developer Starter in Android - STX Next Lightning Talks - Feb 12, 2016
Kotlin Developer Starter in Android - STX Next Lightning Talks - Feb 12, 2016STX Next
 
friends functionToshu
friends functionToshufriends functionToshu
friends functionToshuSidd Singh
 

Similar to Type Script 3.x - Was war. Was kommt! (20)

14 operator overloading
14 operator overloading14 operator overloading
14 operator overloading
 
Modern c++ (C++ 11/14)
Modern c++ (C++ 11/14)Modern c++ (C++ 11/14)
Modern c++ (C++ 11/14)
 
Mercury: A Functional Review
Mercury: A Functional ReviewMercury: A Functional Review
Mercury: A Functional Review
 
Composing an App with Free Monads (using Cats)
Composing an App with Free Monads (using Cats)Composing an App with Free Monads (using Cats)
Composing an App with Free Monads (using Cats)
 
Functional programming-advantages
Functional programming-advantagesFunctional programming-advantages
Functional programming-advantages
 
Thinking in Functions
Thinking in FunctionsThinking in Functions
Thinking in Functions
 
Make sure to make a copy of the Google Doc for this lab into.pdf
Make sure to make a copy of the Google Doc for this lab into.pdfMake sure to make a copy of the Google Doc for this lab into.pdf
Make sure to make a copy of the Google Doc for this lab into.pdf
 
SCALA - Functional domain
SCALA -  Functional domainSCALA -  Functional domain
SCALA - Functional domain
 
ASP.NET
ASP.NETASP.NET
ASP.NET
 
Lambdas puzzler - Peter Lawrey
Lambdas puzzler - Peter LawreyLambdas puzzler - Peter Lawrey
Lambdas puzzler - Peter Lawrey
 
Automatic Task-based Code Generation for High Performance DSEL
Automatic Task-based Code Generation for High Performance DSELAutomatic Task-based Code Generation for High Performance DSEL
Automatic Task-based Code Generation for High Performance DSEL
 
Lecture 5: Functional Programming
Lecture 5: Functional ProgrammingLecture 5: Functional Programming
Lecture 5: Functional Programming
 
data Structure Lecture 1
data Structure Lecture 1data Structure Lecture 1
data Structure Lecture 1
 
(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...
(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...
(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...
 
Kotlin Developer Starter in Android projects
Kotlin Developer Starter in Android projectsKotlin Developer Starter in Android projects
Kotlin Developer Starter in Android projects
 
Kotlin Developer Starter in Android - STX Next Lightning Talks - Feb 12, 2016
Kotlin Developer Starter in Android - STX Next Lightning Talks - Feb 12, 2016Kotlin Developer Starter in Android - STX Next Lightning Talks - Feb 12, 2016
Kotlin Developer Starter in Android - STX Next Lightning Talks - Feb 12, 2016
 
friends functionToshu
friends functionToshufriends functionToshu
friends functionToshu
 
CPP Assignment Help
CPP Assignment HelpCPP Assignment Help
CPP Assignment Help
 
Stacks.ppt
Stacks.pptStacks.ppt
Stacks.ppt
 
Stacks.ppt
Stacks.pptStacks.ppt
Stacks.ppt
 

More from Johannes Dienst

Developer Relations Metrics - A Humble Guide
Developer Relations Metrics - A Humble GuideDeveloper Relations Metrics - A Humble Guide
Developer Relations Metrics - A Humble GuideJohannes Dienst
 
Real Cross-Platform Workflow UI Automation_JohannesDienst.pdf
Real Cross-Platform Workflow UI Automation_JohannesDienst.pdfReal Cross-Platform Workflow UI Automation_JohannesDienst.pdf
Real Cross-Platform Workflow UI Automation_JohannesDienst.pdfJohannes Dienst
 
The Future of UI Testing - Challenges in UI Automation
The Future of UI Testing - Challenges in UI AutomationThe Future of UI Testing - Challenges in UI Automation
The Future of UI Testing - Challenges in UI AutomationJohannes Dienst
 
Managed Cloud to GitOps: Deploying Several Client Clusters
Managed Cloud to GitOps: Deploying Several Client ClustersManaged Cloud to GitOps: Deploying Several Client Clusters
Managed Cloud to GitOps: Deploying Several Client ClustersJohannes Dienst
 
Rock Solid Software Architecture with ADRs, arc42 and Microsites
Rock Solid Software Architecture with ADRs, arc42 and MicrositesRock Solid Software Architecture with ADRs, arc42 and Microsites
Rock Solid Software Architecture with ADRs, arc42 and MicrositesJohannes Dienst
 
Stoizismus - Praktische Philosophie für den IT-Alltag (Pecha Kucha)
Stoizismus - Praktische Philosophie für den IT-Alltag (Pecha Kucha)Stoizismus - Praktische Philosophie für den IT-Alltag (Pecha Kucha)
Stoizismus - Praktische Philosophie für den IT-Alltag (Pecha Kucha)Johannes Dienst
 
Von Managed-Cloud zu GitOps - Multi Client-Cluster Deployments
Von Managed-Cloud zu GitOps - Multi Client-Cluster DeploymentsVon Managed-Cloud zu GitOps - Multi Client-Cluster Deployments
Von Managed-Cloud zu GitOps - Multi Client-Cluster DeploymentsJohannes Dienst
 
Managed Cloud to GitOps: Deploying Several Client Clusters
Managed Cloud to GitOps: Deploying Several Client ClustersManaged Cloud to GitOps: Deploying Several Client Clusters
Managed Cloud to GitOps: Deploying Several Client ClustersJohannes Dienst
 
Griechische Philosophie für moderne Softwareentwicklung
Griechische Philosophie für moderne SoftwareentwicklungGriechische Philosophie für moderne Softwareentwicklung
Griechische Philosophie für moderne SoftwareentwicklungJohannes Dienst
 
Lessons Learned Using arc42 in a Real DevOps Team
Lessons Learned Using arc42 in a Real DevOps TeamLessons Learned Using arc42 in a Real DevOps Team
Lessons Learned Using arc42 in a Real DevOps TeamJohannes Dienst
 
Lessons Learned: arc42 in einem echten DevOps Team
Lessons Learned: arc42 in einem echten DevOps TeamLessons Learned: arc42 in einem echten DevOps Team
Lessons Learned: arc42 in einem echten DevOps TeamJohannes Dienst
 
Work efficiently with Architecture Decision Records
Work efficiently with Architecture Decision RecordsWork efficiently with Architecture Decision Records
Work efficiently with Architecture Decision RecordsJohannes Dienst
 
The Dev, The Ops, And The Team: What works in a DevOps Team?
The Dev, The Ops, And The Team: What works in a DevOps Team?The Dev, The Ops, And The Team: What works in a DevOps Team?
The Dev, The Ops, And The Team: What works in a DevOps Team?Johannes Dienst
 
Effizient arbeiten mit Architecture Decision Records (ADR)
Effizient arbeiten mit Architecture Decision Records (ADR)Effizient arbeiten mit Architecture Decision Records (ADR)
Effizient arbeiten mit Architecture Decision Records (ADR)Johannes Dienst
 
Leichtgewichtige Softwarearchitektur mit Architecture Decision Records und Qu...
Leichtgewichtige Softwarearchitektur mit Architecture Decision Records und Qu...Leichtgewichtige Softwarearchitektur mit Architecture Decision Records und Qu...
Leichtgewichtige Softwarearchitektur mit Architecture Decision Records und Qu...Johannes Dienst
 
Spock vs Supermutanten: Spezifikationstesten trifft Mutationstesten
Spock vs Supermutanten: Spezifikationstesten trifft MutationstestenSpock vs Supermutanten: Spezifikationstesten trifft Mutationstesten
Spock vs Supermutanten: Spezifikationstesten trifft MutationstestenJohannes Dienst
 
Everything as Code: Pipeline, Infrastructure, Configuration, Documentation
Everything as Code: Pipeline, Infrastructure, Configuration, DocumentationEverything as Code: Pipeline, Infrastructure, Configuration, Documentation
Everything as Code: Pipeline, Infrastructure, Configuration, DocumentationJohannes Dienst
 
DevOps im Konzern - Autonomie vs Betriebssicherheit (Continuous Lifecycle)
DevOps im Konzern - Autonomie vs Betriebssicherheit (Continuous Lifecycle)DevOps im Konzern - Autonomie vs Betriebssicherheit (Continuous Lifecycle)
DevOps im Konzern - Autonomie vs Betriebssicherheit (Continuous Lifecycle)Johannes Dienst
 
Leichtgewichtige Softwarearchitektur mit Architecture Decision Records und Qu...
Leichtgewichtige Softwarearchitektur mit Architecture Decision Records und Qu...Leichtgewichtige Softwarearchitektur mit Architecture Decision Records und Qu...
Leichtgewichtige Softwarearchitektur mit Architecture Decision Records und Qu...Johannes Dienst
 
Pride & Prejudice: Teambildung & Motivation im agilen Umfeld
Pride & Prejudice: Teambildung & Motivation im agilen UmfeldPride & Prejudice: Teambildung & Motivation im agilen Umfeld
Pride & Prejudice: Teambildung & Motivation im agilen UmfeldJohannes Dienst
 

More from Johannes Dienst (20)

Developer Relations Metrics - A Humble Guide
Developer Relations Metrics - A Humble GuideDeveloper Relations Metrics - A Humble Guide
Developer Relations Metrics - A Humble Guide
 
Real Cross-Platform Workflow UI Automation_JohannesDienst.pdf
Real Cross-Platform Workflow UI Automation_JohannesDienst.pdfReal Cross-Platform Workflow UI Automation_JohannesDienst.pdf
Real Cross-Platform Workflow UI Automation_JohannesDienst.pdf
 
The Future of UI Testing - Challenges in UI Automation
The Future of UI Testing - Challenges in UI AutomationThe Future of UI Testing - Challenges in UI Automation
The Future of UI Testing - Challenges in UI Automation
 
Managed Cloud to GitOps: Deploying Several Client Clusters
Managed Cloud to GitOps: Deploying Several Client ClustersManaged Cloud to GitOps: Deploying Several Client Clusters
Managed Cloud to GitOps: Deploying Several Client Clusters
 
Rock Solid Software Architecture with ADRs, arc42 and Microsites
Rock Solid Software Architecture with ADRs, arc42 and MicrositesRock Solid Software Architecture with ADRs, arc42 and Microsites
Rock Solid Software Architecture with ADRs, arc42 and Microsites
 
Stoizismus - Praktische Philosophie für den IT-Alltag (Pecha Kucha)
Stoizismus - Praktische Philosophie für den IT-Alltag (Pecha Kucha)Stoizismus - Praktische Philosophie für den IT-Alltag (Pecha Kucha)
Stoizismus - Praktische Philosophie für den IT-Alltag (Pecha Kucha)
 
Von Managed-Cloud zu GitOps - Multi Client-Cluster Deployments
Von Managed-Cloud zu GitOps - Multi Client-Cluster DeploymentsVon Managed-Cloud zu GitOps - Multi Client-Cluster Deployments
Von Managed-Cloud zu GitOps - Multi Client-Cluster Deployments
 
Managed Cloud to GitOps: Deploying Several Client Clusters
Managed Cloud to GitOps: Deploying Several Client ClustersManaged Cloud to GitOps: Deploying Several Client Clusters
Managed Cloud to GitOps: Deploying Several Client Clusters
 
Griechische Philosophie für moderne Softwareentwicklung
Griechische Philosophie für moderne SoftwareentwicklungGriechische Philosophie für moderne Softwareentwicklung
Griechische Philosophie für moderne Softwareentwicklung
 
Lessons Learned Using arc42 in a Real DevOps Team
Lessons Learned Using arc42 in a Real DevOps TeamLessons Learned Using arc42 in a Real DevOps Team
Lessons Learned Using arc42 in a Real DevOps Team
 
Lessons Learned: arc42 in einem echten DevOps Team
Lessons Learned: arc42 in einem echten DevOps TeamLessons Learned: arc42 in einem echten DevOps Team
Lessons Learned: arc42 in einem echten DevOps Team
 
Work efficiently with Architecture Decision Records
Work efficiently with Architecture Decision RecordsWork efficiently with Architecture Decision Records
Work efficiently with Architecture Decision Records
 
The Dev, The Ops, And The Team: What works in a DevOps Team?
The Dev, The Ops, And The Team: What works in a DevOps Team?The Dev, The Ops, And The Team: What works in a DevOps Team?
The Dev, The Ops, And The Team: What works in a DevOps Team?
 
Effizient arbeiten mit Architecture Decision Records (ADR)
Effizient arbeiten mit Architecture Decision Records (ADR)Effizient arbeiten mit Architecture Decision Records (ADR)
Effizient arbeiten mit Architecture Decision Records (ADR)
 
Leichtgewichtige Softwarearchitektur mit Architecture Decision Records und Qu...
Leichtgewichtige Softwarearchitektur mit Architecture Decision Records und Qu...Leichtgewichtige Softwarearchitektur mit Architecture Decision Records und Qu...
Leichtgewichtige Softwarearchitektur mit Architecture Decision Records und Qu...
 
Spock vs Supermutanten: Spezifikationstesten trifft Mutationstesten
Spock vs Supermutanten: Spezifikationstesten trifft MutationstestenSpock vs Supermutanten: Spezifikationstesten trifft Mutationstesten
Spock vs Supermutanten: Spezifikationstesten trifft Mutationstesten
 
Everything as Code: Pipeline, Infrastructure, Configuration, Documentation
Everything as Code: Pipeline, Infrastructure, Configuration, DocumentationEverything as Code: Pipeline, Infrastructure, Configuration, Documentation
Everything as Code: Pipeline, Infrastructure, Configuration, Documentation
 
DevOps im Konzern - Autonomie vs Betriebssicherheit (Continuous Lifecycle)
DevOps im Konzern - Autonomie vs Betriebssicherheit (Continuous Lifecycle)DevOps im Konzern - Autonomie vs Betriebssicherheit (Continuous Lifecycle)
DevOps im Konzern - Autonomie vs Betriebssicherheit (Continuous Lifecycle)
 
Leichtgewichtige Softwarearchitektur mit Architecture Decision Records und Qu...
Leichtgewichtige Softwarearchitektur mit Architecture Decision Records und Qu...Leichtgewichtige Softwarearchitektur mit Architecture Decision Records und Qu...
Leichtgewichtige Softwarearchitektur mit Architecture Decision Records und Qu...
 
Pride & Prejudice: Teambildung & Motivation im agilen Umfeld
Pride & Prejudice: Teambildung & Motivation im agilen UmfeldPride & Prejudice: Teambildung & Motivation im agilen Umfeld
Pride & Prejudice: Teambildung & Motivation im agilen Umfeld
 

Recently uploaded

Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 

Recently uploaded (20)

Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 

Type Script 3.x - Was war. Was kommt!

  • 1. TypeScript 3.X: Was war. Was kommt! Johannes Dienst
  • 2. Autoimport Declaration Files 2 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
  • 3. Autoimport Modules 3 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
  • 4. Refactoring 4 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
  • 5. Quickfixes 5 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
  • 6. The never type (1) class PseudoAbstractClass { pseudoAbstractMethod(): never { throw new Error(); } } // Leads to error: // Class 'SubClass' incorrectly extends base class 'PseudoAbstractClass' class SubClass extends PseudoAbstractClass { pseudoAbstractMethod() { return 42; } } 6 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
  • 7. The never Type (2) • The never type is the bottom type of the type hierarchy • It signals that a method does not return • The compiler uses it mostly to prevent errors const foo = () => { throw new Error()}; let bar = foo(); bar. // no suggestions 7 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
  • 8. Control-Flow Analysis (1) – Determine type function notNullTest(x: string | null) { if (x === null) { return; } x; // type of x is string in remainder of function } function test(title: any) { if (typeof title == 'string') { // Property 'filter' does not exist on type 'string'. title.filter((t) => t == 'foo'); } } 8 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
  • 9. Control-Flow Analysis (2) – Prevent compile errors if (false) { // @ts-ignore: Unreachable code error console.log("hello"); } 9 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
  • 10. Control-Flow Analysis (3) - NoImplicitAny // Parameter 'title' implicitly has an 'any' type. function implicitAny(title) { title.filter(); } // No error function implicitAny(title: { filter: () => void; }) { title.filter(); } 10 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
  • 11. Control-Flow Analysis (4) – Type widening const c1 = 1; // Type 1 const c2 = c1; // Type 1 const c3 = "abc"; // Type "abc" const c4 = true; // Type true const c5 = (42) ? 1 : "abc"; // Type 1 | "abc" let v1 = 1; // Type number let v2 = c2; // Type number let v3 = c3; // Type string let v4 = c4; // Type boolean let v5 = c5; // Type number | string 11 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
  • 12. Control-Flow Analysis (5) – Generics let x: Promise<string> = new Promise(resolve => { // resolve(10); ~~ Error! resolve("10"); }); let fun1: <T>(x: T) => T = y => y; // Leads to errors, because y is of type T let fun2: <T>(x: T) => T = y => y() + y.foo.bar; type A = <T, U>(x: T, y: U) => [T, U]; type B = <S>(x: S, y: S) => [S, S]; function fun3(a: A, b: B) { // a = b; // Error b = a; // Ok return b; } 12 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
  • 13. Control-Flow Analysis (6) – Definite Assignment Operator let x: number; console.log(x); // Error: Variable is used before assignment let y!: number; console.log(y); // No Error 13 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
  • 14. Control-Flow Analysis (7) – Fixed length Arrays let anArray: [number, number] = [27, 42]; // Error: Type [number, number, number] // not assignable to [number, number] anArray = [1, 2, 3]; 14 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
  • 15. Class based Mixins (1) type Constructor<T = {}> = new(...args: any[]) => T; function Tagged<T extends Constructor>(Base: T) { return class extends Base { _tag: string; constructor(...args: any[]) { super(...args); this._tag = ""; } } } 15 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
  • 16. Class based Mixins (2) class Developer { constructor(public name: string, language: string) {} } class DevOpsGuy extends Tagged(Developer) { operating_system: string; } let devopsguy = new DevOpsGuy("Joe", "Doe"); devopsguy._tag = "The chosen one"; devopsguy.operating_system = "Linux"; 16 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
  • 17. Class based Mixins (3) const WithSoundBite = <T extends Constructor<Developer>>(Base: T) => class extends Base { getSoundBite(): string { return `${this.language} is the best!`; } } class SoundBiter extends WithSoundBite(Developer) { } let sB = new SoundBiter("Jane", "Dane"); sB.getSoundBite(); 17 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
  • 18. Decorators (1) • A decorator is a function with the following signature function dec(target: any, propertyKey: any, descriptor: any) { } • Applicable to classes, methods and parameters 18 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
  • 19. Decorators (2) – Example https://github.com/awerlang/es-decorators const serialized = new WeakMap(); export function serializable() { return function (target: any) { target.prototype.toJSON = function () { const map = serialized.get(target.prototype); const props = Object.keys(map); return props.reduce((previous, key) => { previous[map[key]] = this[key]; return previous; }, {}); } } } 19 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
  • 20. Decorators (3) – Example https://github.com/awerlang/es-decorators export function serialize(name?: string) { return function (target, propertyKey) { let map = serialized.get(target); if (!map) { map = {}; serialized.set(target, map); } map[propertyKey] = name || propertyKey; } } 20 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
  • 21. Decorators (4) – Example https://github.com/awerlang/es-decorators @serializable() class Person { constructor(name: string) { this._name = name; } private _name: string; @serialize() get name() { return this._name; } } const p = new Person('Johannes'); console.log(JSON.stringify(p)); 21 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
  • 22. Async / Await (1) function delay(milliseconds: number) { return new Promise<void>(resolve => { setTimeout(resolve, milliseconds); }); } async function dramaticWelcome() { console.log("Hello"); for (let i = 0; i < 3; i++) { await delay(500); console.log("."); } console.log("World!"); } 22 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
  • 23. Async / Await (2) async function* g() { yield 1; await delay(100); yield* [2, 3]; yield* (async function *() { await delay(100); yield 4; })(); } async function fun() { for await (const x of g()) { console.log(x); } } 23 DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst
  • 24. I love working with smart people and being challenged. I also like working on stuff that‘s relevant. That‘s my adrenaline shot. Anders Hejlsberg DB Systel GmbH | Johannes Dienst | T.IPI 42 | @JohannesDienst