Skip to content

chore: test that autocomplete works without the fallback, re-order the tests #559

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 3 commits into from
Jul 4, 2025

Conversation

lerouxb
Copy link
Collaborator

@lerouxb lerouxb commented Jul 4, 2025

Just a follow-up to make sure that we test this properly.

@@ -65,13 +65,14 @@ function getVirtualLanguageService(
return (versions[fileName] ?? 1).toString();
},
getScriptSnapshot: (fileName) => {
fileName = relativeNodePath(fileName);
if (fileName in codeHolder) {
const relativeFileName = relativeNodePath(fileName);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was actually a bug - I was passing the relative filename to the fallback resolver and that needs the original absolute filename so it can actually load it from disk.

fallbackServiceHost,
});
});

afterEach(function () {
it('autocompletes', async function () {
Copy link
Collaborator Author

@lerouxb lerouxb Jul 4, 2025

Choose a reason for hiding this comment

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

The best way to fully test/prove this automatically (ie. that it can recreate the list) is do comment out deps in extract-types.ts to make it just an empty structure, run extract-types so none of the @types/node and lib files are in there, then run this test. It then finds the entire list.

I tried modifying extract-types to calculate the list automatically by running autocomplete, but it becomes a bit code-surgery with things passed down just for testing and a chicken and egg problem of extract-types using autocomplete which imports the extracted types which aren't generated yet... I tried to fix it with dynamic import, but then TS doesn't want to import the code from the script and it just becomes a rabbit hole.

I think this test that lists what's missing even if you start over with an empty list and the rest of the tests fail because they don't use the fallback is probably good enough.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

(I have now added a version of this as a comment next to the test.)

@lerouxb lerouxb merged commit 4328471 into main Jul 4, 2025
30 checks passed
@lerouxb lerouxb deleted the autocomplete-types-tests branch July 4, 2025 14:48
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.

2 participants