fix: CompilerHost.getSourceFile is being called for odd filenames#23043
fix: CompilerHost.getSourceFile is being called for odd filenames#23043mhegazy merged 1 commit intomicrosoft:mastermicrosoft/TypeScript:masterfrom alan-agius4:feature/compiler-host-falsy-filealan-agius4/TypeScript:feature/compiler-host-falsy-fileCopy head branch name to clipboard
CompilerHost.getSourceFile is being called for odd filenames#23043Conversation
ab6ac08 to
e914821
Compare
|
@alan-agius4 we will need a unit test to go with this change. i would say you need a new file, since we do not have any existing unit test files that cover this area. |
|
@mhegazy, thanks for the example, that was helpful. I added the some tests. |
| refFile?: SourceFile): SourceFile | undefined { | ||
|
|
||
| if (hasExtension(fileName)) { | ||
| // Don't process falsy fileNames |
There was a problem hiding this comment.
how about doing this check on the call to getDefaultLibraryFileName instead. it is making me a bit nervous to have it in this general utility function, just to handle the return of getDefaultLibraryFileName.
There was a problem hiding this comment.
Making you nervous is not a good sign.
You mean here: https://github.com/alan-agius4/TypeScript/blob/a27cd8f9a2e83d4b6fbf4e77c5041d94b01d86f6/src/compiler/program.ts#L611
Change it to something like
const defaultLibraryFileName = getDefaultLibraryFileName();
if (!options.lib && defaultLibraryFileName) {
processRootFile(defaultLibraryFileName, /*isDefaultLib*/ true);
}Ps: I make the change already, and if you are not too convinced about this. I don't mind closing the PR, just leave a comment in the original issue :)
…esides the one being compiled Ignore falsy file names from `getDefaultLibraryFileName` Closes: microsoft#13629
a27cd8f to
7e482b2
Compare
|
thanks. this seems much targeted now. sorry for the back and forth. |
Would love to add some Unit Tests but kinda can't find a way where to test it. If any one is willing to give me pointers on how do you guy usually test this. I'll happily add them
Ignore falsy file names from
getSourceFileFromReferenceWorkerCloses: #13629