From e020fd1154c1ffcde164c85b306cfc3d2880a7e9 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Wed, 17 Oct 2018 13:58:24 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=8B=20decorators=20(#1790)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/babel.js | 3 -- package.json | 2 -- .../lovelace/cards/hui-entity-button-card.ts | 22 ++++++------ src/panels/lovelace/cards/hui-glance-card.ts | 23 ++++++------ tsconfig.json | 1 - yarn.lock | 36 ------------------- 6 files changed, 20 insertions(+), 67 deletions(-) diff --git a/config/babel.js b/config/babel.js index 7bc97d51d5..1c073245dc 100644 --- a/config/babel.js +++ b/config/babel.js @@ -20,9 +20,6 @@ module.exports.babelLoaderConfig = ({ latestBuild }) => { "@babel/plugin-proposal-object-rest-spread", { loose: true, useBuiltIns: true }, ], - // Used for decorators in typescript - ["@babel/plugin-proposal-decorators", { legacy: true }], - ["@babel/plugin-proposal-class-properties", { loose: true }], // Only support the syntax, Webpack will handle it. "@babel/syntax-dynamic-import", [ diff --git a/package.json b/package.json index a0510beefe..64baa83bdb 100644 --- a/package.json +++ b/package.json @@ -91,8 +91,6 @@ "devDependencies": { "@babel/core": "^7.1.2", "@babel/plugin-external-helpers": "^7.0.0", - "@babel/plugin-proposal-class-properties": "^7.1.0", - "@babel/plugin-proposal-decorators": "^7.1.2", "@babel/plugin-proposal-object-rest-spread": "^7.0.0", "@babel/plugin-syntax-dynamic-import": "^7.0.0", "@babel/plugin-transform-react-jsx": "^7.0.0", diff --git a/src/panels/lovelace/cards/hui-entity-button-card.ts b/src/panels/lovelace/cards/hui-entity-button-card.ts index d13f2f8b9f..18c56dc601 100644 --- a/src/panels/lovelace/cards/hui-entity-button-card.ts +++ b/src/panels/lovelace/cards/hui-entity-button-card.ts @@ -1,10 +1,4 @@ -import { - html, - LitElement, - property, - customElement, - eventOptions, -} from "@polymer/lit-element"; +import { html, LitElement } from "@polymer/lit-element"; import { fireEvent } from "../../../common/dom/fire_event.js"; import "../../../components/ha-card.js"; @@ -28,15 +22,18 @@ interface Config extends LovelaceConfig { service_data?: object; } -@customElement("hui-entity-button-card" as any) export class HuiEntityButtonCard extends HassLocalizeLitMixin(LitElement) implements LovelaceCard { - @property() protected hass?: HomeAssistant; - - @property() protected config?: Config; + static get properties() { + return { + hass: {}, + config: {}, + }; + } + public getCardSize() { return 2; } @@ -156,7 +153,6 @@ export class HuiEntityButtonCard extends HassLocalizeLitMixin(LitElement) return `hsl(${hue}, 100%, ${100 - sat / 2}%)`; } - @eventOptions({ passive: true }) private handleClick() { const config = this.config; if (!config) { @@ -191,3 +187,5 @@ declare global { "hui-entity-button-card": HuiEntityButtonCard; } } + +customElements.define("hui-entity-button-card", HuiEntityButtonCard); diff --git a/src/panels/lovelace/cards/hui-glance-card.ts b/src/panels/lovelace/cards/hui-glance-card.ts index 9991b2c436..9256c4c115 100644 --- a/src/panels/lovelace/cards/hui-glance-card.ts +++ b/src/panels/lovelace/cards/hui-glance-card.ts @@ -1,10 +1,4 @@ -import { - html, - LitElement, - customElement, - property, - eventOptions, -} from "@polymer/lit-element"; +import { html, LitElement } from "@polymer/lit-element"; import { classMap } from "lit-html/directives/classMap.js"; import { repeat } from "lit-html/directives/repeat"; @@ -41,17 +35,19 @@ interface Config extends LovelaceConfig { entities: EntityConfig[]; } -@customElement("hui-glance-card" as any) export class HuiGlanceCard extends HassLocalizeLitMixin(LitElement) implements LovelaceCard { - @property() protected hass?: HomeAssistant; - - @property() protected config?: Config; - protected configEntities?: EntityConfig[]; + static get properties() { + return { + hass: {}, + config: {}, + }; + } + public getCardSize() { return 3; } @@ -185,7 +181,6 @@ export class HuiGlanceCard extends HassLocalizeLitMixin(LitElement) `; } - @eventOptions({ passive: true }) private handleClick(ev: MouseEvent) { const config = (ev.currentTarget as any).entityConf as EntityConfig; const entityId = config.entity; @@ -210,3 +205,5 @@ declare global { "hui-glance-card": HuiGlanceCard; } } + +customElements.define("hui-glance-card", HuiGlanceCard); diff --git a/tsconfig.json b/tsconfig.json index 857b7b5270..b5402c3807 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,7 +9,6 @@ "noUnusedParameters": true, "noImplicitReturns": true, "noFallthroughCasesInSwitch": true, - "experimentalDecorators": true, "strict": true, "noImplicitAny": false } diff --git a/yarn.lock b/yarn.lock index 2415595042..14d75ba2f9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -542,28 +542,6 @@ "@babel/helper-remap-async-to-generator" "^7.1.0" "@babel/plugin-syntax-async-generators" "^7.0.0" -"@babel/plugin-proposal-class-properties@^7.1.0": - version "7.1.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.1.0.tgz#9af01856b1241db60ec8838d84691aa0bd1e8df4" - integrity sha512-/PCJWN+CKt5v1xcGn4vnuu13QDoV+P7NcICP44BoonAJoPSGwVkgrXihFIQGiEjjPlUDBIw1cM7wYFLARS2/hw== - dependencies: - "@babel/helper-function-name" "^7.1.0" - "@babel/helper-member-expression-to-functions" "^7.0.0" - "@babel/helper-optimise-call-expression" "^7.0.0" - "@babel/helper-plugin-utils" "^7.0.0" - "@babel/helper-replace-supers" "^7.1.0" - "@babel/plugin-syntax-class-properties" "^7.0.0" - -"@babel/plugin-proposal-decorators@^7.1.2": - version "7.1.2" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-decorators/-/plugin-proposal-decorators-7.1.2.tgz#79829bd75fced6581ec6c7ab1930e8d738e892e7" - integrity sha512-YooynBO6PmBgHvAd0fl5e5Tq/a0pEC6RqF62ouafme8FzdIVH41Mz/u1dn8fFVm4jzEJ+g/MsOxouwybJPuP8Q== - dependencies: - "@babel/helper-plugin-utils" "^7.0.0" - "@babel/helper-replace-supers" "^7.1.0" - "@babel/helper-split-export-declaration" "^7.0.0" - "@babel/plugin-syntax-decorators" "^7.1.0" - "@babel/plugin-proposal-json-strings@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.0.0.tgz#3b4d7b5cf51e1f2e70f52351d28d44fc2970d01e" @@ -619,20 +597,6 @@ dependencies: "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-syntax-class-properties@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.0.0.tgz#e051af5d300cbfbcec4a7476e37a803489881634" - integrity sha512-cR12g0Qzn4sgkjrbrzWy2GE7m9vMl/sFkqZ3gIpAQdrvPDnLM8180i+ANDFIXfjHo9aqp0ccJlQ0QNZcFUbf9w== - dependencies: - "@babel/helper-plugin-utils" "^7.0.0" - -"@babel/plugin-syntax-decorators@^7.1.0": - version "7.1.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-decorators/-/plugin-syntax-decorators-7.1.0.tgz#2fa7c1a7905a299c9853ebcef340306675f9cbdc" - integrity sha512-uQvRSbgQ0nQg3jsmIixXXDCgSpkBolJ9X7NYThMKCcjvE8dN2uWJUzTUNNAeuKOjARTd+wUQV0ztXpgunZYKzQ== - dependencies: - "@babel/helper-plugin-utils" "^7.0.0" - "@babel/plugin-syntax-dynamic-import@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-dynamic-import/-/plugin-syntax-dynamic-import-7.0.0.tgz#6dfb7d8b6c3be14ce952962f658f3b7eb54c33ee"