2015-01-29 20:23:02 +01:00
|
|
|
|
// @module: commonjs
|
2017-10-04 22:14:05 +02:00
|
|
|
|
// @skipLibCheck: true
|
2018-06-12 21:52:06 +02:00
|
|
|
|
// @includebuiltfile: typescriptServices.d.ts
|
2016-04-25 19:40:14 +02:00
|
|
|
|
// @noImplicitAny:true
|
|
|
|
|
// @strictNullChecks:true
|
2015-01-29 20:23:02 +01:00
|
|
|
|
|
2018-06-12 21:52:06 +02:00
|
|
|
|
// @filename: node_modules/typescript/index.d.ts
|
|
|
|
|
declare module "typescript" {
|
|
|
|
|
export = ts;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @filename: APISample_transform.ts
|
2015-01-29 20:23:02 +01:00
|
|
|
|
/*
|
2018-06-12 21:52:06 +02:00
|
|
|
|
* 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
|
2015-01-29 20:23:02 +01:00
|
|
|
|
* Please log a "breaking change" issue for any API breaking change affecting this issue
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
declare var console: any;
|
|
|
|
|
|
2015-04-03 00:45:52 +02:00
|
|
|
|
import * as ts from "typescript";
|
2015-01-29 20:23:02 +01:00
|
|
|
|
|
2015-04-03 00:45:52 +02:00
|
|
|
|
const source = "let x: string = 'string'";
|
2015-01-29 20:23:02 +01:00
|
|
|
|
|
2015-04-03 00:45:52 +02:00
|
|
|
|
let result = ts.transpile(source, { module: ts.ModuleKind.CommonJS });
|
2015-01-29 20:23:02 +01:00
|
|
|
|
|
|
|
|
|
console.log(JSON.stringify(result));
|