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

add types for spinnies #59503

Merged
merged 1 commit into from
Mar 31, 2022
Merged

add types for spinnies #59503

merged 1 commit into from
Mar 31, 2022

Conversation

benjamincburns
Copy link
Contributor

@benjamincburns benjamincburns commented Mar 28, 2022

Please fill in this template.

If adding a new definition:

  • The package does not already provide its own types, or cannot have its .d.ts files generated via --declaration
  • If this is for an npm package, match the name. If not, do not conflict with the name of an npm package.
  • Create it with dts-gen --dt, not by basing it on an existing project.
  • Represents shape of module/library correctly
  • tslint.json should contain { "extends": "@definitelytyped/dtslint/dt.json" }, and no additional rules.
  • tsconfig.json should have noImplicitAny, noImplicitThis, strictNullChecks, and strictFunctionTypes set to true.

@typescript-bot
Copy link
Contributor

typescript-bot commented Mar 28, 2022

@benjamincburns 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

This PR adds a new definition, so it needs to be reviewed by a DT maintainer 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
  • ✅ Only a DT maintainer can approve changes when there are new packages added

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": 59503,
  "author": "benjamincburns",
  "headCommitOid": "e0b046f80c8cfc81f1a24e2cd339eb7c051cbc33",
  "mergeBaseOid": "d6d658846c9659deea6898e60f687159f463b2dd",
  "lastPushDate": "2022-03-30T02:01:09.000Z",
  "lastActivityDate": "2022-03-31T00:39:49.000Z",
  "mergeOfferDate": "2022-03-30T20:59:50.000Z",
  "mergeRequestDate": "2022-03-31T00:39:49.000Z",
  "mergeRequestUser": "benjamincburns",
  "hasMergeConflict": false,
  "isFirstContribution": true,
  "tooManyFiles": false,
  "hugeChange": false,
  "popularityLevel": "Well-liked by everyone",
  "pkgInfo": [
    {
      "name": "spinnies",
      "kind": "add",
      "files": [
        {
          "path": "types/spinnies/index.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/spinnies/spinnies-tests.ts",
          "kind": "test"
        },
        {
          "path": "types/spinnies/tsconfig.json",
          "kind": "package-meta-ok"
        },
        {
          "path": "types/spinnies/tslint.json",
          "kind": "package-meta-ok"
        }
      ],
      "owners": [],
      "addedOwners": [
        "benjamincburns"
      ],
      "deletedOwners": [],
      "popularityLevel": "Well-liked by everyone"
    }
  ],
  "reviews": [
    {
      "type": "approved",
      "reviewer": "peterblazejewicz",
      "date": "2022-03-30T20:59:11.000Z",
      "isMaintainer": true
    },
    {
      "type": "stale",
      "reviewer": "kerolloz",
      "date": "2022-03-28T05:22:00.000Z",
      "abbrOid": "0aae6d3"
    }
  ],
  "mainBotCommentID": 1080095439,
  "ciResult": "pass"
}

@typescript-bot typescript-bot added New Definition This PR creates a new definition package. Check Config Changes a module config files labels Mar 28, 2022
@typescript-bot
Copy link
Contributor

🔔 @benjamincburns — you're the only owner, but it would still be good if you find someone to review this PR in the next few days, otherwise a maintainer will look at it. (And if you do find someone, maybe even recruit them to be a second owner to make future changes easier...)

@typescript-bot typescript-bot added this to Waiting for Code Reviews in New Pull Request Status Board Mar 28, 2022
@typescript-bot typescript-bot removed the Check Config Changes a module config files label Mar 28, 2022
@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Maintainer Action in New Pull Request Status Board Mar 28, 2022
@typescript-bot typescript-bot moved this from Needs Maintainer Action to Waiting for Code Reviews in New Pull Request Status Board Mar 28, 2022
@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Maintainer Action in New Pull Request Status Board Mar 28, 2022
@typescript-bot typescript-bot added the Other Approved This PR was reviewed and signed-off by a community member. label Mar 28, 2022
@peterblazejewicz
Copy link
Member

  1. for TS 4.4 better interop you could write optional properties to support exact optional property types syntax when consumed by client code:
status?: SpinnerStatus | undefined;

https://devblogs.microsoft.com/typescript/announcing-typescript-4-4/#exact-optional-property-types

  1. the package uses chalk. Chalk is whitelisted on DDT, so you can reuse types from chalk by adding a depdency for external types:
{
    "private": true,
    "dependencies": {
        "chalk": "^2.4.2"
    }
}

https://github.com/DefinitelyTyped/DefinitelyTyped#packagejson

@benjamincburns
Copy link
Contributor Author

benjamincburns commented Mar 30, 2022

  1. for TS 4.4 better interop you could write optional properties to support exact optional property types syntax when consumed by client code:
status?: SpinnerStatus | undefined;

@peterblazejewicz I'm not sure I understand your recommended change here. I don't think it's a valid/desirable use case to assign undefined to an optional field of Options or SpinnerOptions.

If anything, it's probably more correct for me to rewrite both interfaces as having no optional fields, but change all method signatures that accept those two types as arguments to accepting Partial<SpinnerOptions> or Partial<Options>. This is because Spinnies fills in all missing fields with defaults (or in the case of SpinnerOptions, values from the instance-level Options) internally prior to using/assigning/returning Options or SpinnerOptions.

@benjamincburns
Copy link
Contributor Author

benjamincburns commented Mar 30, 2022

3. the package uses chalk. Chalk is whitelisted on DDT, so you can reuse types from chalk by adding a depdency for external types:

{
    "private": true,
    "dependencies": {
        "chalk": "^2.4.2"
    }
}

Unfortunately chalk@2.4.2 doesn't expose a string literal union type like the ForegroundColor type in chalk@5.0.1. Instead I'll pull the allowlist of color literals from the spinnies source and make a union type from that.

@typescript-bot typescript-bot removed the Other Approved This PR was reviewed and signed-off by a community member. label Mar 30, 2022
@typescript-bot typescript-bot moved this from Needs Maintainer Action to Waiting for Code Reviews in New Pull Request Status Board Mar 30, 2022
@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Maintainer Action in New Pull Request Status Board Mar 30, 2022
@typescript-bot
Copy link
Contributor

@peterblazejewicz, @kerolloz 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?

Copy link
Member

@peterblazejewicz peterblazejewicz left a comment

Choose a reason for hiding this comment

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

LGTM!
@benjamincburns thx!

@typescript-bot typescript-bot added Maintainer Approved Self Merge This PR can now be self-merged by the PR author or an owner labels Mar 30, 2022
@typescript-bot typescript-bot moved this from Needs Maintainer Action to Waiting for Author to Merge in New Pull Request Status Board Mar 30, 2022
@typescript-bot
Copy link
Contributor

@benjamincburns: Everything looks good here. I am ready to merge this PR (at e0b046f) 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! ❤️

@typescript-bot
Copy link
Contributor

@kerolloz 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?

@benjamincburns
Copy link
Contributor Author

Ready to merge

@typescript-bot typescript-bot moved this from Waiting for Author to Merge to Recently Merged in New Pull Request Status Board Mar 31, 2022
@typescript-bot typescript-bot merged commit e93b92c into DefinitelyTyped:master Mar 31, 2022
@typescript-bot typescript-bot removed this from Recently Merged in New Pull Request Status Board Mar 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Maintainer Approved New Definition This PR creates a new definition package. Self Merge This PR can now be self-merged by the PR author or an owner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants