Skip to content

Conversation

ghost
Copy link

@ghost ghost commented Jul 11, 2018

Noticed while looking at #24857 -- there's no ScriptInfo for a tsconfig.json file so we have to use a union.

@ghost ghost requested a review from sheetalkamat July 11, 2018 19:23
@ghost
Copy link
Author

ghost commented Jul 11, 2018

Latest commit fixes #24857. The problem was that when b.ts is renamed, it becomes part of an inferred project because tsconfig.json only lists certain files. Since we were using program.getSourceFile() to test for file existence, that failed when the file was moved outside of the program.

export const enum ScriptInfoOrConfigKind { ScriptInfo, Config }
/* @internal */
export type ScriptInfoOrConfig =
| { readonly kind: ScriptInfoOrConfigKind.ScriptInfo, readonly info: ScriptInfo }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need this? You can look determine if its sourceFile(config) by just checking

function isConfigFile(config: SourceFile | ScriptInfo) : config is SourceFile {
(config as SourceFile).kind !== undefined; 
}

@ghost ghost merged commit af412e3 into master Jul 12, 2018
@ghost ghost deleted the scriptInfoOrConfigFile branch July 12, 2018 19:09
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant