Merge pull request #142 from Microsoft/declFileErrorReporting

Compile the generated decl files and report those errors in the baseline so we can verify the result of dts file for correctness
This commit is contained in:
Sheetal Nandi 2014-07-18 12:42:07 -07:00
Родитель 91b8a4531f e0ce0e97d5
Коммит 1abedc30c4
37 изменённых файлов: 830 добавлений и 136 удалений

Просмотреть файл

@ -49,6 +49,7 @@ class CompilerBaselineRunner extends RunnerBase {
var createNewInstance = false;
var lastUnit = units[units.length - 1];
var rootDir = lastUnit.originalFilePath.indexOf('conformance') === -1 ? 'tests/cases/compiler/' : lastUnit.originalFilePath.substring(0, lastUnit.originalFilePath.lastIndexOf('/')) + '/';
var result: Harness.Compiler.CompilerResult;
var options: ts.CompilerOptions;
@ -58,6 +59,10 @@ class CompilerBaselineRunner extends RunnerBase {
var otherFiles: { unitName: string; content: string }[];
var harnessCompiler: Harness.Compiler.HarnessCompiler;
var declToBeCompiled: { unitName: string; content: string }[] = [];
var declOtherFiles: { unitName: string; content: string }[] = [];
var declResult: Harness.Compiler.CompilerResult;
var createNewInstance = false;
before(() => {
@ -67,7 +72,6 @@ class CompilerBaselineRunner extends RunnerBase {
// otherwise, assume all files are just meant to be in the same compilation session without explicit references to one another.
toBeCompiled = [];
otherFiles = [];
var rootDir = lastUnit.originalFilePath.indexOf('conformance') === -1 ? 'tests/cases/compiler/' : lastUnit.originalFilePath.substring(0, lastUnit.originalFilePath.lastIndexOf('/')) + '/';
if (/require\(/.test(lastUnit.content) || /reference\spath/.test(lastUnit.content)) {
toBeCompiled.push({ unitName: rootDir + lastUnit.name, content: lastUnit.content });
units.forEach(unit => {
@ -114,94 +118,106 @@ class CompilerBaselineRunner extends RunnerBase {
}
});
function getErrorBaseline(toBeCompiled: { unitName: string; content: string }[],
otherFiles: { unitName: string; content: string }[],
result: Harness.Compiler.CompilerResult
) {
var outputLines: string[] = [];
// Count up all the errors we find so we don't miss any
var totalErrorsReported = 0;
function outputErrorText(error: Harness.Compiler.MinimalDiagnostic) {
var errLines = RunnerBase.removeFullPaths(error.message)
.split('\n')
.map(s => s.length > 0 && s.charAt(s.length - 1) === '\r' ? s.substr(0, s.length - 1) : s)
.filter(s => s.length > 0)
.map(s => '!!! ' + s);
errLines.forEach(e => outputLines.push(e));
totalErrorsReported++;
}
// Report glovbal errors:
var globalErrors = result.errors.filter(err => !err.filename);
globalErrors.forEach(err => outputErrorText(err));
// 'merge' the lines of each input file with any errors associated with it
toBeCompiled.concat(otherFiles).forEach(inputFile => {
// Filter down to the errors in the file
var fileErrors = result.errors.filter(e => {
var errFn = e.filename;
return errFn && errFn === inputFile.unitName;
});
// Header
outputLines.push('==== ' + inputFile.unitName + ' (' + fileErrors.length + ' errors) ====');
// Make sure we emit something for every error
var markedErrorCount = 0;
// For each line, emit the line followed by any error squiggles matching this line
// Note: IE JS engine incorrectly handles consecutive delimiters here when using RegExp split, so
// we have to string-based splitting instead and try to figure out the delimiting chars
var lineStarts = ts.getLineStarts(inputFile.content);
var lines = inputFile.content.split('\n');
lines.forEach((line, lineIndex) => {
if (line.length > 0 && line.charAt(line.length - 1) === '\r') {
line = line.substr(0, line.length - 1);
}
var thisLineStart = lineStarts[lineIndex];
var nextLineStart: number;
// On the last line of the file, fake the next line start number so that we handle errors on the last character of the file correctly
if (lineIndex === lines.length - 1) {
nextLineStart = inputFile.content.length;
} else {
nextLineStart = lineStarts[lineIndex + 1];
}
// Emit this line from the original file
outputLines.push(' ' + line);
fileErrors.forEach(err => {
// Does any error start or continue on to this line? Emit squiggles
if ((err.end >= thisLineStart) && ((err.start < nextLineStart) || (lineIndex === lines.length - 1))) {
// How many characters from the start of this line the error starts at (could be positive or negative)
var relativeOffset = err.start - thisLineStart;
// How many characters of the error are on this line (might be longer than this line in reality)
var length = (err.end - err.start) - Math.max(0, thisLineStart - err.start);
// Calculate the start of the squiggle
var squiggleStart = Math.max(0, relativeOffset);
// TODO/REVIEW: this doesn't work quite right in the browser if a multi file test has files whose names are just the right length relative to one another
outputLines.push(' ' + line.substr(0, squiggleStart).replace(/[^\s]/g, ' ') + new Array(Math.min(length, line.length - squiggleStart) + 1).join('~'));
// If the error ended here, or we're at the end of the file, emit its message
if ((lineIndex === lines.length - 1) || nextLineStart > err.end) {
// Just like above, we need to do a split on a string instead of on a regex
// because the JS engine does regexes wrong
outputErrorText(err);
markedErrorCount++;
}
}
});
});
// Verify we didn't miss any errors in this file
assert.equal(markedErrorCount, fileErrors.length, 'count of errors in ' + inputFile.unitName);
});
// Verify we didn't miss any errors in total
assert.equal(totalErrorsReported, result.errors.length, 'total number of errors');
return outputLines.join('\r\n');
}
// check errors
it('Correct errors for ' + fileName, () => {
if (this.errors) {
Harness.Baseline.runBaseline('Correct errors for ' + fileName, justName.replace(/\.ts$/, '.errors.txt'), (): string => {
if (result.errors.length === 0) return null;
var outputLines: string[] = [];
// Count up all the errors we find so we don't miss any
var totalErrorsReported = 0;
// 'merge' the lines of each input file with any errors associated with it
toBeCompiled.concat(otherFiles).forEach(inputFile => {
// Filter down to the errors in the file
// TODO/REVIEW: this doesn't work quite right in the browser if a multi file test has files whose names are just the right length relative to one another
var fileErrors = result.errors.filter(e => {
var errFn = e.filename;
return errFn && errFn.indexOf(inputFile.unitName) === errFn.length - inputFile.unitName.length;
});
// Add this to the number of errors we've seen so far
totalErrorsReported += fileErrors.length;
// Header
outputLines.push('==== ' + inputFile.unitName + ' (' + fileErrors.length + ' errors) ====');
// Make sure we emit something for every error
var markedErrorCount = 0;
// For each line, emit the line followed by any error squiggles matching this line
// Note: IE JS engine incorrectly handles consecutive delimiters here when using RegExp split, so
// we have to string-based splitting instead and try to figure out the delimiting chars
// var fileLineMap = TypeScript.LineMap1.fromString(inputFile.content);
var lines = inputFile.content.split('\n');
var currentLineStart = 0;
lines.forEach((line, lineIndex) => {
if (line.length > 0 && line.charAt(line.length - 1) === '\r') {
line = line.substr(0, line.length - 1);
}
var thisLineStart = currentLineStart; //fileLineMap.getLineStartPosition(lineIndex);
var nextLineStart: number;
// On the last line of the file, fake the next line start number so that we handle errors on the last character of the file correctly
if (lineIndex === lines.length - 1) {
nextLineStart = inputFile.content.length;
} else {
nextLineStart = currentLineStart + line.length + 1; //fileLineMap.getLineStartPosition(lineIndex + 1);
}
// Emit this line from the original file
outputLines.push(' ' + line);
fileErrors.forEach(err => {
// Does any error start or continue on to this line? Emit squiggles
if ((err.end >= thisLineStart) && ((err.start < nextLineStart) || (lineIndex === lines.length - 1))) {
// How many characters from the start of this line the error starts at (could be positive or negative)
var relativeOffset = err.start - thisLineStart;
// How many characters of the error are on this line (might be longer than this line in reality)
var length = (err.end - err.start) - Math.max(0, thisLineStart - err.start);
// Calculate the start of the squiggle
var squiggleStart = Math.max(0, relativeOffset);
// TODO/REVIEW: this doesn't work quite right in the browser if a multi file test has files whose names are just the right length relative to one another
outputLines.push(' ' + line.substr(0, squiggleStart).replace(/[^\s]/g, ' ') + new Array(Math.min(length, line.length - squiggleStart) + 1).join('~'));
// If the error ended here, or we're at the end of the file, emit its message
if ((lineIndex === lines.length - 1) || nextLineStart > err.end) {
// Just like above, we need to do a split on a string instead of on a regex
// because the JS engine does regexes wrong
var errLines = RunnerBase.removeFullPaths(err.message)
.split('\n')
.map(s => s.length > 0 && s.charAt(s.length - 1) === '\r' ? s.substr(0, s.length - 1) : s)
.filter(s => s.length > 0)
.map(s => '!!! ' + s);
errLines.forEach(e => outputLines.push(e));
markedErrorCount++;
}
}
});
currentLineStart += line.length + 1; // +1 for the \n character
});
// Verify we didn't miss any errors in this file
assert.equal(markedErrorCount, fileErrors.length, 'count of errors in ' + inputFile.unitName);
});
// Verify we didn't miss any errors in total
// NEWTODO: Re-enable this -- somehow got broken
// assert.equal(totalErrorsReported, result.errors.length, 'total number of errors');
return outputLines.join('\r\n');
return getErrorBaseline(toBeCompiled, otherFiles, result);
});
}
});
@ -215,49 +231,35 @@ class CompilerBaselineRunner extends RunnerBase {
}
});
/*
it(".d.ts compiles without error", () => {
// Compile .d.ts files
it('Correct compiler generated.d.ts for ' + fileName, () => {
if (options.declaration && result.errors.length === 0 && result.declFilesCode.length !== result.files.length) {
throw new Error('There were no errors and declFiles generated did not match number of js files generated');
}
// if the .d.ts is non-empty, confirm it compiles correctly as well
if (this.decl && result.declFilesCode.length > 0 && result.errors.length === 0) {
var declErrors: string[] = undefined;
var declOtherFiles: { unitName: string; content: string }[] = [];
// use other files if it is dts
for (var i = 0; i < otherFiles.length; i++) {
if (TypeScript.isDTSFile(otherFiles[i].unitName)) {
declOtherFiles.push(otherFiles[i]);
if (options.declaration && result.errors.length === 0 && result.declFilesCode.length > 0) {
function getDtsFile(file: { unitName: string; content: string }) {
if (Harness.Compiler.isDTS(file.unitName)) {
return file;
} else {
var declFile = ts.forEach(result.declFilesCode,
declFile => declFile.fileName === (file.unitName.substr(0, file.unitName.length - ".ts".length) + ".d.ts")
? declFile : undefined);
return { unitName: rootDir + Harness.Path.getFileName(declFile.fileName), content: declFile.code };
}
}
for (var i = 0; i < result.declFilesCode.length; i++) {
var declCode = result.declFilesCode[i];
// don't want to use the fullpath for the unitName or the file won't be resolved correctly
// TODO: wrong path for conformance tests?
var declFile = { unitName: 'tests/cases/compiler/' + Harness.getFileName(declCode.fileName), content: declCode.code };
if (i != result.declFilesCode.length - 1) {
declOtherFiles.push(declFile);
}
}
harnessCompiler.compileFiles(
[declFile],
declOtherFiles,
(result) => {
declErrors = result.errors.map(err => err.message + "\r\n");
},
function (settings) {
ts.forEach(toBeCompiled, file => { declToBeCompiled.push(getDtsFile(file)); });
ts.forEach(otherFiles, file => { declOtherFiles.push(getDtsFile(file)); });
harnessCompiler.compileFiles(declToBeCompiled, declOtherFiles, function (compileResult) {
declResult = compileResult;
}, function (settings) {
harnessCompiler.setCompilerSettings(tcSettings);
});
if (declErrors && declErrors.length) {
throw new Error('.d.ts file output of ' + fileName + ' did not compile. Errors: ' + declErrors.map(err => JSON.stringify(err)).join('\r\n'));
}
});
}
});
*/
it('Correct JS output for ' + fileName, () => {
if (!ts.fileExtensionIs(lastUnit.name, '.d.ts') && this.emit) {
@ -293,6 +295,12 @@ class CompilerBaselineRunner extends RunnerBase {
}
}
if (declResult && declResult.errors.length) {
jsCode += '\r\n\r\n//// [DtsFileErrors]\r\n';
jsCode += '\r\n\r\n';
jsCode += getErrorBaseline(declToBeCompiled, declOtherFiles, declResult);
}
if (jsCode.length > 0) {
return tsCode + '\r\n\r\n' + jsCode;
} else {

Просмотреть файл

@ -806,10 +806,22 @@ module Harness {
code: string;
}
export function stringEndsWith(str: string, end: string) {
function stringEndsWith(str: string, end: string) {
return str.substr(str.length - end.length) === end;
}
export function isDTS(fileName: string) {
return stringEndsWith(fileName, '.d.ts');
}
export function isJS(fileName: string) {
return stringEndsWith(fileName, '.js');
}
export function isJSMap(fileName: string) {
return stringEndsWith(fileName, '.js.map');
}
/** Contains the code and errors of a compilation and some helper methods to check its status. */
export class CompilerResult {
public files: GeneratedFile[] = [];
@ -824,13 +836,13 @@ module Harness {
fileResults.forEach(emittedFile => {
var fileObj = { fileName: emittedFile.fileName, code: emittedFile.file };
if (stringEndsWith(emittedFile.fileName, '.d.ts')) {
if (isDTS(emittedFile.fileName)) {
// .d.ts file, add to declFiles emit
this.declFilesCode.push(fileObj);
} else if (stringEndsWith(emittedFile.fileName, '.js')) {
} else if (isJS(emittedFile.fileName)) {
// .js file, add to files
this.files.push(fileObj);
} else if (stringEndsWith(emittedFile.fileName, '.js.map')) {
} else if (isJSMap(emittedFile.fileName)) {
this.sourceMaps.push(fileObj);
} else {
throw new Error('Unrecognized file extension for file ' + emittedFile.fileName);

Просмотреть файл

@ -175,18 +175,18 @@ class ProjectRunner extends RunnerBase {
// we need to instead create files that can live in the project reference folder
// but make sure extension of these files matches with the filename the compiler asked to write
diskRelativeName = "diskFile" + nonSubfolderDiskFiles++ +
(Harness.Compiler.stringEndsWith(filename, ".d.ts") ? ".d.ts" :
Harness.Compiler.stringEndsWith(filename, ".js") ? ".js" : ".js.map");
(Harness.Compiler.isDTS(filename) ? ".d.ts" :
Harness.Compiler.isJS(filename) ? ".js" : ".js.map");
}
if (Harness.Compiler.stringEndsWith(filename, ".js")) {
if (Harness.Compiler.isJS(filename)) {
// Make sure if there is URl we have it cleaned up
var indexOfSourceMapUrl = data.lastIndexOf("//# sourceMappingURL=");
if (indexOfSourceMapUrl != -1) {
data = data.substring(0, indexOfSourceMapUrl + 21) + cleanProjectUrl(data.substring(indexOfSourceMapUrl + 21));
}
}
else if (Harness.Compiler.stringEndsWith(filename, ".js.map")) {
else if (Harness.Compiler.isJSMap(filename)) {
// Make sure sources list is cleaned
var sourceMapData = JSON.parse(data);
for (var i = 0; i < sourceMapData.sources.length; i++) {
@ -332,7 +332,7 @@ class ProjectRunner extends RunnerBase {
it('SourceMapRecord for (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, () => {
Harness.Baseline.runBaseline('SourceMapRecord for (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + '.sourcemap.txt', () => {
return Harness.SourceMapRecoder.getSourceMapRecord(compilerResult.sourceMapData, compilerResult.program,
ts.filter(compilerResult.outputFiles, outputFile => Harness.Compiler.stringEndsWith(outputFile.emittedFileName, ".js")));
ts.filter(compilerResult.outputFiles, outputFile => Harness.Compiler.isJS(outputFile.emittedFileName)));
});
});
}

Просмотреть файл

@ -33,3 +33,22 @@ declare module "SubModule" {
//// [declFileAmbientExternalModuleWithSingleExportedModule_1.d.ts]
/// <reference path='declFileAmbientExternalModuleWithSingleExportedModule_0.d.ts' />
export declare var x: SubModule.m.m3.c;
//// [DtsFileErrors]
==== tests/cases/compiler/declFileAmbientExternalModuleWithSingleExportedModule_1.d.ts (1 errors) ====
/// <reference path='declFileAmbientExternalModuleWithSingleExportedModule_0.d.ts' />
export declare var x: SubModule.m.m3.c;
~~~~~~~~~~~~~~~~
!!! Cannot find name 'SubModule'.
==== tests/cases/compiler/declFileAmbientExternalModuleWithSingleExportedModule_0.d.ts (0 errors) ====
declare module "SubModule" {
module m {
module m3 {
}
}
}

Просмотреть файл

@ -29,3 +29,19 @@ interface Foo<T> {
export = Foo;
//// [declFileExportAssignmentOfGenericInterface_1.d.ts]
export declare var x: a<a<string>>;
//// [DtsFileErrors]
==== tests/cases/compiler/declFileExportAssignmentOfGenericInterface_1.d.ts (1 errors) ====
export declare var x: a<a<string>>;
~~~~~~~~~~~~
!!! Cannot find name 'a'.
==== tests/cases/compiler/declFileExportAssignmentOfGenericInterface_0.d.ts (0 errors) ====
interface Foo<T> {
a: string;
}
export = Foo;

Просмотреть файл

@ -75,3 +75,32 @@ export = b;
export import b1 = require("declFileExportImportChain_b1");
//// [declFileExportImportChain_d.d.ts]
export declare var x: m1.m2.c1;
//// [DtsFileErrors]
==== tests/cases/compiler/declFileExportImportChain_d.d.ts (1 errors) ====
export declare var x: m1.m2.c1;
~~~~~~~~
!!! Cannot find name 'm1'.
==== tests/cases/compiler/declFileExportImportChain_a.d.ts (0 errors) ====
declare module m1 {
module m2 {
class c1 {
}
}
}
export = m1;
==== tests/cases/compiler/declFileExportImportChain_b.d.ts (0 errors) ====
export import a = require("declFileExportImportChain_a");
==== tests/cases/compiler/declFileExportImportChain_b1.d.ts (0 errors) ====
import b = require("declFileExportImportChain_b");
export = b;
==== tests/cases/compiler/declFileExportImportChain_c.d.ts (0 errors) ====
export import b1 = require("declFileExportImportChain_b1");

Просмотреть файл

@ -66,3 +66,29 @@ export = a;
export import b = require("declFileExportImportChain2_b");
//// [declFileExportImportChain2_d.d.ts]
export declare var x: m1.m2.c1;
//// [DtsFileErrors]
==== tests/cases/compiler/declFileExportImportChain2_d.d.ts (1 errors) ====
export declare var x: m1.m2.c1;
~~~~~~~~
!!! Cannot find name 'm1'.
==== tests/cases/compiler/declFileExportImportChain2_a.d.ts (0 errors) ====
declare module m1 {
module m2 {
class c1 {
}
}
}
export = m1;
==== tests/cases/compiler/declFileExportImportChain2_b.d.ts (0 errors) ====
import a = require("declFileExportImportChain2_a");
export = a;
==== tests/cases/compiler/declFileExportImportChain2_c.d.ts (0 errors) ====
export import b = require("declFileExportImportChain2_b");

Просмотреть файл

@ -113,3 +113,45 @@ declare module templa.dom.mvc.composite {
constructor();
}
}
//// [DtsFileErrors]
==== tests/cases/compiler/declFileGenericType2.d.ts (6 errors) ====
declare module templa.mvc {
}
declare module templa.mvc {
}
declare module templa.mvc {
}
declare module templa.mvc.composite {
}
declare module templa.dom.mvc {
interface IElementController<ModelType extends templa.mvc.IModel> extends templa.mvc.IController<ModelType> {
~~~~~~~~~~~~~~~~~
!!! Module 'templa.mvc' has no exported member 'IModel'.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! Module 'templa.mvc' has no exported member 'IController'.
}
}
declare module templa.dom.mvc {
class AbstractElementController<ModelType extends templa.mvc.IModel> extends templa.mvc.AbstractController<ModelType> implements IElementController<ModelType> {
~~~~~~~~~~~~~~~~~
!!! Module 'templa.mvc' has no exported member 'IModel'.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! Module 'templa.mvc' has no exported member 'AbstractController'.
constructor();
}
}
declare module templa.dom.mvc.composite {
class AbstractCompositeElementController<ModelType extends templa.mvc.composite.ICompositeControllerModel> extends AbstractElementController<ModelType> {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! Module 'templa.mvc.composite' has no exported member 'ICompositeControllerModel'.
_controllers: templa.mvc.IController<templa.mvc.IModel>[];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! Module 'templa.mvc' has no exported member 'IController'.
constructor();
}
}

Просмотреть файл

@ -57,3 +57,38 @@ export declare var a: {
test1: a1.connectModule;
test2(): a1.connectModule;
};
//// [DtsFileErrors]
==== tests/cases/compiler/declFileImportModuleWithExportAssignment_1.d.ts (3 errors) ====
export declare var a: {
(): a1.connectExport;
~~~~~~~~~~~~~~~~
!!! Cannot find name 'a1'.
test1: a1.connectModule;
~~~~~~~~~~~~~~~~
!!! Cannot find name 'a1'.
test2(): a1.connectModule;
~~~~~~~~~~~~~~~~
!!! Cannot find name 'a1'.
};
==== tests/cases/compiler/declFileImportModuleWithExportAssignment_0.d.ts (0 errors) ====
declare module m2 {
interface connectModule {
(res: any, req: any, next: any): void;
}
interface connectExport {
use: (mod: connectModule) => connectExport;
listen: (port: number) => void;
}
}
declare var m2: {
(): m2.connectExport;
test1: m2.connectModule;
test2(): m2.connectModule;
};
export = m2;

Просмотреть файл

@ -29,3 +29,19 @@ declare module 'mod1' {
declare module 'moo' {
var p: List<x.Foo>;
}
//// [DtsFileErrors]
==== tests/cases/compiler/declFileImportedTypeUseInTypeArgPosition.d.ts (1 errors) ====
declare class List<T> {
}
declare module 'mod1' {
}
declare module 'moo' {
var p: List<x.Foo>;
~~~~~
!!! Cannot find name 'x'.
}

Просмотреть файл

@ -46,3 +46,23 @@ declare module m2 {
export import x = m.c;
var d: x;
}
//// [DtsFileErrors]
==== tests/cases/compiler/declFileInternalAliases.d.ts (1 errors) ====
declare module m {
class c {
}
}
declare module m1 {
var d: x;
~
!!! Cannot find name 'x'.
}
declare module m2 {
export import x = m.c;
var d: x;
}

Просмотреть файл

@ -82,3 +82,41 @@ declare module M {
m3(): C;
}
}
//// [DtsFileErrors]
==== tests/cases/compiler/declInput-2.d.ts (5 errors) ====
declare module M {
class E {
}
interface I1 {
}
class D {
private c;
m1: number;
m2: string;
m22: C;
~
!!! Cannot find name 'C'.
m23: E;
m24: I1;
m25: I2;
~~
!!! Cannot find name 'I2'.
m232(): E;
m242(): I1;
m252(): I2;
~~
!!! Cannot find name 'I2'.
m26(i: I1): void;
m262(i: I2): void;
~~
!!! Cannot find name 'I2'.
m3(): C;
~
!!! Cannot find name 'C'.
}
}

Просмотреть файл

@ -193,3 +193,67 @@ export declare module M.Q {
}
}
}
//// [DtsFileErrors]
==== tests/cases/compiler/declarationEmit_nameConflicts_0.d.ts (1 errors) ====
export declare module M {
function f(): void;
class C {
}
module N {
function g(): void;
interface I {
}
}
export import a = M.f;
export import b = M.C;
export import c = N;
export import d = im;
~~~~~~~~~~~~~~~~~~~~~
!!! Cannot find name 'im'.
}
export declare module M.P {
function f(): void;
class C {
}
module N {
function g(): void;
interface I {
}
}
export import im = M.P.f;
var a: () => void;
var b: typeof M.C;
var c: typeof M.N;
var g: () => void;
var d: typeof M.d;
}
export declare module M.Q {
function f(): void;
class C {
}
module N {
function g(): void;
interface I {
}
}
interface b extends M.C {
}
interface I extends M.N.I {
}
module c {
interface I extends M.N.I {
}
}
}
==== tests/cases/compiler/declarationEmit_nameConflicts_1.d.ts (0 errors) ====
declare module f {
class c {
}
}
export = f;

Просмотреть файл

@ -30,13 +30,10 @@
var x = 42;
export = x;
==== tests/cases/conformance/externalModules/expBoolean.ts (1 errors) ====
==== tests/cases/conformance/externalModules/expBoolean.ts (0 errors) ====
var x = true;
export = x;
~~~~~~~~~
!!! Cannot compile external modules unless the '--module' flag is provided.
==== tests/cases/conformance/externalModules/expArray.ts (0 errors) ====
var x = [1,2];
export = x;
@ -49,12 +46,9 @@
var x;
export = x;
==== tests/cases/conformance/externalModules/expGeneric.ts (1 errors) ====
==== tests/cases/conformance/externalModules/expGeneric.ts (0 errors) ====
function x<T>(a: T){
~~~~
return a;
~~~~~~
!!! Cannot compile external modules unless the '--module' flag is provided.
}
export = x;

Просмотреть файл

@ -47,3 +47,22 @@ declare class Widget1 {
export import w = require('./w1');
//// [consumer.d.ts]
export declare function w(): Widget1;
//// [DtsFileErrors]
==== tests/cases/compiler/consumer.d.ts (1 errors) ====
export declare function w(): Widget1;
~~~~~~~
!!! Cannot find name 'Widget1'.
==== tests/cases/compiler/w1.d.ts (0 errors) ====
export = Widget1;
declare class Widget1 {
name: string;
}
==== tests/cases/compiler/exporter.d.ts (0 errors) ====
export import w = require('./w1');

Просмотреть файл

@ -39,3 +39,22 @@ interface Widget1 {
export import w = require('./w1');
//// [consumer.d.ts]
export declare function w(): Widget1;
//// [DtsFileErrors]
==== tests/cases/compiler/consumer.d.ts (1 errors) ====
export declare function w(): Widget1;
~~~~~~~
!!! Cannot find name 'Widget1'.
==== tests/cases/compiler/w1.d.ts (0 errors) ====
export = Widget1;
interface Widget1 {
name: string;
}
==== tests/cases/compiler/exporter.d.ts (0 errors) ====
export import w = require('./w1');

Просмотреть файл

@ -9,3 +9,13 @@ var x = function somefn() {
//// [functionExpressionReturningItself.d.ts]
declare var x: () => typeof somefn;
//// [DtsFileErrors]
==== tests/cases/compiler/functionExpressionReturningItself.d.ts (1 errors) ====
declare var x: () => typeof somefn;
~~~~~~
!!! Cannot find name 'somefn'.

Просмотреть файл

@ -29,3 +29,19 @@ export declare class B {
//// [importDeclarationUsedAsTypeQuery_1.d.ts]
/// <reference path='importDeclarationUsedAsTypeQuery_require.d.ts' />
export declare var x: typeof a;
//// [DtsFileErrors]
==== tests/cases/compiler/importDeclarationUsedAsTypeQuery_1.d.ts (1 errors) ====
/// <reference path='importDeclarationUsedAsTypeQuery_require.d.ts' />
export declare var x: typeof a;
~
!!! Cannot find name 'a'.
==== tests/cases/compiler/importDeclarationUsedAsTypeQuery_require.d.ts (0 errors) ====
export declare class B {
id: number;
}

Просмотреть файл

@ -34,3 +34,19 @@ declare module a {
declare module c {
var x: b;
}
//// [DtsFileErrors]
==== tests/cases/compiler/internalAliasClass.d.ts (1 errors) ====
declare module a {
class c {
}
}
declare module c {
var x: b;
~
!!! Cannot find name 'b'.
}

Просмотреть файл

@ -50,3 +50,22 @@ export declare module m2 {
var cProp: c;
}
}
//// [DtsFileErrors]
==== tests/cases/compiler/internalAliasClassInsideLocalModuleWithoutExport.d.ts (1 errors) ====
export declare module x {
class c {
foo(a: number): number;
}
}
export declare module m2 {
module m3 {
var cProp: c;
~
!!! Cannot find name 'c'.
}
}

Просмотреть файл

@ -36,3 +36,18 @@ export declare module x {
}
}
export declare var cProp: xc;
//// [DtsFileErrors]
==== tests/cases/compiler/internalAliasClassInsideTopLevelModuleWithoutExport.d.ts (1 errors) ====
export declare module x {
class c {
foo(a: number): number;
}
}
export declare var cProp: xc;
~~
!!! Cannot find name 'xc'.

Просмотреть файл

@ -41,3 +41,22 @@ declare module a {
declare module c {
var bVal: b;
}
//// [DtsFileErrors]
==== tests/cases/compiler/internalAliasEnum.d.ts (1 errors) ====
declare module a {
enum weekend {
Friday = 0,
Saturday = 1,
Sunday = 2,
}
}
declare module c {
var bVal: b;
~
!!! Cannot find name 'b'.
}

Просмотреть файл

@ -41,3 +41,22 @@ export declare module a {
export declare module c {
var bVal: b;
}
//// [DtsFileErrors]
==== tests/cases/compiler/internalAliasEnumInsideLocalModuleWithoutExport.d.ts (1 errors) ====
export declare module a {
enum weekend {
Friday = 0,
Saturday = 1,
Sunday = 2,
}
}
export declare module c {
var bVal: b;
~
!!! Cannot find name 'b'.
}

Просмотреть файл

@ -36,3 +36,20 @@ export declare module a {
}
}
export declare var bVal: b;
//// [DtsFileErrors]
==== tests/cases/compiler/internalAliasEnumInsideTopLevelModuleWithoutExport.d.ts (1 errors) ====
export declare module a {
enum weekend {
Friday = 0,
Saturday = 1,
Sunday = 2,
}
}
export declare var bVal: b;
~
!!! Cannot find name 'b'.

Просмотреть файл

@ -41,3 +41,21 @@ declare module a {
declare module c {
var x: b.c;
}
//// [DtsFileErrors]
==== tests/cases/compiler/internalAliasInitializedModule.d.ts (1 errors) ====
declare module a {
module b {
class c {
}
}
}
declare module c {
var x: b.c;
~~~
!!! Cannot find name 'b'.
}

Просмотреть файл

@ -41,3 +41,21 @@ export declare module a {
export declare module c {
var x: b.c;
}
//// [DtsFileErrors]
==== tests/cases/compiler/internalAliasInitializedModuleInsideLocalModuleWithoutExport.d.ts (1 errors) ====
export declare module a {
module b {
class c {
}
}
}
export declare module c {
var x: b.c;
~~~
!!! Cannot find name 'b'.
}

Просмотреть файл

@ -36,3 +36,19 @@ export declare module a {
}
}
export declare var x: b.c;
//// [DtsFileErrors]
==== tests/cases/compiler/internalAliasInitializedModuleInsideTopLevelModuleWithoutExport.d.ts (1 errors) ====
export declare module a {
module b {
class c {
}
}
}
export declare var x: b.c;
~~~
!!! Cannot find name 'b'.

Просмотреть файл

@ -25,3 +25,19 @@ declare module a {
declare module c {
var x: b;
}
//// [DtsFileErrors]
==== tests/cases/compiler/internalAliasInterface.d.ts (1 errors) ====
declare module a {
interface I {
}
}
declare module c {
var x: b;
~
!!! Cannot find name 'b'.
}

Просмотреть файл

@ -27,3 +27,19 @@ export declare module a {
export declare module c {
var x: b;
}
//// [DtsFileErrors]
==== tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExport.d.ts (1 errors) ====
export declare module a {
interface I {
}
}
export declare module c {
var x: b;
~
!!! Cannot find name 'b'.
}

Просмотреть файл

@ -20,3 +20,17 @@ export declare module a {
}
}
export declare var x: b;
//// [DtsFileErrors]
==== tests/cases/compiler/internalAliasInterfaceInsideTopLevelModuleWithoutExport.d.ts (1 errors) ====
export declare module a {
interface I {
}
}
export declare var x: b;
~
!!! Cannot find name 'b'.

Просмотреть файл

@ -32,3 +32,22 @@ declare module a {
declare module c {
var x: b.I;
}
//// [DtsFileErrors]
==== tests/cases/compiler/internalAliasUninitializedModule.d.ts (1 errors) ====
declare module a {
module b {
interface I {
foo(): any;
}
}
}
declare module c {
var x: b.I;
~~~
!!! Cannot find name 'b'.
}

Просмотреть файл

@ -32,3 +32,22 @@ export declare module a {
export declare module c {
var x: b.I;
}
//// [DtsFileErrors]
==== tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExport.d.ts (1 errors) ====
export declare module a {
module b {
interface I {
foo(): any;
}
}
}
export declare module c {
var x: b.I;
~~~
!!! Cannot find name 'b'.
}

Просмотреть файл

@ -26,3 +26,20 @@ export declare module a {
}
}
export declare var x: b.I;
//// [DtsFileErrors]
==== tests/cases/compiler/internalAliasUninitializedModuleInsideTopLevelModuleWithoutExport.d.ts (1 errors) ====
export declare module a {
module b {
interface I {
foo(): any;
}
}
}
export declare var x: b.I;
~~~
!!! Cannot find name 'b'.

Просмотреть файл

@ -49,3 +49,28 @@ declare class MainModule {
constructor();
}
export = MainModule;
//// [DtsFileErrors]
==== tests/cases/compiler/missingImportAfterModuleImport_1.d.ts (1 errors) ====
/// <reference path='missingImportAfterModuleImport_0.d.ts' />
declare class MainModule {
SubModule: SubModule;
~~~~~~~~~
!!! Cannot find name 'SubModule'.
constructor();
}
export = MainModule;
==== tests/cases/compiler/missingImportAfterModuleImport_0.d.ts (0 errors) ====
declare module "SubModule" {
class SubModule {
static StaticVar: number;
InstanceVar: number;
constructor();
}
export = SubModule;
}

Просмотреть файл

@ -1,3 +1,11 @@
!!! Cannot find global type 'Array'.
!!! Cannot find global type 'Boolean'.
!!! Cannot find global type 'Function'.
!!! Cannot find global type 'IArguments'.
!!! Cannot find global type 'Number'.
!!! Cannot find global type 'Object'.
!!! Cannot find global type 'RegExp'.
!!! Cannot find global type 'String'.
==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509698.ts (0 errors) ====
/// <style requireSemi="on" />
/// <reference no-default-lib="true"/>

Просмотреть файл

@ -23,3 +23,15 @@ var Outer;
declare module Outer {
var f: typeof Inner;
}
//// [DtsFileErrors]
==== tests/cases/compiler/privacyCheckTypeOfInvisibleModuleNoError.d.ts (1 errors) ====
declare module Outer {
var f: typeof Inner;
~~~~~
!!! Cannot find name 'Inner'.
}

Просмотреть файл

@ -1,3 +1,11 @@
!!! Cannot find global type 'Array'.
!!! Cannot find global type 'Boolean'.
!!! Cannot find global type 'Function'.
!!! Cannot find global type 'IArguments'.
!!! Cannot find global type 'Number'.
!!! Cannot find global type 'Object'.
!!! Cannot find global type 'RegExp'.
!!! Cannot find global type 'String'.
==== tests/cases/compiler/typeCheckTypeArgument.ts (6 errors) ====
/// <reference no-default-lib="true"/>