Skip to content

[koa] Add v2 types#74990

Merged
typescript-bot merged 1 commit into
DefinitelyTyped:masterfrom
unrevised6419:resurect-koa-v2
May 14, 2026
Merged

[koa] Add v2 types#74990
typescript-bot merged 1 commit into
DefinitelyTyped:masterfrom
unrevised6419:resurect-koa-v2

Conversation

@unrevised6419
Copy link
Copy Markdown
Contributor

@unrevised6419 unrevised6419 commented May 12, 2026

Adds types/koa/v2 to provide type definitions for the still-supported Koa v2.x line, alongside the existing v3 types in types/koa.

Method

types/koa/v2 was created by copying the current types/koa (v3) and reverting only the v3-related changes. Since v2 existed, four commits touched types/koa:

  1. 7eb661eUpdate @types/koa to match koa version 3reverted
  2. 9a370b0Make all packages work with esModuleInterop — kept (infra)
  3. 2f29f0cFix packages for TS 6.0 strict=true — kept (infra)
  4. c19b4e9add custom AsyncLocalStorage support to Application constructorreverted (v3-only API)

package.json set to 2.15.9999; deps pinned to v2-compatible versions.

Checklist

  • Use a meaningful title for the pull request. Include the name of the package modified.
  • Test the change in your own code. (Compile and run.)
  • Add or edit tests to reflect the change.
  • Follow the advice from the readme.
  • Avoid common mistakes.
  • Run pnpm test koa.

If changing an existing definition:

  • Provide a URL to documentation or source code which provides context for the suggested changes: https://github.com/koajs/koa/tree/v2.x
  • If this PR brings the type definitions up to date with a new version of the JS library, update the version number in the package.json.

@typescript-bot
Copy link
Copy Markdown
Contributor

typescript-bot commented May 12, 2026

@unrevised6419 Thank you for submitting this PR! I see this is your first time submitting to DefinitelyTyped 👋 — I'm the local bot who will help you through the process of getting things through.

This is a live comment that I will keep updated.

This PR touches some part of DefinitelyTyped infrastructure, so a DT maintainer will need to review it. This is rare — did you mean to do this?

1 package in this PR (and infra files)

Code Reviews

Because this is a widely-used package, a DT maintainer will need to review it before it can be merged.

You can test the changes of this PR in the Playground.

Status

  • ✅ No merge conflicts
  • ✅ Continuous integration tests have passed
  • ✅ A DT maintainer needs to approve changes that affect DT infrastructure (attw.json)

All of the items on the list are green. To merge, you need to post a comment including the string "Ready to merge" to bring in your changes.


