To using decorate, we can modifiy tsconfig.json: { "compilerOptions": { ... "experimentalDecorators": true, ... } } So for example we want to build a '@LogMethod' decorator, which arroding to the system logging level to decide whether…
TypeScript will always compile even if there are ridiculous errors in your project. This lesson shows how to configure your .tsconfig with "noEmitOnError" so that no files are output if tsc reports an error.  tsconfig.json: { "compilerOptio…
Vue 2.2 introduced a simple dependency injection system, allowing you to use provide and inject in your component options. This lesson shows you how to use them using the @Inject and @Provide decorators in tandem! When you want to provide some servic…
前言 在第一篇中,我们简单介绍了TypeScript的一些简单语法,那么如果我们只是简单使用TypeScript开发一个web项目,应该做哪些准备?接下来我们就结合TypeScript和Webpack来创建一个基于TypeScript的Web应用程序. 准备工作 为了创建第一个Web应用,我们先做一些基本的准备工作,需要安装以下依赖: webpack webpack-cli webpack-dev-server webpack-merge html-webpack-plugin clean-we…
If Typescript is the first language in which you've encountered generics, the concept can be quite difficult to understand. We skip the lecture in this lesson and dive straight into a real-world use-case that is guaranteed to help you understand the…
该文章用于督促自己学习TypeScript,作为学笔记进行保存,如果有错误的地方欢迎指正 2019-03-27  16:50:03 一.什么是TypeScript? TypeScript是javascript的超集,在ts中可以使用所有的js代码,并对js进行了扩展,包括类型效验,数据类型,接口等 如图所示,TypeScript包含了javascript并进行延伸 二.准备工作 在说TypeScript之前先说一下如何让ts编译为js代码 首先安装 typescrpt, npm install…
We usually think of types as something that can define a single layer of an object: with an interface we normally specify a list of a few properties and their respective types. If any one of those properties is another object we must refer again to i…
A literal type is a type that represents exactly one value, e.g. one specific string or number. You can combine literal types with union types to model a finite set of valid values for a variable. In this lesson, we explore the all kinds of literal t…
Some functions may have different return types depending on the types of the arguments with which they’re invoked. Using TypeScript’s function overloads, you can create an overload for each allowed combination of parameter and return types. This way,…
ypeScript 2.2 introduced the object, a type that represents any non-primitive type. It can be used to more accurately type methods such as Object.create. Don't confuse it with the Object type or {}, the empty object type, though! So one thing we need…