-
Notifications
You must be signed in to change notification settings - Fork 92
chore: use erasable syntax #1175
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
Conversation
There was a problem hiding this 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
$scoreFusionoperator
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.
|
I'll get rid of the workaround after pnpm PR is merged |
8eddeba to
94c7cd2
Compare
src/documentSource.ts
Outdated
| 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]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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
There was a problem hiding this comment.
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
src/explorer/documentListTreeItem.ts
Outdated
| view = 'view', | ||
| timeseries = 'timeseries', | ||
| } | ||
| export const COLLECTION_TYPES = { |
There was a problem hiding this comment.
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
addaleax
left a comment
There was a problem hiding this 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
|
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 |
nbbeeken
left a comment
There was a problem hiding this 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 ✅
src/documentSource.ts
Outdated
| DOCUMENT_SOURCE_CODELENS = 'codelens', | ||
| } | ||
| export const DocumentSource = { | ||
| DocumentSource_TREEVIEW: 'treeview', |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
src/documentSource.ts
Outdated
| DocumentSource_TREEVIEW: 'treeview', | ||
| DocumentSource_PLAYGROUND: 'playground', | ||
| DocumentSource_COLLECTIONVIEW: 'collectionview', | ||
| DocumentSource_CODELENS: 'codelens', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
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-nodefor that, a shame 😢Still, having less ts-node is cool. 🤷