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

Type annotations #41

Merged
merged 15 commits into from
Jun 12, 2024
Merged

Conversation

yoonieaj
Copy link
Collaborator

@yoonieaj yoonieaj commented Jun 4, 2024

Proposed Changes

Added type interfaces and type annotations for functions and constants in style.ts. This should improve code organisation/readability.
...

Type of Change

(Write an X or a brief description next to the type or types that best describe your changes.)

Type Applies?
🚨 Breaking change (fix or feature that would cause existing functionality to change)
New feature (non-breaking change that adds functionality)
🐛 Bug fix (non-breaking change that fixes an issue)
🎨 User interface change (change to user interface; provide screenshots)
♻️ Refactoring (internal change to codebase, without changing functionality) x
🚦 Test update (change that only adds or modifies tests)
📚 Documentation update (change that only updates documentation)
📦 Dependency update (change that updates a dependency)
🔧 Internal (change that only affects developers or continuous integration)

Checklist

(Complete each of the following items for your pull request. Indicate that you have completed an item by changing the [ ] into a [x] in the raw text, or by clicking on the checkbox in the rendered description on GitHub.)

Before opening your pull request:

  • I have performed a self-review of my changes.
    • Check that all changed files included in this pull request are intentional changes.
    • Check that all changes are relevant to the purpose of this pull request, as described above.
  • I have added tests for my changes, if applicable.
    • This is required for all bug fixes and new features.
  • I have updated the project documentation, if applicable.
    • This is required for new features.
  • If this is my first contribution, I have added myself to the list of contributors.
  • I have updated the project Changelog (this is required for all changes).

After opening your pull request:

  • I have verified that the CI tests have passed.
  • I have reviewed the test coverage changes reported by Coveralls.
  • I have requested a review from a project maintainer.

Questions and Comments

Hello Professor Liu! I have a few questions about the changes I've made so far:

  1. The code doesn't seem to care whether the DrawnObject attributes are optional, so I'm not sure if I made the right call on which attributes should be optional?
  2. Since the preset Styles only specify certain attributes, can I leave every one of these attributes as optional?

@yoonieaj yoonieaj marked this pull request as ready for review June 4, 2024 18:37
@yoonieaj yoonieaj marked this pull request as draft June 4, 2024 18:39
@yoonieaj yoonieaj requested a review from david-yz-liu June 4, 2024 18:39
@coveralls
Copy link
Collaborator

coveralls commented Jun 4, 2024

Pull Request Test Coverage Report for Build 9372440637

Details

  • 16 of 16 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 86.781%

Totals Coverage Status
Change from base Build 9327208107: 0.0%
Covered Lines: 380
Relevant Lines: 423

💛 - Coveralls

@david-yz-liu
Copy link
Owner

  1. Weird that the compiler doesn't seem to be catching that, but we can look into that later. I think show_indexes and style can both be optional as well.
  2. Yes it's good for all Style attributes to be optional 👍

@yoonieaj yoonieaj marked this pull request as ready for review June 5, 2024 19:13
@coveralls
Copy link
Collaborator

coveralls commented Jun 5, 2024

Pull Request Test Coverage Report for Build 9389923649

Details

  • 17 of 17 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 86.801%

Totals Coverage Status
Change from base Build 9376313216: 0.0%
Covered Lines: 381
Relevant Lines: 424

💛 - Coveralls

@yoonieaj yoonieaj marked this pull request as draft June 5, 2024 19:16
@yoonieaj
Copy link
Collaborator Author

yoonieaj commented Jun 5, 2024

Proposed Changes

Added type interfaces and type annotations for functions and constants in style.ts. This should improve code organisation/readability.
...

Type of Change

(Write an X or a brief description next to the type or types that best describe your changes.)

Type Applies?
🚨 Breaking change (fix or feature that would cause existing functionality to change)
New feature (non-breaking change that adds functionality)
🐛 Bug fix (non-breaking change that fixes an issue)
🎨 User interface change (change to user interface; provide screenshots)
♻️ Refactoring (internal change to codebase, without changing functionality) x
🚦 Test update (change that only adds or modifies tests)
📚 Documentation update (change that only updates documentation)
📦 Dependency update (change that updates a dependency)
🔧 Internal (change that only affects developers or continuous integration)

Checklist

(Complete each of the following items for your pull request. Indicate that you have completed an item by changing the [ ] into a [x] in the raw text, or by clicking on the checkbox in the rendered description on GitHub.)

Before opening your pull request:

  • I have performed a self-review of my changes.
    • Check that all changed files included in this pull request are intentional changes.
    • Check that all changes are relevant to the purpose of this pull request, as described above.
  • I have added tests for my changes, if applicable.
    • This is required for all bug fixes and new features.
  • I have updated the project documentation, if applicable.
    • This is required for new features.
  • If this is my first contribution, I have added myself to the list of contributors.
  • I have updated the project Changelog (this is required for all changes).

After opening your pull request:

  • I have verified that the CI tests have passed.
  • I have reviewed the test coverage changes reported by Coveralls.
  • I have requested a review from a project maintainer.

Questions and Comments

(Include any questions or comments you have regarding your changes.)

@yoonieaj yoonieaj marked this pull request as ready for review June 5, 2024 19:27
@coveralls
Copy link
Collaborator

coveralls commented Jun 5, 2024

Pull Request Test Coverage Report for Build 9390090716

Details

  • 17 of 17 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 86.801%

Totals Coverage Status
Change from base Build 9376313216: 0.0%
Covered Lines: 381
Relevant Lines: 424

💛 - Coveralls

Copy link
Owner

@david-yz-liu david-yz-liu left a comment

Choose a reason for hiding this comment

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

@yoonieaj great work. I left a few inline comments. Also:

  1. I see that you left a comment with your full PR description. Instead, you can edit your existing PR description and then copy back in the contents of that comment.
  2. Since you've defined the DrawnObject type very well, please go ahead and modify the other source code files to use this type annotation instead of the old "object" type. You don't need to add type annotations to all functions/values in those other files though, just make sure to use DrawnObject where appropriate.

@@ -73,7 +73,7 @@ function drawAutomatedStackFrames(stack_frames, configuration) {
let width;
let height;

if (stack_frame.name !== "BLANK") {
if (stack_frame.type !== "BLANK") {
Copy link
Owner

Choose a reason for hiding this comment

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

This change is out of scope of this PR (and in fact I suspect it's related to what @sarahsonder is working on currently).

@@ -0,0 +1,25 @@
interface DrawnObject {
Copy link
Owner

Choose a reason for hiding this comment

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

Use the export keyword for these types, and then import them explicitly in style.ts.

Copy link
Owner

Choose a reason for hiding this comment

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

Also rename this type to DrawnEntity, since the word "object" has another meaning in the context of memory model diagrams.

@coveralls
Copy link
Collaborator

coveralls commented Jun 11, 2024

Pull Request Test Coverage Report for Build 9457996657

Details

  • 15 of 15 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 87.596%

Totals Coverage Status
Change from base Build 9410692102: 0.0%
Covered Lines: 388
Relevant Lines: 429

💛 - Coveralls

@coveralls
Copy link
Collaborator

coveralls commented Jun 11, 2024

Pull Request Test Coverage Report for Build 9458015375

Details

  • 15 of 15 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 87.596%

Totals Coverage Status
Change from base Build 9410692102: 0.0%
Covered Lines: 388
Relevant Lines: 429

💛 - Coveralls

@yoonieaj yoonieaj requested a review from david-yz-liu June 11, 2024 01:22
value: any;
show_indexes?: boolean;
style?: Style;
height: number;
Copy link
Owner

Choose a reason for hiding this comment

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

I think this, width, and rowBreaker are also optional?

@@ -244,7 +245,7 @@ function drawAutomatedOtherItems(
* The returned object has two attributes as 'stack_frames' and 'other_items'.
* Each of these attributes are a list of objects that were originally given by the user.
*
* @param {object[]} objects - The list of objects, including stack-frames (if any) and other items, that
* @param {Object[]} objects - The list of objects, including stack-frames (if any) and other items, that
Copy link
Owner

Choose a reason for hiding this comment

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

Is this meant to be DrawnEntity?

@coveralls
Copy link
Collaborator

coveralls commented Jun 11, 2024

Pull Request Test Coverage Report for Build 9474095102

Details

  • 15 of 15 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 87.596%

Totals Coverage Status
Change from base Build 9410692102: 0.0%
Covered Lines: 388
Relevant Lines: 429

💛 - Coveralls

@yoonieaj yoonieaj requested a review from david-yz-liu June 11, 2024 23:28
@david-yz-liu david-yz-liu merged commit 399a80e into david-yz-liu:master Jun 12, 2024
3 checks passed
@yoonieaj yoonieaj deleted the type-annotations branch September 17, 2024 00:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants