Symbols missing from nodes when SourceFile requested via LanguageService, but not via Program #7581
Labels
API
Relates to the public API for TypeScript
Breaking Change
Would introduce errors in existing code
Bug
A bug in TypeScript
Milestone
I got tripped up when using the compiler API, and I wanted to see if it was just me being confused or an actual bug. :) It seems like
SourceFile
s that are returned fromLanguageService.getSourceFile()
don't include symbols, whereas those loaded viaProgram.getSourceFile()
do.If I request a file via:
...it will be returned without symbols, so if I try calling any of
TypeChecker
's methods on it, it will either throw errors or returnedundefined
. If instead I request files via:..the returned file has the symbols and works fine with
TypeChecker
.I understand that mixing these two APIs is probably not a normal use case. I'm working on a tool that alters the source of a program as it's being compiled, so having access to
LanguageService
is really helpful, but I also need theTypeChecker
.(Also, if this is just a problem with my implementation of
LanguageServiceHost
, please let me know!)TypeScript Version: Behavior appears on 1.8.7, 1.8.9, and 1.9.0-dev.20160318
Test Case
test.ts
case.ts
Expected behavior:
Actual behavior:
Thanks for your help, and for the great work on TypeScript and the compiler API!
The text was updated successfully, but these errors were encountered: