Skip to content

Could not find declaration file for declarative-event-listeners #76

@Lithl

Description

@Lithl

Trying to follow the documentation to make use of @listen, I added import {DeclarativeEventListeners} from '@polymer/decorators/lib/declarative-event-listeners.js'; to the top of my file and my element extends DeclarativeEventListeners(PolymerElement). However, when my typescript is compiled, I get:

node_modules/@polymer/decorators/lib/decorators.d.ts:11:32 - error TS7016: Could not find a declaration file for module '@polymer/polymer/polymer-element.js'. '/path/to/node_modules/@polymer/polymer/polymer-element.js' implicitly has an 'any' type.

11 import { PolymerElement } from '@polymer/polymer/polymer-element.js';
                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

path/to/index.ts:3:41 - error TS7016: Could not find a declaration file for module '@polymer/decorators/lib/declarative-event-listeners.js'. '/path/to/node_modules/@polymer/decorators/lib/declarative-event-listeners.js' implicitly has an 'any' type.

3 import {DeclarativeEventListeners} from '@polymer/decorators/lib/declarative-event-listeners.js';
                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If I mark the function being decorated as private, I get an additional error:

path/to/index.ts:39:4 - error TS2345: Argument of type 'MyClass' is not assignable to parameter of type 'ElementPrototype & HasEventListener<"myFunction_">'.
  Type 'MyClass' is not assignable to type 'HasEventListener<"myFunction_">'.
    Property 'myFunction_' is private in type 'MyClass' but not in type 'HasEventListener<"myFunction_">'.

39   @listen('select', document)
      ~~~~~~~~~~~~~~~~~~~~~~~~~~

I have no such problem marking a function private and annotating it with @observe or marking a property private and annotating with @query.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions