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

core.d.ts exports its own EventListener (dts bundling issue with 8.0.0-beta.8) #29806

Closed
cexbrayat opened this issue Apr 10, 2019 · 1 comment
Assignees
Labels
area: core Issues related to the framework runtime
Milestone

Comments

@cexbrayat
Copy link
Member

cexbrayat commented Apr 10, 2019

🐞 bug report

Affected Package

The issue is caused by package @angular/core

Is this a regression?

Yes, 8.0.0-beta.7 was fine, this issue started in 8.0.0-beta.8 and is still present in 8.0.0-beta.11.

Description

core.d.ts now exports its own EventListener (see https://cdn.jsdelivr.net/npm/@angular/core@8.0.0-beta.8/core.d.ts) which triggers compilation errors in some cases.

🔬 Minimal Reproduction

const host = document.createElement('ns-app'); // HTMLElement
const myApp = renderComponent(AppComponent, { host }); // Host expects RElement|string
// RElement should compatible with HTMLElement
// but now fails with the following error

🔥 Exception or Error

Type 'HTMLElement' is not assignable to type 'string | RElement'.
  Type 'HTMLElement' is not assignable to type 'RElement'.
    Types of property 'addEventListener' are incompatible.
      Type '{ <K extends "error" | "click" | "input" | "keyup" | "keydown" | "focus" | "progress" | "select" | "scroll" | "blur" | "fullscreenchange" | "fullscreenerror" | "abort" | "animationcancel" | ... 74 more ... | "paste">(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEv...' is not assignable to type '(type: string, listener: EventListener, useCapture?: boolean) => void'.
        Types of parameters 'listener' and 'listener' are incompatible.
          Type 'EventListener' is not assignable to type '(this: HTMLElement, ev: any) => any'.
            Type 'EventListener' provides no match for the signature '(this: HTMLElement, ev: any): any'.

🌍 Your Environment

Angular Version:

8.0.0-beta.11

Anything else relevant?

This started with 8.0.0-beta.8 which activated dts bundling for the core package (see 7b0e9ed)
As core has its own EventListener (see

export class EventListener {
) it gets included in core.d.ts.

cc @alan-agius4 as we talked about it on Slack

@pkozlowski-opensource pkozlowski-opensource added area: core Issues related to the framework runtime comp: ivy labels Apr 10, 2019
@ngbot ngbot bot added this to the needsTriage milestone Apr 10, 2019
@cexbrayat cexbrayat changed the title core.d.ts export its own EventListener (dts bundling issue with 8.0.0-beta.8) core.d.ts exports its own EventListener (dts bundling issue with 8.0.0-beta.8) Apr 10, 2019
BioPhoton pushed a commit to BioPhoton/angular that referenced this issue May 21, 2019
…29809)

With dts bundles, `core.d.ts` will include an `EventListener` class as it's used in https://github.com/angular/angular/blob/303eae918d997070a36b523ddc97e018f622c258/packages/core/src/debug/debug_node.ts#L32

This will conflict with the DOM EventListener, as anything in `core.d.ts` which is using the DOM EventListener will fallback in using the one defined in the same module and hence build will fail because their implementation is different.

With this change, we rename the local `EventListener` to `DebugEventListener`, the later one is non exported.

Fixes angular#29806

PR Close angular#29809
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: core Issues related to the framework runtime
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants