Skip to content

[jquery] Fix module import error in jquery 4.0.0#74984

Open
TomiBelan wants to merge 1 commit into
DefinitelyTyped:masterfrom
TomiBelan:jquery
Open

[jquery] Fix module import error in jquery 4.0.0#74984
TomiBelan wants to merge 1 commit into
DefinitelyTyped:masterfrom
TomiBelan:jquery

Conversation

@TomiBelan
Copy link
Copy Markdown

Please fill in this template.

If changing an existing definition:

  • Provide a URL to documentation or source code which provides context for the suggested changes: [@types/jquery] TS error after updating to 4.0.0 #74639
  • 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.

This is my attempt to fix the issue described in #74639 and #74367 (comment), which is that simply importing jquery gives an error if you use modern TypeScript options.

Please check my work. I don't really know what I'm doing. I thought somebody would fix it by now, but here we are.

This PR does not contain any regression tests, because dtslint only allows "module": "commonjs" or "node16", in which the issue doesn't happen. It also doesn't allow "moduleResolution".

Best I have is this manual test:

  • $ pnpm add typescript jquery @types/jquery
    Packages: +3
    +++
    Progress: resolved 3, reused 2, downloaded 1, added 3, done
    
    dependencies:
    + @types/jquery 4.0.0
    + jquery 4.0.0
    + typescript 6.0.3
    
    Done in 1.2s using pnpm v11.1.0
  • $ echo 'import $ from "jquery";' > main.ts
  • $ pnpm tsc main.ts
    node_modules/.pnpm/@types+jquery@4.0.0/node_modules/@types/jquery/index.d.mts:4:10 - error TS2661: Cannot export 'jQuery'. Only local declarations can be exported from a module.
    
    4 export { jQuery, jQuery as $ };
               ~~~~~~
    
    node_modules/.pnpm/@types+jquery@4.0.0/node_modules/@types/jquery/index.d.mts:4:18 - error TS2661: Cannot export 'jQuery'. Only local declarations can be exported from a module.
    
    4 export { jQuery, jQuery as $ };
                       ~~~~~~
    
    
    Found 2 errors in the same file, starting at: node_modules/.pnpm/@types+jquery@4.0.0/node_modules/@types/jquery/index.d.mts:4

    (You may notice that with new defaults in TypeScript 6.0, the error is trivially reproducible with default tsc options.)

  • $ pnpm add link:../DefinitelyTyped/types/jquery
    Packages: -1
    -
    Progress: resolved 3, reused 3, downloaded 0, added 0, done
    
    dependencies:
    - @types/jquery 4.0.0
    + @types/jquery 4.0.9999 <- ../DefinitelyTyped/types/jquery
    
    Done in 685ms using pnpm v11.1.0
  • $ pnpm tsc main.ts

    (tsc prints nothing.)

This should prove that the PR fixes the issue. I hope it doesn't break anything else.

FYI CC @DreierF, @valipanahi, @gabritto, @andersk, @marekdedic

@typescript-bot
Copy link
Copy Markdown
Contributor

typescript-bot commented May 11, 2026

@TomiBelan 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.

1 package in this PR

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 failed
  • 🕐 Only a DT maintainer can approve changes without tests

Once every item on this list is checked, I'll ask you for permission to merge and publish the changes.


Diagnostic Information: What the bot saw about this PR
{
  "type": "info",
  "now": "-",
  "pr_number": 74984,
  "author": "TomiBelan",
  "headCommitOid": "4cc1f001ea8da6af7da160b4ee158bb5c77b2fe9",
  "mergeBaseOid": "1d859fa5f1c4b759f25935c4e3257a63237a4efe",
  "lastPushDate": "2026-05-11T21:14:23.000Z",
  "lastActivityDate": "2026-05-12T06:21:46.000Z",
  "hasMergeConflict": false,
  "isFirstContribution": true,
  "tooManyFiles": false,
  "hugeChange": false,
  "tooManyCommits": false,
  "tooManyReviews": false,
  "popularityLevel": "Critical",
  "pkgInfo": [
    {
      "name": "jquery",
      "kind": "edit",
      "files": [
        {
          "path": "types/jquery/index.d.mts",
          "kind": "definition"
        },
        {
          "path": "types/jquery/slim.d.mts",
          "kind": "definition"
        }
      ],
      "owners": [
        "leonard-thieu",
        "borisyankov",
        "choffmeister",
        "Steve-Fenton",
        "Diullei",
        "tasoili",
        "seanski",
        "Guuz",
        "ksummerlin",
        "basarat",
        "nwolverson",
        "derekcicerone",
        "AndrewGaspar",
        "seikichi",
        "benjaminjackman",
        "JoshStrobl",
        "johnnyreilly",
        "DickvdBrink",
        "King2500",
        "terrymun",
        "martin-badin",
        "princefishthrower"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Critical"
    }
  ],
  "reviews": [],
  "mainBotCommentID": 4425251938,
  "ciResult": "fail",
  "ciUrl": "https://github.com/DefinitelyTyped/DefinitelyTyped/commit/4cc1f001ea8da6af7da160b4ee158bb5c77b2fe9/checks?check_suite_id=68495588348"
}

@typescript-bot
Copy link
Copy Markdown
Contributor

Hey @TomiBelan,

😒 Your PR doesn't modify any tests, so it's hard to know what's being fixed, and your changes might regress in the future. Please consider adding tests to cover the change you're making. Including tests allows this PR to be merged by yourself and the owners of this module.

This can potentially save days of time for you!

@typescript-bot
Copy link
Copy Markdown
Contributor

🔔 @leonard-thieu @borisyankov @choffmeister @Steve-Fenton @Diullei @tasoili @seanski @Guuz @ksummerlin @basarat @nwolverson @derekcicerone @AndrewGaspar @seikichi @benjaminjackman @JoshStrobl @johnnyreilly @DickvdBrink @King2500 @terrymun @martin-badin @princefishthrower — 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 added the The CI failed When GH Actions fails label May 11, 2026
@typescript-bot
Copy link
Copy Markdown
Contributor

@TomiBelan The CI build failed! Please review the logs for more information.

Once you've pushed the fixes, the build will automatically re-run. Thanks!

Note: builds that are failing do not end up on the list of PRs for the DT maintainers to review.

@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Author Action in Pull Request Status Board May 11, 2026
@TomiBelan
Copy link
Copy Markdown
Author

Error in jquery.pin
Error: Package @types/jquery.pin is not marked as non-npm, but no implementation package was found on npm. If these types are not for an npm package, please add "nonNpm": true to the package.json. Otherwise, ensure the name of this package matches the name of the npm package.
at combineErrorsAndWarnings (/home/runner/work/DefinitelyTyped/DefinitelyTyped/node_modules/.pnpm/@DefinitelyTyped+dtslint@0.2.43_typescript@6.0.0-dev.20260416/node_modules/@definitelytyped/dtslint/src/index.ts:266:26)
at runTests (/home/runner/work/DefinitelyTyped/DefinitelyTyped/node_modules/.pnpm/@DefinitelyTyped+dtslint@0.2.43_typescript@6.0.0-dev.20260416/node_modules/@definitelytyped/dtslint/src/index.ts:257:18)
at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
 ELIFECYCLE  Command failed with exit code 1.
Error: Process completed with exit code 1.

That doesn't look related to this PR. Please review it anyway and ignore the bot.

@Steve-Fenton
Copy link
Copy Markdown
Member

Just to check Chesterton's Fence before we proceed on this one... why were these lines originally added. I suspect we may resolve whatever problem you are experiencing, but open up problems previously fixed for other folks.

Can we check the history for the line being removed so we understand the issue or PR that motivated it's addition?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Critical package The CI failed When GH Actions fails Untested Change This PR does not touch tests

Projects

Status: Needs Author Action

Development

Successfully merging this pull request may close these issues.

3 participants