mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
Add more test cases
This commit is contained in:
parent
40f6b6719f
commit
67eff65e03
@ -25,8 +25,15 @@ module ts {
|
||||
return indentStrings[1].length;
|
||||
}
|
||||
|
||||
function isDeclarationFile(sourceFile: SourceFile): boolean {
|
||||
if (sourceFile.flags & NodeFlags.DeclarationFile) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function shouldEmitToOwnFile(sourceFile: SourceFile, compilerOptions: CompilerOptions): boolean {
|
||||
if (!(sourceFile.flags & NodeFlags.DeclarationFile)) {
|
||||
if (!isDeclarationFile(sourceFile)) {
|
||||
if ((isExternalModule(sourceFile) || !compilerOptions.out) && !fileExtensionIs(sourceFile.filename, ".js")) {
|
||||
return true;
|
||||
}
|
||||
@ -3242,14 +3249,15 @@ module ts {
|
||||
if (compilerOptions.out) {
|
||||
emitFile(compilerOptions.out);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// targetSourceFile is specified (e.g calling emitter from language service or calling getSemanticDiagnostic from language service)
|
||||
if (shouldEmitToOwnFile(targetSourceFile, compilerOptions)) {
|
||||
// If shouldEmitToOwnFile return true or targetSourceFile is an external module file, then emit targetSourceFile in its own output file
|
||||
var jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, ".js");
|
||||
emitFile(jsFilePath, targetSourceFile);
|
||||
}
|
||||
else if (compilerOptions.out) {
|
||||
else if (!isDeclarationFile(targetSourceFile) && compilerOptions.out) {
|
||||
// Otherwise, if --out is specified and targetSourceFile shouldn't be emitted to own file, then emit all, non-external-module file, into one single output file
|
||||
emitFile(compilerOptions.out);
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
EmitOutputStatus : JSGeneratedWithSemanticErrors
|
||||
EmitOutputStatus : Succeeded
|
||||
|
||||
EmitOutputStatus : JSGeneratedWithSemanticErrors
|
||||
EmitOutputStatus : Succeeded
|
||||
Filename : tests/cases/fourslash/inputFile2.js
|
||||
var x1 = "hello world";
|
||||
var Foo = (function () {
|
||||
|
||||
@ -0,0 +1,15 @@
|
||||
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
|
||||
var x = "hello";
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
|
||||
EmitOutputStatus : Succeeded
|
||||
Filename : declSingle.js
|
||||
var x = "hello";
|
||||
var x1 = 1000;
|
||||
|
||||
@ -4,11 +4,7 @@
|
||||
|
||||
// @Filename: decl.d.ts
|
||||
// @emitThisFile: true
|
||||
//// declare x: string;
|
||||
//// declare class Bar {
|
||||
//// x : string;
|
||||
//// y : number
|
||||
//// }
|
||||
//// interface I { a: string; }
|
||||
|
||||
// @Filename: inputFile2.ts
|
||||
// @emitThisFile: true
|
||||
|
||||
18
tests/cases/fourslash/getEmitOutputWithDeclarationFile2.ts
Normal file
18
tests/cases/fourslash/getEmitOutputWithDeclarationFile2.ts
Normal file
@ -0,0 +1,18 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @BaselineFile: getEmitOutputWithDeclarationFile2.baseline
|
||||
|
||||
// @Filename: decl.d.ts
|
||||
// @emitThisFile: true
|
||||
//// interface I { a: string; }
|
||||
|
||||
// @Filename: inputFile2.ts
|
||||
// @emitThisFile: true
|
||||
//// export class Foo { }
|
||||
|
||||
// @Filename: inputFile3.ts
|
||||
// @emitThisFile: true
|
||||
//// var x:string = "hello";
|
||||
|
||||
debugger;
|
||||
verify.baselineGetEmitOutput();
|
||||
21
tests/cases/fourslash/getEmitOutputWithDeclarationFile3.ts
Normal file
21
tests/cases/fourslash/getEmitOutputWithDeclarationFile3.ts
Normal file
@ -0,0 +1,21 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @BaselineFile: getEmitOutputWithDeclarationFile3.baseline
|
||||
// @out: declSingle.js
|
||||
|
||||
// @Filename: decl.d.ts
|
||||
// @emitThisFile: true
|
||||
//// interface I { a: string; }
|
||||
|
||||
// @Filename: inputFile2.ts
|
||||
//// export class Foo { }
|
||||
|
||||
// @Filename: inputFile3.ts
|
||||
// @emitThisFile: true
|
||||
//// var x:string = "hello";
|
||||
|
||||
// @Filename: inputFile4.ts
|
||||
//// var x1:number = 1000;
|
||||
|
||||
debugger;
|
||||
verify.baselineGetEmitOutput();
|
||||
Loading…
x
Reference in New Issue
Block a user