mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Change the API for getting diagnostics so that all calls go through a Program instance.
This commit is contained in:
@@ -10111,11 +10111,6 @@ module ts {
|
||||
return isImportResolvedToValue(getSymbolOfNode(node));
|
||||
}
|
||||
|
||||
function hasSemanticDiagnostics(sourceFile?: SourceFile) {
|
||||
// Return true if there is any semantic error in a file or globally
|
||||
return getDiagnostics(sourceFile).length > 0 || getGlobalDiagnostics().length > 0;
|
||||
}
|
||||
|
||||
function isImportResolvedToValue(symbol: Symbol): boolean {
|
||||
var target = resolveImport(symbol);
|
||||
// const enums and modules that contain only const enums are not considered values from the emit perespective
|
||||
@@ -10210,7 +10205,6 @@ module ts {
|
||||
getNodeCheckFlags,
|
||||
getEnumMemberValue,
|
||||
isTopLevelValueImportWithEntityName,
|
||||
hasSemanticDiagnostics,
|
||||
isDeclarationVisible,
|
||||
isImplementationOfOverload,
|
||||
writeTypeOfDeclaration,
|
||||
@@ -10226,14 +10220,15 @@ module ts {
|
||||
// Bind all source files and propagate errors
|
||||
forEach(host.getSourceFiles(), file => {
|
||||
bindSourceFile(file);
|
||||
forEach(file.bindDiagnostics, d => diagnostics.add(d));
|
||||
});
|
||||
|
||||
// Initialize global symbol table
|
||||
forEach(host.getSourceFiles(), file => {
|
||||
if (!isExternalModule(file)) {
|
||||
extendSymbolTable(globals, file.locals);
|
||||
}
|
||||
});
|
||||
|
||||
// Initialize special symbols
|
||||
getSymbolLinks(undefinedSymbol).type = undefinedType;
|
||||
getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments");
|
||||
|
||||
@@ -118,6 +118,12 @@ module ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function addRange<T>(to: T[], from: T[]): void {
|
||||
for (var i = 0, n = from.length; i < n; i++) {
|
||||
to.push(from[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last element of an array if non-empty, undefined otherwise.
|
||||
*/
|
||||
@@ -369,6 +375,10 @@ module ts {
|
||||
return text1 ? 1 : -1;
|
||||
}
|
||||
|
||||
export function sortAndDeduplicateDiagnostics(diagnostics: Diagnostic[]): Diagnostic[] {
|
||||
return deduplicateSortedDiagnostics(diagnostics.sort(compareDiagnostics));
|
||||
}
|
||||
|
||||
export function deduplicateSortedDiagnostics(diagnostics: Diagnostic[]): Diagnostic[] {
|
||||
if (diagnostics.length < 2) {
|
||||
return diagnostics;
|
||||
|
||||
+11
-12
@@ -4395,13 +4395,13 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
var hasSemanticDiagnostics = false;
|
||||
var isEmitBlocked = false;
|
||||
var isDeclarationEmitBlocked = false;
|
||||
|
||||
if (targetSourceFile === undefined) {
|
||||
// No targetSourceFile is specified (e.g. calling emitter from batch compiler)
|
||||
hasSemanticDiagnostics = resolver.hasSemanticDiagnostics();
|
||||
isEmitBlocked = host.isEmitBlocked();
|
||||
isDeclarationEmitBlocked = host.isDeclarationEmitBlocked();
|
||||
|
||||
forEach(host.getSourceFiles(), sourceFile => {
|
||||
if (shouldEmitToOwnFile(sourceFile, compilerOptions)) {
|
||||
@@ -4418,8 +4418,8 @@ module ts {
|
||||
// targetSourceFile is specified (e.g calling emitter from language service or calling getSemanticDiagnostic from language service)
|
||||
if (shouldEmitToOwnFile(targetSourceFile, compilerOptions)) {
|
||||
// If shouldEmitToOwnFile returns true or targetSourceFile is an external module file, then emit targetSourceFile in its own output file
|
||||
hasSemanticDiagnostics = resolver.hasSemanticDiagnostics(targetSourceFile);
|
||||
isEmitBlocked = host.isEmitBlocked(targetSourceFile);
|
||||
isDeclarationEmitBlocked = host.isDeclarationEmitBlocked(targetSourceFile);
|
||||
|
||||
var jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, ".js");
|
||||
emitFile(jsFilePath, targetSourceFile);
|
||||
@@ -4429,8 +4429,8 @@ module ts {
|
||||
// Emit all, non-external-module file, into one single output file
|
||||
forEach(host.getSourceFiles(), sourceFile => {
|
||||
if (!shouldEmitToOwnFile(sourceFile, compilerOptions)) {
|
||||
hasSemanticDiagnostics = hasSemanticDiagnostics || resolver.hasSemanticDiagnostics(sourceFile);
|
||||
isEmitBlocked = isEmitBlocked || host.isEmitBlocked(sourceFile);
|
||||
isDeclarationEmitBlocked = isDeclarationEmitBlocked || host.isDeclarationEmitBlocked(sourceFile);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -4441,15 +4441,14 @@ module ts {
|
||||
function emitFile(jsFilePath: string, sourceFile?: SourceFile) {
|
||||
if (!isEmitBlocked) {
|
||||
emitJavaScript(jsFilePath, sourceFile);
|
||||
if (!hasSemanticDiagnostics && compilerOptions.declaration) {
|
||||
if (!isDeclarationEmitBlocked && compilerOptions.declaration) {
|
||||
writeDeclarationFile(jsFilePath, sourceFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sort and make the unique list of diagnostics
|
||||
diagnostics.sort(compareDiagnostics);
|
||||
diagnostics = deduplicateSortedDiagnostics(diagnostics);
|
||||
diagnostics = sortAndDeduplicateDiagnostics(diagnostics);
|
||||
|
||||
// Update returnCode if there is any EmitterError
|
||||
var hasEmitterError = forEach(diagnostics, diagnostic => diagnostic.category === DiagnosticCategory.Error);
|
||||
@@ -4457,13 +4456,13 @@ module ts {
|
||||
// Check and update returnCode for syntactic and semantic
|
||||
var emitResultStatus: EmitReturnStatus;
|
||||
if (isEmitBlocked) {
|
||||
emitResultStatus = EmitReturnStatus.AllOutputGenerationSkipped;
|
||||
emitResultStatus = EmitReturnStatus.DiagnosticsPresent_AllOutputsSkipped;
|
||||
} else if (hasEmitterError) {
|
||||
emitResultStatus = EmitReturnStatus.EmitErrorsEncountered;
|
||||
} else if (hasSemanticDiagnostics && compilerOptions.declaration) {
|
||||
emitResultStatus = EmitReturnStatus.DeclarationGenerationSkipped;
|
||||
} else if (hasSemanticDiagnostics && !compilerOptions.declaration) {
|
||||
emitResultStatus = EmitReturnStatus.JSGeneratedWithSemanticErrors;
|
||||
} else if (isDeclarationEmitBlocked && compilerOptions.declaration) {
|
||||
emitResultStatus = EmitReturnStatus.DiagnosticsPresent_JavaScriptGenerated_DeclarationNotGenerated;
|
||||
} else if (isDeclarationEmitBlocked && !compilerOptions.declaration) {
|
||||
emitResultStatus = EmitReturnStatus.DiagnosticsPresent_JavaScriptGenerated;
|
||||
} else {
|
||||
emitResultStatus = EmitReturnStatus.Succeeded;
|
||||
}
|
||||
|
||||
@@ -357,7 +357,7 @@ module ts {
|
||||
forEachChild(sourceFile, walk);
|
||||
}
|
||||
|
||||
export function getSyntacticDiagnostics(sourceFile: SourceFile) {
|
||||
export function getSyntacticDiagnostics(sourceFile: SourceFile): Diagnostic[] {
|
||||
if (!sourceFile.syntacticDiagnostics) {
|
||||
sourceFile.syntacticDiagnostics = sourceFile.referenceDiagnostics.concat(sourceFile.parseDiagnostics);
|
||||
}
|
||||
|
||||
+87
-18
@@ -75,6 +75,37 @@ module ts {
|
||||
};
|
||||
}
|
||||
|
||||
export function getPreEmitDiagnostics(program: Program): Diagnostic[] {
|
||||
var diagnostics = program.getSyntacticDiagnostics().concat(program.getGlobalDiagnostics()).concat(program.getSemanticDiagnostics());
|
||||
return sortAndDeduplicateDiagnostics(diagnostics);
|
||||
}
|
||||
|
||||
export function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string {
|
||||
if (typeof messageText === "string") {
|
||||
return messageText;
|
||||
}
|
||||
else {
|
||||
var diagnosticChain = messageText;
|
||||
var result = "";
|
||||
|
||||
var indent = 0;
|
||||
while (diagnosticChain) {
|
||||
if (indent) {
|
||||
result += newLine;
|
||||
|
||||
for (var i = 0; i < indent; i++) {
|
||||
result += " ";
|
||||
}
|
||||
}
|
||||
result += diagnosticChain.messageText;
|
||||
indent++;
|
||||
diagnosticChain = diagnosticChain.next;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
export function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program {
|
||||
var program: Program;
|
||||
var files: SourceFile[] = [];
|
||||
@@ -97,10 +128,9 @@ module ts {
|
||||
getSourceFile: getSourceFile,
|
||||
getSourceFiles: () => files,
|
||||
getCompilerOptions: () => options,
|
||||
getDiagnostics,
|
||||
getSyntacticDiagnostics,
|
||||
getGlobalDiagnostics,
|
||||
getTypeCheckerDiagnostics,
|
||||
getTypeCheckerGlobalDiagnostics,
|
||||
getSemanticDiagnostics,
|
||||
getDeclarationDiagnostics,
|
||||
getTypeChecker,
|
||||
getDiagnosticsProducingTypeChecker,
|
||||
@@ -116,7 +146,7 @@ module ts {
|
||||
};
|
||||
return program;
|
||||
|
||||
function getEmitHost(writeFileCallback?: WriteFileCallback) {
|
||||
function getEmitHost(writeFileCallback?: WriteFileCallback): EmitHost {
|
||||
return {
|
||||
getCanonicalFileName: host.getCanonicalFileName,
|
||||
getCommonSourceDirectory: program.getCommonSourceDirectory,
|
||||
@@ -126,17 +156,28 @@ module ts {
|
||||
getSourceFile: program.getSourceFile,
|
||||
getSourceFiles: program.getSourceFiles,
|
||||
isEmitBlocked,
|
||||
isDeclarationEmitBlocked,
|
||||
writeFile: writeFileCallback || host.writeFile,
|
||||
};
|
||||
}
|
||||
|
||||
function hasPreEmitDiagnostics(sourceFile?: SourceFile): boolean {
|
||||
var hasSyntacticDiagnostics = program.getSyntacticDiagnostics(sourceFile).length > 0;
|
||||
var hasSemanticDiagnostics = program.getSemanticDiagnostics(sourceFile).length > 0;
|
||||
|
||||
function isEmitBlocked(sourceFile?: SourceFile): boolean {
|
||||
if (options.noEmitOnError) {
|
||||
return getDiagnostics(sourceFile).length !== 0 || getTypeCheckerDiagnostics(sourceFile).length !== 0;
|
||||
if (hasSyntacticDiagnostics || hasSemanticDiagnostics) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return !sourceFile && program.getGlobalDiagnostics().length > 0;
|
||||
}
|
||||
|
||||
function isEmitBlocked(sourceFile?: SourceFile): boolean {
|
||||
return options.noEmitOnError && hasPreEmitDiagnostics(sourceFile);
|
||||
}
|
||||
|
||||
function isDeclarationEmitBlocked(sourceFile?: SourceFile) {
|
||||
return hasPreEmitDiagnostics(sourceFile);
|
||||
}
|
||||
|
||||
function getDiagnosticsProducingTypeChecker() {
|
||||
@@ -170,20 +211,51 @@ module ts {
|
||||
return hasProperty(filesByName, fileName) ? filesByName[fileName] : undefined;
|
||||
}
|
||||
|
||||
function getTypeCheckerDiagnostics(sourceFile?: SourceFile): Diagnostic[] {
|
||||
return getDiagnosticsProducingTypeChecker().getDiagnostics(sourceFile);
|
||||
function getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[] {
|
||||
if (sourceFile) {
|
||||
return ts.getSyntacticDiagnostics(sourceFile);
|
||||
}
|
||||
|
||||
var allDiagnostics: Diagnostic[] = [];
|
||||
forEach(program.getSourceFiles(), sourceFile => {
|
||||
addRange(allDiagnostics, ts.getSyntacticDiagnostics(sourceFile));
|
||||
});
|
||||
|
||||
return sortAndDeduplicateDiagnostics(allDiagnostics);
|
||||
}
|
||||
|
||||
function getTypeCheckerGlobalDiagnostics(): Diagnostic[] {
|
||||
return getDiagnosticsProducingTypeChecker().getGlobalDiagnostics();
|
||||
function getSemanticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] {
|
||||
var typeChecker = getDiagnosticsProducingTypeChecker();
|
||||
|
||||
Debug.assert(!!sourceFile.bindDiagnostics);
|
||||
var bindDiagnostics = sourceFile.bindDiagnostics;
|
||||
var checkDiagnostics = typeChecker.getDiagnostics(sourceFile);
|
||||
var programDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName);
|
||||
|
||||
return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics);
|
||||
}
|
||||
|
||||
function getDiagnostics(sourceFile?: SourceFile): Diagnostic[]{
|
||||
return sourceFile ? diagnostics.getDiagnostics(sourceFile.fileName) : diagnostics.getDiagnostics();
|
||||
function getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[] {
|
||||
if (sourceFile) {
|
||||
return sortAndDeduplicateDiagnostics(getSemanticDiagnosticsForFile(sourceFile));
|
||||
}
|
||||
|
||||
var allDiagnostics: Diagnostic[] = [];
|
||||
forEach(program.getSourceFiles(), sourceFile => {
|
||||
addRange(allDiagnostics, getSemanticDiagnosticsForFile(sourceFile));
|
||||
});
|
||||
|
||||
return sortAndDeduplicateDiagnostics(allDiagnostics);
|
||||
}
|
||||
|
||||
function getGlobalDiagnostics(): Diagnostic[]{
|
||||
return diagnostics.getGlobalDiagnostics();
|
||||
var typeChecker = getDiagnosticsProducingTypeChecker();
|
||||
|
||||
var allDiagnostics: Diagnostic[] = [];
|
||||
addRange(allDiagnostics, typeChecker.getGlobalDiagnostics());
|
||||
addRange(allDiagnostics, diagnostics.getGlobalDiagnostics());
|
||||
|
||||
return sortAndDeduplicateDiagnostics(allDiagnostics);
|
||||
}
|
||||
|
||||
function hasExtension(fileName: string): boolean {
|
||||
@@ -272,9 +344,6 @@ module ts {
|
||||
else {
|
||||
files.push(file);
|
||||
}
|
||||
forEach(getSyntacticDiagnostics(file), e => {
|
||||
diagnostics.add(e);
|
||||
});
|
||||
}
|
||||
}
|
||||
return file;
|
||||
|
||||
+9
-3
@@ -364,13 +364,19 @@ module ts {
|
||||
|
||||
function compileProgram(): EmitReturnStatus {
|
||||
// First get any syntactic errors.
|
||||
var errors = program.getDiagnostics();
|
||||
var errors = program.getSyntacticDiagnostics();
|
||||
reportDiagnostics(errors);
|
||||
|
||||
// If we didn't have any syntactic errors, then also try getting the semantic errors.
|
||||
// If we didn't have any syntactic errors, then also try getting the global and
|
||||
// semantic errors.
|
||||
if (errors.length === 0) {
|
||||
var errors = program.getTypeCheckerDiagnostics();
|
||||
var errors = program.getGlobalDiagnostics();
|
||||
reportDiagnostics(errors);
|
||||
|
||||
if (errors.length === 0) {
|
||||
var errors = program.getSemanticDiagnostics();
|
||||
reportDiagnostics(errors);
|
||||
}
|
||||
}
|
||||
|
||||
// If the user doesn't want us to emit, then we're done at this point.
|
||||
|
||||
+23
-13
@@ -946,13 +946,10 @@ module ts {
|
||||
*/
|
||||
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult;
|
||||
|
||||
// These will merge with the below diagnostics function in a followup checkin.
|
||||
getTypeCheckerDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getTypeCheckerGlobalDiagnostics(): Diagnostic[];
|
||||
|
||||
getDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getGlobalDiagnostics(): Diagnostic[];
|
||||
getDeclarationDiagnostics(sourceFile: SourceFile): Diagnostic[];
|
||||
getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
|
||||
// Gets a type checker that can be used to semantically analyze source fils in the program.
|
||||
getTypeChecker(): TypeChecker;
|
||||
@@ -992,12 +989,26 @@ module ts {
|
||||
|
||||
// Return code used by getEmitOutput function to indicate status of the function
|
||||
export enum EmitReturnStatus {
|
||||
Succeeded = 0, // All outputs generated if requested (.js, .map, .d.ts), no errors reported
|
||||
AllOutputGenerationSkipped = 1, // No .js generated because of syntax errors, nothing generated
|
||||
JSGeneratedWithSemanticErrors = 2, // .js and .map generated with semantic errors
|
||||
DeclarationGenerationSkipped = 3, // .d.ts generation skipped because of semantic errors or declaration emitter specific errors; Output .js with semantic errors
|
||||
EmitErrorsEncountered = 4, // Emitter errors occurred during emitting process
|
||||
CompilerOptionsErrors = 5, // Errors occurred in parsing compiler options, nothing generated
|
||||
// All outputs generated if requested (.js, .map, .d.ts), no errors reported
|
||||
Succeeded = 0,
|
||||
|
||||
// No .js, .map or d.ts generated because of diagnostics and the presence of the
|
||||
// -noEmitOnError optoin.
|
||||
DiagnosticsPresent_AllOutputsSkipped = 1,
|
||||
|
||||
// .js and .map generated. However, diagnostics were generated as well.
|
||||
// No .d.ts was requested or generated.
|
||||
DiagnosticsPresent_JavaScriptGenerated = 2,
|
||||
|
||||
// .js, .map generated. .d.ts was requested but was not generated due to the
|
||||
// presence of diagnostics.
|
||||
DiagnosticsPresent_JavaScriptGenerated_DeclarationNotGenerated = 3,
|
||||
|
||||
// Emitter errors occurred during emitting process.
|
||||
EmitErrorsEncountered = 4,
|
||||
|
||||
// Errors occurred in parsing compiler options, nothing generated
|
||||
CompilerOptionsErrors = 5,
|
||||
}
|
||||
|
||||
export interface EmitResult {
|
||||
@@ -1137,7 +1148,6 @@ module ts {
|
||||
isTopLevelValueImportWithEntityName(node: ImportDeclaration): boolean;
|
||||
getNodeCheckFlags(node: Node): NodeCheckFlags;
|
||||
getEnumMemberValue(node: EnumMember): number;
|
||||
hasSemanticDiagnostics(sourceFile?: SourceFile): boolean;
|
||||
isDeclarationVisible(node: Declaration): boolean;
|
||||
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean;
|
||||
writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
|
||||
|
||||
@@ -25,7 +25,9 @@ module ts {
|
||||
|
||||
export interface EmitHost extends ScriptReferenceHost {
|
||||
getSourceFiles(): SourceFile[];
|
||||
|
||||
isEmitBlocked(sourceFile?: SourceFile): boolean;
|
||||
isDeclarationEmitBlocked(sourceFile?: SourceFile): boolean;
|
||||
|
||||
getCommonSourceDirectory(): string;
|
||||
getCanonicalFileName(fileName: string): string;
|
||||
@@ -210,36 +212,10 @@ module ts {
|
||||
length,
|
||||
code: messageChain.code,
|
||||
category: messageChain.category,
|
||||
messageText: messageChain
|
||||
messageText: messageChain.next ? messageChain : messageChain.messageText
|
||||
};
|
||||
}
|
||||
|
||||
export function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string {
|
||||
if (typeof messageText === "string") {
|
||||
return messageText;
|
||||
}
|
||||
else {
|
||||
var diagnosticChain = messageText;
|
||||
var result = "";
|
||||
|
||||
var indent = 0;
|
||||
while (diagnosticChain) {
|
||||
if (indent) {
|
||||
result += newLine;
|
||||
|
||||
for (var i = 0; i < indent; i++) {
|
||||
result += " ";
|
||||
}
|
||||
}
|
||||
result += diagnosticChain.messageText;
|
||||
indent++;
|
||||
diagnosticChain = diagnosticChain.next;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
export function getErrorSpanForNode(node: Node): Node {
|
||||
var errorSpan: Node;
|
||||
switch (node.kind) {
|
||||
@@ -1144,7 +1120,7 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
return sortAndDeplicateList(allDiagnostics);
|
||||
return sortAndDeduplicateDiagnostics(allDiagnostics);
|
||||
}
|
||||
|
||||
function sortAndDeduplicate() {
|
||||
@@ -1153,17 +1129,13 @@ module ts {
|
||||
}
|
||||
|
||||
diagnosticsModified = false;
|
||||
nonFileDiagnostics = sortAndDeplicateList(nonFileDiagnostics);
|
||||
nonFileDiagnostics = sortAndDeduplicateDiagnostics(nonFileDiagnostics);
|
||||
|
||||
for (var key in fileDiagnostics) {
|
||||
if (hasProperty(fileDiagnostics, key)) {
|
||||
fileDiagnostics[key] = sortAndDeplicateList(fileDiagnostics[key]);
|
||||
fileDiagnostics[key] = sortAndDeduplicateDiagnostics(fileDiagnostics[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function sortAndDeplicateList(diagnostics: Diagnostic[]): Diagnostic[] {
|
||||
return deduplicateSortedDiagnostics(diagnostics.sort(compareDiagnostics))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1142,14 +1142,23 @@ module FourSlash {
|
||||
var emitOutput = this.languageService.getEmitOutput(emitFile.fileName);
|
||||
var emitOutputStatus = emitOutput.emitOutputStatus;
|
||||
// Print emitOutputStatus in readable format
|
||||
resultString += "EmitOutputStatus : " + ts.EmitReturnStatus[emitOutputStatus];
|
||||
resultString += "\n";
|
||||
resultString += "EmitOutputStatus : " + ts.EmitReturnStatus[emitOutputStatus] + ts.sys.newLine;
|
||||
|
||||
if (emitOutputStatus !== ts.EmitReturnStatus.Succeeded) {
|
||||
resultString += "Diagnostics:" + ts.sys.newLine;
|
||||
var diagnostics = ts.getPreEmitDiagnostics(this.languageService.getProgram());
|
||||
for (var i = 0, n = diagnostics.length; i < n; i++) {
|
||||
resultString += " " + diagnostics[0].messageText + ts.sys.newLine;
|
||||
}
|
||||
}
|
||||
|
||||
emitOutput.outputFiles.forEach((outputFile, idx, array) => {
|
||||
var fileName = "FileName : " + outputFile.name + "\n";
|
||||
var fileName = "FileName : " + outputFile.name + ts.sys.newLine;
|
||||
resultString = resultString + fileName + outputFile.text;
|
||||
});
|
||||
resultString += "\n";
|
||||
resultString += ts.sys.newLine;
|
||||
});
|
||||
|
||||
return resultString;
|
||||
},
|
||||
true /* run immediately */);
|
||||
@@ -2215,11 +2224,11 @@ module FourSlash {
|
||||
ts.sys.useCaseSensitiveFileNames);
|
||||
// TODO (drosen): We need to enforce checking on these tests.
|
||||
var program = ts.createProgram([Harness.Compiler.fourslashFileName, fileName], { out: "fourslashTestOutput.js", noResolve: true, target: ts.ScriptTarget.ES3 }, host);
|
||||
var checker = ts.createTypeChecker(program, /*produceDiagnostics*/ true);
|
||||
|
||||
var errors = program.getDiagnostics().concat(checker.getDiagnostics());
|
||||
if (errors.length > 0) {
|
||||
throw new Error('Error compiling ' + fileName + ': ' + errors.map(e => ts.flattenDiagnosticMessageText(e.messageText, ts.sys.newLine)).join('\r\n'));
|
||||
var diagnostics = ts.getPreEmitDiagnostics(program);
|
||||
if (diagnostics.length > 0) {
|
||||
throw new Error('Error compiling ' + fileName + ': ' +
|
||||
diagnostics.map(e => ts.flattenDiagnosticMessageText(e.messageText, ts.sys.newLine)).join('\r\n'));
|
||||
}
|
||||
program.emit();
|
||||
result = result || ''; // Might have an empty fourslash file
|
||||
|
||||
@@ -1083,10 +1083,11 @@ module Harness {
|
||||
(fn, contents, writeByteOrderMark) => fileOutputs.push({ fileName: fn, code: contents, writeByteOrderMark: writeByteOrderMark }),
|
||||
options.target, useCaseSensitiveFileNames, currentDirectory));
|
||||
|
||||
debugger;
|
||||
var emitResult = program.emit();
|
||||
|
||||
var errors: HarnessDiagnostic[] = [];
|
||||
program.getDiagnostics().concat(program.getTypeCheckerDiagnostics()).concat(emitResult.diagnostics).forEach(err => {
|
||||
ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics).forEach(err => {
|
||||
// TODO: new compiler formats errors after this point to add . and newlines so we'll just do it manually for now
|
||||
errors.push(getMinimalDiagnostic(err));
|
||||
});
|
||||
|
||||
@@ -127,23 +127,20 @@ class ProjectRunner extends RunnerBase {
|
||||
writeFile: (fileName: string, data: string, writeByteOrderMark: boolean) => void): CompileProjectFilesResult {
|
||||
|
||||
var program = ts.createProgram(getInputFiles(), createCompilerOptions(), createCompilerHost());
|
||||
var errors = program.getDiagnostics();
|
||||
var sourceMapData: ts.SourceMapData[] = null;
|
||||
if (!errors.length) {
|
||||
errors = program.getTypeCheckerDiagnostics();
|
||||
var emitResult = program.emit();
|
||||
errors = ts.concatenate(errors, emitResult.diagnostics);
|
||||
sourceMapData = emitResult.sourceMaps;
|
||||
var errors = ts.getPreEmitDiagnostics(program);
|
||||
|
||||
// Clean up source map data that will be used in baselining
|
||||
if (sourceMapData) {
|
||||
for (var i = 0; i < sourceMapData.length; i++) {
|
||||
for (var j = 0; j < sourceMapData[i].sourceMapSources.length; j++) {
|
||||
sourceMapData[i].sourceMapSources[j] = cleanProjectUrl(sourceMapData[i].sourceMapSources[j]);
|
||||
}
|
||||
sourceMapData[i].jsSourceMappingURL = cleanProjectUrl(sourceMapData[i].jsSourceMappingURL);
|
||||
sourceMapData[i].sourceMapSourceRoot = cleanProjectUrl(sourceMapData[i].sourceMapSourceRoot);
|
||||
var emitResult = program.emit();
|
||||
errors = ts.concatenate(errors, emitResult.diagnostics);
|
||||
var sourceMapData = emitResult.sourceMaps;
|
||||
|
||||
// Clean up source map data that will be used in baselining
|
||||
if (sourceMapData) {
|
||||
for (var i = 0; i < sourceMapData.length; i++) {
|
||||
for (var j = 0; j < sourceMapData[i].sourceMapSources.length; j++) {
|
||||
sourceMapData[i].sourceMapSources[j] = cleanProjectUrl(sourceMapData[i].sourceMapSources[j]);
|
||||
}
|
||||
sourceMapData[i].jsSourceMappingURL = cleanProjectUrl(sourceMapData[i].jsSourceMappingURL);
|
||||
sourceMapData[i].sourceMapSourceRoot = cleanProjectUrl(sourceMapData[i].sourceMapSourceRoot);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2168,7 +2168,7 @@ module ts {
|
||||
|
||||
fileName = normalizeSlashes(fileName);
|
||||
|
||||
return program.getDiagnostics(getValidSourceFile(fileName));
|
||||
return program.getSyntacticDiagnostics(getValidSourceFile(fileName));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2179,18 +2179,19 @@ module ts {
|
||||
synchronizeHostData();
|
||||
|
||||
fileName = normalizeSlashes(fileName)
|
||||
var compilerOptions = program.getCompilerOptions();
|
||||
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 = 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));
|
||||
var semanticDiagnostics = program.getSemanticDiagnostics(targetSourceFile);
|
||||
if (!program.getCompilerOptions().declaration) {
|
||||
return semanticDiagnostics;
|
||||
}
|
||||
return allDiagnostics
|
||||
|
||||
// If '-d' is enabled, check for emitter error. One example of emitter error is export class implements non-export interface
|
||||
var declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile);
|
||||
return semanticDiagnostics.concat(declarationDiagnostics);
|
||||
}
|
||||
|
||||
function getCompilerOptionsDiagnostics() {
|
||||
|
||||
@@ -10,24 +10,23 @@
|
||||
|
||||
declare var process: any;
|
||||
declare var console: any;
|
||||
declare var os: any;
|
||||
|
||||
import ts = require("typescript");
|
||||
|
||||
export function compile(fileNames: string[], options: ts.CompilerOptions): void {
|
||||
var program = ts.createProgram(fileNames, options);
|
||||
var result = program.emit();
|
||||
var emitResult = program.emit();
|
||||
|
||||
var allDiagnostics = program.getDiagnostics()
|
||||
.concat(program.getTypeCheckerDiagnostics())
|
||||
.concat(result.diagnostics);
|
||||
var allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
||||
|
||||
allDiagnostics.forEach(diagnostic => {
|
||||
var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
|
||||
console.log(`${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${diagnostic.messageText}`);
|
||||
console.log(`${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`);
|
||||
});
|
||||
|
||||
console.log(`Process exiting with code '${result.emitResultStatus}'.`);
|
||||
process.exit(result.emitResultStatus);
|
||||
console.log(`Process exiting with code '${emitResult.emitResultStatus}'.`);
|
||||
process.exit(emitResult.emitResultStatus);
|
||||
}
|
||||
|
||||
compile(process.argv.slice(2), {
|
||||
@@ -752,11 +751,10 @@ declare module "typescript" {
|
||||
* will be invoked when writing the javascript and declaration files.
|
||||
*/
|
||||
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult;
|
||||
getTypeCheckerDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getTypeCheckerGlobalDiagnostics(): Diagnostic[];
|
||||
getDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getGlobalDiagnostics(): Diagnostic[];
|
||||
getDeclarationDiagnostics(sourceFile: SourceFile): Diagnostic[];
|
||||
getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getTypeChecker(): TypeChecker;
|
||||
getCommonSourceDirectory(): string;
|
||||
}
|
||||
@@ -781,9 +779,9 @@ declare module "typescript" {
|
||||
}
|
||||
enum EmitReturnStatus {
|
||||
Succeeded = 0,
|
||||
AllOutputGenerationSkipped = 1,
|
||||
JSGeneratedWithSemanticErrors = 2,
|
||||
DeclarationGenerationSkipped = 3,
|
||||
DiagnosticsPresent_AllOutputsSkipped = 1,
|
||||
DiagnosticsPresent_JavaScriptGenerated = 2,
|
||||
DiagnosticsPresent_JavaScriptGenerated_DeclarationNotGenerated = 3,
|
||||
EmitErrorsEncountered = 4,
|
||||
CompilerOptionsErrors = 5,
|
||||
}
|
||||
@@ -888,7 +886,6 @@ declare module "typescript" {
|
||||
isTopLevelValueImportWithEntityName(node: ImportDeclaration): boolean;
|
||||
getNodeCheckFlags(node: Node): NodeCheckFlags;
|
||||
getEnumMemberValue(node: EnumMember): number;
|
||||
hasSemanticDiagnostics(sourceFile?: SourceFile): boolean;
|
||||
isDeclarationVisible(node: Declaration): boolean;
|
||||
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean;
|
||||
writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
|
||||
@@ -1422,6 +1419,8 @@ declare module "typescript" {
|
||||
}
|
||||
declare module "typescript" {
|
||||
function createCompilerHost(options: CompilerOptions): CompilerHost;
|
||||
function getPreEmitDiagnostics(program: Program): Diagnostic[];
|
||||
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
|
||||
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program;
|
||||
}
|
||||
declare module "typescript" {
|
||||
@@ -1923,14 +1922,14 @@ declare module "typescript" {
|
||||
var ts = require("typescript");
|
||||
function compile(fileNames, options) {
|
||||
var program = ts.createProgram(fileNames, options);
|
||||
var result = program.emit();
|
||||
var allDiagnostics = program.getDiagnostics().concat(program.getTypeCheckerDiagnostics()).concat(result.diagnostics);
|
||||
var emitResult = program.emit();
|
||||
var allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
||||
allDiagnostics.forEach(function (diagnostic) {
|
||||
var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
|
||||
console.log(diagnostic.file.fileName + " (" + lineChar.line + "," + lineChar.character + "): " + diagnostic.messageText);
|
||||
console.log(diagnostic.file.fileName + " (" + lineChar.line + "," + lineChar.character + "): " + ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL));
|
||||
});
|
||||
console.log("Process exiting with code '" + result.emitResultStatus + "'.");
|
||||
process.exit(result.emitResultStatus);
|
||||
console.log("Process exiting with code '" + emitResult.emitResultStatus + "'.");
|
||||
process.exit(emitResult.emitResultStatus);
|
||||
}
|
||||
exports.compile = compile;
|
||||
compile(process.argv.slice(2), {
|
||||
|
||||
@@ -12,6 +12,9 @@ declare var process: any;
|
||||
declare var console: any;
|
||||
>console : any
|
||||
|
||||
declare var os: any;
|
||||
>os : any
|
||||
|
||||
import ts = require("typescript");
|
||||
>ts : typeof ts
|
||||
|
||||
@@ -31,43 +34,33 @@ export function compile(fileNames: string[], options: ts.CompilerOptions): void
|
||||
>fileNames : string[]
|
||||
>options : ts.CompilerOptions
|
||||
|
||||
var result = program.emit();
|
||||
>result : ts.EmitResult
|
||||
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 = program.getDiagnostics()
|
||||
var allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
||||
>allDiagnostics : 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[]
|
||||
>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
|
||||
>getDiagnostics : (sourceFile?: ts.SourceFile) => ts.Diagnostic[]
|
||||
|
||||
.concat(program.getTypeCheckerDiagnostics())
|
||||
>concat : { <U extends ts.Diagnostic[]>(...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): 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[]; }
|
||||
>result.diagnostics : ts.Diagnostic[]
|
||||
>result : ts.EmitResult
|
||||
>emitResult.diagnostics : ts.Diagnostic[]
|
||||
>emitResult : ts.EmitResult
|
||||
>diagnostics : ts.Diagnostic[]
|
||||
|
||||
allDiagnostics.forEach(diagnostic => {
|
||||
>allDiagnostics.forEach(diagnostic => { var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start); console.log(`${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${diagnostic.messageText}`); }) : void
|
||||
>allDiagnostics.forEach(diagnostic => { var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start); console.log(`${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`); }) : 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 lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start); console.log(`${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${diagnostic.messageText}`); } : (diagnostic: ts.Diagnostic) => void
|
||||
>diagnostic => { var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start); console.log(`${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`); } : (diagnostic: ts.Diagnostic) => void
|
||||
>diagnostic : ts.Diagnostic
|
||||
|
||||
var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
|
||||
@@ -82,8 +75,8 @@ export function compile(fileNames: string[], options: ts.CompilerOptions): void
|
||||
>diagnostic : ts.Diagnostic
|
||||
>start : number
|
||||
|
||||
console.log(`${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${diagnostic.messageText}`);
|
||||
>console.log(`${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${diagnostic.messageText}`) : any
|
||||
console.log(`${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`);
|
||||
>console.log(`${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`) : any
|
||||
>console.log : any
|
||||
>console : any
|
||||
>log : any
|
||||
@@ -98,28 +91,35 @@ export function compile(fileNames: string[], options: ts.CompilerOptions): void
|
||||
>lineChar.character : number
|
||||
>lineChar : ts.LineAndCharacter
|
||||
>character : number
|
||||
>ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL) : 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
|
||||
>os.EOL : any
|
||||
>os : any
|
||||
>EOL : any
|
||||
|
||||
});
|
||||
|
||||
console.log(`Process exiting with code '${result.emitResultStatus}'.`);
|
||||
>console.log(`Process exiting with code '${result.emitResultStatus}'.`) : any
|
||||
console.log(`Process exiting with code '${emitResult.emitResultStatus}'.`);
|
||||
>console.log(`Process exiting with code '${emitResult.emitResultStatus}'.`) : any
|
||||
>console.log : any
|
||||
>console : any
|
||||
>log : any
|
||||
>result.emitResultStatus : ts.EmitReturnStatus
|
||||
>result : ts.EmitResult
|
||||
>emitResult.emitResultStatus : ts.EmitReturnStatus
|
||||
>emitResult : ts.EmitResult
|
||||
>emitResultStatus : ts.EmitReturnStatus
|
||||
|
||||
process.exit(result.emitResultStatus);
|
||||
>process.exit(result.emitResultStatus) : any
|
||||
process.exit(emitResult.emitResultStatus);
|
||||
>process.exit(emitResult.emitResultStatus) : any
|
||||
>process.exit : any
|
||||
>process : any
|
||||
>exit : any
|
||||
>result.emitResultStatus : ts.EmitReturnStatus
|
||||
>result : ts.EmitResult
|
||||
>emitResult.emitResultStatus : ts.EmitReturnStatus
|
||||
>emitResult : ts.EmitResult
|
||||
>emitResultStatus : ts.EmitReturnStatus
|
||||
}
|
||||
|
||||
@@ -2268,18 +2268,8 @@ declare module "typescript" {
|
||||
>WriteFileCallback : WriteFileCallback
|
||||
>EmitResult : EmitResult
|
||||
|
||||
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[]
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
>getSyntacticDiagnostics : (sourceFile?: SourceFile) => Diagnostic[]
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>Diagnostic : Diagnostic
|
||||
@@ -2288,8 +2278,14 @@ declare module "typescript" {
|
||||
>getGlobalDiagnostics : () => Diagnostic[]
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
getDeclarationDiagnostics(sourceFile: SourceFile): Diagnostic[];
|
||||
>getDeclarationDiagnostics : (sourceFile: SourceFile) => Diagnostic[]
|
||||
getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
>getSemanticDiagnostics : (sourceFile?: SourceFile) => Diagnostic[]
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
>getDeclarationDiagnostics : (sourceFile?: SourceFile) => Diagnostic[]
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>Diagnostic : Diagnostic
|
||||
@@ -2359,14 +2355,14 @@ declare module "typescript" {
|
||||
Succeeded = 0,
|
||||
>Succeeded : EmitReturnStatus
|
||||
|
||||
AllOutputGenerationSkipped = 1,
|
||||
>AllOutputGenerationSkipped : EmitReturnStatus
|
||||
DiagnosticsPresent_AllOutputsSkipped = 1,
|
||||
>DiagnosticsPresent_AllOutputsSkipped : EmitReturnStatus
|
||||
|
||||
JSGeneratedWithSemanticErrors = 2,
|
||||
>JSGeneratedWithSemanticErrors : EmitReturnStatus
|
||||
DiagnosticsPresent_JavaScriptGenerated = 2,
|
||||
>DiagnosticsPresent_JavaScriptGenerated : EmitReturnStatus
|
||||
|
||||
DeclarationGenerationSkipped = 3,
|
||||
>DeclarationGenerationSkipped : EmitReturnStatus
|
||||
DiagnosticsPresent_JavaScriptGenerated_DeclarationNotGenerated = 3,
|
||||
>DiagnosticsPresent_JavaScriptGenerated_DeclarationNotGenerated : EmitReturnStatus
|
||||
|
||||
EmitErrorsEncountered = 4,
|
||||
>EmitErrorsEncountered : EmitReturnStatus
|
||||
@@ -2852,11 +2848,6 @@ declare module "typescript" {
|
||||
>node : EnumMember
|
||||
>EnumMember : EnumMember
|
||||
|
||||
hasSemanticDiagnostics(sourceFile?: SourceFile): boolean;
|
||||
>hasSemanticDiagnostics : (sourceFile?: SourceFile) => boolean
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
|
||||
isDeclarationVisible(node: Declaration): boolean;
|
||||
>isDeclarationVisible : (node: Declaration) => boolean
|
||||
>node : Declaration
|
||||
@@ -4556,6 +4547,18 @@ declare module "typescript" {
|
||||
>CompilerOptions : CompilerOptions
|
||||
>CompilerHost : CompilerHost
|
||||
|
||||
function getPreEmitDiagnostics(program: Program): Diagnostic[];
|
||||
>getPreEmitDiagnostics : (program: Program) => Diagnostic[]
|
||||
>program : Program
|
||||
>Program : Program
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
|
||||
>flattenDiagnosticMessageText : (messageText: string | DiagnosticMessageChain, newLine: string) => string
|
||||
>messageText : string | DiagnosticMessageChain
|
||||
>DiagnosticMessageChain : DiagnosticMessageChain
|
||||
>newLine : string
|
||||
|
||||
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program;
|
||||
>createProgram : (rootNames: string[], options: CompilerOptions, host?: CompilerHost) => Program
|
||||
>rootNames : string[]
|
||||
|
||||
@@ -783,11 +783,10 @@ declare module "typescript" {
|
||||
* will be invoked when writing the javascript and declaration files.
|
||||
*/
|
||||
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult;
|
||||
getTypeCheckerDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getTypeCheckerGlobalDiagnostics(): Diagnostic[];
|
||||
getDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getGlobalDiagnostics(): Diagnostic[];
|
||||
getDeclarationDiagnostics(sourceFile: SourceFile): Diagnostic[];
|
||||
getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getTypeChecker(): TypeChecker;
|
||||
getCommonSourceDirectory(): string;
|
||||
}
|
||||
@@ -812,9 +811,9 @@ declare module "typescript" {
|
||||
}
|
||||
enum EmitReturnStatus {
|
||||
Succeeded = 0,
|
||||
AllOutputGenerationSkipped = 1,
|
||||
JSGeneratedWithSemanticErrors = 2,
|
||||
DeclarationGenerationSkipped = 3,
|
||||
DiagnosticsPresent_AllOutputsSkipped = 1,
|
||||
DiagnosticsPresent_JavaScriptGenerated = 2,
|
||||
DiagnosticsPresent_JavaScriptGenerated_DeclarationNotGenerated = 3,
|
||||
EmitErrorsEncountered = 4,
|
||||
CompilerOptionsErrors = 5,
|
||||
}
|
||||
@@ -919,7 +918,6 @@ declare module "typescript" {
|
||||
isTopLevelValueImportWithEntityName(node: ImportDeclaration): boolean;
|
||||
getNodeCheckFlags(node: Node): NodeCheckFlags;
|
||||
getEnumMemberValue(node: EnumMember): number;
|
||||
hasSemanticDiagnostics(sourceFile?: SourceFile): boolean;
|
||||
isDeclarationVisible(node: Declaration): boolean;
|
||||
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean;
|
||||
writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
|
||||
@@ -1453,6 +1451,8 @@ declare module "typescript" {
|
||||
}
|
||||
declare module "typescript" {
|
||||
function createCompilerHost(options: CompilerOptions): CompilerHost;
|
||||
function getPreEmitDiagnostics(program: Program): Diagnostic[];
|
||||
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
|
||||
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program;
|
||||
}
|
||||
declare module "typescript" {
|
||||
|
||||
@@ -2415,18 +2415,8 @@ declare module "typescript" {
|
||||
>WriteFileCallback : WriteFileCallback
|
||||
>EmitResult : EmitResult
|
||||
|
||||
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[]
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
>getSyntacticDiagnostics : (sourceFile?: SourceFile) => Diagnostic[]
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>Diagnostic : Diagnostic
|
||||
@@ -2435,8 +2425,14 @@ declare module "typescript" {
|
||||
>getGlobalDiagnostics : () => Diagnostic[]
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
getDeclarationDiagnostics(sourceFile: SourceFile): Diagnostic[];
|
||||
>getDeclarationDiagnostics : (sourceFile: SourceFile) => Diagnostic[]
|
||||
getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
>getSemanticDiagnostics : (sourceFile?: SourceFile) => Diagnostic[]
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
>getDeclarationDiagnostics : (sourceFile?: SourceFile) => Diagnostic[]
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>Diagnostic : Diagnostic
|
||||
@@ -2506,14 +2502,14 @@ declare module "typescript" {
|
||||
Succeeded = 0,
|
||||
>Succeeded : EmitReturnStatus
|
||||
|
||||
AllOutputGenerationSkipped = 1,
|
||||
>AllOutputGenerationSkipped : EmitReturnStatus
|
||||
DiagnosticsPresent_AllOutputsSkipped = 1,
|
||||
>DiagnosticsPresent_AllOutputsSkipped : EmitReturnStatus
|
||||
|
||||
JSGeneratedWithSemanticErrors = 2,
|
||||
>JSGeneratedWithSemanticErrors : EmitReturnStatus
|
||||
DiagnosticsPresent_JavaScriptGenerated = 2,
|
||||
>DiagnosticsPresent_JavaScriptGenerated : EmitReturnStatus
|
||||
|
||||
DeclarationGenerationSkipped = 3,
|
||||
>DeclarationGenerationSkipped : EmitReturnStatus
|
||||
DiagnosticsPresent_JavaScriptGenerated_DeclarationNotGenerated = 3,
|
||||
>DiagnosticsPresent_JavaScriptGenerated_DeclarationNotGenerated : EmitReturnStatus
|
||||
|
||||
EmitErrorsEncountered = 4,
|
||||
>EmitErrorsEncountered : EmitReturnStatus
|
||||
@@ -2999,11 +2995,6 @@ declare module "typescript" {
|
||||
>node : EnumMember
|
||||
>EnumMember : EnumMember
|
||||
|
||||
hasSemanticDiagnostics(sourceFile?: SourceFile): boolean;
|
||||
>hasSemanticDiagnostics : (sourceFile?: SourceFile) => boolean
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
|
||||
isDeclarationVisible(node: Declaration): boolean;
|
||||
>isDeclarationVisible : (node: Declaration) => boolean
|
||||
>node : Declaration
|
||||
@@ -4703,6 +4694,18 @@ declare module "typescript" {
|
||||
>CompilerOptions : CompilerOptions
|
||||
>CompilerHost : CompilerHost
|
||||
|
||||
function getPreEmitDiagnostics(program: Program): Diagnostic[];
|
||||
>getPreEmitDiagnostics : (program: Program) => Diagnostic[]
|
||||
>program : Program
|
||||
>Program : Program
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
|
||||
>flattenDiagnosticMessageText : (messageText: string | DiagnosticMessageChain, newLine: string) => string
|
||||
>messageText : string | DiagnosticMessageChain
|
||||
>DiagnosticMessageChain : DiagnosticMessageChain
|
||||
>newLine : string
|
||||
|
||||
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program;
|
||||
>createProgram : (rootNames: string[], options: CompilerOptions, host?: CompilerHost) => Program
|
||||
>rootNames : string[]
|
||||
|
||||
@@ -12,6 +12,7 @@ declare var process: any;
|
||||
declare var console: any;
|
||||
declare var fs: any;
|
||||
declare var path: any;
|
||||
declare var os: any;
|
||||
|
||||
import ts = require("typescript");
|
||||
|
||||
@@ -45,17 +46,17 @@ function transform(contents: string, compilerOptions: ts.CompilerOptions = {}) {
|
||||
var program = ts.createProgram(["file.ts"], compilerOptions, compilerHost);
|
||||
|
||||
// Query for early errors
|
||||
var errors = program.getDiagnostics();
|
||||
// Do not generate code in the presence of early errors
|
||||
if (!errors.length) {
|
||||
// Type check and get semantic errors
|
||||
errors = program.getTypeCheckerDiagnostics();
|
||||
// Generate output
|
||||
program.emit();
|
||||
}
|
||||
var errors = ts.getPreEmitDiagnostics(program);
|
||||
var emitResult = program.emit();
|
||||
|
||||
errors = errors.concat(emitResult.diagnostics);
|
||||
|
||||
return {
|
||||
outputs: outputs,
|
||||
errors: errors.map(function (e) { return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + e.messageText; })
|
||||
errors: errors.map(function (e) {
|
||||
return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): "
|
||||
+ ts.flattenDiagnosticMessageText(e.messageText, os.EOL);
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
@@ -783,11 +784,10 @@ declare module "typescript" {
|
||||
* will be invoked when writing the javascript and declaration files.
|
||||
*/
|
||||
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult;
|
||||
getTypeCheckerDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getTypeCheckerGlobalDiagnostics(): Diagnostic[];
|
||||
getDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getGlobalDiagnostics(): Diagnostic[];
|
||||
getDeclarationDiagnostics(sourceFile: SourceFile): Diagnostic[];
|
||||
getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getTypeChecker(): TypeChecker;
|
||||
getCommonSourceDirectory(): string;
|
||||
}
|
||||
@@ -812,9 +812,9 @@ declare module "typescript" {
|
||||
}
|
||||
enum EmitReturnStatus {
|
||||
Succeeded = 0,
|
||||
AllOutputGenerationSkipped = 1,
|
||||
JSGeneratedWithSemanticErrors = 2,
|
||||
DeclarationGenerationSkipped = 3,
|
||||
DiagnosticsPresent_AllOutputsSkipped = 1,
|
||||
DiagnosticsPresent_JavaScriptGenerated = 2,
|
||||
DiagnosticsPresent_JavaScriptGenerated_DeclarationNotGenerated = 3,
|
||||
EmitErrorsEncountered = 4,
|
||||
CompilerOptionsErrors = 5,
|
||||
}
|
||||
@@ -919,7 +919,6 @@ declare module "typescript" {
|
||||
isTopLevelValueImportWithEntityName(node: ImportDeclaration): boolean;
|
||||
getNodeCheckFlags(node: Node): NodeCheckFlags;
|
||||
getEnumMemberValue(node: EnumMember): number;
|
||||
hasSemanticDiagnostics(sourceFile?: SourceFile): boolean;
|
||||
isDeclarationVisible(node: Declaration): boolean;
|
||||
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean;
|
||||
writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
|
||||
@@ -1453,6 +1452,8 @@ declare module "typescript" {
|
||||
}
|
||||
declare module "typescript" {
|
||||
function createCompilerHost(options: CompilerOptions): CompilerHost;
|
||||
function getPreEmitDiagnostics(program: Program): Diagnostic[];
|
||||
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
|
||||
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program;
|
||||
}
|
||||
declare module "typescript" {
|
||||
@@ -1978,18 +1979,13 @@ function transform(contents, compilerOptions) {
|
||||
// Create a program from inputs
|
||||
var program = ts.createProgram(["file.ts"], compilerOptions, compilerHost);
|
||||
// Query for early errors
|
||||
var errors = program.getDiagnostics();
|
||||
// Do not generate code in the presence of early errors
|
||||
if (!errors.length) {
|
||||
// Type check and get semantic errors
|
||||
errors = program.getTypeCheckerDiagnostics();
|
||||
// Generate output
|
||||
program.emit();
|
||||
}
|
||||
var errors = ts.getPreEmitDiagnostics(program);
|
||||
var emitResult = program.emit();
|
||||
errors = errors.concat(emitResult.diagnostics);
|
||||
return {
|
||||
outputs: outputs,
|
||||
errors: errors.map(function (e) {
|
||||
return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + e.messageText;
|
||||
return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL);
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@ declare var fs: any;
|
||||
declare var path: any;
|
||||
>path : any
|
||||
|
||||
declare var os: any;
|
||||
>os : any
|
||||
|
||||
import ts = require("typescript");
|
||||
>ts : typeof ts
|
||||
|
||||
@@ -147,52 +150,50 @@ function transform(contents: string, compilerOptions: ts.CompilerOptions = {}) {
|
||||
>compilerHost : { getSourceFile: (fileName: any, target: any) => ts.SourceFile; writeFile: (name: any, text: any, writeByteOrderMark: any) => void; getDefaultLibFileName: () => string; useCaseSensitiveFileNames: () => boolean; getCanonicalFileName: (fileName: any) => any; getCurrentDirectory: () => string; getNewLine: () => string; }
|
||||
|
||||
// Query for early errors
|
||||
var errors = program.getDiagnostics();
|
||||
var errors = ts.getPreEmitDiagnostics(program);
|
||||
>errors : ts.Diagnostic[]
|
||||
>program.getDiagnostics() : ts.Diagnostic[]
|
||||
>program.getDiagnostics : (sourceFile?: ts.SourceFile) => 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
|
||||
>getDiagnostics : (sourceFile?: ts.SourceFile) => ts.Diagnostic[]
|
||||
|
||||
// Do not generate code in the presence of early errors
|
||||
if (!errors.length) {
|
||||
>!errors.length : boolean
|
||||
>errors.length : number
|
||||
>errors : ts.Diagnostic[]
|
||||
>length : number
|
||||
|
||||
// Type check and get semantic errors
|
||||
errors = program.getTypeCheckerDiagnostics();
|
||||
>errors = program.getTypeCheckerDiagnostics() : ts.Diagnostic[]
|
||||
>errors : 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.emit();
|
||||
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
|
||||
}
|
||||
|
||||
errors = errors.concat(emitResult.diagnostics);
|
||||
>errors = errors.concat(emitResult.diagnostics) : ts.Diagnostic[]
|
||||
>errors : ts.Diagnostic[]
|
||||
>errors.concat(emitResult.diagnostics) : ts.Diagnostic[]
|
||||
>errors.concat : { <U extends ts.Diagnostic[]>(...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }
|
||||
>errors : ts.Diagnostic[]
|
||||
>concat : { <U extends ts.Diagnostic[]>(...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }
|
||||
>emitResult.diagnostics : ts.Diagnostic[]
|
||||
>emitResult : ts.EmitResult
|
||||
>diagnostics : ts.Diagnostic[]
|
||||
|
||||
return {
|
||||
>{ outputs: outputs, errors: errors.map(function (e) { return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + e.messageText; }) } : { outputs: any[]; errors: string[]; }
|
||||
>{ outputs: outputs, errors: errors.map(function (e) { return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL); }) } : { outputs: any[]; errors: string[]; }
|
||||
|
||||
outputs: outputs,
|
||||
>outputs : any[]
|
||||
>outputs : any[]
|
||||
|
||||
errors: errors.map(function (e) { return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + e.messageText; })
|
||||
errors: errors.map(function (e) {
|
||||
>errors : string[]
|
||||
>errors.map(function (e) { return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + e.messageText; }) : string[]
|
||||
>errors.map(function (e) { return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL); }) : string[]
|
||||
>errors.map : <U>(callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => U, thisArg?: any) => U[]
|
||||
>errors : ts.Diagnostic[]
|
||||
>map : <U>(callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => U, thisArg?: any) => U[]
|
||||
>function (e) { return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + e.messageText; } : (e: ts.Diagnostic) => string
|
||||
>function (e) { return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL); } : (e: ts.Diagnostic) => string
|
||||
>e : ts.Diagnostic
|
||||
>e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + e.messageText : string
|
||||
|
||||
return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): "
|
||||
>e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL) : string
|
||||
>e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " : string
|
||||
>e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line : string
|
||||
>e.file.fileName + "(" : string
|
||||
@@ -212,10 +213,20 @@ function transform(contents: string, compilerOptions: ts.CompilerOptions = {}) {
|
||||
>e : ts.Diagnostic
|
||||
>start : number
|
||||
>line : number
|
||||
|
||||
+ ts.flattenDiagnosticMessageText(e.messageText, os.EOL);
|
||||
>ts.flattenDiagnosticMessageText(e.messageText, os.EOL) : string
|
||||
>ts.flattenDiagnosticMessageText : (messageText: string | ts.DiagnosticMessageChain, newLine: string) => string
|
||||
>ts : typeof ts
|
||||
>flattenDiagnosticMessageText : (messageText: string | ts.DiagnosticMessageChain, newLine: string) => string
|
||||
>e.messageText : string | ts.DiagnosticMessageChain
|
||||
>e : ts.Diagnostic
|
||||
>messageText : string | ts.DiagnosticMessageChain
|
||||
>os.EOL : any
|
||||
>os : any
|
||||
>EOL : any
|
||||
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2356,18 +2367,8 @@ declare module "typescript" {
|
||||
>WriteFileCallback : WriteFileCallback
|
||||
>EmitResult : EmitResult
|
||||
|
||||
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[]
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
>getSyntacticDiagnostics : (sourceFile?: SourceFile) => Diagnostic[]
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>Diagnostic : Diagnostic
|
||||
@@ -2376,8 +2377,14 @@ declare module "typescript" {
|
||||
>getGlobalDiagnostics : () => Diagnostic[]
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
getDeclarationDiagnostics(sourceFile: SourceFile): Diagnostic[];
|
||||
>getDeclarationDiagnostics : (sourceFile: SourceFile) => Diagnostic[]
|
||||
getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
>getSemanticDiagnostics : (sourceFile?: SourceFile) => Diagnostic[]
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
>getDeclarationDiagnostics : (sourceFile?: SourceFile) => Diagnostic[]
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>Diagnostic : Diagnostic
|
||||
@@ -2447,14 +2454,14 @@ declare module "typescript" {
|
||||
Succeeded = 0,
|
||||
>Succeeded : EmitReturnStatus
|
||||
|
||||
AllOutputGenerationSkipped = 1,
|
||||
>AllOutputGenerationSkipped : EmitReturnStatus
|
||||
DiagnosticsPresent_AllOutputsSkipped = 1,
|
||||
>DiagnosticsPresent_AllOutputsSkipped : EmitReturnStatus
|
||||
|
||||
JSGeneratedWithSemanticErrors = 2,
|
||||
>JSGeneratedWithSemanticErrors : EmitReturnStatus
|
||||
DiagnosticsPresent_JavaScriptGenerated = 2,
|
||||
>DiagnosticsPresent_JavaScriptGenerated : EmitReturnStatus
|
||||
|
||||
DeclarationGenerationSkipped = 3,
|
||||
>DeclarationGenerationSkipped : EmitReturnStatus
|
||||
DiagnosticsPresent_JavaScriptGenerated_DeclarationNotGenerated = 3,
|
||||
>DiagnosticsPresent_JavaScriptGenerated_DeclarationNotGenerated : EmitReturnStatus
|
||||
|
||||
EmitErrorsEncountered = 4,
|
||||
>EmitErrorsEncountered : EmitReturnStatus
|
||||
@@ -2940,11 +2947,6 @@ declare module "typescript" {
|
||||
>node : EnumMember
|
||||
>EnumMember : EnumMember
|
||||
|
||||
hasSemanticDiagnostics(sourceFile?: SourceFile): boolean;
|
||||
>hasSemanticDiagnostics : (sourceFile?: SourceFile) => boolean
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
|
||||
isDeclarationVisible(node: Declaration): boolean;
|
||||
>isDeclarationVisible : (node: Declaration) => boolean
|
||||
>node : Declaration
|
||||
@@ -4644,6 +4646,18 @@ declare module "typescript" {
|
||||
>CompilerOptions : CompilerOptions
|
||||
>CompilerHost : CompilerHost
|
||||
|
||||
function getPreEmitDiagnostics(program: Program): Diagnostic[];
|
||||
>getPreEmitDiagnostics : (program: Program) => Diagnostic[]
|
||||
>program : Program
|
||||
>Program : Program
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
|
||||
>flattenDiagnosticMessageText : (messageText: string | DiagnosticMessageChain, newLine: string) => string
|
||||
>messageText : string | DiagnosticMessageChain
|
||||
>DiagnosticMessageChain : DiagnosticMessageChain
|
||||
>newLine : string
|
||||
|
||||
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program;
|
||||
>createProgram : (rootNames: string[], options: CompilerOptions, host?: CompilerHost) => Program
|
||||
>rootNames : string[]
|
||||
|
||||
@@ -821,11 +821,10 @@ declare module "typescript" {
|
||||
* will be invoked when writing the javascript and declaration files.
|
||||
*/
|
||||
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult;
|
||||
getTypeCheckerDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getTypeCheckerGlobalDiagnostics(): Diagnostic[];
|
||||
getDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getGlobalDiagnostics(): Diagnostic[];
|
||||
getDeclarationDiagnostics(sourceFile: SourceFile): Diagnostic[];
|
||||
getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getTypeChecker(): TypeChecker;
|
||||
getCommonSourceDirectory(): string;
|
||||
}
|
||||
@@ -850,9 +849,9 @@ declare module "typescript" {
|
||||
}
|
||||
enum EmitReturnStatus {
|
||||
Succeeded = 0,
|
||||
AllOutputGenerationSkipped = 1,
|
||||
JSGeneratedWithSemanticErrors = 2,
|
||||
DeclarationGenerationSkipped = 3,
|
||||
DiagnosticsPresent_AllOutputsSkipped = 1,
|
||||
DiagnosticsPresent_JavaScriptGenerated = 2,
|
||||
DiagnosticsPresent_JavaScriptGenerated_DeclarationNotGenerated = 3,
|
||||
EmitErrorsEncountered = 4,
|
||||
CompilerOptionsErrors = 5,
|
||||
}
|
||||
@@ -957,7 +956,6 @@ declare module "typescript" {
|
||||
isTopLevelValueImportWithEntityName(node: ImportDeclaration): boolean;
|
||||
getNodeCheckFlags(node: Node): NodeCheckFlags;
|
||||
getEnumMemberValue(node: EnumMember): number;
|
||||
hasSemanticDiagnostics(sourceFile?: SourceFile): boolean;
|
||||
isDeclarationVisible(node: Declaration): boolean;
|
||||
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean;
|
||||
writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
|
||||
@@ -1491,6 +1489,8 @@ declare module "typescript" {
|
||||
}
|
||||
declare module "typescript" {
|
||||
function createCompilerHost(options: CompilerOptions): CompilerHost;
|
||||
function getPreEmitDiagnostics(program: Program): Diagnostic[];
|
||||
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
|
||||
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program;
|
||||
}
|
||||
declare module "typescript" {
|
||||
|
||||
@@ -2541,18 +2541,8 @@ declare module "typescript" {
|
||||
>WriteFileCallback : WriteFileCallback
|
||||
>EmitResult : EmitResult
|
||||
|
||||
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[]
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
>getSyntacticDiagnostics : (sourceFile?: SourceFile) => Diagnostic[]
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>Diagnostic : Diagnostic
|
||||
@@ -2561,8 +2551,14 @@ declare module "typescript" {
|
||||
>getGlobalDiagnostics : () => Diagnostic[]
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
getDeclarationDiagnostics(sourceFile: SourceFile): Diagnostic[];
|
||||
>getDeclarationDiagnostics : (sourceFile: SourceFile) => Diagnostic[]
|
||||
getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
>getSemanticDiagnostics : (sourceFile?: SourceFile) => Diagnostic[]
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
>getDeclarationDiagnostics : (sourceFile?: SourceFile) => Diagnostic[]
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>Diagnostic : Diagnostic
|
||||
@@ -2632,14 +2628,14 @@ declare module "typescript" {
|
||||
Succeeded = 0,
|
||||
>Succeeded : EmitReturnStatus
|
||||
|
||||
AllOutputGenerationSkipped = 1,
|
||||
>AllOutputGenerationSkipped : EmitReturnStatus
|
||||
DiagnosticsPresent_AllOutputsSkipped = 1,
|
||||
>DiagnosticsPresent_AllOutputsSkipped : EmitReturnStatus
|
||||
|
||||
JSGeneratedWithSemanticErrors = 2,
|
||||
>JSGeneratedWithSemanticErrors : EmitReturnStatus
|
||||
DiagnosticsPresent_JavaScriptGenerated = 2,
|
||||
>DiagnosticsPresent_JavaScriptGenerated : EmitReturnStatus
|
||||
|
||||
DeclarationGenerationSkipped = 3,
|
||||
>DeclarationGenerationSkipped : EmitReturnStatus
|
||||
DiagnosticsPresent_JavaScriptGenerated_DeclarationNotGenerated = 3,
|
||||
>DiagnosticsPresent_JavaScriptGenerated_DeclarationNotGenerated : EmitReturnStatus
|
||||
|
||||
EmitErrorsEncountered = 4,
|
||||
>EmitErrorsEncountered : EmitReturnStatus
|
||||
@@ -3125,11 +3121,6 @@ declare module "typescript" {
|
||||
>node : EnumMember
|
||||
>EnumMember : EnumMember
|
||||
|
||||
hasSemanticDiagnostics(sourceFile?: SourceFile): boolean;
|
||||
>hasSemanticDiagnostics : (sourceFile?: SourceFile) => boolean
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
|
||||
isDeclarationVisible(node: Declaration): boolean;
|
||||
>isDeclarationVisible : (node: Declaration) => boolean
|
||||
>node : Declaration
|
||||
@@ -4829,6 +4820,18 @@ declare module "typescript" {
|
||||
>CompilerOptions : CompilerOptions
|
||||
>CompilerHost : CompilerHost
|
||||
|
||||
function getPreEmitDiagnostics(program: Program): Diagnostic[];
|
||||
>getPreEmitDiagnostics : (program: Program) => Diagnostic[]
|
||||
>program : Program
|
||||
>Program : Program
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
|
||||
>flattenDiagnosticMessageText : (messageText: string | DiagnosticMessageChain, newLine: string) => string
|
||||
>messageText : string | DiagnosticMessageChain
|
||||
>DiagnosticMessageChain : DiagnosticMessageChain
|
||||
>newLine : string
|
||||
|
||||
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program;
|
||||
>createProgram : (rootNames: string[], options: CompilerOptions, host?: CompilerHost) => Program
|
||||
>rootNames : string[]
|
||||
|
||||
@@ -5,7 +5,3 @@ var x = 0;
|
||||
//// [declarationEmit_invalidReference2.js]
|
||||
/// <reference path="invalid.ts" />
|
||||
var x = 0;
|
||||
|
||||
|
||||
//// [declarationEmit_invalidReference2.d.ts]
|
||||
declare var x: number;
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : tests/cases/fourslash/inputFile1.js
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : tests/cases/fourslash/inputFile1.js
|
||||
var x = 5;
|
||||
var Bar = (function () {
|
||||
function Bar() {
|
||||
}
|
||||
return Bar;
|
||||
})();
|
||||
FileName : tests/cases/fourslash/inputFile1.d.ts
|
||||
FileName : tests/cases/fourslash/inputFile1.d.ts
|
||||
declare var x: number;
|
||||
declare class Bar {
|
||||
x: string;
|
||||
y: number;
|
||||
}
|
||||
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : tests/cases/fourslash/inputFile2.js
|
||||
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : tests/cases/fourslash/inputFile2.js
|
||||
var x1 = "hello world";
|
||||
var Foo = (function () {
|
||||
function Foo() {
|
||||
}
|
||||
return Foo;
|
||||
})();
|
||||
FileName : tests/cases/fourslash/inputFile2.d.ts
|
||||
FileName : tests/cases/fourslash/inputFile2.d.ts
|
||||
declare var x1: string;
|
||||
declare class Foo {
|
||||
x: string;
|
||||
y: number;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : declSingleFile.js
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : declSingleFile.js
|
||||
var x = 5;
|
||||
var Bar = (function () {
|
||||
function Bar() {
|
||||
@@ -12,7 +12,7 @@ var Foo = (function () {
|
||||
}
|
||||
return Foo;
|
||||
})();
|
||||
FileName : declSingleFile.d.ts
|
||||
FileName : declSingleFile.d.ts
|
||||
declare var x: number;
|
||||
declare class Bar {
|
||||
x: string;
|
||||
@@ -23,4 +23,4 @@ declare class Foo {
|
||||
x: string;
|
||||
y: number;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : declSingleFile.js
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : declSingleFile.js
|
||||
var x = 5;
|
||||
var Bar = (function () {
|
||||
function Bar() {
|
||||
}
|
||||
return Bar;
|
||||
})();
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
EmitOutputStatus : JSGeneratedWithSemanticErrors
|
||||
FileName : declSingleFile.js
|
||||
EmitOutputStatus : DiagnosticsPresent_JavaScriptGenerated
|
||||
Diagnostics:
|
||||
Subsequent variable declarations must have the same type. Variable 'x' must be of type 'number', but here has type 'string'.
|
||||
Subsequent variable declarations must have the same type. Variable 'x' must be of type 'number', but here has type 'string'.
|
||||
FileName : declSingleFile.js
|
||||
var x = 5;
|
||||
var Bar = (function () {
|
||||
function Bar() {
|
||||
@@ -12,4 +15,4 @@ var Bar2 = (function () {
|
||||
}
|
||||
return Bar2;
|
||||
})();
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : declSingleFile.js.map
|
||||
{"version":3,"file":"declSingleFile.js","sourceRoot":"","sources":["../tests/cases/fourslash/inputFile.ts"],"names":["M","M.constructor"],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB,IAAM,CAAC;IAAPA,SAAMA,CAACA;IAGPC,CAACA;IAADD,QAACA;AAADA,CAACA,AAHD,IAGC"}FileName : declSingleFile.js
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : declSingleFile.js.map
|
||||
{"version":3,"file":"declSingleFile.js","sourceRoot":"","sources":["../tests/cases/fourslash/inputFile.ts"],"names":["M","M.constructor"],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB,IAAM,CAAC;IAAPA,SAAMA,CAACA;IAGPC,CAACA;IAADD,QAACA;AAADA,CAACA,AAHD,IAGC"}FileName : declSingleFile.js
|
||||
var x = 109;
|
||||
var foo = "hello world";
|
||||
var M = (function () {
|
||||
@@ -8,4 +8,4 @@ var M = (function () {
|
||||
}
|
||||
return M;
|
||||
})();
|
||||
//# sourceMappingURL=mapRootDir/declSingleFile.js.map
|
||||
//# sourceMappingURL=mapRootDir/declSingleFile.js.map
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : tests/cases/fourslash/inputFile.js
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : tests/cases/fourslash/inputFile.js
|
||||
var x;
|
||||
var M = (function () {
|
||||
function M() {
|
||||
}
|
||||
return M;
|
||||
})();
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : tests/cases/fourslash/inputFile2.js
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : tests/cases/fourslash/inputFile2.js
|
||||
var x;
|
||||
var Foo = (function () {
|
||||
function Foo() {
|
||||
}
|
||||
return Foo;
|
||||
})();
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : outputDir/singleFile.js
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : outputDir/singleFile.js
|
||||
var x;
|
||||
var Bar = (function () {
|
||||
function Bar() {
|
||||
@@ -12,4 +12,4 @@ var Foo = (function () {
|
||||
}
|
||||
return Foo;
|
||||
})();
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : tests/cases/fourslash/inputFile3.js
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : tests/cases/fourslash/inputFile3.js
|
||||
exports.foo = 10;
|
||||
exports.bar = "hello world";
|
||||
FileName : tests/cases/fourslash/inputFile3.d.ts
|
||||
FileName : tests/cases/fourslash/inputFile3.d.ts
|
||||
export declare var foo: number;
|
||||
export declare var bar: string;
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : tests/cases/fourslash/inputFile.js.map
|
||||
{"version":3,"file":"inputFile.js","sourceRoot":"","sources":["inputFile.ts"],"names":["M","M.constructor"],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB,IAAM,CAAC;IAAPA,SAAMA,CAACA;IAGPC,CAACA;IAADD,QAACA;AAADA,CAACA,AAHD,IAGC"}FileName : tests/cases/fourslash/inputFile.js
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : tests/cases/fourslash/inputFile.js.map
|
||||
{"version":3,"file":"inputFile.js","sourceRoot":"","sources":["inputFile.ts"],"names":["M","M.constructor"],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB,IAAM,CAAC;IAAPA,SAAMA,CAACA;IAGPC,CAACA;IAADD,QAACA;AAADA,CAACA,AAHD,IAGC"}FileName : tests/cases/fourslash/inputFile.js
|
||||
var x = 109;
|
||||
var foo = "hello world";
|
||||
var M = (function () {
|
||||
@@ -8,4 +8,4 @@ var M = (function () {
|
||||
}
|
||||
return M;
|
||||
})();
|
||||
//# sourceMappingURL=inputFile.js.map
|
||||
//# sourceMappingURL=inputFile.js.map
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : sample/outDir/inputFile1.js.map
|
||||
{"version":3,"file":"inputFile1.js","sourceRoot":"","sources":["../../tests/cases/fourslash/inputFile1.ts"],"names":["M","M.constructor"],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB,IAAM,CAAC;IAAPA,SAAMA,CAACA;IAGPC,CAACA;IAADD,QAACA;AAADA,CAACA,AAHD,IAGC"}FileName : sample/outDir/inputFile1.js
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : sample/outDir/inputFile1.js.map
|
||||
{"version":3,"file":"inputFile1.js","sourceRoot":"","sources":["../../tests/cases/fourslash/inputFile1.ts"],"names":["M","M.constructor"],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB,IAAM,CAAC;IAAPA,SAAMA,CAACA;IAGPC,CAACA;IAADD,QAACA;AAADA,CAACA,AAHD,IAGC"}FileName : sample/outDir/inputFile1.js
|
||||
var x = 109;
|
||||
var foo = "hello world";
|
||||
var M = (function () {
|
||||
@@ -8,12 +8,12 @@ var M = (function () {
|
||||
}
|
||||
return M;
|
||||
})();
|
||||
//# sourceMappingURL=inputFile1.js.map
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : sample/outDir/inputFile2.js.map
|
||||
{"version":3,"file":"inputFile2.js","sourceRoot":"","sources":["../../tests/cases/fourslash/inputFile2.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,aAAa,CAAC;AAC1B,EAAE,CAAC,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC;IACvB,IAAI,CAAC,GAAG,EAAE,CAAC;AACd,CAAC"}FileName : sample/outDir/inputFile2.js
|
||||
//# sourceMappingURL=inputFile1.js.map
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : sample/outDir/inputFile2.js.map
|
||||
{"version":3,"file":"inputFile2.js","sourceRoot":"","sources":["../../tests/cases/fourslash/inputFile2.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,aAAa,CAAC;AAC1B,EAAE,CAAC,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC;IACvB,IAAI,CAAC,GAAG,EAAE,CAAC;AACd,CAAC"}FileName : sample/outDir/inputFile2.js
|
||||
var intro = "hello world";
|
||||
if (intro !== undefined) {
|
||||
var k = 10;
|
||||
}
|
||||
//# sourceMappingURL=inputFile2.js.map
|
||||
//# sourceMappingURL=inputFile2.js.map
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : tests/cases/fourslash/inputFile.js.map
|
||||
{"version":3,"file":"inputFile.js","sourceRoot":"sourceRootDir/","sources":["inputFile.ts"],"names":["M","M.constructor"],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB,IAAM,CAAC;IAAPA,SAAMA,CAACA;IAGPC,CAACA;IAADD,QAACA;AAADA,CAACA,AAHD,IAGC"}FileName : tests/cases/fourslash/inputFile.js
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : tests/cases/fourslash/inputFile.js.map
|
||||
{"version":3,"file":"inputFile.js","sourceRoot":"sourceRootDir/","sources":["inputFile.ts"],"names":["M","M.constructor"],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB,IAAM,CAAC;IAAPA,SAAMA,CAACA;IAGPC,CAACA;IAADD,QAACA;AAADA,CAACA,AAHD,IAGC"}FileName : tests/cases/fourslash/inputFile.js
|
||||
var x = 109;
|
||||
var foo = "hello world";
|
||||
var M = (function () {
|
||||
@@ -8,4 +8,4 @@ var M = (function () {
|
||||
}
|
||||
return M;
|
||||
})();
|
||||
//# sourceMappingURL=inputFile.js.map
|
||||
//# sourceMappingURL=inputFile.js.map
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : tests/cases/fourslash/inputFile1.js.map
|
||||
{"version":3,"file":"inputFile1.js","sourceRoot":"sourceRootDir/","sources":["inputFile1.ts"],"names":["M","M.constructor"],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB,IAAM,CAAC;IAAPA,SAAMA,CAACA;IAGPC,CAACA;IAADD,QAACA;AAADA,CAACA,AAHD,IAGC"}FileName : tests/cases/fourslash/inputFile1.js
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : tests/cases/fourslash/inputFile1.js.map
|
||||
{"version":3,"file":"inputFile1.js","sourceRoot":"sourceRootDir/","sources":["inputFile1.ts"],"names":["M","M.constructor"],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB,IAAM,CAAC;IAAPA,SAAMA,CAACA;IAGPC,CAACA;IAADD,QAACA;AAADA,CAACA,AAHD,IAGC"}FileName : tests/cases/fourslash/inputFile1.js
|
||||
var x = 109;
|
||||
var foo = "hello world";
|
||||
var M = (function () {
|
||||
@@ -8,14 +8,14 @@ var M = (function () {
|
||||
}
|
||||
return M;
|
||||
})();
|
||||
//# sourceMappingURL=inputFile1.js.map
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : tests/cases/fourslash/inputFile2.js.map
|
||||
{"version":3,"file":"inputFile2.js","sourceRoot":"sourceRootDir/","sources":["inputFile2.ts"],"names":["C","C.constructor"],"mappings":"AAAA,IAAI,GAAG,GAAG,wBAAwB,CAAC;AACnC,IAAM,CAAC;IAAPA,SAAMA,CAACA;IAGPC,CAACA;IAADD,QAACA;AAADA,CAACA,AAHD,IAGC"}FileName : tests/cases/fourslash/inputFile2.js
|
||||
//# sourceMappingURL=inputFile1.js.map
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : tests/cases/fourslash/inputFile2.js.map
|
||||
{"version":3,"file":"inputFile2.js","sourceRoot":"sourceRootDir/","sources":["inputFile2.ts"],"names":["C","C.constructor"],"mappings":"AAAA,IAAI,GAAG,GAAG,wBAAwB,CAAC;AACnC,IAAM,CAAC;IAAPA,SAAMA,CAACA;IAGPC,CAACA;IAADD,QAACA;AAADA,CAACA,AAHD,IAGC"}FileName : tests/cases/fourslash/inputFile2.js
|
||||
var bar = "hello world Typescript";
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
//# sourceMappingURL=inputFile2.js.map
|
||||
//# sourceMappingURL=inputFile2.js.map
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : tests/cases/fourslash/inputFile2.js
|
||||
EmitOutputStatus : Succeeded
|
||||
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : tests/cases/fourslash/inputFile2.js
|
||||
var x1 = "hello world";
|
||||
var Foo = (function () {
|
||||
function Foo() {
|
||||
}
|
||||
return Foo;
|
||||
})();
|
||||
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : tests/cases/fourslash/inputFile2.js
|
||||
EmitOutputStatus : Succeeded
|
||||
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : tests/cases/fourslash/inputFile2.js
|
||||
var Foo = (function () {
|
||||
function Foo() {
|
||||
}
|
||||
return Foo;
|
||||
})();
|
||||
exports.Foo = Foo;
|
||||
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : tests/cases/fourslash/inputFile3.js
|
||||
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : tests/cases/fourslash/inputFile3.js
|
||||
var x = "hello";
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : declSingle.js
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : declSingle.js
|
||||
var x = "hello";
|
||||
var x1 = 1000;
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
EmitOutputStatus : JSGeneratedWithSemanticErrors
|
||||
FileName : tests/cases/fourslash/inputFile1.js
|
||||
EmitOutputStatus : DiagnosticsPresent_JavaScriptGenerated
|
||||
Diagnostics:
|
||||
'const' declarations are only available when targeting ECMAScript 6 and higher.
|
||||
'const' declarations are only available when targeting ECMAScript 6 and higher.
|
||||
FileName : tests/cases/fourslash/inputFile1.js
|
||||
// File contains early errors. All outputs should be skipped.
|
||||
const uninitialized_const_error;
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
EmitOutputStatus : EmitErrorsEncountered
|
||||
FileName : tests/cases/fourslash/inputFile.js
|
||||
EmitOutputStatus : EmitErrorsEncountered
|
||||
Diagnostics:
|
||||
FileName : tests/cases/fourslash/inputFile.js
|
||||
var M;
|
||||
(function (M) {
|
||||
var C = (function () {
|
||||
@@ -9,4 +10,4 @@ var M;
|
||||
})();
|
||||
M.foo = new C();
|
||||
})(M || (M = {}));
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
EmitOutputStatus : EmitErrorsEncountered
|
||||
FileName : tests/cases/fourslash/inputFile.js
|
||||
EmitOutputStatus : EmitErrorsEncountered
|
||||
Diagnostics:
|
||||
FileName : tests/cases/fourslash/inputFile.js
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
var C = (function () {
|
||||
function C() {
|
||||
@@ -11,4 +12,4 @@ define(["require", "exports"], function (require, exports) {
|
||||
M.foo = new C();
|
||||
})(M = exports.M || (exports.M = {}));
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
EmitOutputStatus : JSGeneratedWithSemanticErrors
|
||||
FileName : tests/cases/fourslash/inputFile.js
|
||||
EmitOutputStatus : DiagnosticsPresent_JavaScriptGenerated
|
||||
Diagnostics:
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
FileName : tests/cases/fourslash/inputFile.js
|
||||
var x = "hello world";
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
EmitOutputStatus : DeclarationGenerationSkipped
|
||||
FileName : tests/cases/fourslash/inputFile.js
|
||||
EmitOutputStatus : DiagnosticsPresent_JavaScriptGenerated_DeclarationNotGenerated
|
||||
Diagnostics:
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
FileName : tests/cases/fourslash/inputFile.js
|
||||
var x = "hello world";
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : tests/cases/fourslash/inputFile1.js
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : tests/cases/fourslash/inputFile1.js
|
||||
// File to emit, does not contain semantic errors
|
||||
// expected to be emitted correctelly regardless of the semantic errors in the other file
|
||||
var noErrors = true;
|
||||
FileName : tests/cases/fourslash/inputFile1.d.ts
|
||||
FileName : tests/cases/fourslash/inputFile1.d.ts
|
||||
declare var noErrors: boolean;
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
EmitOutputStatus : DeclarationGenerationSkipped
|
||||
FileName : out.js
|
||||
EmitOutputStatus : DiagnosticsPresent_JavaScriptGenerated_DeclarationNotGenerated
|
||||
Diagnostics:
|
||||
Type 'string' is not assignable to type 'boolean'.
|
||||
FileName : out.js
|
||||
// File to emit, does not contain semantic errors, but --out is passed
|
||||
// expected to not generate declarations because of the semantic errors in the other file
|
||||
var noErrors = true;
|
||||
// File not emitted, and contains semantic errors
|
||||
var semanticError = "string";
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : tests/cases/fourslash/inputFile1.js
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : tests/cases/fourslash/inputFile1.js
|
||||
// File to emit, does not contain syntactic errors
|
||||
// expected to be emitted correctelly regardless of the syntactic errors in the other file
|
||||
var noErrors = true;
|
||||
|
||||
|
||||
|
||||
+5
-3
@@ -1,8 +1,10 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : out.js
|
||||
EmitOutputStatus : DiagnosticsPresent_JavaScriptGenerated
|
||||
Diagnostics:
|
||||
'=' expected.
|
||||
FileName : out.js
|
||||
// File to emit, does not contain syntactic errors, but --out is passed
|
||||
// expected to not generate outputs because of the syntactic errors in the other file.
|
||||
var noErrors = true;
|
||||
// File not emitted, and contains syntactic errors
|
||||
var syntactic = Error;
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
FileName : tests/cases/fourslash/inputFile.js
|
||||
EmitOutputStatus : DiagnosticsPresent_JavaScriptGenerated
|
||||
Diagnostics:
|
||||
Type expected.
|
||||
FileName : tests/cases/fourslash/inputFile.js
|
||||
var x;
|
||||
|
||||
|
||||
|
||||
+4
-1
@@ -11,5 +11,8 @@
|
||||
"m1.ts",
|
||||
"test.ts"
|
||||
],
|
||||
"emittedFiles": []
|
||||
"emittedFiles": [
|
||||
"m1.js",
|
||||
"test.js"
|
||||
]
|
||||
}
|
||||
+4
-1
@@ -11,5 +11,8 @@
|
||||
"m1.ts",
|
||||
"test.ts"
|
||||
],
|
||||
"emittedFiles": []
|
||||
"emittedFiles": [
|
||||
"m1.js",
|
||||
"test.js"
|
||||
]
|
||||
}
|
||||
+4
-1
@@ -10,5 +10,8 @@
|
||||
"m1.ts",
|
||||
"test.ts"
|
||||
],
|
||||
"emittedFiles": []
|
||||
"emittedFiles": [
|
||||
"m1.js",
|
||||
"test.js"
|
||||
]
|
||||
}
|
||||
+4
-1
@@ -10,5 +10,8 @@
|
||||
"m1.ts",
|
||||
"test.ts"
|
||||
],
|
||||
"emittedFiles": []
|
||||
"emittedFiles": [
|
||||
"m1.js",
|
||||
"test.js"
|
||||
]
|
||||
}
|
||||
+4
-1
@@ -10,5 +10,8 @@
|
||||
"m1.ts",
|
||||
"test.ts"
|
||||
],
|
||||
"emittedFiles": []
|
||||
"emittedFiles": [
|
||||
"m1.js",
|
||||
"test.js"
|
||||
]
|
||||
}
|
||||
+4
-1
@@ -10,5 +10,8 @@
|
||||
"m1.ts",
|
||||
"test.ts"
|
||||
],
|
||||
"emittedFiles": []
|
||||
"emittedFiles": [
|
||||
"m1.js",
|
||||
"test.js"
|
||||
]
|
||||
}
|
||||
+3
-1
@@ -8,5 +8,7 @@
|
||||
"lib.d.ts",
|
||||
"main.ts"
|
||||
],
|
||||
"emittedFiles": []
|
||||
"emittedFiles": [
|
||||
"main.js"
|
||||
]
|
||||
}
|
||||
+3
-1
@@ -8,5 +8,7 @@
|
||||
"lib.d.ts",
|
||||
"main.ts"
|
||||
],
|
||||
"emittedFiles": []
|
||||
"emittedFiles": [
|
||||
"main.js"
|
||||
]
|
||||
}
|
||||
@@ -10,24 +10,23 @@
|
||||
|
||||
declare var process: any;
|
||||
declare var console: any;
|
||||
declare var os: any;
|
||||
|
||||
import ts = require("typescript");
|
||||
|
||||
export function compile(fileNames: string[], options: ts.CompilerOptions): void {
|
||||
var program = ts.createProgram(fileNames, options);
|
||||
var result = program.emit();
|
||||
var emitResult = program.emit();
|
||||
|
||||
var allDiagnostics = program.getDiagnostics()
|
||||
.concat(program.getTypeCheckerDiagnostics())
|
||||
.concat(result.diagnostics);
|
||||
var allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
||||
|
||||
allDiagnostics.forEach(diagnostic => {
|
||||
var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
|
||||
console.log(`${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${diagnostic.messageText}`);
|
||||
console.log(`${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`);
|
||||
});
|
||||
|
||||
console.log(`Process exiting with code '${result.emitResultStatus}'.`);
|
||||
process.exit(result.emitResultStatus);
|
||||
console.log(`Process exiting with code '${emitResult.emitResultStatus}'.`);
|
||||
process.exit(emitResult.emitResultStatus);
|
||||
}
|
||||
|
||||
compile(process.argv.slice(2), {
|
||||
|
||||
@@ -12,6 +12,7 @@ declare var process: any;
|
||||
declare var console: any;
|
||||
declare var fs: any;
|
||||
declare var path: any;
|
||||
declare var os: any;
|
||||
|
||||
import ts = require("typescript");
|
||||
|
||||
@@ -45,17 +46,17 @@ function transform(contents: string, compilerOptions: ts.CompilerOptions = {}) {
|
||||
var program = ts.createProgram(["file.ts"], compilerOptions, compilerHost);
|
||||
|
||||
// Query for early errors
|
||||
var errors = program.getDiagnostics();
|
||||
// Do not generate code in the presence of early errors
|
||||
if (!errors.length) {
|
||||
// Type check and get semantic errors
|
||||
errors = program.getTypeCheckerDiagnostics();
|
||||
// Generate output
|
||||
program.emit();
|
||||
}
|
||||
var errors = ts.getPreEmitDiagnostics(program);
|
||||
var emitResult = program.emit();
|
||||
|
||||
errors = errors.concat(emitResult.diagnostics);
|
||||
|
||||
return {
|
||||
outputs: outputs,
|
||||
errors: errors.map(function (e) { return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + e.messageText; })
|
||||
errors: errors.map(function (e) {
|
||||
return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): "
|
||||
+ ts.flattenDiagnosticMessageText(e.messageText, os.EOL);
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -18,5 +18,5 @@
|
||||
|
||||
// @Filename: inputFile5.js
|
||||
//// var x2 = 1000;
|
||||
|
||||
debugger;
|
||||
verify.baselineGetEmitOutput();
|
||||
@@ -12,5 +12,5 @@
|
||||
// @Filename: inputFile2.ts
|
||||
//// // File not emitted, and contains semantic errors
|
||||
//// var semanticError: boolean = "string";
|
||||
|
||||
debugger;
|
||||
verify.baselineGetEmitOutput();
|
||||
Reference in New Issue
Block a user