Fix the duplicate function implementation error that depended on order of files
This commit is contained in:
parent
11b270f6ca
commit
81763543f3
|
@ -10770,6 +10770,7 @@ namespace ts {
|
|||
|
||||
let symbol = getSymbolOfNode(node);
|
||||
let firstDeclaration = getDeclarationOfKind(symbol, node.kind);
|
||||
|
||||
// Only type check the symbol once
|
||||
if (node === firstDeclaration) {
|
||||
checkFunctionOrConstructorSymbol(symbol);
|
||||
|
@ -11782,7 +11783,13 @@ namespace ts {
|
|||
let symbol = getSymbolOfNode(node);
|
||||
let localSymbol = node.localSymbol || symbol;
|
||||
|
||||
let firstDeclaration = getDeclarationOfKind(localSymbol, node.kind);
|
||||
let firstDeclaration = forEach(symbol.declarations, declaration => {
|
||||
// Get first non javascript function declaration
|
||||
if (declaration.kind === node.kind && !isJavaScript(getSourceFile(declaration).fileName)) {
|
||||
return declaration;
|
||||
}
|
||||
});
|
||||
|
||||
// Only type check the symbol once
|
||||
if (node === firstDeclaration) {
|
||||
checkFunctionOrConstructorSymbol(localSymbol);
|
||||
|
|
|
@ -11,10 +11,14 @@
|
|||
// @emitThisFile: true
|
||||
////function foo() { return 30; }/*2*/
|
||||
|
||||
goTo.marker("1");
|
||||
verify.getSemanticDiagnostics('[]');
|
||||
goTo.marker("2");
|
||||
verify.getSemanticDiagnostics("[]");
|
||||
verify.getSemanticDiagnostics('[\n {\n "message": "Duplicate function implementation.",\n "start": 9,\n "length": 3,\n "category": "error",\n "code": 2393\n }\n]');
|
||||
verify.verifyGetEmitOutputContentsForCurrentFile([
|
||||
{ fileName: "out.js", content: "function foo() { return 10; }\r\nfunction foo() { return 30; }\r\n" },
|
||||
{ fileName: "out.d.ts", content: "" }]);
|
||||
goTo.marker("2");
|
||||
verify.getSemanticDiagnostics('[\n {\n "message": "Duplicate function implementation.",\n "start": 9,\n "length": 3,\n "category": "error",\n "code": 2393\n }\n]');
|
||||
verify.getSemanticDiagnostics('[\n {\n "message": "Duplicate function implementation.",\n "start": 9,\n "length": 3,\n "category": "error",\n "code": 2393\n }\n]');
|
||||
goTo.marker("1");
|
||||
verify.getSemanticDiagnostics('[]');
|
Loading…
Reference in a new issue