-
Notifications
You must be signed in to change notification settings - Fork 628
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
chore: enable strict mode for workspace-minimap #2078
chore: enable strict mode for workspace-minimap #2078
Conversation
Added various type checks and changes to focus_region.ts which follows proper standards for the TypeScript "strict-mode" compiler checks.
Fixed all type error in ordinance with TypeScript's "strict-mode"
Fully updated and fixed all type errors after enabling strict-mode.
…Namatuzio/blockly-samples into enable-strict-workspace-minimap
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your work on this! This looks like a great start :D
Amazing feedback, thank you! I'll get right on the changes needed to be made! |
Added the changes request under the PR
I updated the PR as per the requested changes! As always, let me know if anything else needs to be further updated, thanks! |
@BeksOmega I added the requested changes!
|
When I tested removing the JSDOM code locally, I didn't receive any errors :/ Could you post back with the errors you're receiving? Hopefully with a bit more info we can figure out what's up! |
Of course! So funnily enough, yesterday when I tested it, it was working perfectly fine without the code, which confused me. I decided to make another local branch on my machine to test it out. I added some of the changes from the PR and luckily I was able to reproduce it:
I took a look at the errors that were being thrown and realized it was stemming from protected primaryWorkspace: Blockly.WorkspaceSvg;
protected minimapWorkspace: Blockly.WorkspaceSvg;
protected focusRegion: FocusRegion;
protected onMouseMoveWrapper: Blockly.browserEvents.Data | null = null;
protected onMouseDownWrapper: Blockly.browserEvents.Data | null = null;
protected onMouseUpWrapper: Blockly.browserEvents.Data | null = null;
protected minimapWrapper: HTMLDivElement;
/**
* Constructor for a minimap.
*
* @param workspace The workspace to mirror.
*/
constructor(workspace: Blockly.WorkspaceSvg) {
this.primaryWorkspace = workspace;
this.minimapWorkspace = new Blockly.WorkspaceSvg(new Blockly.Options({}));
this.focusRegion = new FocusRegion(this.primaryWorkspace, this.minimapWorkspace);
this.minimapWrapper = document.createElement('div');
} It was all caused by the old way I handled the constructor! This makes sense as to why in my initial PR, I noted the issue. Of course with the new changes to protected primaryWorkspace: Blockly.WorkspaceSvg;
protected minimapWorkspace: Blockly.WorkspaceSvg | null = null;
protected focusRegion: FocusRegion | null = null;
protected onMouseMoveWrapper: Blockly.browserEvents.Data | null = null;
protected onMouseDownWrapper: Blockly.browserEvents.Data | null = null;
protected onMouseUpWrapper: Blockly.browserEvents.Data | null = null;
protected minimapWrapper: HTMLDivElement | null = null;
/**
* Constructor for a minimap.
*
* @param workspace The workspace to mirror.
*/
constructor(workspace: Blockly.WorkspaceSvg) {
this.primaryWorkspace = workspace;
} I'll make some changes to the PR once more, removing the tester file code that I added so we can get this merged. Thanks again @BeksOmega for the opportunity to work on this! |
Removed the JSDOM code found in `plugins/workspace-minimap/test/minimap-test.mocha.js` as it was unnecessary due to updates to the code.
Sweet this looks great @Namatuzio Thank you for your hard work on this :D You just need to run |
I formatted the specific files that were causing errors in the build so everything should work just fine now. Thanks a ton! |
* Fixed workscpace-minimap/focus_region.ts type errors Added various type checks and changes to focus_region.ts which follows proper standards for the TypeScript "strict-mode" compiler checks. * fixed type errors in workspace-minimap/minimap.ts Fixed all type error in ordinance with TypeScript's "strict-mode" * Updated workspace-minimap to utilize TS strict-mode Fully updated and fixed all type errors after enabling strict-mode. * Updated index.ts to follow strict-mode rules * fix lint errors in index.ts * Updated testing file to coordinate with strict-mode * Added requested changes Added the changes request under the PR * Added feedback changes * Removed JSDOM test code Removed the JSDOM code found in `plugins/workspace-minimap/test/minimap-test.mocha.js` as it was unnecessary due to updates to the code. * format files using prettier
The basics
The details
Resolves
Fixes #2031
Proposed Changes
plugins\workspace-minimap\src\minimap.ts
plugins\workspace-minimap\src\focus_region.ts
plugins\workspace-minimap\test\index.ts
plugins\workspace-minimap\test\minimap_tests.mocha.js
Reason for Changes
Strict mode is a great way to ensure strong code consistency and maintain high code standards. It allows for fewer faults within code to be possible by patching potential oversights.
Test Coverage
npm run test
results:Documentation
Additional Information
There are 2 warnings when running
npm run test
from a change I added. For some reason when I ran the tests, the tests wouldn't have access to the document object part of theDOM
, so I added the following to the top of the tester file which seemed to have fixed it: