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

Add definitely-type OpenLayers typings and use to fix type mismatches #244

Closed
wants to merge 1 commit into from

Conversation

maurizi
Copy link

@maurizi maurizi commented Oct 9, 2019

Mostly this is effectively non-functional changes to note which interfaces each component implements, with a few tweaks where the typings were incorrect, and also fixes a few incorrect imports that didn't work at all (most notably for me, the SourceVectorTileComponent had incorrect imports, which is what led me to type check this project).

This should fix #235


constructor(private elementRef: ElementRef) {}

ngOnInit() {
this.html = this.elementRef.nativeElement.innerHTML;
this.instance = new Attribution(this);
this.label = this.elementRef.nativeElement.innerHTML;
Copy link
Author

Choose a reason for hiding this comment

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

As far as I can tell, this component is only used in conjunction with AttributionsComponent to call setAttributions(), which takes an AttributionLike (which is a type alias for string | string[] | (FrameState): (string|Array<string>)), so using the Attribution control here was incorrect.

As such, I modified this and AttributionsComponent to work with strings instead.

@@ -11,9 +11,7 @@ import { Extent } from 'ol/extent';
<ng-content></ng-content>
`,
})
export class LayerImageComponent extends LayerComponent implements OnInit, OnChanges {
public source: Image;

Copy link
Author

Choose a reason for hiding this comment

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

The source field here and in several other layers was seemingly unused, and conflicted with the source field in the layer Options interface, so I removed them.

@maurizi maurizi force-pushed the fix-ol-5-typings branch 4 times, most recently from 165630f to 54c24f7 Compare October 9, 2019 23:18
@@ -18,6 +17,8 @@ export class DragBoxInteractionComponent implements OnInit, OnDestroy {
@Input()
boxEndCondition: EndCondition;

onBoxEnd = undefined;
Copy link
Author

Choose a reason for hiding this comment

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

According to 5.3.3 docs onBoxEnd is not optional (https://openlayers.org/en/v5.3.0/apidoc/module-ol_interaction_DragBox.html), but this is actually a typo in the documentation (openlayers/openlayers#9042). Unfortunately the typings on DefinitelyTyped also have this typo.

@maurizi
Copy link
Author

maurizi commented Nov 12, 2019

@Neonox31 @Yakoust any interest in merging this PR?
It looks like it conflicts with #245, so I'd understand if the answer is no, but of particular interest to me is seeing the imports in SourceVectorTileComponent fixed

@maurizi
Copy link
Author

maurizi commented Nov 19, 2019

Superseded by #247

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.

1 participant