2015-01-29 20:23:02 +01:00
|
|
|
=== tests/cases/compiler/APISample_transform.ts ===
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Note: This test is a public API sample. The sample sources can be found
|
|
|
|
at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-simple-transform-function
|
|
|
|
* Please log a "breaking change" issue for any API breaking change affecting this issue
|
|
|
|
*/
|
|
|
|
|
|
|
|
declare var console: any;
|
|
|
|
>console : any
|
|
|
|
|
2015-04-03 00:45:52 +02:00
|
|
|
import * as ts from "typescript";
|
2015-01-29 20:23:02 +01:00
|
|
|
>ts : typeof ts
|
|
|
|
|
2015-04-03 00:45:52 +02:00
|
|
|
const source = "let x: string = 'string'";
|
2015-01-29 20:23:02 +01:00
|
|
|
>source : string
|
|
|
|
|
2015-04-03 00:45:52 +02:00
|
|
|
let result = ts.transpile(source, { module: ts.ModuleKind.CommonJS });
|
|
|
|
>result : string
|
|
|
|
>ts.transpile(source, { module: ts.ModuleKind.CommonJS }) : string
|
|
|
|
>ts.transpile : (input: string, compilerOptions?: ts.CompilerOptions, fileName?: string, diagnostics?: ts.Diagnostic[]) => string
|
|
|
|
>ts : typeof ts
|
|
|
|
>transpile : (input: string, compilerOptions?: ts.CompilerOptions, fileName?: string, diagnostics?: ts.Diagnostic[]) => string
|
2015-01-29 20:23:02 +01:00
|
|
|
>source : string
|
2015-04-03 00:45:52 +02:00
|
|
|
>{ module: ts.ModuleKind.CommonJS } : { [x: string]: ts.ModuleKind; module: ts.ModuleKind; }
|
|
|
|
>module : ts.ModuleKind
|
|
|
|
>ts.ModuleKind.CommonJS : ts.ModuleKind
|
|
|
|
>ts.ModuleKind : typeof ts.ModuleKind
|
|
|
|
>ts : typeof ts
|
|
|
|
>ModuleKind : typeof ts.ModuleKind
|
|
|
|
>CommonJS : ts.ModuleKind
|
2015-01-29 20:23:02 +01:00
|
|
|
|
|
|
|
console.log(JSON.stringify(result));
|
|
|
|
>console.log(JSON.stringify(result)) : any
|
|
|
|
>console.log : any
|
|
|
|
>console : any
|
|
|
|
>log : any
|
|
|
|
>JSON.stringify(result) : string
|
|
|
|
>JSON.stringify : { (value: any): string; (value: any, replacer: (key: string, value: any) => any): string; (value: any, replacer: any[]): string; (value: any, replacer: (key: string, value: any) => any, space: any): string; (value: any, replacer: any[], space: any): string; }
|
|
|
|
>JSON : JSON
|
|
|
|
>stringify : { (value: any): string; (value: any, replacer: (key: string, value: any) => any): string; (value: any, replacer: any[]): string; (value: any, replacer: (key: string, value: any) => any, space: any): string; (value: any, replacer: any[], space: any): string; }
|
2015-04-03 00:45:52 +02:00
|
|
|
>result : string
|
2015-01-29 20:23:02 +01:00
|
|
|
|