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

[opentype.js] Improve Glyph #61702

Merged
merged 2 commits into from
Aug 12, 2022

Conversation

alecmev
Copy link
Contributor

@alecmev alecmev commented Aug 12, 2022


The actual change is in the second commit, the first one is a Prettier pass.

@typescript-bot
Copy link
Contributor

typescript-bot commented Aug 12, 2022

@alecmev Thank you for submitting this PR!

This is a live comment which I will keep updated.

1 package in this PR

Code Reviews

Because you edited one package and updated the tests (👏), I can help you merge this PR once someone else signs off on it.

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

Status

  • ✅ No merge conflicts
  • ✅ Continuous integration tests have passed
  • ✅ Most recent commit is approved by type definition owners, DT maintainers or others

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": 61702,
  "author": "alecmev",
  "headCommitOid": "fb9c1adc735f5e5a3de644b3f9cfda77b072c14f",
  "mergeBaseOid": "3f99ce278474a3f7a8bdf783dd7a2aa30849c686",
  "lastPushDate": "2022-08-12T17:57:39.000Z",
  "lastActivityDate": "2022-08-12T18:25:20.000Z",
  "mergeOfferDate": "2022-08-12T18:24:47.000Z",
  "mergeRequestDate": "2022-08-12T18:25:20.000Z",
  "mergeRequestUser": "alecmev",
  "hasMergeConflict": false,
  "isFirstContribution": false,
  "tooManyFiles": false,
  "hugeChange": false,
  "popularityLevel": "Well-liked by everyone",
  "pkgInfo": [
    {
      "name": "opentype.js",
      "kind": "edit",
      "files": [
        {
          "path": "types/opentype.js/index.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/opentype.js/opentype.js-tests.ts",
          "kind": "test"
        }
      ],
      "owners": [
        "danmarshall",
        "edzis",
        "peterblazejewicz"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Well-liked by everyone"
    }
  ],
  "reviews": [
    {
      "type": "approved",
      "reviewer": "danmarshall",
      "date": "2022-08-12T18:24:05.000Z",
      "isMaintainer": false
    }
  ],
  "mainBotCommentID": 1213374453,
  "ciResult": "pass"
}

@typescript-bot typescript-bot added this to Waiting for Code Reviews in New Pull Request Status Board Aug 12, 2022
@typescript-bot
Copy link
Contributor

🔔 @danmarshall @edzis @peterblazejewicz — 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.

yMax?: number | undefined;
advanceWidth?: number | undefined;
leftSideBearing?: number | undefined;
path: Path;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The getter always returns a Path, while the setter also accepts () => Path, but I think it's more practical to not include it in the type. It's not possible to type them separately right now, unfortunately: microsoft/TypeScript#43662

Comment on lines +173 to +176
xMin?: number | undefined;
xMax?: number | undefined;
yMin?: number | undefined;
yMax?: number | undefined;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These aren't private.

yMin?: number | undefined;
yMax?: number | undefined;
advanceWidth?: number | undefined;
leftSideBearing?: number | undefined;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The missing property that made me create this PR.

Comment on lines +170 to +171
name: string | null;
unicode?: number | undefined;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The code has no guards against these being null / undefined.


private bindConstructorValues(options: GlyphOptions): void;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's no point in calling this outside of the constructor. The library itself never uses it either.

Copy link
Member

Choose a reason for hiding this comment

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

there as no point of addition 'private', just remove from declaration, so user cannot access this (unless doing module augmentation)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tried to google this when I was creating the PR, but couldn't find anything conclusive. My intention was to document this for future contributors, so that they don't add this back by mistake. Or is a comment preferred?

Copy link
Member

Choose a reason for hiding this comment

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

easy, improve in future, it will come back

yMax?: number | undefined;
advanceWidth?: number | undefined;
leftSideBearing?: number | undefined;
path?: Path | (() => Path) | undefined;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case it can, indeed, be a callback.

Copy link
Contributor

@danmarshall danmarshall left a comment

Choose a reason for hiding this comment

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

LGTM

@typescript-bot typescript-bot added Owner Approved A listed owner of this package signed off on the pull request. Self Merge This PR can now be self-merged by the PR author or an owner labels Aug 12, 2022
@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Waiting for Author to Merge in New Pull Request Status Board Aug 12, 2022
@alecmev
Copy link
Contributor Author

alecmev commented Aug 12, 2022

Ready to merge

@typescript-bot typescript-bot moved this from Waiting for Author to Merge to Recently Merged in New Pull Request Status Board Aug 12, 2022
@typescript-bot typescript-bot merged commit 5b22548 into DefinitelyTyped:master Aug 12, 2022
@alecmev alecmev deleted the opentype-glyph branch August 12, 2022 18:26
@typescript-bot typescript-bot removed this from Recently Merged in New Pull Request Status Board Aug 12, 2022
Comment on lines +143 to +144
// @ts-expect-error
Glyph.bindConstructorValues({});
Copy link
Member

Choose a reason for hiding this comment

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

just remove on next iteration (private methods)

shlyren pushed a commit to shlyren/DefinitelyTyped that referenced this pull request Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Owner Approved A listed owner of this package signed off on the pull request. 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