Original address: https://blogs.msdn.microsoft.com/typescript/2016/01/28/announcing-typescript-1-8-beta/
Today, we released the TypeScript 1.8 Beta, along with the 1.8 release that brought a lot of changes. Welcome to use and feedback to us: send us your feedback. It can be obtained from Visual Studio, NuGet (Compiler and MSBuild Task), NPM, or directly from source.
For NPM users, use the following command to obtain the.
Install -G [email protected]
In VS Code, you can download the package above, and then update the. vscode/settings.json file with the following prompts.
" TYPESCRIPT.TSDK " " /some/path/to/node_modules/typescript/lib "
JavaScript in TypeScript compilation
The TypeScript 1.8,typescript compiler can use JavaScript files with TypeScript files. To enable this feature, simply add a compile option--allowjs, or add "Allowjs" to the CompilerOptions configuration section of the Tsconfig.json configuration file: True. This is a great feature:
Convert JavaScript project to TypeScript project
For large projects, transitioning from a JavaScript project to a TypeScript project means risk. For specific projects, simply converting all. js files to a. ts file can result in a large number of compilation errors. Makes the conversion process very unfriendly. Now, by allowing TypeScript compilation to compile JavaScript code, you can convert one file at a time, but still allow the entire project to be compiled. This allows the developer to have complete control over the conversion process.
Using third-party JavaScript libraries makes it easier
In order to use the existing JavaScript library in the TypeScript project, the developer has to use the type definition (. d.ts) file so that the TypeScript compiler knows what you are doing at compile time, and at runtime, the JavaScript engine knows what you are doing 。 There is no problem until you need to package your external script library. To package This step, the developer needs a third-party packager, such as Webpack or browserify, and so on. With TypeScript 1.8, you simply have to include a third-party JavaScript library in your project, and the compiler will handle it, including the Source map!
Trivial JavaScript processing
Compiled with JavaScript in TypeScript, the TypeScript compiler can work with JavaScript files in the same way. This includes es3/es5, different types of module definitions, and packaging. For example, for a ES6 to ES5 downgrade conversion using the TypeScript compiler, you only need to use the following command:
> TSC--allowjs--outdir out Target_file.js
Extended JSX Support
After a lot of discussion, TypeScript 1.8 has brought some key improvements to extend the support of TSX/JSX.
Custom-made JSX factory
Along with React, JSX syntax is not just used for React. The JSX factory allows the default React factory to be rewritten. Accompanying--JSX react using the new compilation flag--reactnamespace <factory_name>, the TSX's author can now control the name of the factory.
Stateless feature components
In React 0.14, stateless functional components are a new concept that has been used extensively. Starting with TypeScript 1.8, we support stateless functional components in the TSX file.
interface Greeterprops { name:string;} Class Greeter extends React.component<greeterprops, {}> { render () { return < Div>hello, {this .props.name}</div>; } }//stateless Functional component Simplegreeterlet Simplegreeter = ({name = ' world ') = <div>hello, {name}</div>;
Syntax highlighting in VS2015
With the TypeScript 1.8 update in Visual Studio, JSX now has improvements to code classification and coloring.
TypeScript Nuget Package
For a long time, some of our users have asked for the official TypeScript Nuget package, starting with 1.8 Beta, where we will distribute TypeScript compilers and MSBuild tasks through Nuget, with links to the following packages:
TypeScript compiler
TypeScript MSBuild Task
In addition, we also provide typescript daily builds in MyGet. Although the build is not provided, you can easily get it and let us know what you think. You can find build:here here.
Chakra Core + TypeScript
We've been trying to improve the performance of the TypeScript compiler, and we tested it a few weeks after Chakra Core was released. The following is a diagram of each compilation engine compiling different sizes of code. We found that Chakra Core has important improvements. Compared to the previous version has 5-20% improvement, for Node has 10-50% increase, based on the above reasons, we will switch to Chakracore at the appropriate time.
There's more.
TypeScript 1.8 also includes many features, including: f-bounded polymorphism, string literal type, and so on. If you would like to learn more about these new features, check out: What ' s new page. Furthermore, we always encourage you to browse existing questions, submit requests, or go directly to Gitter to communicate with us.
Translation: TypeScript 1.8 Beta Release