Skip to content
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

feat(types): Add types for node modules and various fixing #470

Merged
merged 34 commits into from
Jul 11, 2022

Conversation

Snazzah
Copy link
Contributor

@Snazzah Snazzah commented Jul 9, 2022

This PR includes the following changes:

  • __dirname and __filename are now typed, but deprecated to point people to use import
  • entries(), keys(), and values() are typed in Headers
  • stream() is typed in Blob
  • process.isBun is typed
Added Module Types (listed here, mainly from @types/node)
  • assert
    • assert.doesNotMatch is typed, but is not defined in the polyfill
  • buffer
    • Not sure if I should comment out functions that don't work right now (like toJSON)
    • Should deprecations like new Buffer() and Buffer.slice be kept?
  • constants
  • crypto
  • domain
  • events
  • http
  • https
  • os
    • For types like Platform, Architecture and Signals, not sure whether to have them global, put them in a NodeJS namespace or a BunJS namespace
    • os needs to have a better polyfill, since none of the functions seem to give proper information
  • punycode
  • process
  • querystring
  • stream
  • string_decoder
  • sys
  • timers
  • tty
  • url
  • util
  • zlib
  • supports-color
Missing Buffer methods
toJSON
writeUIntLE
writeUintLE
writeUIntBE
writeUintBE
writeIntLE
writeIntBE
readUIntLE
readUIntBE
readIntLE
readIntBE

types/bun/globals.d.ts Outdated Show resolved Hide resolved
@Snazzah Snazzah changed the title fix(types): Various types fixing fix(types): Adding types for node modules and various fixing Jul 9, 2022
@Snazzah Snazzah changed the title fix(types): Adding types for node modules and various fixing fix(types): Add types for node modules and various fixing Jul 9, 2022
This really shouldn't do anything differently, but it no longer hangs whenever I bundle types. Not sure if anyone else has this problem but, ehhhh...

for (let i = 0; i < filesToCat.length; i++) {
const name = filesToCat[i];
fileContents.push("// " + name + "\n\n" + (await file(resolve(import.meta.dir, name)).text()) + "\n");
Copy link
Collaborator

Choose a reason for hiding this comment

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

This was intentionally loading the files in parallel instead of one at a time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, that makes a bit more sense. Should I just revert this then?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah

@Snazzah Snazzah changed the title fix(types): Add types for node modules and various fixing feat(types): Add types for node modules and various fixing Jul 10, 2022
Copy link
Collaborator

@xHyroM xHyroM left a comment

Choose a reason for hiding this comment

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

Can you add partial types for net? (#516)

@@ -0,0 +1,18 @@

declare module 'tty' {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this one isn't actually implemented

we should do it, but let's not put it in types until it works

* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/string_decoder.js)
*/
declare module 'string_decoder' {
class StringDecoder {
Copy link
Collaborator

Choose a reason for hiding this comment

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

oh man I hope nobody uses this

its going to be so slow

@Jarred-Sumner
Copy link
Collaborator

going to merge this then comment out tty one

no need to keep it waiting longer

@Jarred-Sumner Jarred-Sumner merged commit 4394169 into oven-sh:main Jul 11, 2022
@Snazzah Snazzah deleted the fix/update-types branch July 11, 2022 20:58
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.

None yet

4 participants