Diagnostic Information: What the bot saw about this PR
{
  "type": "info",
  "now": "-",
  "pr_number": 74990,
  "author": "unrevised6419",
  "headCommitOid": "11fda3790e538c0f90289a89c635f0b9a01d3bd5",
  "mergeBaseOid": "3c0b15fc1e4e9a3ab449e463673b3c33355c9e85",
  "lastPushDate": "2026-05-12T18:23:14.000Z",
  "lastActivityDate": "2026-05-14T20:20:29.000Z",
  "mergeOfferDate": "2026-05-14T19:56:00.000Z",
  "mergeRequestDate": "2026-05-14T20:20:29.000Z",
  "mergeRequestUser": "unrevised6419",
  "hasMergeConflict": false,
  "isFirstContribution": true,
  "tooManyFiles": false,
  "hugeChange": false,
  "tooManyCommits": false,
  "tooManyReviews": false,
  "popularityLevel": "Critical",
  "pkgInfo": [
    {
      "name": null,
      "kind": "edit",
      "files": [
        {
          "path": "attw.json",
          "kind": "infrastructure"
        }
      ],
      "owners": [],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Critical",
      "isSafeInfrastructureEdit": false
    },
    {
      "name": "koa",
      "kind": "edit",
      "files": [
        {
          "path": "types/koa/.npmignore",
          "kind": "package-meta-ok"
        },
        {
          "path": "types/koa/v2/.eslintrc.json",
          "kind": "package-meta",
          "suspect": "not [the expected form](https://github.com/DefinitelyTyped/DefinitelyTyped#user-content-linter-eslintrcjson) (check: `rules`)"
        },
        {
          "path": "types/koa/v2/.npmignore",
          "kind": "package-meta-ok"
        },
        {
          "path": "types/koa/v2/index.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/koa/v2/package.json",
          "kind": "package-meta-ok"
        },
        {
          "path": "types/koa/v2/test/constructor.ts",
          "kind": "test"
        },
        {
          "path": "types/koa/v2/test/default.ts",
          "kind": "test"
        },
        {
          "path": "types/koa/v2/test/index.ts",
          "kind": "test"
        },
        {
          "path": "types/koa/v2/test/settings.ts",
          "kind": "test"
        },
        {
          "path": "types/koa/v2/test/typed-response-body.ts",
          "kind": "test"
        },
        {
          "path": "types/koa/v2/tsconfig.json",
          "kind": "package-meta-ok"
        }
      ],
      "owners": [
        "jkeylu",
        "brikou",
        "harryparkdotio",
        "chatoo2412",
        "tellnes",
        "pkuczynski",
        "vnoder"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Critical"
    }
  ],
  "reviews": [
    {
      "type": "approved",
      "reviewer": "jakebailey",
      "date": "2026-05-14T19:55:20.000Z",
      "isMaintainer": true
    },
    {
      "type": "stale",
      "reviewer": "pkuczynski",
      "date": "2026-05-12T18:51:41.000Z",
      "abbrOid": "c7f51d7"
    }
  ],
  "mainBotCommentID": 4433490854,
  "ciResult": "pass"
}

@typescript-bot
Copy link
Copy Markdown
Contributor

🔔 @jkeylu @brikou @harryparkdotio @chatoo2412 @tellnes @pkuczynski @vnoder — please review this PR in the next few days. Be sure to explicitly select Approve or Request Changes in the GitHub UI so I know what's going on.

@typescript-bot typescript-bot moved this to Waiting for Code Reviews in Pull Request Status Board May 12, 2026
@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Maintainer Action in Pull Request Status Board May 12, 2026
@typescript-bot typescript-bot moved this from Needs Maintainer Action to Waiting for Code Reviews in Pull Request Status Board May 12, 2026
@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Maintainer Action in Pull Request Status Board May 12, 2026
@typescript-bot typescript-bot added the Owner Approved A listed owner of this package signed off on the pull request. label May 12, 2026
@jakebailey
Copy link
Copy Markdown
Member

This code doesn't match what's in https://app.unpkg.com/@types/koa@2.15.0; the import syntax is different and the dependencies are different. Is that all intentional?

@unrevised6419
Copy link
Copy Markdown
Contributor Author

Only these two commits where not reverted intentionally

9a370b0
2f29f0c

@unrevised6419
Copy link
Copy Markdown
Contributor Author

unrevised6419 commented May 13, 2026

Let me do some more tests locally on https://github.com/strapi/strapi

I'm installing it locally directly from the path, but I guess there should be some process for release, or how can I pack it locally?

@jakebailey
Copy link
Copy Markdown
Member

You can run pnpm pack inside the dir to get an approximation. The npmignore should be accurate.

@unrevised6419
Copy link
Copy Markdown
Contributor Author

unrevised6419 commented May 13, 2026

Tried pnpm pack, from what I saw only package.json does not match, will try to copy it from the last released @types/koa version

@unrevised6419
Copy link
Copy Markdown
Contributor Author

I'll try to see how I can do a "real" pack locally using https://github.com/microsoft/DefinitelyTyped-tools/tree/main/packages/publisher

@jakebailey
Copy link
Copy Markdown
Member

The publisher just builds the tarball directly from the source.

I'm not sure what you're missing, but in the published package, it's:

import * as accepts from "accepts";
import { AsyncLocalStorage } from "async_hooks";
import * as Cookies from "cookies";
import { EventEmitter } from "events";
import { IncomingHttpHeaders, IncomingMessage, OutgoingHttpHeaders, Server, ServerResponse } from "http";
import { Http2ServerRequest, Http2ServerResponse } from "http2";
import httpAssert = require("http-assert");
import * as contentDisposition from "content-disposition";
import * as HttpErrors from "http-errors";
import * as Keygrip from "keygrip";
import * as compose from "koa-compose";
import { ListenOptions, Socket } from "net";
import { ParsedUrlQuery } from "querystring";
import * as url from "url";

But here, you've written:

import accepts = require("accepts");
import { AsyncLocalStorage } from "async_hooks";
import Cookies = require("cookies");
import { EventEmitter } from "events";
import { IncomingHttpHeaders, IncomingMessage, OutgoingHttpHeaders, Server, ServerResponse } from "http";
import { Http2ServerRequest, Http2ServerResponse } from "http2";
import httpAssert = require("http-assert");
import contentDisposition = require("content-disposition");
import HttpErrors = require("http-errors");
import Keygrip = require("keygrip");
import compose = require("koa-compose");
import { ListenOptions, Socket } from "net";
import { ParsedUrlQuery } from "querystring";
import * as url from "url";

Differences can be okay, I am just asking for an explanation.

@unrevised6419
Copy link
Copy Markdown
Contributor Author

unrevised6419 commented May 13, 2026

It seems these changes were made by the DefinitelyTyped maintainers in 9a370b0#diff-bb94074d9ae1164d531dd6eb17a8858f06f4129662469a7d5e1dd19cb5eed86c (see files in types/koa/) across the DefinitelyTyped, that's why I did not revert them 🤔

#73954

Should I revert them back to what was in 2.15.0?

I'll do some more tests tomorrow.

@jakebailey
Copy link
Copy Markdown
Member

I see. I am unsure why that was not published to npm.

What about the package.json diff?

@unrevised6419
Copy link
Copy Markdown
Contributor Author

unrevised6419 commented May 13, 2026

That DefinitelyTyped core change was made after the koa v3 types release, that's why it did not land in v2

Will revert the package.json diff also. I suppose it needs to be * and DefinitelyTyped picks the right version itself 🤔

@jakebailey
Copy link
Copy Markdown
Member

That'll end up picking an arbitrary one, and then likely the latest, so you should just check koa v2 upstream to see what they use.

@unrevised6419
Copy link
Copy Markdown
Contributor Author

Ok. Will do so. Strange why previously all versions were *

@unrevised6419
Copy link
Copy Markdown
Contributor Author

unrevised6419 commented May 14, 2026

Question: Why all of the package.json#dependencies.<name> across the /DefinitelyTyped, use * as the version?
As you said, won't they resolve to any (latest) version?
Should they match the right versions that the package uses?

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@typescript-bot typescript-bot removed the Owner Approved A listed owner of this package signed off on the pull request. label May 14, 2026
@typescript-bot typescript-bot moved this from Needs Maintainer Action to Waiting for Code Reviews in Pull Request Status Board May 14, 2026
@unrevised6419
Copy link
Copy Markdown
Contributor Author

unrevised6419 commented May 14, 2026

I did revert the package.json to be exactly as it was in @types/koa@2.15.0

Using current PR and this one #74991
I did some testing in strapi/strapi#25424, and it seems to work fine.

@typescript-bot
Copy link
Copy Markdown
Contributor

@pkuczynski Thank you for reviewing this PR! The author has pushed new commits since your last review. Could you take another look and submit a fresh review?

@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Maintainer Action in Pull Request Status Board May 14, 2026
@unrevised6419 unrevised6419 requested a review from pkuczynski May 14, 2026 10:23
@typescript-bot typescript-bot added Maintainer Approved Self Merge This PR can now be self-merged by the PR author or an owner labels May 14, 2026
@typescript-bot typescript-bot moved this from Needs Maintainer Action to Waiting for Author to Merge in Pull Request Status Board May 14, 2026
@typescript-bot
Copy link
Copy Markdown
Contributor

@unrevised6419: Everything looks good here. I am ready to merge this PR (at 11fda37) on your behalf whenever you think it's ready.

If you'd like that to happen, please post a comment saying:

Ready to merge

and I'll merge this PR almost instantly. Thanks for helping out! ❤️

(@jkeylu, @brikou, @harryparkdotio, @chatoo2412, @tellnes, @pkuczynski, @vnoder: you can do this too.)

@unrevised6419
Copy link
Copy Markdown
Contributor Author

Ready to merge

@typescript-bot typescript-bot moved this from Waiting for Author to Merge to Recently Merged in Pull Request Status Board May 14, 2026
@typescript-bot typescript-bot merged commit 3c84079 into DefinitelyTyped:master May 14, 2026
5 checks passed
@unrevised6419 unrevised6419 deleted the resurect-koa-v2 branch May 14, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Check Config Changes a module config files Critical package Edits Infrastructure Maintainer Approved Self Merge This PR can now be self-merged by the PR author or an owner

Projects

Status: Recently Merged

Development

Successfully merging this pull request may close these issues.

4 participants