Merge pull request #2787 from Microsoft/APISamplesBaselines

Don't run typewriter tests on the APISamples.  It's too noisy.
This commit is contained in:
CyrusNajmabadi 2015-04-15 18:18:12 -07:00
commit a93971a40a
9 changed files with 4 additions and 1717 deletions

View File

@ -253,6 +253,10 @@ class CompilerBaselineRunner extends RunnerBase {
});
it('Correct type baselines for ' + fileName, () => {
if (fileName.indexOf("APISample") >= 0) {
return;
}
// NEWTODO: Type baselines
if (result.errors.length === 0) {
// The full walker simulates the types that you would get from doing a full

View File

@ -1,131 +0,0 @@
=== tests/cases/compiler/APISample_compile.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-minimal-compiler
* Please log a "breaking change" issue for any API breaking change affecting this issue
*/
declare var process: any;
>process : Symbol(process, Decl(APISample_compile.ts, 7, 11))
declare var console: any;
>console : Symbol(console, Decl(APISample_compile.ts, 8, 11))
declare var os: any;
>os : Symbol(os, Decl(APISample_compile.ts, 9, 11))
import ts = require("typescript");
>ts : Symbol(ts, Decl(APISample_compile.ts, 9, 20))
export function compile(fileNames: string[], options: ts.CompilerOptions): void {
>compile : Symbol(compile, Decl(APISample_compile.ts, 11, 34))
>fileNames : Symbol(fileNames, Decl(APISample_compile.ts, 13, 24))
>options : Symbol(options, Decl(APISample_compile.ts, 13, 44))
>ts : Symbol(ts, Decl(APISample_compile.ts, 9, 20))
>CompilerOptions : Symbol(ts.CompilerOptions, Decl(typescript.d.ts, 1074, 5))
var program = ts.createProgram(fileNames, options);
>program : Symbol(program, Decl(APISample_compile.ts, 14, 7))
>ts.createProgram : Symbol(ts.createProgram, Decl(typescript.d.ts, 1225, 113))
>ts : Symbol(ts, Decl(APISample_compile.ts, 9, 20))
>createProgram : Symbol(ts.createProgram, Decl(typescript.d.ts, 1225, 113))
>fileNames : Symbol(fileNames, Decl(APISample_compile.ts, 13, 24))
>options : Symbol(options, Decl(APISample_compile.ts, 13, 44))
var emitResult = program.emit();
>emitResult : Symbol(emitResult, Decl(APISample_compile.ts, 15, 7))
>program.emit : Symbol(ts.Program.emit, Decl(typescript.d.ts, 767, 39))
>program : Symbol(program, Decl(APISample_compile.ts, 14, 7))
>emit : Symbol(ts.Program.emit, Decl(typescript.d.ts, 767, 39))
var allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
>allDiagnostics : Symbol(allDiagnostics, Decl(APISample_compile.ts, 17, 7))
>ts.getPreEmitDiagnostics(program).concat : Symbol(Array.concat, Decl(lib.d.ts, 1025, 13), Decl(lib.d.ts, 1030, 46))
>ts.getPreEmitDiagnostics : Symbol(ts.getPreEmitDiagnostics, Decl(typescript.d.ts, 1223, 98))
>ts : Symbol(ts, Decl(APISample_compile.ts, 9, 20))
>getPreEmitDiagnostics : Symbol(ts.getPreEmitDiagnostics, Decl(typescript.d.ts, 1223, 98))
>program : Symbol(program, Decl(APISample_compile.ts, 14, 7))
>concat : Symbol(Array.concat, Decl(lib.d.ts, 1025, 13), Decl(lib.d.ts, 1030, 46))
>emitResult.diagnostics : Symbol(ts.EmitResult.diagnostics, Decl(typescript.d.ts, 820, 29))
>emitResult : Symbol(emitResult, Decl(APISample_compile.ts, 15, 7))
>diagnostics : Symbol(ts.EmitResult.diagnostics, Decl(typescript.d.ts, 820, 29))
allDiagnostics.forEach(diagnostic => {
>allDiagnostics.forEach : Symbol(Array.forEach, Decl(lib.d.ts, 1108, 95))
>allDiagnostics : Symbol(allDiagnostics, Decl(APISample_compile.ts, 17, 7))
>forEach : Symbol(Array.forEach, Decl(lib.d.ts, 1108, 95))
>diagnostic : Symbol(diagnostic, Decl(APISample_compile.ts, 19, 27))
var { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
>line : Symbol(line, Decl(APISample_compile.ts, 20, 13))
>character : Symbol(character, Decl(APISample_compile.ts, 20, 19))
>diagnostic.file.getLineAndCharacterOfPosition : Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1286, 26))
>diagnostic.file : Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1062, 26))
>diagnostic : Symbol(diagnostic, Decl(APISample_compile.ts, 19, 27))
>file : Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1062, 26))
>getLineAndCharacterOfPosition : Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1286, 26))
>diagnostic.start : Symbol(ts.Diagnostic.start, Decl(typescript.d.ts, 1063, 25))
>diagnostic : Symbol(diagnostic, Decl(APISample_compile.ts, 19, 27))
>start : Symbol(ts.Diagnostic.start, Decl(typescript.d.ts, 1063, 25))
var message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
>message : Symbol(message, Decl(APISample_compile.ts, 21, 11))
>ts.flattenDiagnosticMessageText : Symbol(ts.flattenDiagnosticMessageText, Decl(typescript.d.ts, 1224, 67))
>ts : Symbol(ts, Decl(APISample_compile.ts, 9, 20))
>flattenDiagnosticMessageText : Symbol(ts.flattenDiagnosticMessageText, Decl(typescript.d.ts, 1224, 67))
>diagnostic.messageText : Symbol(ts.Diagnostic.messageText, Decl(typescript.d.ts, 1065, 23))
>diagnostic : Symbol(diagnostic, Decl(APISample_compile.ts, 19, 27))
>messageText : Symbol(ts.Diagnostic.messageText, Decl(typescript.d.ts, 1065, 23))
console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
>console : Symbol(console, Decl(APISample_compile.ts, 8, 11))
>diagnostic.file.fileName : Symbol(ts.SourceFile.fileName, Decl(typescript.d.ts, 743, 29))
>diagnostic.file : Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1062, 26))
>diagnostic : Symbol(diagnostic, Decl(APISample_compile.ts, 19, 27))
>file : Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1062, 26))
>fileName : Symbol(ts.SourceFile.fileName, Decl(typescript.d.ts, 743, 29))
>line : Symbol(line, Decl(APISample_compile.ts, 20, 13))
>character : Symbol(character, Decl(APISample_compile.ts, 20, 19))
>message : Symbol(message, Decl(APISample_compile.ts, 21, 11))
});
var exitCode = emitResult.emitSkipped ? 1 : 0;
>exitCode : Symbol(exitCode, Decl(APISample_compile.ts, 25, 7))
>emitResult.emitSkipped : Symbol(ts.EmitResult.emitSkipped, Decl(typescript.d.ts, 819, 26))
>emitResult : Symbol(emitResult, Decl(APISample_compile.ts, 15, 7))
>emitSkipped : Symbol(ts.EmitResult.emitSkipped, Decl(typescript.d.ts, 819, 26))
console.log(`Process exiting with code '${exitCode}'.`);
>console : Symbol(console, Decl(APISample_compile.ts, 8, 11))
>exitCode : Symbol(exitCode, Decl(APISample_compile.ts, 25, 7))
process.exit(exitCode);
>process : Symbol(process, Decl(APISample_compile.ts, 7, 11))
>exitCode : Symbol(exitCode, Decl(APISample_compile.ts, 25, 7))
}
compile(process.argv.slice(2), {
>compile : Symbol(compile, Decl(APISample_compile.ts, 11, 34))
>process : Symbol(process, Decl(APISample_compile.ts, 7, 11))
noEmitOnError: true, noImplicitAny: true,
>noEmitOnError : Symbol(noEmitOnError, Decl(APISample_compile.ts, 30, 32))
>noImplicitAny : Symbol(noImplicitAny, Decl(APISample_compile.ts, 31, 24))
target: ts.ScriptTarget.ES5, module: ts.ModuleKind.CommonJS
>target : Symbol(target, Decl(APISample_compile.ts, 31, 45))
>ts.ScriptTarget.ES5 : Symbol(ts.ScriptTarget.ES5, Decl(typescript.d.ts, 1117, 16))
>ts.ScriptTarget : Symbol(ts.ScriptTarget, Decl(typescript.d.ts, 1115, 5))
>ts : Symbol(ts, Decl(APISample_compile.ts, 9, 20))
>ScriptTarget : Symbol(ts.ScriptTarget, Decl(typescript.d.ts, 1115, 5))
>ES5 : Symbol(ts.ScriptTarget.ES5, Decl(typescript.d.ts, 1117, 16))
>module : Symbol(module, Decl(APISample_compile.ts, 32, 32))
>ts.ModuleKind.CommonJS : Symbol(ts.ModuleKind.CommonJS, Decl(typescript.d.ts, 1108, 17))
>ts.ModuleKind : Symbol(ts.ModuleKind, Decl(typescript.d.ts, 1106, 5))
>ts : Symbol(ts, Decl(APISample_compile.ts, 9, 20))
>ModuleKind : Symbol(ts.ModuleKind, Decl(typescript.d.ts, 1106, 5))
>CommonJS : Symbol(ts.ModuleKind.CommonJS, Decl(typescript.d.ts, 1108, 17))
});

View File

