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

Typings: cannot construct legacy elements with properties defined only with type #5173

Closed
jlaamanen opened this issue Apr 3, 2018 · 0 comments

Comments

@jlaamanen
Copy link
Contributor

Description

Unable to use legacy Polymer element constructor when using shorthand property definitions (i.e. only giving the property type instead of metadata object).

Steps to Reproduce

Try to create an element:

Polymer({
  is: "my-element",
  properties: {
    foo: Number,
    bar: {
      type: Number
    }
  }
});

Expected Results

No errors

Actual Results

There will be an error:

[ts]
Argument of type '{ is: string; properties: { foo: NumberConstructor; bar: { type: NumberConstructor; }; }; }' is not assignable to parameter of type 'PolymerInit'.
  Types of property 'properties' are incompatible.
    Type '{ foo: NumberConstructor; bar: { type: NumberConstructor; }; }' is not assignable to type 'PolymerElementProperties'.
      Property 'foo' is incompatible with index signature.
        Type 'NumberConstructor' has no properties in common with type 'PolymerElementPropertiesMeta'.

If foo property is removed or defined with a metadata object, the error will disappear.

Browsers Affected

All

Versions

  • Polymer: v2.6.0

There is a fast and simple fix for this issue: add | Function to property type. I will be posting a PR about this shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants