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

fix(sinon): use sinonjs__fake-timers rather than alias #52294

Closed
wants to merge 1 commit into from

Conversation

bcoe
Copy link
Contributor

@bcoe bcoe commented Apr 9, 2021

https://github.com/sinonjs/fake-timers appears to have added types which are incompatible
with the current implementation in DefinitelyTyped.

CC: @fatso83

Refs: sinonjs/sinon#2353
Refs: sinonjs/sinon#2352

Please fill in this template.

Select one of these and delete the others:

If changing an existing definition:

  • If this PR brings the type definitions up to date with a new version of the JS library, update the version number in the header.

https://github.com/sinonjs/fake-timers appears to have added types which are incompatible
with the current implementation in DefinitelyTyped.

Refs: sinonjs/sinon#2353
Refs: sinonjs/sinon#2352
@typescript-bot typescript-bot added Critical package Untested Change This PR does not touch tests labels Apr 9, 2021
@typescript-bot typescript-bot added this to Waiting for Code Reviews in New Pull Request Status Board Apr 9, 2021
@typescript-bot
Copy link
Contributor

typescript-bot commented Apr 9, 2021

@bcoe 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 which 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.

Status

  • ✅ No merge conflicts
  • ✅ Continuous integration tests have passed
  • 🕐 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": 52294,
  "author": "bcoe",
  "headCommitOid": "51905f47c56293f8fddf30aa0773da3205a5164d",
  "lastPushDate": "2021-04-09T18:04:40.000Z",
  "lastActivityDate": "2021-04-09T19:24:15.000Z",
  "maintainerBlessed": false,
  "hasMergeConflict": false,
  "isFirstContribution": true,
  "popularityLevel": "Critical",
  "pkgInfo": [
    {
      "name": "sinon",
      "kind": "edit",
      "files": [
        {
          "path": "types/sinon/index.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/sinon/tsconfig.json",
          "kind": "package-meta-ok"
        }
      ],
      "owners": [
        "mrbigdog2u",
        "lumaxis",
        "nicojs",
        "43081j",
        "joshuakgoldberg",
        "gjednaszewski",
        "johnjesse",
        "alecf",
        "SimonSchick"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Critical"
    }
  ],
  "reviews": [
    {
      "type": "approved",
      "reviewer": "nicojs",
      "date": "2021-04-09T19:03:46.000Z",
      "isMaintainer": false
    }
  ],
  "ciResult": "pass"
}

@typescript-bot
Copy link
Contributor

🔔 @MrBigDog2U @lumaxis @nicojs @43081j @JoshuaKGoldberg @gjednaszewski @johnjesse @alecf @SimonSchick — 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 from Waiting for Code Reviews to Needs Maintainer Review in New Pull Request Status Board Apr 9, 2021
@43081j
Copy link
Contributor

43081j commented Apr 9, 2021

We should probably double check with someone like @sandersn if this is the right approach. It feels like the recent webpack issue where they also published their own types.

I have a feeling we should just add it as a dependency and a path mapping rather than trying to import the mangled name directly

@bcoe
Copy link
Contributor Author

bcoe commented Apr 9, 2021

@43081j @sandersn the culprit is here, they've been shipping their own types for a while, I think, but they vary significantly between 6.x and 7.x.

I'd advocate shipping a hot fix, if possible, even if this isn't ultimately how the problem is addressed -- refactoring to use the new timer types might be appropriate.

Copy link
Contributor

@nicojs nicojs left a comment

Choose a reason for hiding this comment

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

@bcoe you've pinged me personally and want to help. I think I understand what you're doing here, you're making sure the types from sinon uses the fake-timers that are shipped as a dependency of this project.

I think this is a valid short term fix.

@typescript-bot typescript-bot added the Owner Approved A listed owner of this package signed off on the pull request. label Apr 9, 2021
@43081j
Copy link
Contributor

43081j commented Apr 9, 2021

Fwiw I don't think we should be using the mangled name in an import like that (the types package name).

A path mapping would be better. I'm surprised the existing mapping didn't achieve that.

We really need input from a maintainer on that as we have to be very careful around changing dependency chains

@sandersn
Copy link
Contributor

sandersn commented Apr 9, 2021

I think I missed it, but is there a reason that @types/sinon can't use add the latest version of @sinonjs/fake-timers to package.json now that it ships its own types?

Even if it's not possible, the import in index.d.ts still needs to read ... from "@sinonjs/fake-timers" -- sinonjs__fake-timers is a name-mangling that only exists in the DT repo, not on npm. I'm not sure why the existing path mapping doesn't work, though.

@bcoe
Copy link
Contributor Author

bcoe commented Apr 9, 2021

@nicojs thank you for taking the time to eyeball -- we have ~100 builds failing right now, is why this is top of mind for me.

@43081j I hear your concern, and want to be mindful since I'm relatively new to this problem space (I don't want to make things worse). Sounds like, due to the popularity of Sinon we need a core maintainer to chime in regardless.

@sandersn
Copy link
Contributor

sandersn commented Apr 9, 2021

I just looked at the sinon PR -- I'd much prefer to see sinon's types here on DT update to be compatible with v7 of fake-timers.

To do that, you'll need to

  1. add @sinon/fake-timers@7 to package.json (and create package.json if it doesn't exist)
  2. Replace the blanket @sinon/* path mapping in tsconfig with an itemized list of the other @sinon/ packages that are still on DT.

@bcoe
Copy link
Contributor Author

bcoe commented Apr 9, 2021

@sandersn where I'm confused, is looking at the existing types I don't see too much overlap with the types now generated in @types/fake-timers:

https://gist.github.com/bcoe/27193d79d6a44d25f83f1caa04ba7162

Feels like this will be a significant breaking change, so unfortunately someone with a deeper knowledge of the problem space than myself might need to take on the work.

@43081j
Copy link
Contributor

43081j commented Apr 9, 2021

I can try tackle it the way Sanders suggested if you like and see where I get to.

I'll have a go either way and see what happens

@bcoe
Copy link
Contributor Author

bcoe commented Apr 9, 2021

@43081j I'm bumping into the issue on a bunch of repos with large test suites, so I can help test an approach you submit.

@typescript-bot
Copy link
Contributor

👋 Hi there! I’ve run some quick measurements against master and your PR. These metrics should help the humans reviewing this PR gauge whether it might negatively affect compile times or editor responsiveness for users who install these typings.

Let’s review the numbers, shall we?

Comparison details 📊
master #52294 diff
Batch compilation
Memory usage (MiB) 87.1 88.1 +1.1%
Type count 13225 13225 0%
Assignability cache size 4257 4257 0%
Language service
Samples taken 1614 1614 0%
Identifiers in tests 1614 1614 0%
getCompletionsAtPosition
    Mean duration (ms) 349.2 354.0 +1.4%
    Mean CV 9.2% 9.4%
    Worst duration (ms) 528.8 507.7 -4.0%
    Worst identifier foo sinon
getQuickInfoAtPosition
    Mean duration (ms) 353.8 358.0 +1.2%
    Mean CV 10.2% 10.3%
    Worst duration (ms) 564.2 521.3 -7.6%
    Worst identifier stub stub

It looks like nothing changed too much. I won’t post performance data again unless it gets worse.

@typescript-bot typescript-bot added the Perf: Same typescript-bot determined that this PR will not significantly impact compilation performance. label Apr 9, 2021
@bcoe
Copy link
Contributor Author

bcoe commented Apr 9, 2021

closing in favor of #52297.

@bcoe bcoe closed this Apr 9, 2021
@typescript-bot typescript-bot removed this from Needs Maintainer Review in New Pull Request Status Board Apr 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Critical package Owner Approved A listed owner of this package signed off on the pull request. Perf: Same typescript-bot determined that this PR will not significantly impact compilation performance. Untested Change This PR does not touch tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants