Skip to content

Conversation

@gagik
Copy link
Contributor

@gagik gagik commented Nov 4, 2025

With mongodb-js/mongosh#2601 and mongodb-js/compass#7613, this should leave devtools-shared and MCP as last bastions of non-erasable syntax in our products 😄

I admit this went out of hand, originally I thought erasable syntax will be just a couple of enums being converted to consts.
Then I noticed we use a lot of enums.
Then I noticed half of scripts use CJS-specific things.
Then I realized configuring mocha properly to use this erasable syntax is too complicated... so we still use ts-node for that, a shame 😢
Still, having less ts-node is cool. 🤷

@gagik gagik requested a review from a team as a code owner November 4, 2025 10:24
Copilot AI review requested due to automatic review settings November 4, 2025 10:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR disables the experimental strip types feature in Node.js to fix failing tests. The change adds the --no-experimental-strip-types flag to the test-webview script while also adding new MongoDB syntax highlighting for similarity operators ($similarityCosine, $similarityDotProduct, $similarityEuclidean) and the $scoreFusion operator.

  • Disables experimental strip types feature for webview tests
  • Adds syntax highlighting support for MongoDB similarity operators
  • Adds syntax highlighting support for MongoDB $scoreFusion operator

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
package.json Adds --no-experimental-strip-types flag to test-webview script to disable the experimental feature
syntaxes/mongodbInjection.tmLanguage.json Adds TextMate grammar rules for MongoDB similarity operators and score fusion operator

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@gagik gagik marked this pull request as draft November 4, 2025 10:26
@gagik gagik changed the title chore: disable experimental strip types to fix tests chore: use erasable syntax Nov 12, 2025
@gagik gagik marked this pull request as ready for review November 12, 2025 14:19
@gagik gagik marked this pull request as draft November 12, 2025 14:20
@gagik gagik marked this pull request as ready for review December 3, 2025 14:10
@gagik gagik added the no-title-validation Skips validation of PR titles (conventional commit adherence + JIRA ticket inclusion) label Dec 3, 2025
@gagik
Copy link
Contributor Author

gagik commented Dec 3, 2025

I'll get rid of the workaround after pnpm PR is merged

Comment on lines 1 to 9
export const DOCUMENT_SOURCE = {
DOCUMENT_SOURCE_TREEVIEW: 'treeview',
DOCUMENT_SOURCE_PLAYGROUND: 'playground',
DOCUMENT_SOURCE_COLLECTIONVIEW: 'collectionview',
DOCUMENT_SOURCE_CODELENS: 'codelens',
} as const;

export type DocumentSource =
(typeof DOCUMENT_SOURCE)[keyof typeof DOCUMENT_SOURCE];

Choose a reason for hiding this comment

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

Suggested change
export const DOCUMENT_SOURCE = {
DOCUMENT_SOURCE_TREEVIEW: 'treeview',
DOCUMENT_SOURCE_PLAYGROUND: 'playground',
DOCUMENT_SOURCE_COLLECTIONVIEW: 'collectionview',
DOCUMENT_SOURCE_CODELENS: 'codelens',
} as const;
export type DocumentSource =
(typeof DOCUMENT_SOURCE)[keyof typeof DOCUMENT_SOURCE];
export const DocumentSource = {
DOCUMENT_SOURCE_TREEVIEW: 'treeview',
DOCUMENT_SOURCE_PLAYGROUND: 'playground',
DOCUMENT_SOURCE_COLLECTIONVIEW: 'collectionview',
DOCUMENT_SOURCE_CODELENS: 'codelens',
} as const;
export type DocumentSource =
(typeof DocumentSource)[keyof typeof DocumentSource];

Then we don't have as many code changes where this is used? it's also kinda convenient if we stick with """enums""" and their type being named the same thing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh amazing, didn't realize this is possible

view = 'view',
timeseries = 'timeseries',
}
export const COLLECTION_TYPES = {

Choose a reason for hiding this comment

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

same idea, keep the name and type the same. I won't comment on the rest we can just discuss on my DocumentSource comment

Copy link
Contributor

@addaleax addaleax left a comment

Choose a reason for hiding this comment

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

Looks good, although I'd love to see @nbbeeken's suggestion of using the fact that types and variables are separate namespaces and we can just align them

@gagik
Copy link
Contributor Author

gagik commented Dec 12, 2025

so... I did do the change but I figured I should also use this as an opportunity to make the naming more consistent and easier to read. I settled on
<enum type in camelcase, in singular form>.<enum value variant in UPPER_SNAKE_CASE
singular form in particular makes more sense to me, the rest is a bit subjective

Copy link

@nbbeeken nbbeeken left a comment

Choose a reason for hiding this comment

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

I think maybe a small mistake was made, but approach lgtm, so I'll leave the check ✅

DOCUMENT_SOURCE_CODELENS = 'codelens',
}
export const DocumentSource = {
DocumentSource_TREEVIEW: 'treeview',

Choose a reason for hiding this comment

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

enum value variant in UPPER_SNAKE_CASE

Was this a search and replace mistake? cus wouldn't this be DOCUMENT_SOURCE_TREEVIEW?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🙈 too much regex for a friday evening

DocumentSource_TREEVIEW: 'treeview',
DocumentSource_PLAYGROUND: 'playground',
DocumentSource_COLLECTIONVIEW: 'collectionview',
DocumentSource_CODELENS: 'codelens',

Choose a reason for hiding this comment

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

Suggested change
DocumentSource_CODELENS: 'codelens',
codelens: 'codelens',

If you are workshopping patterns it is also kind nice when the key and the value are identical. of course not always possible and I lean more towards less code changes than more when we just want to migrate off the code gen stuff.

your upper snake case pattern is just as good, only sharing opinions here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cleaned up the stutter here; I'd probably also have preferred the casing to not be upper snake case but I'll keep it the way it (largely) was to avoid doing too many mass string replacements

Copy link
Contributor Author

@gagik gagik Dec 15, 2025

Choose a reason for hiding this comment

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

actually managed to do this with a script and that was simple-ish... so we should have consistent naming now

@gagik gagik merged commit c84482b into main Dec 15, 2025
12 checks passed
@gagik gagik deleted the gagik/fix-tests branch December 15, 2025 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-title-validation Skips validation of PR titles (conventional commit adherence + JIRA ticket inclusion)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants