-
Notifications
You must be signed in to change notification settings - Fork 70
feat: Shell API autocomplete type definitions MONGOSH-2032 #2434
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
base: main
Are you sure you want to change the base?
Conversation
```sh cd packages/shell-api && \ npm run compile && \ npx api-extractor run ; \ npx ts-node bin/api-postprocess.ts ; \ cat lib/api-processed.d.ts ```
@@ -294,7 +294,7 @@ describe('completer.completer', function () { | |||
|
|||
it('returns all suggestions', async function () { | |||
const i = 'db.'; | |||
const attr = shellSignatures.Database.attributes as any; | |||
const attr = shellSignatures.DatabaseImpl.attributes as any; |
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.
The fact that Database and Collection are now types and the classes got replaced with DatabaseImpl and CollectionImpl is having a lot of knock-on effects and kinda ended up being responsible for most of this diff.
I'm wondering if we should keep them as Database and Collection but then rather name the new types to be something like DatabaseWithSchema and CollectionWithSchema. Then maybe the change will be smaller?
Not sure which way around would work out better ergonomically overall.
"types": "./lib/index.d.ts" | ||
}, | ||
"./api": { | ||
"types": "./lib/api-processed.d.ts" |
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'm not sure what would be the best way to export/publish this and then reference it from the outside.
I think import type ShellApi from '@monogdb-js/shell-api/api'
works with this and I tried it manually from a file, but I'll see shortly when I plug this into mongodb-ts-autocomplete
InterruptFlag, | ||
}; | ||
|
||
// TODO: do we really want all these? |
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.
Just a reminder for myself to remove this TODO comment before merging and after bringing it up with the team.
it('calls help function', async function () { | ||
expect((await toShellResult(apiClass.help())).type).to.equal('Help'); | ||
expect((await toShellResult(apiClass.help)).type).to.equal('Help'); | ||
}); | ||
}); | ||
describe('signatures', function () { | ||
it('type', function () { | ||
expect(signatures.Collection.type).to.equal('Collection'); | ||
// TODO: do we want the signatures to be CollectionImpl or Collection? |
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.
Just a reminder for myself to remove this TODO comment before merging and after bringing it up with the team.
@@ -0,0 +1,102 @@ | |||
// TODO: does it make sense to have all this stuff? Don't we just need enough for the top-level API, ie. the globals? |
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.
Just a reminder for myself to remove this TODO comment before merging and after bringing it up with the team.
'Running "' + joinedCommand + '" in ' + args[2]?.cwd ?? process.cwd() | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore TS2869 Right operand of ?? is unreachable because the left operand is never nullish. | ||
`Running "${joinedCommand}" in ${args[2]?.cwd ?? process.cwd()}` |
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.
drive-by. For some reason I got a compile error on this line in CI.
This is a continuation of Anna's work here.
Notes: