Your Choice JavaScript News

TypeScript News Wednesday, March 28 Typescript, Excellent typescript support, Castable typescript library & more…

TypeScript News TLDR / Table of Contents

  • Announcing TypeScript 2.8
    • TypeScript, excellent TypeScript support, conditional types, TypeScript compiler, Wenlu Wang TypeScript
  • TypeScriptのリフレクションでJSONの型変換を自動化する
    • 12/21追記npmに公開しました。npm install @bitr/castableCastable TypeScript Libraryhttps://github.com/bitrinjani/castable数値をダブルクォートでくくってJSONで送ってくるWebサービスに対処するたまには純粋に技術的な話を。今C#でプロトタイプを作ったビットコイン自動取引システムをNode.jsに移行しようと試みています。C#の型安全性を保っ…
    • Castable TypeScript Library, return source, (Github issue), export function element, propertyKey
  • Why TypeScript · TypeScript Deep Dive
    • TypeScript, default TypeScript, multi-file code bases, original JavaScript file, optional Type checking
  • Conditional types are a new construct in TypeScript that allow us to choose types based on other types.
  • Just like how JavaScript can make decisions at runtime based on the characteristics of a value, conditional types let TypeScript make decisions in the type system based on the characteristics of other types.
  • selects types from its first argument that are assignable to its second argument: – – does the opposite; it removes types from its first argument that are not assignable to its second: – – Thanks to a pull request from Manoj Patel, TypeScript now features an flag which can be…
  • TypeScript 2.8 will rewrite it to the following when compiling to CommonJS and ES5: – – Currently, when TypeScript uses JSX, it looks up a global namespace to look up certain types (e.g. whats the type of a JSX component?)
  • Similarly, TypeScript now provides a new type in that removes optionality from each property: – – The operator can be handy when you want to call out that a mapped type is adding modifiers.

Tags: TypeScript, excellent TypeScript support, conditional types, TypeScript compiler, Wenlu Wang TypeScript

  • install @bitr/castable – – – – – Castable TypeScript serverResponse = `{ – name: Milk, – price: 200, – tax: 10, – }`; – const product = sum = product.price + product.tax; – console.log(`sum: ${sum}`); // 200 + 10 = serverResponse = `{ – name: Milk, – price: 200, -…
  • == undefined ?
  • customType : designType; – this[propertyKey] = propertyKey, type, 0); – }); – } – – convert(source: any, propertyKey: string, type: any, depth: number) { – if (type === undefined) { – return source; – } – switch (type.name) { – case ‘Number’: – return Number(source); – case ‘String’: – return…
  • map(el = this.convert(el, propertyKey, elementType, nextDepth)); – default: – return new type(source); – } – (string, number, { cast, element, Castable } from ‘@bitr/castable’; – – class Detail extends Castable { – @cast shipping: number; – @cast address: string; – } – – class Product extends Castable { – @cast…

Tags: Castable TypeScript Library, return source, (Github issue), export function element, propertyKey

  • Here’s how: – – TypeScript provides compile time type safety for your JavaScript code.
  • TypeScript will try to infer as much of the type information as it can in order to give you type safety with minimal cost of productivity during code development.
  • The function will accept anything that contains all the things ( and ) it expects: – – To make it easy for you to migrate your JavaScript code to TypeScript, even if there are compilation errors, by default TypeScript will emit valid JavaScript the best that it can.
  • TypeScript provides you with a sliding scale of how much or how little effort you want to put in your declarations, the more effort you put the more type safety + code intelligence you get.
  • By default (as is to be expected of good JS code) TypeScript expects you to declare (i.e. use somewhere) before you use a variable – – As a quick fix you can tell TypeScript that there is indeed something called : – – If you want you can build on…

Tags: TypeScript, default TypeScript, multi-file code bases, original JavaScript file, optional Type checking

Comments are closed, but trackbacks and pingbacks are open.