@ -1,168 +0,0 @@
=== tests/cases/compiler/APISample_compile.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-minimal-compiler
* Please log a "breaking change" issue for any API breaking change affecting this issue
*/
declare var process: any;
>process : any
declare var console: any;
>console : any
declare var os: any;
>os : any
import ts = require("typescript");
>ts : typeof ts
export function compile(fileNames: string[], options: ts.CompilerOptions): void {
>compile : (fileNames: string[], options: ts.CompilerOptions) => void
>fileNames : string[]
>options : ts.CompilerOptions
>ts : any
>CompilerOptions : ts.CompilerOptions
var program = ts.createProgram(fileNames, options);
>program : ts.Program
>ts.createProgram(fileNames, options) : ts.Program
>ts.createProgram : (rootNames: string[], options: ts.CompilerOptions, host?: ts.CompilerHost) => ts.Program
>ts : typeof ts
>createProgram : (rootNames: string[], options: ts.CompilerOptions, host?: ts.CompilerHost) => ts.Program
>fileNames : string[]
>options : ts.CompilerOptions
var emitResult = program.emit();
>emitResult : ts.EmitResult
>program.emit() : ts.EmitResult
>program.emit : (targetSourceFile?: ts.SourceFile, writeFile?: ts.WriteFileCallback) => ts.EmitResult
>program : ts.Program
>emit : (targetSourceFile?: ts.SourceFile, writeFile?: ts.WriteFileCallback) => ts.EmitResult
var allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
>allDiagnostics : ts.Diagnostic[]
>ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics) : ts.Diagnostic[]
>ts.getPreEmitDiagnostics(program).concat : { <U extends ts.Diagnostic[]>(...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }
>ts.getPreEmitDiagnostics(program) : ts.Diagnostic[]
>ts.getPreEmitDiagnostics : (program: ts.Program) => ts.Diagnostic[]
>ts : typeof ts
>getPreEmitDiagnostics : (program: ts.Program) => ts.Diagnostic[]
>program : ts.Program
>concat : { <U extends ts.Diagnostic[]>(...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }
>emitResult.diagnostics : ts.Diagnostic[]
>emitResult : ts.EmitResult
>diagnostics : ts.Diagnostic[]
allDiagnostics.forEach(diagnostic => {
>allDiagnostics.forEach(diagnostic => { var { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); var message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`); }) : void
>allDiagnostics.forEach : (callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => void, thisArg?: any) => void
>allDiagnostics : ts.Diagnostic[]
>forEach : (callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => void, thisArg?: any) => void
>diagnostic => { var { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); var message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`); } : (diagnostic: ts.Diagnostic) => void
>diagnostic : ts.Diagnostic
var { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
>line : number
>character : number
>diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start) : ts.LineAndCharacter
>diagnostic.file.getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
>diagnostic.file : ts.SourceFile
>diagnostic : ts.Diagnostic
>file : ts.SourceFile
>getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
>diagnostic.start : number
>diagnostic : ts.Diagnostic
>start : number
var message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
>message : string
>ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n') : string
>ts.flattenDiagnosticMessageText : (messageText: string | ts.DiagnosticMessageChain, newLine: string) => string
>ts : typeof ts
>flattenDiagnosticMessageText : (messageText: string | ts.DiagnosticMessageChain, newLine: string) => string
>diagnostic.messageText : string | ts.DiagnosticMessageChain
>diagnostic : ts.Diagnostic
>messageText : string | ts.DiagnosticMessageChain
>'\n' : string
console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
>console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`) : any
>console.log : any
>console : any
>log : any
>`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}` : string
>diagnostic.file.fileName : string
>diagnostic.file : ts.SourceFile
>diagnostic : ts.Diagnostic
>file : ts.SourceFile
>fileName : string
>line + 1 : number
>line : number
>1 : number
>character + 1 : number
>character : number
>1 : number
>message : string
});
var exitCode = emitResult.emitSkipped ? 1 : 0;
>exitCode : number
>emitResult.emitSkipped ? 1 : 0 : number
>emitResult.emitSkipped : boolean
>emitResult : ts.EmitResult
>emitSkipped : boolean
>1 : number
>0 : number
console.log(`Process exiting with code '${exitCode}'.`);
>console.log(`Process exiting with code '${exitCode}'.`) : any
>console.log : any
>console : any
>log : any
>`Process exiting with code '${exitCode}'.` : string
>exitCode : number
process.exit(exitCode);
>process.exit(exitCode) : any
>process.exit : any
>process : any
>exit : any
>exitCode : number
}
compile(process.argv.slice(2), {
>compile(process.argv.slice(2), { noEmitOnError: true, noImplicitAny: true, target: ts.ScriptTarget.ES5, module: ts.ModuleKind.CommonJS}) : void
>compile : (fileNames: string[], options: ts.CompilerOptions) => void
>process.argv.slice(2) : any
>process.argv.slice : any
>process.argv : any
>process : any
>argv : any
>slice : any
>2 : number
>{ noEmitOnError: true, noImplicitAny: true, target: ts.ScriptTarget.ES5, module: ts.ModuleKind.CommonJS} : { [x: string]: boolean | ts.ScriptTarget | ts.ModuleKind; noEmitOnError: boolean; noImplicitAny: boolean; target: ts.ScriptTarget; module: ts.ModuleKind; }
noEmitOnError: true, noImplicitAny: true,
>noEmitOnError : boolean
>true : boolean
>noImplicitAny : boolean
>true : boolean
target: ts.ScriptTarget.ES5, module: ts.ModuleKind.CommonJS
>target : ts.ScriptTarget
>ts.ScriptTarget.ES5 : ts.ScriptTarget
>ts.ScriptTarget : typeof ts.ScriptTarget
>ts : typeof ts
>ScriptTarget : typeof ts.ScriptTarget
>ES5 : ts.ScriptTarget
>module : ts.ModuleKind
>ts.ModuleKind.CommonJS : ts.ModuleKind
>ts.ModuleKind : typeof ts.ModuleKind
>ts : typeof ts
>ModuleKind : typeof ts.ModuleKind
>CommonJS : ts.ModuleKind
});

View File

@ -1,260 +0,0 @@
=== tests/cases/compiler/APISample_linter.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#traversing-the-ast-with-a-little-linter
* Please log a "breaking change" issue for any API breaking change affecting this issue
*/
declare var process: any;
>process : Symbol(process, Decl(APISample_linter.ts, 7, 11))
declare var console: any;
>console : Symbol(console, Decl(APISample_linter.ts, 8, 11))
declare var readFileSync: any;
>readFileSync : Symbol(readFileSync, Decl(APISample_linter.ts, 9, 11))
import * as ts from "typescript";
>ts : Symbol(ts, Decl(APISample_linter.ts, 11, 6))
export function delint(sourceFile: ts.SourceFile) {
>delint : Symbol(delint, Decl(APISample_linter.ts, 11, 33))
>sourceFile : Symbol(sourceFile, Decl(APISample_linter.ts, 13, 23))
>ts : Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>SourceFile : Symbol(ts.SourceFile, Decl(typescript.d.ts, 740, 5), Decl(typescript.d.ts, 1285, 5))
delintNode(sourceFile);
>delintNode : Symbol(delintNode, Decl(APISample_linter.ts, 14, 27))
>sourceFile : Symbol(sourceFile, Decl(APISample_linter.ts, 13, 23))
function delintNode(node: ts.Node) {
>delintNode : Symbol(delintNode, Decl(APISample_linter.ts, 14, 27))
>node : Symbol(node, Decl(APISample_linter.ts, 16, 24))
>ts : Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>Node : Symbol(ts.Node, Decl(typescript.d.ts, 296, 5), Decl(typescript.d.ts, 1245, 32))
switch (node.kind) {
>node.kind : Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
>node : Symbol(node, Decl(APISample_linter.ts, 16, 24))
>kind : Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
case ts.SyntaxKind.ForStatement:
>ts.SyntaxKind.ForStatement : Symbol(ts.SyntaxKind.ForStatement, Decl(typescript.d.ts, 209, 29))
>ts.SyntaxKind : Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>ts : Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>SyntaxKind : Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>ForStatement : Symbol(ts.SyntaxKind.ForStatement, Decl(typescript.d.ts, 209, 29))
case ts.SyntaxKind.ForInStatement:
>ts.SyntaxKind.ForInStatement : Symbol(ts.SyntaxKind.ForInStatement, Decl(typescript.d.ts, 210, 27))
>ts.SyntaxKind : Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>ts : Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>SyntaxKind : Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>ForInStatement : Symbol(ts.SyntaxKind.ForInStatement, Decl(typescript.d.ts, 210, 27))
case ts.SyntaxKind.WhileStatement:
>ts.SyntaxKind.WhileStatement : Symbol(ts.SyntaxKind.WhileStatement, Decl(typescript.d.ts, 208, 26))
>ts.SyntaxKind : Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>ts : Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>SyntaxKind : Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>WhileStatement : Symbol(ts.SyntaxKind.WhileStatement, Decl(typescript.d.ts, 208, 26))
case ts.SyntaxKind.DoStatement:
>ts.SyntaxKind.DoStatement : Symbol(ts.SyntaxKind.DoStatement, Decl(typescript.d.ts, 207, 26))
>ts.SyntaxKind : Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>ts : Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>SyntaxKind : Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>DoStatement : Symbol(ts.SyntaxKind.DoStatement, Decl(typescript.d.ts, 207, 26))
if ((<ts.IterationStatement>node).statement.kind !== ts.SyntaxKind.Block) {
>(<ts.IterationStatement>node).statement.kind : Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
>(<ts.IterationStatement>node).statement : Symbol(ts.IterationStatement.statement, Decl(typescript.d.ts, 589, 52))
>ts : Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>IterationStatement : Symbol(ts.IterationStatement, Decl(typescript.d.ts, 588, 5))
>node : Symbol(node, Decl(APISample_linter.ts, 16, 24))
>statement : Symbol(ts.IterationStatement.statement, Decl(typescript.d.ts, 589, 52))
>kind : Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
>ts.SyntaxKind.Block : Symbol(ts.SyntaxKind.Block, Decl(typescript.d.ts, 202, 36))
>ts.SyntaxKind : Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>ts : Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>SyntaxKind : Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>Block : Symbol(ts.SyntaxKind.Block, Decl(typescript.d.ts, 202, 36))
report(node, "A looping statement's contents should be wrapped in a block body.");
>report : Symbol(report, Decl(APISample_linter.ts, 48, 5))
>node : Symbol(node, Decl(APISample_linter.ts, 16, 24))
}
break;
case ts.SyntaxKind.IfStatement:
>ts.SyntaxKind.IfStatement : Symbol(ts.SyntaxKind.IfStatement, Decl(typescript.d.ts, 206, 34))
>ts.SyntaxKind : Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>ts : Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>SyntaxKind : Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>IfStatement : Symbol(ts.SyntaxKind.IfStatement, Decl(typescript.d.ts, 206, 34))
let ifStatement = (<ts.IfStatement>node);
>ifStatement : Symbol(ifStatement, Decl(APISample_linter.ts, 28, 19))
>ts : Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>IfStatement : Symbol(ts.IfStatement, Decl(typescript.d.ts, 583, 5))
>node : Symbol(node, Decl(APISample_linter.ts, 16, 24))
if (ifStatement.thenStatement.kind !== ts.SyntaxKind.Block) {
>ifStatement.thenStatement.kind : Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
>ifStatement.thenStatement : Symbol(ts.IfStatement.thenStatement, Decl(typescript.d.ts, 585, 31))
>ifStatement : Symbol(ifStatement, Decl(APISample_linter.ts, 28, 19))
>thenStatement : Symbol(ts.IfStatement.thenStatement, Decl(typescript.d.ts, 585, 31))
>kind : Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
>ts.SyntaxKind.Block : Symbol(ts.SyntaxKind.Block, Decl(typescript.d.ts, 202, 36))
>ts.SyntaxKind : Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>ts : Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>SyntaxKind : Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>Block : Symbol(ts.SyntaxKind.Block, Decl(typescript.d.ts, 202, 36))
report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body.");
>report : Symbol(report, Decl(APISample_linter.ts, 48, 5))
>ifStatement.thenStatement : Symbol(ts.IfStatement.thenStatement, Decl(typescript.d.ts, 585, 31))
>ifStatement : Symbol(ifStatement, Decl(APISample_linter.ts, 28, 19))
>thenStatement : Symbol(ts.IfStatement.thenStatement, Decl(typescript.d.ts, 585, 31))
}
if (ifStatement.elseStatement &&
>ifStatement.elseStatement : Symbol(ts.IfStatement.elseStatement, Decl(typescript.d.ts, 586, 33))
>ifStatement : Symbol(ifStatement, Decl(APISample_linter.ts, 28, 19))
>elseStatement : Symbol(ts.IfStatement.elseStatement, Decl(typescript.d.ts, 586, 33))
ifStatement.elseStatement.kind !== ts.SyntaxKind.Block &&
>ifStatement.elseStatement.kind : Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
>ifStatement.elseStatement : Symbol(ts.IfStatement.elseStatement, Decl(typescript.d.ts, 586, 33))
>ifStatement : Symbol(ifStatement, Decl(APISample_linter.ts, 28, 19))
>elseStatement : Symbol(ts.IfStatement.elseStatement, Decl(typescript.d.ts, 586, 33))
>kind : Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
>ts.SyntaxKind.Block : Symbol(ts.SyntaxKind.Block, Decl(typescript.d.ts, 202, 36))
>ts.SyntaxKind : Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>ts : Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>SyntaxKind : Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>Block : Symbol(ts.SyntaxKind.Block, Decl(typescript.d.ts, 202, 36))
ifStatement.elseStatement.kind !== ts.SyntaxKind.IfStatement) {
>ifStatement.elseStatement.kind : Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
>ifStatement.elseStatement : Symbol(ts.IfStatement.elseStatement, Decl(typescript.d.ts, 586, 33))
>ifStatement : Symbol(ifStatement, Decl(APISample_linter.ts, 28, 19))
>elseStatement : Symbol(ts.IfStatement.elseStatement, Decl(typescript.d.ts, 586, 33))
>kind : Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
>ts.SyntaxKind.IfStatement : Symbol(ts.SyntaxKind.IfStatement, Decl(typescript.d.ts, 206, 34))
>ts.SyntaxKind : Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>ts : Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>SyntaxKind : Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>IfStatement : Symbol(ts.SyntaxKind.IfStatement, Decl(typescript.d.ts, 206, 34))
report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body.");
>report : Symbol(report, Decl(APISample_linter.ts, 48, 5))
>ifStatement.elseStatement : Symbol(ts.IfStatement.elseStatement, Decl(typescript.d.ts, 586, 33))
>ifStatement : Symbol(ifStatement, Decl(APISample_linter.ts, 28, 19))
>elseStatement : Symbol(ts.IfStatement.elseStatement, Decl(typescript.d.ts, 586, 33))
}
break;
case ts.SyntaxKind.BinaryExpression:
>ts.SyntaxKind.BinaryExpression : Symbol(ts.SyntaxKind.BinaryExpression, Decl(typescript.d.ts, 192, 37))
>ts.SyntaxKind : Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>ts : Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>SyntaxKind : Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>BinaryExpression : Symbol(ts.SyntaxKind.BinaryExpression, Decl(typescript.d.ts, 192, 37))
let op = (<ts.BinaryExpression>node).operatorToken.kind;
>op : Symbol(op, Decl(APISample_linter.ts, 40, 19))
>(<ts.BinaryExpression>node).operatorToken.kind : Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
>(<ts.BinaryExpression>node).operatorToken : Symbol(ts.BinaryExpression.operatorToken, Decl(typescript.d.ts, 497, 25))
>ts : Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>BinaryExpression : Symbol(ts.BinaryExpression, Decl(typescript.d.ts, 495, 5))
>node : Symbol(node, Decl(APISample_linter.ts, 16, 24))
>operatorToken : Symbol(ts.BinaryExpression.operatorToken, Decl(typescript.d.ts, 497, 25))
>kind : Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
if (op === ts.SyntaxKind.EqualsEqualsToken || op == ts.SyntaxKind.ExclamationEqualsToken) {
>op : Symbol(op, Decl(APISample_linter.ts, 40, 19))
>ts.SyntaxKind.EqualsEqualsToken : Symbol(ts.SyntaxKind.EqualsEqualsToken, Decl(typescript.d.ts, 51, 36))
>ts.SyntaxKind : Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>ts : Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>SyntaxKind : Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>EqualsEqualsToken : Symbol(ts.SyntaxKind.EqualsEqualsToken, Decl(typescript.d.ts, 51, 36))
>op : Symbol(op, Decl(APISample_linter.ts, 40, 19))
>ts.SyntaxKind.ExclamationEqualsToken : Symbol(ts.SyntaxKind.ExclamationEqualsToken, Decl(typescript.d.ts, 52, 31))
>ts.SyntaxKind : Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>ts : Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>SyntaxKind : Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>ExclamationEqualsToken : Symbol(ts.SyntaxKind.ExclamationEqualsToken, Decl(typescript.d.ts, 52, 31))
report(node, "Use '===' and '!=='.")
>report : Symbol(report, Decl(APISample_linter.ts, 48, 5))
>node : Symbol(node, Decl(APISample_linter.ts, 16, 24))
}
break;
}
ts.forEachChild(node, delintNode);
>ts.forEachChild : Symbol(ts.forEachChild, Decl(typescript.d.ts, 1214, 48))
>ts : Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>forEachChild : Symbol(ts.forEachChild, Decl(typescript.d.ts, 1214, 48))
>node : Symbol(node, Decl(APISample_linter.ts, 16, 24))
>delintNode : Symbol(delintNode, Decl(APISample_linter.ts, 14, 27))
}
function report(node: ts.Node, message: string) {
>report : Symbol(report, Decl(APISample_linter.ts, 48, 5))
>node : Symbol(node, Decl(APISample_linter.ts, 50, 20))
>ts : Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>Node : Symbol(ts.Node, Decl(typescript.d.ts, 296, 5), Decl(typescript.d.ts, 1245, 32))
>message : Symbol(message, Decl(APISample_linter.ts, 50, 34))
let { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart());
>line : Symbol(line, Decl(APISample_linter.ts, 51, 13))
>character : Symbol(character, Decl(APISample_linter.ts, 51, 19))
>sourceFile.getLineAndCharacterOfPosition : Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1286, 26))
>sourceFile : Symbol(sourceFile, Decl(APISample_linter.ts, 13, 23))
>getLineAndCharacterOfPosition : Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1286, 26))
>node.getStart : Symbol(ts.Node.getStart, Decl(typescript.d.ts, 1250, 53))
>node : Symbol(node, Decl(APISample_linter.ts, 50, 20))
>getStart : Symbol(ts.Node.getStart, Decl(typescript.d.ts, 1250, 53))
console.log(`${sourceFile.fileName} (${line + 1},${character + 1}): ${message}`);
>console : Symbol(console, Decl(APISample_linter.ts, 8, 11))
>sourceFile.fileName : Symbol(ts.SourceFile.fileName, Decl(typescript.d.ts, 743, 29))
>sourceFile : Symbol(sourceFile, Decl(APISample_linter.ts, 13, 23))
>fileName : Symbol(ts.SourceFile.fileName, Decl(typescript.d.ts, 743, 29))
>line : Symbol(line, Decl(APISample_linter.ts, 51, 13))
>character : Symbol(character, Decl(APISample_linter.ts, 51, 19))
>message : Symbol(message, Decl(APISample_linter.ts, 50, 34))
}
}
const fileNames = process.argv.slice(2);
>fileNames : Symbol(fileNames, Decl(APISample_linter.ts, 56, 5))
>process : Symbol(process, Decl(APISample_linter.ts, 7, 11))
fileNames.forEach(fileName => {
>fileNames : Symbol(fileNames, Decl(APISample_linter.ts, 56, 5))
>fileName : Symbol(fileName, Decl(APISample_linter.ts, 57, 18))
// Parse a file
let sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true);
>sourceFile : Symbol(sourceFile, Decl(APISample_linter.ts, 59, 7))
>ts.createSourceFile : Symbol(ts.createSourceFile, Decl(typescript.d.ts, 1215, 107))
>ts : Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>createSourceFile : Symbol(ts.createSourceFile, Decl(typescript.d.ts, 1215, 107))
>fileName : Symbol(fileName, Decl(APISample_linter.ts, 57, 18))
>readFileSync : Symbol(readFileSync, Decl(APISample_linter.ts, 9, 11))
>fileName : Symbol(fileName, Decl(APISample_linter.ts, 57, 18))
>ts.ScriptTarget.ES6 : Symbol(ts.ScriptTarget.ES6, Decl(typescript.d.ts, 1118, 16))
>ts.ScriptTarget : Symbol(ts.ScriptTarget, Decl(typescript.d.ts, 1115, 5))
>ts : Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>ScriptTarget : Symbol(ts.ScriptTarget, Decl(typescript.d.ts, 1115, 5))
>ES6 : Symbol(ts.ScriptTarget.ES6, Decl(typescript.d.ts, 1118, 16))
// delint it
delint(sourceFile);
>delint : Symbol(delint, Decl(APISample_linter.ts, 11, 33))
>sourceFile : Symbol(sourceFile, Decl(APISample_linter.ts, 59, 7))
});

View File

@ -1,312 +0,0 @@
=== tests/cases/compiler/APISample_linter.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#traversing-the-ast-with-a-little-linter
* Please log a "breaking change" issue for any API breaking change affecting this issue
*/
declare var process: any;
>process : any
declare var console: any;
>console : any
declare var readFileSync: any;
>readFileSync : any
import * as ts from "typescript";
>ts : typeof ts
export function delint(sourceFile: ts.SourceFile) {
>delint : (sourceFile: ts.SourceFile) => void
>sourceFile : ts.SourceFile
>ts : any
>SourceFile : ts.SourceFile
delintNode(sourceFile);
>delintNode(sourceFile) : void
>delintNode : (node: ts.Node) => void
>sourceFile : ts.SourceFile
function delintNode(node: ts.Node) {
>delintNode : (node: ts.Node) => void
>node : ts.Node
>ts : any
>Node : ts.Node
switch (node.kind) {
>node.kind : ts.SyntaxKind
>node : ts.Node
>kind : ts.SyntaxKind
case ts.SyntaxKind.ForStatement:
>ts.SyntaxKind.ForStatement : ts.SyntaxKind
>ts.SyntaxKind : typeof ts.SyntaxKind
>ts : typeof ts
>SyntaxKind : typeof ts.SyntaxKind
>ForStatement : ts.SyntaxKind
case ts.SyntaxKind.ForInStatement:
>ts.SyntaxKind.ForInStatement : ts.SyntaxKind
>ts.SyntaxKind : typeof ts.SyntaxKind
>ts : typeof ts
>SyntaxKind : typeof ts.SyntaxKind
>ForInStatement : ts.SyntaxKind
case ts.SyntaxKind.WhileStatement:
>ts.SyntaxKind.WhileStatement : ts.SyntaxKind
>ts.SyntaxKind : typeof ts.SyntaxKind
>ts : typeof ts
>SyntaxKind : typeof ts.SyntaxKind
>WhileStatement : ts.SyntaxKind
case ts.SyntaxKind.DoStatement:
>ts.SyntaxKind.DoStatement : ts.SyntaxKind
>ts.SyntaxKind : typeof ts.SyntaxKind
>ts : typeof ts
>SyntaxKind : typeof ts.SyntaxKind
>DoStatement : ts.SyntaxKind
if ((<ts.IterationStatement>node).statement.kind !== ts.SyntaxKind.Block) {
>(<ts.IterationStatement>node).statement.kind !== ts.SyntaxKind.Block : boolean
>(<ts.IterationStatement>node).statement.kind : ts.SyntaxKind
>(<ts.IterationStatement>node).statement : ts.Statement
>(<ts.IterationStatement>node) : ts.IterationStatement
><ts.IterationStatement>node : ts.IterationStatement
>ts : any
>IterationStatement : ts.IterationStatement
>node : ts.Node
>statement : ts.Statement
>kind : ts.SyntaxKind
>ts.SyntaxKind.Block : ts.SyntaxKind
>ts.SyntaxKind : typeof ts.SyntaxKind
>ts : typeof ts
>SyntaxKind : typeof ts.SyntaxKind
>Block : ts.SyntaxKind
report(node, "A looping statement's contents should be wrapped in a block body.");
>report(node, "A looping statement's contents should be wrapped in a block body.") : void
>report : (node: ts.Node, message: string) => void
>node : ts.Node
>"A looping statement's contents should be wrapped in a block body." : string
}
break;
case ts.SyntaxKind.IfStatement:
>ts.SyntaxKind.IfStatement : ts.SyntaxKind
>ts.SyntaxKind : typeof ts.SyntaxKind
>ts : typeof ts
>SyntaxKind : typeof ts.SyntaxKind
>IfStatement : ts.SyntaxKind
let ifStatement = (<ts.IfStatement>node);
>ifStatement : ts.IfStatement
>(<ts.IfStatement>node) : ts.IfStatement
><ts.IfStatement>node : ts.IfStatement
>ts : any
>IfStatement : ts.IfStatement
>node : ts.Node
if (ifStatement.thenStatement.kind !== ts.SyntaxKind.Block) {
>ifStatement.thenStatement.kind !== ts.SyntaxKind.Block : boolean
>ifStatement.thenStatement.kind : ts.SyntaxKind
>ifStatement.thenStatement : ts.Statement
>ifStatement : ts.IfStatement
>thenStatement : ts.Statement
>kind : ts.SyntaxKind
>ts.SyntaxKind.Block : ts.SyntaxKind
>ts.SyntaxKind : typeof ts.SyntaxKind
>ts : typeof ts
>SyntaxKind : typeof ts.SyntaxKind
>Block : ts.SyntaxKind
report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body.");
>report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body.") : void
>report : (node: ts.Node, message: string) => void
>ifStatement.thenStatement : ts.Statement
>ifStatement : ts.IfStatement
>thenStatement : ts.Statement
>"An if statement's contents should be wrapped in a block body." : string
}
if (ifStatement.elseStatement &&
>ifStatement.elseStatement && ifStatement.elseStatement.kind !== ts.SyntaxKind.Block && ifStatement.elseStatement.kind !== ts.SyntaxKind.IfStatement : boolean
>ifStatement.elseStatement && ifStatement.elseStatement.kind !== ts.SyntaxKind.Block : boolean
>ifStatement.elseStatement : ts.Statement
>ifStatement : ts.IfStatement
>elseStatement : ts.Statement
ifStatement.elseStatement.kind !== ts.SyntaxKind.Block &&
>ifStatement.elseStatement.kind !== ts.SyntaxKind.Block : boolean
>ifStatement.elseStatement.kind : ts.SyntaxKind
>ifStatement.elseStatement : ts.Statement
>ifStatement : ts.IfStatement
>elseStatement : ts.Statement
>kind : ts.SyntaxKind
>ts.SyntaxKind.Block : ts.SyntaxKind
>ts.SyntaxKind : typeof ts.SyntaxKind
>ts : typeof ts
>SyntaxKind : typeof ts.SyntaxKind
>Block : ts.SyntaxKind
ifStatement.elseStatement.kind !== ts.SyntaxKind.IfStatement) {
>ifStatement.elseStatement.kind !== ts.SyntaxKind.IfStatement : boolean
>ifStatement.elseStatement.kind : ts.SyntaxKind
>ifStatement.elseStatement : ts.Statement
>ifStatement : ts.IfStatement
>elseStatement : ts.Statement
>kind : ts.SyntaxKind
>ts.SyntaxKind.IfStatement : ts.SyntaxKind
>ts.SyntaxKind : typeof ts.SyntaxKind
>ts : typeof ts
>SyntaxKind : typeof ts.SyntaxKind
>IfStatement : ts.SyntaxKind
report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body.");
>report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body.") : void
>report : (node: ts.Node, message: string) => void
>ifStatement.elseStatement : ts.Statement
>ifStatement : ts.IfStatement
>elseStatement : ts.Statement
>"An else statement's contents should be wrapped in a block body." : string
}
break;
case ts.SyntaxKind.BinaryExpression:
>ts.SyntaxKind.BinaryExpression : ts.SyntaxKind
>ts.SyntaxKind : typeof ts.SyntaxKind
>ts : typeof ts
>SyntaxKind : typeof ts.SyntaxKind
>BinaryExpression : ts.SyntaxKind
let op = (<ts.BinaryExpression>node).operatorToken.kind;
>op : ts.SyntaxKind
>(<ts.BinaryExpression>node).operatorToken.kind : ts.SyntaxKind
>(<ts.BinaryExpression>node).operatorToken : ts.Node
>(<ts.BinaryExpression>node) : ts.BinaryExpression
><ts.BinaryExpression>node : ts.BinaryExpression
>ts : any
>BinaryExpression : ts.BinaryExpression
>node : ts.Node
>operatorToken : ts.Node
>kind : ts.SyntaxKind
if (op === ts.SyntaxKind.EqualsEqualsToken || op == ts.SyntaxKind.ExclamationEqualsToken) {
>op === ts.SyntaxKind.EqualsEqualsToken || op == ts.SyntaxKind.ExclamationEqualsToken : boolean
>op === ts.SyntaxKind.EqualsEqualsToken : boolean
>op : ts.SyntaxKind
>ts.SyntaxKind.EqualsEqualsToken : ts.SyntaxKind
>ts.SyntaxKind : typeof ts.SyntaxKind
>ts : typeof ts
>SyntaxKind : typeof ts.SyntaxKind
>EqualsEqualsToken : ts.SyntaxKind
>op == ts.SyntaxKind.ExclamationEqualsToken : boolean
>op : ts.SyntaxKind
>ts.SyntaxKind.ExclamationEqualsToken : ts.SyntaxKind
>ts.SyntaxKind : typeof ts.SyntaxKind
>ts : typeof ts
>SyntaxKind : typeof ts.SyntaxKind
>ExclamationEqualsToken : ts.SyntaxKind
report(node, "Use '===' and '!=='.")
>report(node, "Use '===' and '!=='.") : void
>report : (node: ts.Node, message: string) => void
>node : ts.Node
>"Use '===' and '!=='." : string
}
break;
}
ts.forEachChild(node, delintNode);
>ts.forEachChild(node, delintNode) : void
>ts.forEachChild : <T>(node: ts.Node, cbNode: (node: ts.Node) => T, cbNodeArray?: (nodes: ts.Node[]) => T) => T
>ts : typeof ts
>forEachChild : <T>(node: ts.Node, cbNode: (node: ts.Node) => T, cbNodeArray?: (nodes: ts.Node[]) => T) => T
>node : ts.Node
>delintNode : (node: ts.Node) => void
}
function report(node: ts.Node, message: string) {
>report : (node: ts.Node, message: string) => void
>node : ts.Node
>ts : any
>Node : ts.Node
>message : string
let { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart());
>line : number
>character : number
>sourceFile.getLineAndCharacterOfPosition(node.getStart()) : ts.LineAndCharacter
>sourceFile.getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
>sourceFile : ts.SourceFile
>getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
>node.getStart() : number
>node.getStart : (sourceFile?: ts.SourceFile) => number
>node : ts.Node
>getStart : (sourceFile?: ts.SourceFile) => number
console.log(`${sourceFile.fileName} (${line + 1},${character + 1}): ${message}`);
>console.log(`${sourceFile.fileName} (${line + 1},${character + 1}): ${message}`) : any
>console.log : any
>console : any
>log : any
>`${sourceFile.fileName} (${line + 1},${character + 1}): ${message}` : string
>sourceFile.fileName : string
>sourceFile : ts.SourceFile
>fileName : string
>line + 1 : number
>line : number
>1 : number
>character + 1 : number
>character : number
>1 : number
>message : string
}
}
const fileNames = process.argv.slice(2);
>fileNames : any
>process.argv.slice(2) : any
>process.argv.slice : any
>process.argv : any
>process : any
>argv : any
>slice : any
>2 : number
fileNames.forEach(fileName => {
>fileNames.forEach(fileName => { // Parse a file let sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true); // delint it delint(sourceFile);}) : any
>fileNames.forEach : any
>fileNames : any
>forEach : any
>fileName => { // Parse a file let sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true); // delint it delint(sourceFile);} : (fileName: any) => void
>fileName : any
// Parse a file
let sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true);
>sourceFile : ts.SourceFile
>ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true) : ts.SourceFile
>ts.createSourceFile : (fileName: string, sourceText: string, languageVersion: ts.ScriptTarget, setParentNodes?: boolean) => ts.SourceFile
>ts : typeof ts
>createSourceFile : (fileName: string, sourceText: string, languageVersion: ts.ScriptTarget, setParentNodes?: boolean) => ts.SourceFile
>fileName : any
>readFileSync(fileName).toString() : any
>readFileSync(fileName).toString : any
>readFileSync(fileName) : any
>readFileSync : any
>fileName : any
>toString : any
>ts.ScriptTarget.ES6 : ts.ScriptTarget
>ts.ScriptTarget : typeof ts.ScriptTarget
>ts : typeof ts
>ScriptTarget : typeof ts.ScriptTarget
>ES6 : ts.ScriptTarget
>true : boolean
// delint it
delint(sourceFile);
>delint(sourceFile) : void
>delint : (sourceFile: ts.SourceFile) => void
>sourceFile : ts.SourceFile
});

View File

@ -1,37 +0,0 @@
=== 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 : Symbol(console, Decl(APISample_transform.ts, 7, 11))
import * as ts from "typescript";
>ts : Symbol(ts, Decl(APISample_transform.ts, 9, 6))
const source = "let x: string = 'string'";
>source : Symbol(source, Decl(APISample_transform.ts, 11, 5))
let result = ts.transpile(source, { module: ts.ModuleKind.CommonJS });
>result : Symbol(result, Decl(APISample_transform.ts, 13, 3))
>ts.transpile : Symbol(ts.transpile, Decl(typescript.d.ts, 1752, 5))
>ts : Symbol(ts, Decl(APISample_transform.ts, 9, 6))
>transpile : Symbol(ts.transpile, Decl(typescript.d.ts, 1752, 5))
>source : Symbol(source, Decl(APISample_transform.ts, 11, 5))
>module : Symbol(module, Decl(APISample_transform.ts, 13, 35))
>ts.ModuleKind.CommonJS : Symbol(ts.ModuleKind.CommonJS, Decl(typescript.d.ts, 1108, 17))
>ts.ModuleKind : Symbol(ts.ModuleKind, Decl(typescript.d.ts, 1106, 5))
>ts : Symbol(ts, Decl(APISample_transform.ts, 9, 6))
>ModuleKind : Symbol(ts.ModuleKind, Decl(typescript.d.ts, 1106, 5))
>CommonJS : Symbol(ts.ModuleKind.CommonJS, Decl(typescript.d.ts, 1108, 17))
console.log(JSON.stringify(result));
>console : Symbol(console, Decl(APISample_transform.ts, 7, 11))
>JSON.stringify : Symbol(JSON.stringify, Decl(lib.d.ts, 964, 70), Decl(lib.d.ts, 969, 34), Decl(lib.d.ts, 975, 78), Decl(lib.d.ts, 981, 51), Decl(lib.d.ts, 988, 90))
>JSON : Symbol(JSON, Decl(lib.d.ts, 955, 42), Decl(lib.d.ts, 1000, 11))
>stringify : Symbol(JSON.stringify, Decl(lib.d.ts, 964, 70), Decl(lib.d.ts, 969, 34), Decl(lib.d.ts, 975, 78), Decl(lib.d.ts, 981, 51), Decl(lib.d.ts, 988, 90))
>result : Symbol(result, Decl(APISample_transform.ts, 13, 3))

View File

@ -1,44 +0,0 @@
=== 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
import * as ts from "typescript";
>ts : typeof ts
const source = "let x: string = 'string'";
>source : string
>"let x: string = 'string'" : string
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
>source : string
>{ 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
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; }
>result : string

View File

@ -1,322 +0,0 @@
=== tests/cases/compiler/APISample_watcher.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#incremental-build-support-using-the-language-services
* Please log a "breaking change" issue for any API breaking change affecting this issue
*/
declare var process: any;
>process : Symbol(process, Decl(APISample_watcher.ts, 7, 11))
declare var console: any;
>console : Symbol(console, Decl(APISample_watcher.ts, 8, 11))
declare var fs: any;
>fs : Symbol(fs, Decl(APISample_watcher.ts, 9, 11))
declare var path: any;
>path : Symbol(path, Decl(APISample_watcher.ts, 10, 11))
import * as ts from "typescript";
>ts : Symbol(ts, Decl(APISample_watcher.ts, 12, 6))
function watch(rootFileNames: string[], options: ts.CompilerOptions) {
>watch : Symbol(watch, Decl(APISample_watcher.ts, 12, 33))
>rootFileNames : Symbol(rootFileNames, Decl(APISample_watcher.ts, 14, 15))
>options : Symbol(options, Decl(APISample_watcher.ts, 14, 39))
>ts : Symbol(ts, Decl(APISample_watcher.ts, 12, 6))
>CompilerOptions : Symbol(ts.CompilerOptions, Decl(typescript.d.ts, 1074, 5))
const files: ts.Map<{ version: number }> = {};
>files : Symbol(files, Decl(APISample_watcher.ts, 15, 9))
>ts : Symbol(ts, Decl(APISample_watcher.ts, 12, 6))
>Map : Symbol(ts.Map, Decl(typescript.d.ts, 15, 29))
>version : Symbol(version, Decl(APISample_watcher.ts, 15, 25))
// initialize the list of files
rootFileNames.forEach(fileName => {
>rootFileNames.forEach : Symbol(Array.forEach, Decl(lib.d.ts, 1108, 95))
>rootFileNames : Symbol(rootFileNames, Decl(APISample_watcher.ts, 14, 15))
>forEach : Symbol(Array.forEach, Decl(lib.d.ts, 1108, 95))
>fileName : Symbol(fileName, Decl(APISample_watcher.ts, 18, 26))
files[fileName] = { version: 0 };
>files : Symbol(files, Decl(APISample_watcher.ts, 15, 9))
>fileName : Symbol(fileName, Decl(APISample_watcher.ts, 18, 26))
>version : Symbol(version, Decl(APISample_watcher.ts, 19, 27))
});
// Create the language service host to allow the LS to communicate with the host
const servicesHost: ts.LanguageServiceHost = {
>servicesHost : Symbol(servicesHost, Decl(APISample_watcher.ts, 23, 9))
>ts : Symbol(ts, Decl(APISample_watcher.ts, 12, 6))
>LanguageServiceHost : Symbol(ts.LanguageServiceHost, Decl(typescript.d.ts, 1318, 5))
getScriptFileNames: () => rootFileNames,
>getScriptFileNames : Symbol(getScriptFileNames, Decl(APISample_watcher.ts, 23, 50))
>rootFileNames : Symbol(rootFileNames, Decl(APISample_watcher.ts, 14, 15))
getScriptVersion: (fileName) => files[fileName] && files[fileName].version.toString(),
>getScriptVersion : Symbol(getScriptVersion, Decl(APISample_watcher.ts, 24, 48))
>fileName : Symbol(fileName, Decl(APISample_watcher.ts, 25, 27))
>files : Symbol(files, Decl(APISample_watcher.ts, 15, 9))
>fileName : Symbol(fileName, Decl(APISample_watcher.ts, 25, 27))
>files[fileName].version.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
>files[fileName].version : Symbol(version, Decl(APISample_watcher.ts, 15, 25))
>files : Symbol(files, Decl(APISample_watcher.ts, 15, 9))
>fileName : Symbol(fileName, Decl(APISample_watcher.ts, 25, 27))
>version : Symbol(version, Decl(APISample_watcher.ts, 15, 25))
>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
getScriptSnapshot: (fileName) => {
>getScriptSnapshot : Symbol(getScriptSnapshot, Decl(APISample_watcher.ts, 25, 94))
>fileName : Symbol(fileName, Decl(APISample_watcher.ts, 26, 28))
if (!fs.existsSync(fileName)) {
>fs : Symbol(fs, Decl(APISample_watcher.ts, 9, 11))
>fileName : Symbol(fileName, Decl(APISample_watcher.ts, 26, 28))
return undefined;
>undefined : Symbol(undefined)
}
return ts.ScriptSnapshot.fromString(fs.readFileSync(fileName).toString());
>ts.ScriptSnapshot.fromString : Symbol(ts.ScriptSnapshot.fromString, Decl(typescript.d.ts, 1311, 27))
>ts.ScriptSnapshot : Symbol(ts.ScriptSnapshot, Decl(typescript.d.ts, 1310, 5))
>ts : Symbol(ts, Decl(APISample_watcher.ts, 12, 6))
>ScriptSnapshot : Symbol(ts.ScriptSnapshot, Decl(typescript.d.ts, 1310, 5))
>fromString : Symbol(ts.ScriptSnapshot.fromString, Decl(typescript.d.ts, 1311, 27))
>fs : Symbol(fs, Decl(APISample_watcher.ts, 9, 11))
>fileName : Symbol(fileName, Decl(APISample_watcher.ts, 26, 28))
},
getCurrentDirectory: () => process.cwd(),
>getCurrentDirectory : Symbol(getCurrentDirectory, Decl(APISample_watcher.ts, 32, 10))
>process : Symbol(process, Decl(APISample_watcher.ts, 7, 11))
getCompilationSettings: () => options,
>getCompilationSettings : Symbol(getCompilationSettings, Decl(APISample_watcher.ts, 33, 49))
>options : Symbol(options, Decl(APISample_watcher.ts, 14, 39))
getDefaultLibFileName: (options) => ts.getDefaultLibFilePath(options),
>getDefaultLibFileName : Symbol(getDefaultLibFileName, Decl(APISample_watcher.ts, 34, 46))
>options : Symbol(options, Decl(APISample_watcher.ts, 35, 32))
>ts.getDefaultLibFilePath : Symbol(ts.getDefaultLibFilePath, Decl(typescript.d.ts, 1760, 44))
>ts : Symbol(ts, Decl(APISample_watcher.ts, 12, 6))
>getDefaultLibFilePath : Symbol(ts.getDefaultLibFilePath, Decl(typescript.d.ts, 1760, 44))
>options : Symbol(options, Decl(APISample_watcher.ts, 35, 32))
};
// Create the language service files
const services = ts.createLanguageService(servicesHost, ts.createDocumentRegistry())
>services : Symbol(services, Decl(APISample_watcher.ts, 39, 9))
>ts.createLanguageService : Symbol(ts.createLanguageService, Decl(typescript.d.ts, 1758, 97))
>ts : Symbol(ts, Decl(APISample_watcher.ts, 12, 6))
>createLanguageService : Symbol(ts.createLanguageService, Decl(typescript.d.ts, 1758, 97))
>servicesHost : Symbol(servicesHost, Decl(APISample_watcher.ts, 23, 9))
>ts.createDocumentRegistry : Symbol(ts.createDocumentRegistry, Decl(typescript.d.ts, 1756, 193))
>ts : Symbol(ts, Decl(APISample_watcher.ts, 12, 6))
>createDocumentRegistry : Symbol(ts.createDocumentRegistry, Decl(typescript.d.ts, 1756, 193))
// Now let's watch the files
rootFileNames.forEach(fileName => {
>rootFileNames.forEach : Symbol(Array.forEach, Decl(lib.d.ts, 1108, 95))
>rootFileNames : Symbol(rootFileNames, Decl(APISample_watcher.ts, 14, 15))
>forEach : Symbol(Array.forEach, Decl(lib.d.ts, 1108, 95))
>fileName : Symbol(fileName, Decl(APISample_watcher.ts, 42, 26))
// First time around, emit all files
emitFile(fileName);
>emitFile : Symbol(emitFile, Decl(APISample_watcher.ts, 61, 7))
>fileName : Symbol(fileName, Decl(APISample_watcher.ts, 42, 26))
// Add a watch on the file to handle next change
fs.watchFile(fileName,
>fs : Symbol(fs, Decl(APISample_watcher.ts, 9, 11))
>fileName : Symbol(fileName, Decl(APISample_watcher.ts, 42, 26))
{ persistent: true, interval: 250 },
>persistent : Symbol(persistent, Decl(APISample_watcher.ts, 48, 13))
>interval : Symbol(interval, Decl(APISample_watcher.ts, 48, 31))
(curr, prev) => {
>curr : Symbol(curr, Decl(APISample_watcher.ts, 49, 13))
>prev : Symbol(prev, Decl(APISample_watcher.ts, 49, 18))
// Check timestamp
if (+curr.mtime <= +prev.mtime) {
>curr : Symbol(curr, Decl(APISample_watcher.ts, 49, 13))
>prev : Symbol(prev, Decl(APISample_watcher.ts, 49, 18))
return;
}
// Update the version to signal a change in the file
files[fileName].version++;
>files[fileName].version : Symbol(version, Decl(APISample_watcher.ts, 15, 25))
>files : Symbol(files, Decl(APISample_watcher.ts, 15, 9))
>fileName : Symbol(fileName, Decl(APISample_watcher.ts, 42, 26))
>version : Symbol(version, Decl(APISample_watcher.ts, 15, 25))
// write the changes to disk
emitFile(fileName);
>emitFile : Symbol(emitFile, Decl(APISample_watcher.ts, 61, 7))
>fileName : Symbol(fileName, Decl(APISample_watcher.ts, 42, 26))
});
});
function emitFile(fileName: string) {
>emitFile : Symbol(emitFile, Decl(APISample_watcher.ts, 61, 7))
>fileName : Symbol(fileName, Decl(APISample_watcher.ts, 63, 22))
let output = services.getEmitOutput(fileName);
>output : Symbol(output, Decl(APISample_watcher.ts, 64, 11))
>services.getEmitOutput : Symbol(ts.LanguageService.getEmitOutput, Decl(typescript.d.ts, 1362, 132))
>services : Symbol(services, Decl(APISample_watcher.ts, 39, 9))
>getEmitOutput : Symbol(ts.LanguageService.getEmitOutput, Decl(typescript.d.ts, 1362, 132))
>fileName : Symbol(fileName, Decl(APISample_watcher.ts, 63, 22))
if (!output.emitSkipped) {
>output.emitSkipped : Symbol(ts.EmitOutput.emitSkipped, Decl(typescript.d.ts, 1565, 34))
>output : Symbol(output, Decl(APISample_watcher.ts, 64, 11))
>emitSkipped : Symbol(ts.EmitOutput.emitSkipped, Decl(typescript.d.ts, 1565, 34))
console.log(`Emitting ${fileName}`);
>console : Symbol(console, Decl(APISample_watcher.ts, 8, 11))
>fileName : Symbol(fileName, Decl(APISample_watcher.ts, 63, 22))
}
else {
console.log(`Emitting ${fileName} failed`);
>console : Symbol(console, Decl(APISample_watcher.ts, 8, 11))
>fileName : Symbol(fileName, Decl(APISample_watcher.ts, 63, 22))
logErrors(fileName);
>logErrors : Symbol(logErrors, Decl(APISample_watcher.ts, 77, 5))
>fileName : Symbol(fileName, Decl(APISample_watcher.ts, 63, 22))
}
output.outputFiles.forEach(o => {
>output.outputFiles.forEach : Symbol(Array.forEach, Decl(lib.d.ts, 1108, 95))
>output.outputFiles : Symbol(ts.EmitOutput.outputFiles, Decl(typescript.d.ts, 1564, 26))
>output : Symbol(output, Decl(APISample_watcher.ts, 64, 11))
>outputFiles : Symbol(ts.EmitOutput.outputFiles, Decl(typescript.d.ts, 1564, 26))
>forEach : Symbol(Array.forEach, Decl(lib.d.ts, 1108, 95))
>o : Symbol(o, Decl(APISample_watcher.ts, 74, 35))
fs.writeFileSync(o.name, o.text, "utf8");
>fs : Symbol(fs, Decl(APISample_watcher.ts, 9, 11))
>o.name : Symbol(ts.OutputFile.name, Decl(typescript.d.ts, 1573, 26))
>o : Symbol(o, Decl(APISample_watcher.ts, 74, 35))
>name : Symbol(ts.OutputFile.name, Decl(typescript.d.ts, 1573, 26))
>o.text : Symbol(ts.OutputFile.text, Decl(typescript.d.ts, 1575, 36))
>o : Symbol(o, Decl(APISample_watcher.ts, 74, 35))
>text : Symbol(ts.OutputFile.text, Decl(typescript.d.ts, 1575, 36))
});
}
function logErrors(fileName: string) {
>logErrors : Symbol(logErrors, Decl(APISample_watcher.ts, 77, 5))
>fileName : Symbol(fileName, Decl(APISample_watcher.ts, 79, 23))
let allDiagnostics = services.getCompilerOptionsDiagnostics()
>allDiagnostics : Symbol(allDiagnostics, Decl(APISample_watcher.ts, 80, 11))
>services.getCompilerOptionsDiagnostics() .concat(services.getSyntacticDiagnostics(fileName)) .concat : Symbol(Array.concat, Decl(lib.d.ts, 1025, 13), Decl(lib.d.ts, 1030, 46))
>services.getCompilerOptionsDiagnostics() .concat : Symbol(Array.concat, Decl(lib.d.ts, 1025, 13), Decl(lib.d.ts, 1030, 46))
>services.getCompilerOptionsDiagnostics : Symbol(ts.LanguageService.getCompilerOptionsDiagnostics, Decl(typescript.d.ts, 1336, 63))
>services : Symbol(services, Decl(APISample_watcher.ts, 39, 9))
>getCompilerOptionsDiagnostics : Symbol(ts.LanguageService.getCompilerOptionsDiagnostics, Decl(typescript.d.ts, 1336, 63))
.concat(services.getSyntacticDiagnostics(fileName))
>concat : Symbol(Array.concat, Decl(lib.d.ts, 1025, 13), Decl(lib.d.ts, 1030, 46))
>services.getSyntacticDiagnostics : Symbol(ts.LanguageService.getSyntacticDiagnostics, Decl(typescript.d.ts, 1334, 37))
>services : Symbol(services, Decl(APISample_watcher.ts, 39, 9))
>getSyntacticDiagnostics : Symbol(ts.LanguageService.getSyntacticDiagnostics, Decl(typescript.d.ts, 1334, 37))
>fileName : Symbol(fileName, Decl(APISample_watcher.ts, 79, 23))
.concat(services.getSemanticDiagnostics(fileName));
>concat : Symbol(Array.concat, Decl(lib.d.ts, 1025, 13), Decl(lib.d.ts, 1030, 46))
>services.getSemanticDiagnostics : Symbol(ts.LanguageService.getSemanticDiagnostics, Decl(typescript.d.ts, 1335, 64))
>services : Symbol(services, Decl(APISample_watcher.ts, 39, 9))
>getSemanticDiagnostics : Symbol(ts.LanguageService.getSemanticDiagnostics, Decl(typescript.d.ts, 1335, 64))
>fileName : Symbol(fileName, Decl(APISample_watcher.ts, 79, 23))
allDiagnostics.forEach(diagnostic => {
>allDiagnostics.forEach : Symbol(Array.forEach, Decl(lib.d.ts, 1108, 95))
>allDiagnostics : Symbol(allDiagnostics, Decl(APISample_watcher.ts, 80, 11))
>forEach : Symbol(Array.forEach, Decl(lib.d.ts, 1108, 95))
>diagnostic : Symbol(diagnostic, Decl(APISample_watcher.ts, 84, 31))
let message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
>message : Symbol(message, Decl(APISample_watcher.ts, 85, 15))
>ts.flattenDiagnosticMessageText : Symbol(ts.flattenDiagnosticMessageText, Decl(typescript.d.ts, 1224, 67))
>ts : Symbol(ts, Decl(APISample_watcher.ts, 12, 6))
>flattenDiagnosticMessageText : Symbol(ts.flattenDiagnosticMessageText, Decl(typescript.d.ts, 1224, 67))
>diagnostic.messageText : Symbol(ts.Diagnostic.messageText, Decl(typescript.d.ts, 1065, 23))
>diagnostic : Symbol(diagnostic, Decl(APISample_watcher.ts, 84, 31))
>messageText : Symbol(ts.Diagnostic.messageText, Decl(typescript.d.ts, 1065, 23))
if (diagnostic.file) {
>diagnostic.file : Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1062, 26))
>diagnostic : Symbol(diagnostic, Decl(APISample_watcher.ts, 84, 31))
>file : Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1062, 26))
let { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
>line : Symbol(line, Decl(APISample_watcher.ts, 87, 21))
>character : Symbol(character, Decl(APISample_watcher.ts, 87, 27))
>diagnostic.file.getLineAndCharacterOfPosition : Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1286, 26))
>diagnostic.file : Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1062, 26))
>diagnostic : Symbol(diagnostic, Decl(APISample_watcher.ts, 84, 31))
>file : Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1062, 26))
>getLineAndCharacterOfPosition : Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1286, 26))
>diagnostic.start : Symbol(ts.Diagnostic.start, Decl(typescript.d.ts, 1063, 25))
>diagnostic : Symbol(diagnostic, Decl(APISample_watcher.ts, 84, 31))
>start : Symbol(ts.Diagnostic.start, Decl(typescript.d.ts, 1063, 25))
console.log(` Error ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
>console : Symbol(console, Decl(APISample_watcher.ts, 8, 11))
>diagnostic.file.fileName : Symbol(ts.SourceFile.fileName, Decl(typescript.d.ts, 743, 29))
>diagnostic.file : Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1062, 26))
>diagnostic : Symbol(diagnostic, Decl(APISample_watcher.ts, 84, 31))
>file : Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1062, 26))
>fileName : Symbol(ts.SourceFile.fileName, Decl(typescript.d.ts, 743, 29))
>line : Symbol(line, Decl(APISample_watcher.ts, 87, 21))
>character : Symbol(character, Decl(APISample_watcher.ts, 87, 27))
>message : Symbol(message, Decl(APISample_watcher.ts, 85, 15))
}
else {
console.log(` Error: ${message}`);
>console : Symbol(console, Decl(APISample_watcher.ts, 8, 11))
>message : Symbol(message, Decl(APISample_watcher.ts, 85, 15))
}
});
}
}
// Initialize files constituting the program as all .ts files in the current directory
const currentDirectoryFiles = fs.readdirSync(process.cwd()).
>currentDirectoryFiles : Symbol(currentDirectoryFiles, Decl(APISample_watcher.ts, 98, 5))
>fs : Symbol(fs, Decl(APISample_watcher.ts, 9, 11))
>process : Symbol(process, Decl(APISample_watcher.ts, 7, 11))
filter(fileName=> fileName.length >= 3 && fileName.substr(fileName.length - 3, 3) === ".ts");
>fileName : Symbol(fileName, Decl(APISample_watcher.ts, 99, 11))
>fileName : Symbol(fileName, Decl(APISample_watcher.ts, 99, 11))
>fileName : Symbol(fileName, Decl(APISample_watcher.ts, 99, 11))
>fileName : Symbol(fileName, Decl(APISample_watcher.ts, 99, 11))
// Start the watcher
watch(currentDirectoryFiles, { module: ts.ModuleKind.CommonJS });
>watch : Symbol(watch, Decl(APISample_watcher.ts, 12, 33))
>currentDirectoryFiles : Symbol(currentDirectoryFiles, Decl(APISample_watcher.ts, 98, 5))
>module : Symbol(module, Decl(APISample_watcher.ts, 102, 30))
>ts.ModuleKind.CommonJS : Symbol(ts.ModuleKind.CommonJS, Decl(typescript.d.ts, 1108, 17))
>ts.ModuleKind : Symbol(ts.ModuleKind, Decl(typescript.d.ts, 1106, 5))
>ts : Symbol(ts, Decl(APISample_watcher.ts, 12, 6))
>ModuleKind : Symbol(ts.ModuleKind, Decl(typescript.d.ts, 1106, 5))
>CommonJS : Symbol(ts.ModuleKind.CommonJS, Decl(typescript.d.ts, 1108, 17))

View File

@ -1,443 +0,0 @@
=== tests/cases/compiler/APISample_watcher.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#incremental-build-support-using-the-language-services
* Please log a "breaking change" issue for any API breaking change affecting this issue
*/
declare var process: any;
>process : any
declare var console: any;
>console : any
declare var fs: any;
>fs : any
declare var path: any;
>path : any
import * as ts from "typescript";
>ts : typeof ts
function watch(rootFileNames: string[], options: ts.CompilerOptions) {
>watch : (rootFileNames: string[], options: ts.CompilerOptions) => void
>rootFileNames : string[]
>options : ts.CompilerOptions
>ts : any
>CompilerOptions : ts.CompilerOptions
const files: ts.Map<{ version: number }> = {};
>files : ts.Map<{ version: number; }>
>ts : any
>Map : ts.Map<T>
>version : number
>{} : { [x: string]: undefined; }
// initialize the list of files
rootFileNames.forEach(fileName => {
>rootFileNames.forEach(fileName => { files[fileName] = { version: 0 }; }) : void
>rootFileNames.forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void
>rootFileNames : string[]
>forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void
>fileName => { files[fileName] = { version: 0 }; } : (fileName: string) => void
>fileName : string
files[fileName] = { version: 0 };
>files[fileName] = { version: 0 } : { version: number; }
>files[fileName] : { version: number; }
>files : ts.Map<{ version: number; }>
>fileName : string
>{ version: 0 } : { version: number; }
>version : number
>0 : number
});
// Create the language service host to allow the LS to communicate with the host
const servicesHost: ts.LanguageServiceHost = {
>servicesHost : ts.LanguageServiceHost
>ts : any
>LanguageServiceHost : ts.LanguageServiceHost
>{ getScriptFileNames: () => rootFileNames, getScriptVersion: (fileName) => files[fileName] && files[fileName].version.toString(), getScriptSnapshot: (fileName) => { if (!fs.existsSync(fileName)) { return undefined; } return ts.ScriptSnapshot.fromString(fs.readFileSync(fileName).toString()); }, getCurrentDirectory: () => process.cwd(), getCompilationSettings: () => options, getDefaultLibFileName: (options) => ts.getDefaultLibFilePath(options), } : { getScriptFileNames: () => string[]; getScriptVersion: (fileName: string) => string; getScriptSnapshot: (fileName: string) => ts.IScriptSnapshot; getCurrentDirectory: () => any; getCompilationSettings: () => ts.CompilerOptions; getDefaultLibFileName: (options: ts.CompilerOptions) => string; }
getScriptFileNames: () => rootFileNames,
>getScriptFileNames : () => string[]
>() => rootFileNames : () => string[]
>rootFileNames : string[]
getScriptVersion: (fileName) => files[fileName] && files[fileName].version.toString(),
>getScriptVersion : (fileName: string) => string
>(fileName) => files[fileName] && files[fileName].version.toString() : (fileName: string) => string
>fileName : string
>files[fileName] && files[fileName].version.toString() : string
>files[fileName] : { version: number; }
>files : ts.Map<{ version: number; }>
>fileName : string
>files[fileName].version.toString() : string
>files[fileName].version.toString : (radix?: number) => string
>files[fileName].version : number
>files[fileName] : { version: number; }
>files : ts.Map<{ version: number; }>
>fileName : string
>version : number
>toString : (radix?: number) => string
getScriptSnapshot: (fileName) => {
>getScriptSnapshot : (fileName: string) => ts.IScriptSnapshot
>(fileName) => { if (!fs.existsSync(fileName)) { return undefined; } return ts.ScriptSnapshot.fromString(fs.readFileSync(fileName).toString()); } : (fileName: string) => ts.IScriptSnapshot
>fileName : string
if (!fs.existsSync(fileName)) {
>!fs.existsSync(fileName) : boolean
>fs.existsSync(fileName) : any
>fs.existsSync : any
>fs : any
>existsSync : any
>fileName : string
return undefined;
>undefined : undefined
}
return ts.ScriptSnapshot.fromString(fs.readFileSync(fileName).toString());
>ts.ScriptSnapshot.fromString(fs.readFileSync(fileName).toString()) : ts.IScriptSnapshot
>ts.ScriptSnapshot.fromString : (text: string) => ts.IScriptSnapshot
>ts.ScriptSnapshot : typeof ts.ScriptSnapshot
>ts : typeof ts
>ScriptSnapshot : typeof ts.ScriptSnapshot
>fromString : (text: string) => ts.IScriptSnapshot
>fs.readFileSync(fileName).toString() : any
>fs.readFileSync(fileName).toString : any
>fs.readFileSync(fileName) : any
>fs.readFileSync : any
>fs : any
>readFileSync : any
>fileName : string
>toString : any
},
getCurrentDirectory: () => process.cwd(),
>getCurrentDirectory : () => any
>() => process.cwd() : () => any
>process.cwd() : any
>process.cwd : any
>process : any
>cwd : any
getCompilationSettings: () => options,
>getCompilationSettings : () => ts.CompilerOptions
>() => options : () => ts.CompilerOptions
>options : ts.CompilerOptions
getDefaultLibFileName: (options) => ts.getDefaultLibFilePath(options),
>getDefaultLibFileName : (options: ts.CompilerOptions) => string
>(options) => ts.getDefaultLibFilePath(options) : (options: ts.CompilerOptions) => string
>options : ts.CompilerOptions
>ts.getDefaultLibFilePath(options) : string
>ts.getDefaultLibFilePath : (options: ts.CompilerOptions) => string
>ts : typeof ts
>getDefaultLibFilePath : (options: ts.CompilerOptions) => string
>options : ts.CompilerOptions
};
// Create the language service files
const services = ts.createLanguageService(servicesHost, ts.createDocumentRegistry())
>services : ts.LanguageService
>ts.createLanguageService(servicesHost, ts.createDocumentRegistry()) : ts.LanguageService
>ts.createLanguageService : (host: ts.LanguageServiceHost, documentRegistry?: ts.DocumentRegistry) => ts.LanguageService
>ts : typeof ts
>createLanguageService : (host: ts.LanguageServiceHost, documentRegistry?: ts.DocumentRegistry) => ts.LanguageService
>servicesHost : ts.LanguageServiceHost
>ts.createDocumentRegistry() : ts.DocumentRegistry
>ts.createDocumentRegistry : () => ts.DocumentRegistry
>ts : typeof ts
>createDocumentRegistry : () => ts.DocumentRegistry
// Now let's watch the files
rootFileNames.forEach(fileName => {
>rootFileNames.forEach(fileName => { // First time around, emit all files emitFile(fileName); // Add a watch on the file to handle next change fs.watchFile(fileName, { persistent: true, interval: 250 }, (curr, prev) => { // Check timestamp if (+curr.mtime <= +prev.mtime) { return; } // Update the version to signal a change in the file files[fileName].version++; // write the changes to disk emitFile(fileName); }); }) : void
>rootFileNames.forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void
>rootFileNames : string[]
>forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void
>fileName => { // First time around, emit all files emitFile(fileName); // Add a watch on the file to handle next change fs.watchFile(fileName, { persistent: true, interval: 250 }, (curr, prev) => { // Check timestamp if (+curr.mtime <= +prev.mtime) { return; } // Update the version to signal a change in the file files[fileName].version++; // write the changes to disk emitFile(fileName); }); } : (fileName: string) => void
>fileName : string
// First time around, emit all files
emitFile(fileName);
>emitFile(fileName) : void
>emitFile : (fileName: string) => void
>fileName : string
// Add a watch on the file to handle next change
fs.watchFile(fileName,
>fs.watchFile(fileName, { persistent: true, interval: 250 }, (curr, prev) => { // Check timestamp if (+curr.mtime <= +prev.mtime) { return; } // Update the version to signal a change in the file files[fileName].version++; // write the changes to disk emitFile(fileName); }) : any
>fs.watchFile : any
>fs : any
>watchFile : any
>fileName : string
{ persistent: true, interval: 250 },
>{ persistent: true, interval: 250 } : { persistent: boolean; interval: number; }
>persistent : boolean
>true : boolean
>interval : number
>250 : number
(curr, prev) => {
>(curr, prev) => { // Check timestamp if (+curr.mtime <= +prev.mtime) { return; } // Update the version to signal a change in the file files[fileName].version++; // write the changes to disk emitFile(fileName); } : (curr: any, prev: any) => void
>curr : any
>prev : any
// Check timestamp
if (+curr.mtime <= +prev.mtime) {
>+curr.mtime <= +prev.mtime : boolean
>+curr.mtime : number
>curr.mtime : any
>curr : any
>mtime : any
>+prev.mtime : number
>prev.mtime : any
>prev : any
>mtime : any
return;
}
// Update the version to signal a change in the file
files[fileName].version++;
>files[fileName].version++ : number
>files[fileName].version : number
>files[fileName] : { version: number; }
>files : ts.Map<{ version: number; }>
>fileName : string
>version : number
// write the changes to disk
emitFile(fileName);
>emitFile(fileName) : void
>emitFile : (fileName: string) => void
>fileName : string
});
});
function emitFile(fileName: string) {
>emitFile : (fileName: string) => void
>fileName : string
let output = services.getEmitOutput(fileName);
>output : ts.EmitOutput
>services.getEmitOutput(fileName) : ts.EmitOutput
>services.getEmitOutput : (fileName: string) => ts.EmitOutput
>services : ts.LanguageService
>getEmitOutput : (fileName: string) => ts.EmitOutput
>fileName : string
if (!output.emitSkipped) {
>!output.emitSkipped : boolean
>output.emitSkipped : boolean
>output : ts.EmitOutput
>emitSkipped : boolean
console.log(`Emitting ${fileName}`);
>console.log(`Emitting ${fileName}`) : any
>console.log : any
>console : any
>log : any
>`Emitting ${fileName}` : string
>fileName : string
}
else {
console.log(`Emitting ${fileName} failed`);
>console.log(`Emitting ${fileName} failed`) : any
>console.log : any
>console : any
>log : any
>`Emitting ${fileName} failed` : string
>fileName : string
logErrors(fileName);
>logErrors(fileName) : void
>logErrors : (fileName: string) => void
>fileName : string
}
output.outputFiles.forEach(o => {
>output.outputFiles.forEach(o => { fs.writeFileSync(o.name, o.text, "utf8"); }) : void
>output.outputFiles.forEach : (callbackfn: (value: ts.OutputFile, index: number, array: ts.OutputFile[]) => void, thisArg?: any) => void
>output.outputFiles : ts.OutputFile[]
>output : ts.EmitOutput
>outputFiles : ts.OutputFile[]
>forEach : (callbackfn: (value: ts.OutputFile, index: number, array: ts.OutputFile[]) => void, thisArg?: any) => void
>o => { fs.writeFileSync(o.name, o.text, "utf8"); } : (o: ts.OutputFile) => void
>o : ts.OutputFile
fs.writeFileSync(o.name, o.text, "utf8");
>fs.writeFileSync(o.name, o.text, "utf8") : any
>fs.writeFileSync : any
>fs : any
>writeFileSync : any
>o.name : string
>o : ts.OutputFile
>name : string
>o.text : string
>o : ts.OutputFile
>text : string
>"utf8" : string
});
}
function logErrors(fileName: string) {
>logErrors : (fileName: string) => void
>fileName : string
let allDiagnostics = services.getCompilerOptionsDiagnostics()
>allDiagnostics : ts.Diagnostic[]
>services.getCompilerOptionsDiagnostics() .concat(services.getSyntacticDiagnostics(fileName)) .concat(services.getSemanticDiagnostics(fileName)) : ts.Diagnostic[]
>services.getCompilerOptionsDiagnostics() .concat(services.getSyntacticDiagnostics(fileName)) .concat : { <U extends ts.Diagnostic[]>(...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }
>services.getCompilerOptionsDiagnostics() .concat(services.getSyntacticDiagnostics(fileName)) : ts.Diagnostic[]
>services.getCompilerOptionsDiagnostics() .concat : { <U extends ts.Diagnostic[]>(...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }
>services.getCompilerOptionsDiagnostics() : ts.Diagnostic[]
>services.getCompilerOptionsDiagnostics : () => ts.Diagnostic[]
>services : ts.LanguageService
>getCompilerOptionsDiagnostics : () => ts.Diagnostic[]
.concat(services.getSyntacticDiagnostics(fileName))
>concat : { <U extends ts.Diagnostic[]>(...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }
>services.getSyntacticDiagnostics(fileName) : ts.Diagnostic[]
>services.getSyntacticDiagnostics : (fileName: string) => ts.Diagnostic[]
>services : ts.LanguageService
>getSyntacticDiagnostics : (fileName: string) => ts.Diagnostic[]
>fileName : string
.concat(services.getSemanticDiagnostics(fileName));
>concat : { <U extends ts.Diagnostic[]>(...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }
>services.getSemanticDiagnostics(fileName) : ts.Diagnostic[]
>services.getSemanticDiagnostics : (fileName: string) => ts.Diagnostic[]
>services : ts.LanguageService
>getSemanticDiagnostics : (fileName: string) => ts.Diagnostic[]
>fileName : string
allDiagnostics.forEach(diagnostic => {
>allDiagnostics.forEach(diagnostic => { let message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"); if (diagnostic.file) { let { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); console.log(` Error ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`); } else { console.log(` Error: ${message}`); } }) : void
>allDiagnostics.forEach : (callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => void, thisArg?: any) => void
>allDiagnostics : ts.Diagnostic[]
>forEach : (callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => void, thisArg?: any) => void
>diagnostic => { let message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"); if (diagnostic.file) { let { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); console.log(` Error ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`); } else { console.log(` Error: ${message}`); } } : (diagnostic: ts.Diagnostic) => void
>diagnostic : ts.Diagnostic
let message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
>message : string
>ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n") : string
>ts.flattenDiagnosticMessageText : (messageText: string | ts.DiagnosticMessageChain, newLine: string) => string
>ts : typeof ts
>flattenDiagnosticMessageText : (messageText: string | ts.DiagnosticMessageChain, newLine: string) => string
>diagnostic.messageText : string | ts.DiagnosticMessageChain
>diagnostic : ts.Diagnostic
>messageText : string | ts.DiagnosticMessageChain
>"\n" : string
if (diagnostic.file) {
>diagnostic.file : ts.SourceFile
>diagnostic : ts.Diagnostic
>file : ts.SourceFile
let { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
>line : number
>character : number
>diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start) : ts.LineAndCharacter
>diagnostic.file.getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
>diagnostic.file : ts.SourceFile
>diagnostic : ts.Diagnostic
>file : ts.SourceFile
>getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
>diagnostic.start : number
>diagnostic : ts.Diagnostic
>start : number
console.log(` Error ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
>console.log(` Error ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`) : any
>console.log : any
>console : any
>log : any
>` Error ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}` : string
>diagnostic.file.fileName : string
>diagnostic.file : ts.SourceFile
>diagnostic : ts.Diagnostic
>file : ts.SourceFile
>fileName : string
>line + 1 : number
>line : number
>1 : number
>character + 1 : number
>character : number
>1 : number
>message : string
}
else {
console.log(` Error: ${message}`);
>console.log(` Error: ${message}`) : any
>console.log : any
>console : any
>log : any
>` Error: ${message}` : string
>message : string
}
});
}
}
// Initialize files constituting the program as all .ts files in the current directory
const currentDirectoryFiles = fs.readdirSync(process.cwd()).
>currentDirectoryFiles : any
>fs.readdirSync(process.cwd()). filter(fileName=> fileName.length >= 3 && fileName.substr(fileName.length - 3, 3) === ".ts") : any
>fs.readdirSync(process.cwd()). filter : any
>fs.readdirSync(process.cwd()) : any
>fs.readdirSync : any
>fs : any
>readdirSync : any
>process.cwd() : any
>process.cwd : any
>process : any
>cwd : any
filter(fileName=> fileName.length >= 3 && fileName.substr(fileName.length - 3, 3) === ".ts");
>filter : any
>fileName=> fileName.length >= 3 && fileName.substr(fileName.length - 3, 3) === ".ts" : (fileName: any) => boolean
>fileName : any
>fileName.length >= 3 && fileName.substr(fileName.length - 3, 3) === ".ts" : boolean
>fileName.length >= 3 : boolean
>fileName.length : any
>fileName : any
>length : any
>3 : number
>fileName.substr(fileName.length - 3, 3) === ".ts" : boolean
>fileName.substr(fileName.length - 3, 3) : any
>fileName.substr : any
>fileName : any
>substr : any
>fileName.length - 3 : number
>fileName.length : any
>fileName : any
>length : any
>3 : number
>3 : number
>".ts" : string
// Start the watcher
watch(currentDirectoryFiles, { module: ts.ModuleKind.CommonJS });
>watch(currentDirectoryFiles, { module: ts.ModuleKind.CommonJS }) : void
>watch : (rootFileNames: string[], options: ts.CompilerOptions) => void
>currentDirectoryFiles : any
>{ 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