mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-22 12:03:44 -05:00
Fix bug: Still implement a method even if the return type is defined in another file (#24978)
This commit is contained in:
@@ -4110,15 +4110,14 @@ namespace ts {
|
||||
if (declaration.parent && declaration.parent.kind === SyntaxKind.VariableDeclaration) {
|
||||
return declarationNameToString((<VariableDeclaration>declaration.parent).name);
|
||||
}
|
||||
if (context && !context.encounteredError && !(context.flags & NodeBuilderFlags.AllowAnonymousIdentifier)) {
|
||||
context.encounteredError = true;
|
||||
}
|
||||
switch (declaration.kind) {
|
||||
case SyntaxKind.ClassExpression:
|
||||
return "(Anonymous class)";
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
return "(Anonymous function)";
|
||||
if (context && !context.encounteredError && !(context.flags & NodeBuilderFlags.AllowAnonymousIdentifier)) {
|
||||
context.encounteredError = true;
|
||||
}
|
||||
return declaration.kind === SyntaxKind.ClassExpression ? "(Anonymous class)" : "(Anonymous function)";
|
||||
}
|
||||
}
|
||||
const nameType = symbol.nameType;
|
||||
|
||||
@@ -3066,6 +3066,7 @@ namespace ts {
|
||||
Subtype
|
||||
}
|
||||
|
||||
// NOTE: If modifying this enum, must modify `TypeFormatFlags` too!
|
||||
export const enum NodeBuilderFlags {
|
||||
None = 0,
|
||||
// Options
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: /I.ts
|
||||
////export interface J {}
|
||||
////export interface I {
|
||||
//// x: J;
|
||||
//// m(): J;
|
||||
////}
|
||||
|
||||
// @Filename: /C.ts
|
||||
////import { I } from "./I";
|
||||
////export class C implements I {}
|
||||
|
||||
goTo.file("/C.ts");
|
||||
verify.codeFix({
|
||||
description: "Implement interface 'I'",
|
||||
newFileContent:
|
||||
`import { I } from "./I";
|
||||
export class C implements I {
|
||||
x: import("/I").J;
|
||||
m(): import("/I").J {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
}`,
|
||||
});
|
||||
@@ -13,4 +13,13 @@
|
||||
////}
|
||||
|
||||
goTo.file("/b.ts");
|
||||
verify.not.codeFixAvailable();
|
||||
verify.codeFix({
|
||||
index: 0,
|
||||
description: "Infer type of 'x' from usage",
|
||||
newFileContent:
|
||||
`export class C {
|
||||
set x(val: Promise<typeof import("/a")>) { val; }
|
||||
method() { this.x = import("./a"); }
|
||||
}`,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user