Skip to content

ScriptInfo versioning improvements #53001

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

Merged
merged 11 commits into from
Mar 1, 2023
Merged

ScriptInfo versioning improvements #53001

merged 11 commits into from
Mar 1, 2023

Conversation

sheetalkamat
Copy link
Member

  • aeec611 With this change, if file is opened, it is not immediately switched to versioning cache (which is used for editing). It is deferred till we actually receive edit request or its opened with different contents than on the disk.
  • 327675c When closing file, it does not read contents of file right away. Instead defers it till next project update.

The other commits are test changes to baseline file version and text for program in the baseline done to ensure the changes dont unexpectedly change versioning and text in the program.

@andrewbranch discovered this while investigating #52792 though as discussed offline it doesnt fix that issue completely.

@DanielRosenwasser
Copy link
Member

Can you merge and update baselines?

@andrewbranch
Copy link
Member

@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 28, 2023

Heya @andrewbranch, I've started to run the tarball bundle task on this PR at 256f46c. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 28, 2023

Hey @andrewbranch, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/147774/artifacts?artifactName=tgz&fileId=820F40592AA03C3B5D1EB5846E034EFC6F12CE90E87427DC48D55541B5409F8602&fileName=/typescript-5.1.0-insiders.20230228.tgz"
    }
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/[email protected]".;

@@ -3081,10 +3077,9 @@ declare namespace ts {
readonly containingProjects: Project[];
private formatSettings;
private preferences;
private textStorage;
constructor(host: ServerHost, fileName: NormalizedPath, scriptKind: ScriptKind, hasMixedContent: boolean, path: Path, initialVersion?: ScriptInfoVersion);
constructor(host: ServerHost, fileName: NormalizedPath, scriptKind: ScriptKind, hasMixedContent: boolean, path: Path, initialVersion?: number);
Copy link
Member

@jakebailey jakebailey Mar 1, 2023

Choose a reason for hiding this comment

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

Given this breaking change, is anyone depending on this that we should worry about? Is there a way to write this code as to not break existing users, i.e. keep the old thing around, deprecate, and pull a version out of it?

Copy link
Member Author

Choose a reason for hiding this comment

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

I have looked up but didn't find any usage for this which is why i just modified this without adding overload.
You think overload thats marked deprecated is better even then?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, now that I'm looking, I've only been able to find 3 examples of this being used (a subset of https://sourcegraph.com/search?q=context:global+/new+.*%5CbScriptInfo%5C%28/+lang:typescript+-file:harness+-file:editorServices+-file:languageServiceHost&patternType=standard&sm=1&groupBy=repo are the right thing), and those all a decade old and unmaintained. So, probably safe.

Copy link
Member

@jakebailey jakebailey left a comment

Choose a reason for hiding this comment

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

So, code wise, I think this looks correct. Just so I understand it, we're effectively removing the double-versioning and now have one version number, consulting ScriptVersionCache only when present, and more lazily creating it?

But @andrewbranch probably will have a better idea of what the intent was.

Copy link
Member

@andrewbranch andrewbranch left a comment

Choose a reason for hiding this comment

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

Awesome, thank you! I’ll follow up on the remaining case where the export map cache needs to be cleared.

@sheetalkamat sheetalkamat merged commit 1da6d87 into main Mar 1, 2023
@sheetalkamat sheetalkamat deleted the versioning branch March 1, 2023 23:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants