Skip to content

refactor(cdk/drag-drop): Correctly type drag handle parent drag witho… #24664

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/cdk/drag-drop/directives/drag-handle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
SkipSelf,
} from '@angular/core';
import {Subject} from 'rxjs';
import type {CdkDrag} from './drag';
Copy link
Member

Choose a reason for hiding this comment

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

If I remember correctly, we aren't allowed to use type imports because the internal JS tooling can't handle them.

Copy link
Member

Choose a reason for hiding this comment

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

I've confirmed that we can't use type-only imports and exports, because Closure doesn't know how to handle them. I've also submitted #24678 to lint against it automatically.

import {CDK_DRAG_PARENT} from '../drag-parent';
import {assertElementNode} from './assertions';

Expand All @@ -38,7 +39,7 @@ export const CDK_DRAG_HANDLE = new InjectionToken<CdkDragHandle>('CdkDragHandle'
})
export class CdkDragHandle implements OnDestroy {
/** Closest parent draggable instance. */
_parentDrag: {} | undefined;
_parentDrag: CdkDrag | undefined;

/** Emits when the state of the handle has changed. */
readonly _stateChanges = new Subject<CdkDragHandle>();
Expand All @@ -56,7 +57,7 @@ export class CdkDragHandle implements OnDestroy {

constructor(
public element: ElementRef<HTMLElement>,
@Inject(CDK_DRAG_PARENT) @Optional() @SkipSelf() parentDrag?: any,
@Inject(CDK_DRAG_PARENT) @Optional() @SkipSelf() parentDrag?: CdkDrag,
) {
if (typeof ngDevMode === 'undefined' || ngDevMode) {
assertElementNode(element.nativeElement, 'cdkDragHandle');
Expand Down