Skip to content

Conversation

Phillip9587
Copy link
Contributor

This PR adds type definitions to finalhandler. It includes the following changes:

Ref: expressjs/typescript-wg#1

cc @RobinTail @hichemfantar

@Phillip9587 Phillip9587 added the v3 label Mar 26, 2025
Copy link

socket-security bot commented Mar 26, 2025

New dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@arethetypeswrong/[email protected] Transitive: environment, filesystem, network, shell, unsafe +52 31.7 MB andrewbranch
npm/@tsconfig/[email protected] None 0 2.36 kB typescript-deploys
npm/@types/[email protected] None +1 83.3 kB
npm/[email protected] None 0 0 B
npm/[email protected] None 0 22.9 MB typescript-bot

View full report↗︎

Copy link

@RobinTail RobinTail left a comment

Choose a reason for hiding this comment

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

👍🏽

@Phillip9587
Copy link
Contributor Author

Hey @RobinTail, can you review again please? I implemented your suggestions.

Copy link

@RobinTail RobinTail left a comment

Choose a reason for hiding this comment

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

LGTM, @Phillip9587

Co-authored-by: Anna Bocharova <[email protected]>
Copy link

@RobinTail RobinTail left a comment

Choose a reason for hiding this comment

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

🏅

@Phillip9587
Copy link
Contributor Author

Can we release this as a minor and recommend users to migrate away from @types/finalhandler to the built-in types, or would this require a major release?

@bjohansebas
Copy link
Member

Nope, this should be released in a major version, mainly because it could break TypeScript users, whether they use it with Express or not. Besides, it's not natural to add TypeScript support in a non-major version.

Copy link
Contributor Author

@Phillip9587 Phillip9587 left a comment

Choose a reason for hiding this comment

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

How about merging this into the master branch without publishing it for now?
That way, we can continue iterating and improving the types.
Once we're ready to release v3, we can add index.d.ts to the files and types fields in package.json.

@@ -5,6 +5,9 @@
"author": "Douglas Christopher Wilson <[email protected]>",
"license": "MIT",
"repository": "pillarjs/finalhandler",
"type": "commonjs",
"main": "index.js",
"types": "index.d.ts",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
"types": "index.d.ts",

Choose a reason for hiding this comment

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

I believe types would be resolved automatically even without this entry.
Just because of the index.* naming

Choose a reason for hiding this comment

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

At least in my PR attw resolves them without types in package.json

Comment on lines +39 to +40
"index.js",
"index.d.ts"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
"index.js",
"index.d.ts"
"index.js"

@bjohansebas
Copy link
Member

Just to say, it's normal to release this in a minor version. Also, this is blocked until the types are officially accepted in the repositories.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants