-
Notifications
You must be signed in to change notification settings - Fork 25
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
Convert to typescript #92
base: master
Are you sure you want to change the base?
Conversation
CC @rom1504 |
New dependencies detected. Learn more about Socket for GitHub ↗︎
|
FWIW |
This looks ok to me. Maybe a bit too many Any? What do you recommend instead of node fetch? This package is maintained mostly by @extremeheat and @LucienHH so they'll have the final word on whether we do this |
NodeJS has a native |
I'm looking more and some points
|
About dropping node fetch sgtm, this can be done in another PR, since that's a pretty trivial change |
Must've missed it.
Sure, if that's something that's wanted.
Definitely too many EDIT: There are actually quite a few typings in the global |
What do you think of using Btw if you encounter modules that don't have typings and @types/ package you can try AFAIK standard doesn't work with ts (I suppose its too old), try https://github.com/standard/ts-standard Also outDir is missing... don't forget to enable sourceMap so debugger can map paths to source Also what do you think of adding And also lets add And doesn't adding module: Node16 mean that output format will be changed to esm, which is breaking? |
That's not needed. All modules have types.
It doesn't always work. For this project, it does. For now, I'm making as few changes as possible.
I've gitignored the output.
Not familliar with those options. Mind explaining?
The tests pass, which to me seems like it isn't breaking anything |
Not sure it's wanted. That's probably one of the main problem with typescript. It will create confusion |
I can change the file extensions and make no modifications |
Its pretty straightforward. Changes type to be
Hm it turns out I was using https://eslint.org/docs/latest/rules/no-fallthrough instead of this one. But this is almost the same, helps to catch missed
Oh, now I see, so you don't output them into another dir. But didn't the format of js change to esm? that would be breaking once published to npm since its currently cjs |
My point about examples is I don't know what we should do and I'm not sure there is a good solutions. If they're in JavaScript then people won't be able to contribute back their code to the module since we are then recommending JavaScript and they will be using that. If we have examples in both languages it's pretty bad duplication Maybe the less bad solution is converting them to typescript, but not sure. |
That's why most modern docs websites have that JS/TS toggle, where js version is generated automatically by removing the types. My personal opinion is that they should be in ts so its easier for ts users. Also, it doesn't look like current examples need anything ts-specific |
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.
In this state does this actually build at the moment, seem to get build errors on my end?
constructor (username = '', cache = __dirname, options, codeCallback) { | ||
username: string | ||
options: MicrosoftAuthFlowOptions | ||
xbl?: typeof XboxTokenManager | undefined |
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.
xbl through to doTitleAuth shouldn't be marked as public properties, they're internal and are not part of the API so shouldn't be documented in types.
authTitle?: string | undefined, | ||
relyingParty?: string | undefined, | ||
password?: string | undefined, | ||
fetchEntitlements?: boolean | undefined, |
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.
afaik fetch### shouldn't be part of the Authflow options
mba?: typeof BedrockTokenManager | undefined | ||
mca?: typeof JavaTokenManager | undefined | ||
doTitleAuth?: boolean | undefined | ||
codeCallback: (response: any) => void |
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 response in this callback can vary depending on if MsaTokenManager is being used or LiveTokenManager.
Live - Returns ServerDeviceCodeResponse
Msa - Returns DeviceCodeResponse
@@ -215,7 +239,7 @@ class XboxTokenManager { | |||
* Requests an Xbox Live-related device token that uniquely links the XToken (aka xsts token) | |||
* @param {{ DeviceType, Version }} asDevice The hardware type and version to auth as, for example Android or Nintendo | |||
*/ | |||
async getDeviceToken (asDevice) { | |||
async getDeviceToken (asDevice: { deviceType?: string, deviceVersion?: string } = {}) { |
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.
deviceType can be of 'Nintendo' | 'iOS' | 'Win32'
Also yeah a lot of skipped types here if this refactor is to be worth it we should aim to have a fully typed API. |
That's what I'm working on ;) |
btw doing a similar thing in flying squid: PrismarineJS/flying-squid#651 and |
A custom eslint config? |
Also fixes a couple of bugs I found because typescript was throwing an error.
See: PrismarineJS/prismarine-contribute#7