-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix getTypeAtLocation for dotted implements clauses #39363
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,3 +77,31 @@ describe("unittests:: Public APIs:: isPropertyName", () => { | |
assert.isTrue(ts.isPropertyName(prop), "PrivateIdentifier must be a valid property name."); | ||
}); | ||
}); | ||
|
||
describe("unittests:: Public APIs:: getTypeAtLocation", () => { | ||
it("works on PropertyAccessExpression in implements clause", () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would this be easier as a fourslash test? I mean, the answer is probably No, but I thought that quickinfo used getTypeAtLocation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mmmmmaaybe? I didn’t think about quick info. I had hoped that the type baseliner would do the job, but it didn’t drill all the way down to the problematic node. Quick info also seems susceptible to future changes in which nodes it calls |
||
const content = `namespace Test { | ||
export interface Test {} | ||
} | ||
class Foo implements Test.Test {}`; | ||
|
||
const host = new fakes.CompilerHost(vfs.createFromFileSystem( | ||
Harness.IO, | ||
/*ignoreCase*/ true, | ||
{ documents: [new documents.TextDocument("/file.ts", content)], cwd: "/" })); | ||
|
||
const program = ts.createProgram({ | ||
host, | ||
rootNames: ["/file.ts"], | ||
options: { noLib: true } | ||
}); | ||
|
||
const checker = program.getTypeChecker(); | ||
const file = program.getSourceFile("/file.ts")!; | ||
const classDeclaration = file.statements.find(ts.isClassDeclaration)!; | ||
const propertyAccess = classDeclaration.heritageClauses![0].types[0].expression as ts.PropertyAccessExpression; | ||
const type = checker.getTypeAtLocation(propertyAccess); | ||
assert.ok(!(type.flags & ts.TypeFlags.Any)); | ||
assert.equal(type, checker.getTypeAtLocation(propertyAccess.name)); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.