Skip to content

mapTextChangesToCodeEditsUsingScriptInfo: Handle tsconfig.json text change#25586

Merged
3 commits merged into
masterfrom
scriptInfoOrConfigFile
Jul 12, 2018
Merged

mapTextChangesToCodeEditsUsingScriptInfo: Handle tsconfig.json text change#25586
3 commits merged into
masterfrom
scriptInfoOrConfigFile

Conversation

@ghost
Copy link
Copy Markdown

@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
Copy Markdown
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.

Comment thread src/server/editorServices.ts Outdated
export const enum ScriptInfoOrConfigKind { ScriptInfo, Config }
/* @internal */
export type ScriptInfoOrConfig =
| { readonly kind: ScriptInfoOrConfigKind.ScriptInfo, readonly info: ScriptInfo }
Copy link
Copy Markdown
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
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant