mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Hide the diagnostic producing methods from TypeChecker.
Instead, consumers should get these diagnostics through the Program instance.
This commit is contained in:
+14
-4
@@ -98,9 +98,11 @@ module ts {
|
||||
getSourceFiles: () => files,
|
||||
getCompilerOptions: () => options,
|
||||
getCompilerHost: () => host,
|
||||
getDiagnostics: getDiagnostics,
|
||||
getGlobalDiagnostics: getGlobalDiagnostics,
|
||||
getDeclarationDiagnostics: getDeclarationDiagnostics,
|
||||
getDiagnostics,
|
||||
getGlobalDiagnostics,
|
||||
getTypeCheckerDiagnostics,
|
||||
getTypeCheckerGlobalDiagnostics,
|
||||
getDeclarationDiagnostics,
|
||||
getTypeChecker,
|
||||
getCommonSourceDirectory: () => commonSourceDirectory,
|
||||
emitFiles: invokeEmitter,
|
||||
@@ -115,7 +117,7 @@ module ts {
|
||||
|
||||
function isEmitBlocked(sourceFile?: SourceFile): boolean {
|
||||
if (options.noEmitOnError) {
|
||||
return getDiagnostics(sourceFile).length !== 0 || getDiagnosticsProducingTypeChecker().getDiagnostics(sourceFile).length !== 0;
|
||||
return getDiagnostics(sourceFile).length !== 0 || getTypeCheckerDiagnostics(sourceFile).length !== 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -151,6 +153,14 @@ module ts {
|
||||
return hasProperty(filesByName, fileName) ? filesByName[fileName] : undefined;
|
||||
}
|
||||
|
||||
function getTypeCheckerDiagnostics(sourceFile?: SourceFile): Diagnostic[] {
|
||||
return getDiagnosticsProducingTypeChecker().getDiagnostics(sourceFile);
|
||||
}
|
||||
|
||||
function getTypeCheckerGlobalDiagnostics(): Diagnostic[] {
|
||||
return getDiagnosticsProducingTypeChecker().getGlobalDiagnostics();
|
||||
}
|
||||
|
||||
function getDiagnostics(sourceFile?: SourceFile): Diagnostic[] {
|
||||
return sourceFile ? filter(errors, e => e.file === sourceFile) : errors;
|
||||
}
|
||||
|
||||
@@ -931,6 +931,10 @@ module ts {
|
||||
getSourceFiles(): SourceFile[];
|
||||
getCompilerHost(): CompilerHost;
|
||||
|
||||
// These will merge with the below diagnostics function in a followup checkin.
|
||||
getTypeCheckerDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getTypeCheckerGlobalDiagnostics(): Diagnostic[];
|
||||
|
||||
getDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getGlobalDiagnostics(): Diagnostic[];
|
||||
getDeclarationDiagnostics(sourceFile: SourceFile): Diagnostic[];
|
||||
@@ -997,8 +1001,6 @@ module ts {
|
||||
|
||||
export interface TypeChecker {
|
||||
getEmitResolver(): EmitResolver;
|
||||
getDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getGlobalDiagnostics(): Diagnostic[];
|
||||
getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type;
|
||||
getDeclaredTypeOfSymbol(symbol: Symbol): Type;
|
||||
getPropertiesOfType(type: Type): Symbol[];
|
||||
@@ -1028,6 +1030,10 @@ module ts {
|
||||
isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean;
|
||||
getAliasedSymbol(symbol: Symbol): Symbol;
|
||||
|
||||
// Should not be called directly. Should only be accessed through the Program instance.
|
||||
/* @internal */ getDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
/* @internal */ getGlobalDiagnostics(): Diagnostic[];
|
||||
|
||||
/* @internal */ getNodeCount(): number;
|
||||
/* @internal */ getIdentifierCount(): number;
|
||||
/* @internal */ getSymbolCount(): number;
|
||||
|
||||
@@ -2184,13 +2184,12 @@ module ts {
|
||||
|
||||
fileName = normalizeSlashes(fileName)
|
||||
var compilerOptions = program.getCompilerOptions();
|
||||
var checker = getDiagnosticsProducingTypeChecker();
|
||||
var targetSourceFile = getValidSourceFile(fileName);
|
||||
|
||||
// Only perform the action per file regardless of '-out' flag as LanguageServiceHost is expected to call this function per file.
|
||||
// Therefore only get diagnostics for given file.
|
||||
|
||||
var allDiagnostics = checker.getDiagnostics(targetSourceFile);
|
||||
var allDiagnostics = program.getTypeCheckerDiagnostics(targetSourceFile);
|
||||
if (compilerOptions.declaration) {
|
||||
// If '-d' is enabled, check for emitter error. One example of emitter error is export class implements non-export interface
|
||||
allDiagnostics = allDiagnostics.concat(program.getDeclarationDiagnostics(targetSourceFile));
|
||||
|
||||
@@ -16,11 +16,10 @@ import ts = require("typescript");
|
||||
export function compile(fileNames: string[], options: ts.CompilerOptions): void {
|
||||
var host = ts.createCompilerHost(options);
|
||||
var program = ts.createProgram(fileNames, options, host);
|
||||
var checker = ts.createTypeChecker(program, /*produceDiagnostics*/ true);
|
||||
var result = program.emitFiles();
|
||||
|
||||
var allDiagnostics = program.getDiagnostics()
|
||||
.concat(checker.getDiagnostics())
|
||||
.concat(program.getTypeCheckerDiagnostics())
|
||||
.concat(result.diagnostics);
|
||||
|
||||
allDiagnostics.forEach(diagnostic => {
|
||||
@@ -741,6 +740,8 @@ declare module "typescript" {
|
||||
interface Program extends ScriptReferenceHost {
|
||||
getSourceFiles(): SourceFile[];
|
||||
getCompilerHost(): CompilerHost;
|
||||
getTypeCheckerDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getTypeCheckerGlobalDiagnostics(): Diagnostic[];
|
||||
getDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getGlobalDiagnostics(): Diagnostic[];
|
||||
getDeclarationDiagnostics(sourceFile: SourceFile): Diagnostic[];
|
||||
@@ -789,8 +790,6 @@ declare module "typescript" {
|
||||
}
|
||||
interface TypeChecker {
|
||||
getEmitResolver(): EmitResolver;
|
||||
getDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getGlobalDiagnostics(): Diagnostic[];
|
||||
getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type;
|
||||
getDeclaredTypeOfSymbol(symbol: Symbol): Type;
|
||||
getPropertiesOfType(type: Type): Symbol[];
|
||||
@@ -1917,9 +1916,8 @@ var ts = require("typescript");
|
||||
function compile(fileNames, options) {
|
||||
var host = ts.createCompilerHost(options);
|
||||
var program = ts.createProgram(fileNames, options, host);
|
||||
var checker = ts.createTypeChecker(program, true);
|
||||
var result = program.emitFiles();
|
||||
var allDiagnostics = program.getDiagnostics().concat(checker.getDiagnostics()).concat(result.diagnostics);
|
||||
var allDiagnostics = program.getDiagnostics().concat(program.getTypeCheckerDiagnostics()).concat(result.diagnostics);
|
||||
allDiagnostics.forEach(function (diagnostic) {
|
||||
var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
|
||||
console.log(diagnostic.file.fileName + " (" + lineChar.line + "," + lineChar.character + "): " + diagnostic.messageText);
|
||||
|
||||
@@ -40,14 +40,6 @@ export function compile(fileNames: string[], options: ts.CompilerOptions): void
|
||||
>options : ts.CompilerOptions
|
||||
>host : ts.CompilerHost
|
||||
|
||||
var checker = ts.createTypeChecker(program, /*produceDiagnostics*/ true);
|
||||
>checker : ts.TypeChecker
|
||||
>ts.createTypeChecker(program, /*produceDiagnostics*/ true) : ts.TypeChecker
|
||||
>ts.createTypeChecker : (host: ts.TypeCheckerHost, produceDiagnostics: boolean) => ts.TypeChecker
|
||||
>ts : typeof ts
|
||||
>createTypeChecker : (host: ts.TypeCheckerHost, produceDiagnostics: boolean) => ts.TypeChecker
|
||||
>program : ts.Program
|
||||
|
||||
var result = program.emitFiles();
|
||||
>result : ts.EmitResult
|
||||
>program.emitFiles() : ts.EmitResult
|
||||
@@ -57,21 +49,21 @@ export function compile(fileNames: string[], options: ts.CompilerOptions): void
|
||||
|
||||
var allDiagnostics = program.getDiagnostics()
|
||||
>allDiagnostics : ts.Diagnostic[]
|
||||
>program.getDiagnostics() .concat(checker.getDiagnostics()) .concat(result.diagnostics) : ts.Diagnostic[]
|
||||
>program.getDiagnostics() .concat(checker.getDiagnostics()) .concat : { <U extends ts.Diagnostic[]>(...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }
|
||||
>program.getDiagnostics() .concat(checker.getDiagnostics()) : ts.Diagnostic[]
|
||||
>program.getDiagnostics() .concat(program.getTypeCheckerDiagnostics()) .concat(result.diagnostics) : ts.Diagnostic[]
|
||||
>program.getDiagnostics() .concat(program.getTypeCheckerDiagnostics()) .concat : { <U extends ts.Diagnostic[]>(...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }
|
||||
>program.getDiagnostics() .concat(program.getTypeCheckerDiagnostics()) : ts.Diagnostic[]
|
||||
>program.getDiagnostics() .concat : { <U extends ts.Diagnostic[]>(...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }
|
||||
>program.getDiagnostics() : ts.Diagnostic[]
|
||||
>program.getDiagnostics : (sourceFile?: ts.SourceFile) => ts.Diagnostic[]
|
||||
>program : ts.Program
|
||||
>getDiagnostics : (sourceFile?: ts.SourceFile) => ts.Diagnostic[]
|
||||
|
||||
.concat(checker.getDiagnostics())
|
||||
.concat(program.getTypeCheckerDiagnostics())
|
||||
>concat : { <U extends ts.Diagnostic[]>(...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }
|
||||
>checker.getDiagnostics() : ts.Diagnostic[]
|
||||
>checker.getDiagnostics : (sourceFile?: ts.SourceFile) => ts.Diagnostic[]
|
||||
>checker : ts.TypeChecker
|
||||
>getDiagnostics : (sourceFile?: ts.SourceFile) => ts.Diagnostic[]
|
||||
>program.getTypeCheckerDiagnostics() : ts.Diagnostic[]
|
||||
>program.getTypeCheckerDiagnostics : (sourceFile?: ts.SourceFile) => ts.Diagnostic[]
|
||||
>program : ts.Program
|
||||
>getTypeCheckerDiagnostics : (sourceFile?: ts.SourceFile) => ts.Diagnostic[]
|
||||
|
||||
.concat(result.diagnostics);
|
||||
>concat : { <U extends ts.Diagnostic[]>(...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }
|
||||
@@ -2261,6 +2253,16 @@ declare module "typescript" {
|
||||
>getCompilerHost : () => CompilerHost
|
||||
>CompilerHost : CompilerHost
|
||||
|
||||
getTypeCheckerDiagnostics(sourceFile?: SourceFile): Diagnostic[];␍
|
||||
>getTypeCheckerDiagnostics : (sourceFile?: SourceFile) => Diagnostic[]
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
getTypeCheckerGlobalDiagnostics(): Diagnostic[];␍
|
||||
>getTypeCheckerGlobalDiagnostics : () => Diagnostic[]
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
getDiagnostics(sourceFile?: SourceFile): Diagnostic[];␍
|
||||
>getDiagnostics : (sourceFile?: SourceFile) => Diagnostic[]
|
||||
>sourceFile : SourceFile
|
||||
@@ -2411,16 +2413,6 @@ declare module "typescript" {
|
||||
>getEmitResolver : () => EmitResolver
|
||||
>EmitResolver : EmitResolver
|
||||
|
||||
getDiagnostics(sourceFile?: SourceFile): Diagnostic[];␍
|
||||
>getDiagnostics : (sourceFile?: SourceFile) => Diagnostic[]
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
getGlobalDiagnostics(): Diagnostic[];␍
|
||||
>getGlobalDiagnostics : () => Diagnostic[]
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type;␍
|
||||
>getTypeOfSymbolAtLocation : (symbol: Symbol, node: Node) => Type
|
||||
>symbol : Symbol
|
||||
|
||||
@@ -770,6 +770,8 @@ declare module "typescript" {
|
||||
interface Program extends ScriptReferenceHost {
|
||||
getSourceFiles(): SourceFile[];
|
||||
getCompilerHost(): CompilerHost;
|
||||
getTypeCheckerDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getTypeCheckerGlobalDiagnostics(): Diagnostic[];
|
||||
getDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getGlobalDiagnostics(): Diagnostic[];
|
||||
getDeclarationDiagnostics(sourceFile: SourceFile): Diagnostic[];
|
||||
@@ -818,8 +820,6 @@ declare module "typescript" {
|
||||
}
|
||||
interface TypeChecker {
|
||||
getEmitResolver(): EmitResolver;
|
||||
getDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getGlobalDiagnostics(): Diagnostic[];
|
||||
getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type;
|
||||
getDeclaredTypeOfSymbol(symbol: Symbol): Type;
|
||||
getPropertiesOfType(type: Type): Symbol[];
|
||||
|
||||
@@ -2391,6 +2391,16 @@ declare module "typescript" {
|
||||
>getCompilerHost : () => CompilerHost
|
||||
>CompilerHost : CompilerHost
|
||||
|
||||
getTypeCheckerDiagnostics(sourceFile?: SourceFile): Diagnostic[];␍
|
||||
>getTypeCheckerDiagnostics : (sourceFile?: SourceFile) => Diagnostic[]
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
getTypeCheckerGlobalDiagnostics(): Diagnostic[];␍
|
||||
>getTypeCheckerGlobalDiagnostics : () => Diagnostic[]
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
getDiagnostics(sourceFile?: SourceFile): Diagnostic[];␍
|
||||
>getDiagnostics : (sourceFile?: SourceFile) => Diagnostic[]
|
||||
>sourceFile : SourceFile
|
||||
@@ -2541,16 +2551,6 @@ declare module "typescript" {
|
||||
>getEmitResolver : () => EmitResolver
|
||||
>EmitResolver : EmitResolver
|
||||
|
||||
getDiagnostics(sourceFile?: SourceFile): Diagnostic[];␍
|
||||
>getDiagnostics : (sourceFile?: SourceFile) => Diagnostic[]
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
getGlobalDiagnostics(): Diagnostic[];␍
|
||||
>getGlobalDiagnostics : () => Diagnostic[]
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type;␍
|
||||
>getTypeOfSymbolAtLocation : (symbol: Symbol, node: Node) => Type
|
||||
>symbol : Symbol
|
||||
|
||||
@@ -49,8 +49,7 @@ function transform(contents: string, compilerOptions: ts.CompilerOptions = {}) {
|
||||
// Do not generate code in the presence of early errors
|
||||
if (!errors.length) {
|
||||
// Type check and get semantic errors
|
||||
var checker = program.getTypeChecker(true);
|
||||
errors = checker.getDiagnostics();
|
||||
errors = program.getTypeCheckerDiagnostics();
|
||||
// Generate output
|
||||
program.emitFiles();
|
||||
}
|
||||
@@ -771,6 +770,8 @@ declare module "typescript" {
|
||||
interface Program extends ScriptReferenceHost {
|
||||
getSourceFiles(): SourceFile[];
|
||||
getCompilerHost(): CompilerHost;
|
||||
getTypeCheckerDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getTypeCheckerGlobalDiagnostics(): Diagnostic[];
|
||||
getDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getGlobalDiagnostics(): Diagnostic[];
|
||||
getDeclarationDiagnostics(sourceFile: SourceFile): Diagnostic[];
|
||||
@@ -819,8 +820,6 @@ declare module "typescript" {
|
||||
}
|
||||
interface TypeChecker {
|
||||
getEmitResolver(): EmitResolver;
|
||||
getDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getGlobalDiagnostics(): Diagnostic[];
|
||||
getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type;
|
||||
getDeclaredTypeOfSymbol(symbol: Symbol): Type;
|
||||
getPropertiesOfType(type: Type): Symbol[];
|
||||
@@ -1974,8 +1973,7 @@ function transform(contents, compilerOptions) {
|
||||
// Do not generate code in the presence of early errors
|
||||
if (!errors.length) {
|
||||
// Type check and get semantic errors
|
||||
var checker = program.getTypeChecker(true);
|
||||
errors = checker.getDiagnostics();
|
||||
errors = program.getTypeCheckerDiagnostics();
|
||||
// Generate output
|
||||
program.emitFiles();
|
||||
}
|
||||
|
||||
@@ -162,20 +162,13 @@ function transform(contents: string, compilerOptions: ts.CompilerOptions = {}) {
|
||||
>length : number
|
||||
|
||||
// Type check and get semantic errors
|
||||
var checker = program.getTypeChecker(true);
|
||||
>checker : ts.TypeChecker
|
||||
>program.getTypeChecker(true) : ts.TypeChecker
|
||||
>program.getTypeChecker : (produceDiagnostics: boolean) => ts.TypeChecker
|
||||
>program : ts.Program
|
||||
>getTypeChecker : (produceDiagnostics: boolean) => ts.TypeChecker
|
||||
|
||||
errors = checker.getDiagnostics();
|
||||
>errors = checker.getDiagnostics() : ts.Diagnostic[]
|
||||
errors = program.getTypeCheckerDiagnostics();
|
||||
>errors = program.getTypeCheckerDiagnostics() : ts.Diagnostic[]
|
||||
>errors : ts.Diagnostic[]
|
||||
>checker.getDiagnostics() : ts.Diagnostic[]
|
||||
>checker.getDiagnostics : (sourceFile?: ts.SourceFile) => ts.Diagnostic[]
|
||||
>checker : ts.TypeChecker
|
||||
>getDiagnostics : (sourceFile?: ts.SourceFile) => ts.Diagnostic[]
|
||||
>program.getTypeCheckerDiagnostics() : ts.Diagnostic[]
|
||||
>program.getTypeCheckerDiagnostics : (sourceFile?: ts.SourceFile) => ts.Diagnostic[]
|
||||
>program : ts.Program
|
||||
>getTypeCheckerDiagnostics : (sourceFile?: ts.SourceFile) => ts.Diagnostic[]
|
||||
|
||||
// Generate output
|
||||
program.emitFiles();
|
||||
@@ -2339,6 +2332,16 @@ declare module "typescript" {
|
||||
>getCompilerHost : () => CompilerHost
|
||||
>CompilerHost : CompilerHost
|
||||
|
||||
getTypeCheckerDiagnostics(sourceFile?: SourceFile): Diagnostic[];␍
|
||||
>getTypeCheckerDiagnostics : (sourceFile?: SourceFile) => Diagnostic[]
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
getTypeCheckerGlobalDiagnostics(): Diagnostic[];␍
|
||||
>getTypeCheckerGlobalDiagnostics : () => Diagnostic[]
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
getDiagnostics(sourceFile?: SourceFile): Diagnostic[];␍
|
||||
>getDiagnostics : (sourceFile?: SourceFile) => Diagnostic[]
|
||||
>sourceFile : SourceFile
|
||||
@@ -2489,16 +2492,6 @@ declare module "typescript" {
|
||||
>getEmitResolver : () => EmitResolver
|
||||
>EmitResolver : EmitResolver
|
||||
|
||||
getDiagnostics(sourceFile?: SourceFile): Diagnostic[];␍
|
||||
>getDiagnostics : (sourceFile?: SourceFile) => Diagnostic[]
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
getGlobalDiagnostics(): Diagnostic[];␍
|
||||
>getGlobalDiagnostics : () => Diagnostic[]
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type;␍
|
||||
>getTypeOfSymbolAtLocation : (symbol: Symbol, node: Node) => Type
|
||||
>symbol : Symbol
|
||||
|
||||
@@ -808,6 +808,8 @@ declare module "typescript" {
|
||||
interface Program extends ScriptReferenceHost {
|
||||
getSourceFiles(): SourceFile[];
|
||||
getCompilerHost(): CompilerHost;
|
||||
getTypeCheckerDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getTypeCheckerGlobalDiagnostics(): Diagnostic[];
|
||||
getDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getGlobalDiagnostics(): Diagnostic[];
|
||||
getDeclarationDiagnostics(sourceFile: SourceFile): Diagnostic[];
|
||||
@@ -856,8 +858,6 @@ declare module "typescript" {
|
||||
}
|
||||
interface TypeChecker {
|
||||
getEmitResolver(): EmitResolver;
|
||||
getDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getGlobalDiagnostics(): Diagnostic[];
|
||||
getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type;
|
||||
getDeclaredTypeOfSymbol(symbol: Symbol): Type;
|
||||
getPropertiesOfType(type: Type): Symbol[];
|
||||
|
||||
@@ -2517,6 +2517,16 @@ declare module "typescript" {
|
||||
>getCompilerHost : () => CompilerHost
|
||||
>CompilerHost : CompilerHost
|
||||
|
||||
getTypeCheckerDiagnostics(sourceFile?: SourceFile): Diagnostic[];␍
|
||||
>getTypeCheckerDiagnostics : (sourceFile?: SourceFile) => Diagnostic[]
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
getTypeCheckerGlobalDiagnostics(): Diagnostic[];␍
|
||||
>getTypeCheckerGlobalDiagnostics : () => Diagnostic[]
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
getDiagnostics(sourceFile?: SourceFile): Diagnostic[];␍
|
||||
>getDiagnostics : (sourceFile?: SourceFile) => Diagnostic[]
|
||||
>sourceFile : SourceFile
|
||||
@@ -2667,16 +2677,6 @@ declare module "typescript" {
|
||||
>getEmitResolver : () => EmitResolver
|
||||
>EmitResolver : EmitResolver
|
||||
|
||||
getDiagnostics(sourceFile?: SourceFile): Diagnostic[];␍
|
||||
>getDiagnostics : (sourceFile?: SourceFile) => Diagnostic[]
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
getGlobalDiagnostics(): Diagnostic[];␍
|
||||
>getGlobalDiagnostics : () => Diagnostic[]
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type;␍
|
||||
>getTypeOfSymbolAtLocation : (symbol: Symbol, node: Node) => Type
|
||||
>symbol : Symbol
|
||||
|
||||
@@ -16,11 +16,10 @@ import ts = require("typescript");
|
||||
export function compile(fileNames: string[], options: ts.CompilerOptions): void {
|
||||
var host = ts.createCompilerHost(options);
|
||||
var program = ts.createProgram(fileNames, options, host);
|
||||
var checker = ts.createTypeChecker(program, /*produceDiagnostics*/ true);
|
||||
var result = program.emitFiles();
|
||||
|
||||
var allDiagnostics = program.getDiagnostics()
|
||||
.concat(checker.getDiagnostics())
|
||||
.concat(program.getTypeCheckerDiagnostics())
|
||||
.concat(result.diagnostics);
|
||||
|
||||
allDiagnostics.forEach(diagnostic => {
|
||||
|
||||
@@ -49,8 +49,7 @@ function transform(contents: string, compilerOptions: ts.CompilerOptions = {}) {
|
||||
// Do not generate code in the presence of early errors
|
||||
if (!errors.length) {
|
||||
// Type check and get semantic errors
|
||||
var checker = program.getTypeChecker(true);
|
||||
errors = checker.getDiagnostics();
|
||||
errors = program.getTypeCheckerDiagnostics();
|
||||
// Generate output
|
||||
program.emitFiles();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user