www.felix.fun
@felixrieseberg
Senior Staff Engineer, Slack
Welcome to 2019
JavaScript isn’t just the most popular programming technology - Node.js is everywhere
JavaScript is used to build sophisticated applications.
😰
Vanilla JavaScript requires source code study
JSDoc/ESDoc requires trust in your fellow developer
Both methods are inefficient, frustrating, and failure-prone
📚
/**
* @param {Object} options
* @param {string} options.prop1
* @param {number} options.prop2
* @param {number} [options.prop3=42]
*
* @returns {number}
*/
function myMethod(options) {
const { prop2, prop3 } = options
return prop1 * (prop3 || 42)
}
📚
Vanilla JavaScript requires source code study
JSDoc/ESDoc requires trust in your fellow developer
Both methods are inefficient, frustrating, and failure-prone
Superset of JavaScript
No modification of code at runtime
Excellent editor support
Excellent integration with the npm world
And of course… types.
📚
Starting the TypeScript Compiler
Modern JavaScript is valid TypeScript. You can use the compiler without changing a single line of code.
👷♂️
Slowly port files over
We have features to ship and bugs to fix - we slowly ported file by file.
You’ll quickly dislike working with files not ported over.
👷♂️
Committing with confidence
TypeScript gives us a guarantee that the structural dependencies in the code are sound.
👷♂️
It might look scary
Advanced use of TypeScript involves interfaces, type declarations, and enums.
Nothing new for a developer who’s seen Java, C#, or other typed languages, but possible scary to junior JavaScript devs.
👷♂️
👷♂️
declare type Promisify<T> = T extends Promise<any> ? T : Promise<T>;
type ProxiedObject<T> = {
[P in keyof T]: T[P] extends (...args: infer Arguments) => infer R
? (...args: Arguments) => Promisify<R>
: ProxiedObject<T[P]>
};
export { ProxiedObject };
Slack's most difficult lines of TypeScript
🏆
www.felix.fun