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

Missing Element definitions #44

Closed
almstrand opened this issue Aug 11, 2015 · 2 comments
Closed

Missing Element definitions #44

almstrand opened this issue Aug 11, 2015 · 2 comments

Comments

@almstrand
Copy link
Contributor

The following code runs as expected, though the TypeScript type checker does not recognize properties clientWidth or clientHeight:

/// <reference path="../../bower_components/polymer-ts/polymer-ts.ts" />


@component("my-element")

class MyElement extends polymer.Base {


    attached() {


      console.log(this.clientWidth + 'x' + this.clientHeight);

    }
}


MyElement.register();

Those properties are currently not defined in polymer.Base. Can this be corrected by having polymer.Base extend Element?

Of course, this request assumes that all custom elements are indeed of type Element, and I am not familiar enough with the Polymer 1.0 implementation to know whether that is the case. Is it correct that custom elements are always created by calling createElement() (which returns an object of type Element)?

I came across this issue filed with the TypeScript GitHub repository, which seems relevant. Perhaps that issue needs to be addressed before a change can be made in PolymerTS?

@almstrand almstrand changed the title Missing definitions Missing Element definitions Aug 11, 2015
@nippur72
Copy link
Owner

Yes, exactly, see also #31:

the wrong type is a temporary issue, we are waiting for this issue to be solved in TypeScript. When it will be fixed, your "el" will be an extension of type HTMLElement and you will be able to do DOM operations with it.

I tried once to copy HTMLElement from lib.d.ts but there's a very long chain, so we better wait it to be fixed (I hope in 1.6).

@nippur72
Copy link
Owner

@almstrand This issue is now fixed (#54) as TypeScript 1.6 has changed the way it declares HTMLElement.

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

No branches or pull requests

2 participants