Skip to content

Commit 11b270f

Browse files
committed
Add testcase - generating declaration file results in more errors in ts file
1 parent 9f96f47 commit 11b270f

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

src/harness/fourslash.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,16 @@ namespace FourSlash {
535535
}
536536
}
537537

538+
public verifyGetEmitOutputContentsForCurrentFile(expected: { fileName: string; content: string; }[]): void {
539+
let emit = this.languageService.getEmitOutput(this.activeFile.fileName);
540+
this.taoInvalidReason = "verifyGetEmitOutputContentsForCurrentFile impossible";
541+
assert.equal(emit.outputFiles.length, expected.length, "Number of emit output files");
542+
for (let i = 0; i < emit.outputFiles.length; i++) {
543+
assert.equal(emit.outputFiles[i].name, expected[i].fileName, "FileName");
544+
assert.equal(emit.outputFiles[i].text, expected[i].content, "Content");
545+
}
546+
}
547+
538548
public verifyMemberListContains(symbol: string, text?: string, documentation?: string, kind?: string) {
539549
this.scenarioActions.push("<ShowCompletionList />");
540550
this.scenarioActions.push(`<VerifyCompletionContainsItem ItemName="${symbol}"/>`);

tests/cases/fourslash/fourslash.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,10 @@ module FourSlashInterface {
314314
FourSlash.currentTestState.verifyGetEmitOutputForCurrentFile(expected);
315315
}
316316

317+
public verifyGetEmitOutputContentsForCurrentFile(expected: { fileName: string; content: string; }[]): void {
318+
FourSlash.currentTestState.verifyGetEmitOutputContentsForCurrentFile(expected);
319+
}
320+
317321
public currentParameterHelpArgumentNameIs(name: string) {
318322
FourSlash.currentTestState.verifyCurrentParameterHelpName(name);
319323
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @declaration: true
4+
// @out: out.js
5+
// @jsExtensions: js
6+
// @Filename: b.js
7+
// @emitThisFile: true
8+
////function foo() { return 10; }/*1*/
9+
10+
// @Filename: a.ts
11+
// @emitThisFile: true
12+
////function foo() { return 30; }/*2*/
13+
14+
goTo.marker("2");
15+
verify.getSemanticDiagnostics("[]");
16+
verify.verifyGetEmitOutputContentsForCurrentFile([
17+
{ fileName: "out.js", content: "function foo() { return 10; }\r\nfunction foo() { return 30; }\r\n" },
18+
{ fileName: "out.d.ts", content: "" }]);
19+
goTo.marker("2");
20+
verify.getSemanticDiagnostics('[\n {\n "message": "Duplicate function implementation.",\n "start": 9,\n "length": 3,\n "category": "error",\n "code": 2393\n }\n]');

0 commit comments

Comments
 (0)