Skip to content

Commit

Permalink
refactor: Mark optional parameters as optional. (#6380)
Browse files Browse the repository at this point in the history
* refactor: Mark optional params as optional.

* refactor: Slightly narrow the typing of rendererOverrides.
  • Loading branch information
gonfunko authored Aug 24, 2022
1 parent 1f6481e commit 980fe13
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion core/events/events_bubble_open.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class BubbleOpen extends UiBase {
* 'warning'. Undefined for a blank event.
*/
constructor(
opt_block: BlockSvg, opt_isOpen?: boolean, opt_bubbleType?: string) {
opt_block?: BlockSvg, opt_isOpen?: boolean, opt_bubbleType?: string) {
const workspaceId = opt_block ? opt_block.workspace.id : undefined;
super(workspaceId);
this.blockId = opt_block ? opt_block.id : null;
Expand Down
6 changes: 3 additions & 3 deletions core/flyout_metrics_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class FlyoutMetricsManager extends MetricsManager {
return blockBoundingBox;
}

override getContentMetrics(opt_getWorkspaceCoordinates: boolean) {
override getContentMetrics(opt_getWorkspaceCoordinates?: boolean) {
// The bounding box is in workspace coordinates.
const blockBoundingBox = this.getBoundingBox_();
const scale = opt_getWorkspaceCoordinates ? 1 : this.workspace_.scale;
Expand All @@ -70,8 +70,8 @@ export class FlyoutMetricsManager extends MetricsManager {
}

override getScrollMetrics(
opt_getWorkspaceCoordinates: boolean, opt_viewMetrics: ContainerRegion,
opt_contentMetrics: ContainerRegion) {
opt_getWorkspaceCoordinates?: boolean, opt_viewMetrics?: ContainerRegion,
opt_contentMetrics?: ContainerRegion) {
// AnyDuringMigration because: Expected 1 arguments, but got 0.
const contentMetrics =
opt_contentMetrics || (this.getContentMetrics as AnyDuringMigration)();
Expand Down
2 changes: 1 addition & 1 deletion core/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ export function getObject<T>(
* @alias Blockly.registry.getAllItems
*/
export function getAllItems<T>(
type: string|Type<T>, opt_cased: boolean, opt_throwIfMissing?: boolean):
type: string|Type<T>, opt_cased?: boolean, opt_throwIfMissing?: boolean):
{[key: string]: T|null|(new (...p1: AnyDuringMigration[]) => T)}|null {
type = String(type).toLowerCase();
const typeRegistry = typeMap[type];
Expand Down
3 changes: 2 additions & 1 deletion core/renderers/common/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ export class Renderer implements IRegistrable {
* @param opt_rendererOverrides Rendering constant overrides.
* @internal
*/
init(theme: Theme, opt_rendererOverrides?: object) {
init(
theme: Theme, opt_rendererOverrides?: {[rendererConstant: string]: any}) {
this.constants_ = this.makeConstants_();
if (opt_rendererOverrides) {
this.overrides = opt_rendererOverrides;
Expand Down
3 changes: 2 additions & 1 deletion core/renderers/geras/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export class Renderer extends BaseRenderer {
*
* @internal
*/
override init(theme: Theme, opt_rendererOverrides: AnyDuringMigration) {
override init(
theme: Theme, opt_rendererOverrides?: {[rendererConstant: string]: any}) {
super.init(theme, opt_rendererOverrides);
this.highlightConstants_ = this.makeHighlightConstants_();
this.highlightConstants_.init();
Expand Down

0 comments on commit 980fe13

Please sign in to comment.