diff --git a/package.json b/package.json index 96f436b9..9099e790 100644 --- a/package.json +++ b/package.json @@ -192,7 +192,7 @@ "format": "prettier --write .", "format-check": "prettier --check .", "rollup": "rollup -c", - "prune": "ts-prune --error", + "prune": "ts-prune --error -p tsconfig.prune.json", "test": "vitest run", "coverage": "vitest run --coverage" }, diff --git a/src/card-controller/status-bar-item-manager.ts b/src/card-controller/status-bar-item-manager.ts index cb9dee98..11c988a0 100644 --- a/src/card-controller/status-bar-item-manager.ts +++ b/src/card-controller/status-bar-item-manager.ts @@ -18,7 +18,6 @@ export class StatusBarItemManager { this._api = api; } - private _items: StatusBarItem[] = []; private _dynamicItems: StatusBarItem[] = []; public addDynamicStatusBarItem(item: StatusBarItem): void { diff --git a/src/card-controller/style-manager.ts b/src/card-controller/style-manager.ts index eaf39c81..9ed77c67 100644 --- a/src/card-controller/style-manager.ts +++ b/src/card-controller/style-manager.ts @@ -1,4 +1,4 @@ -import type { StyleInfo } from 'lit/directives/style-map'; +import type { StyleInfo } from 'lit/directives/style-map.js'; import { configDefaults, type AdvancedCameraCardConfig } from '../config/schema/types'; import type { ThemeConfig, ThemeName } from '../config/schema/view'; diff --git a/src/components-lib/menu-button-controller.ts b/src/components-lib/menu-button-controller.ts index 0b86c66f..b8304e0a 100644 --- a/src/components-lib/menu-button-controller.ts +++ b/src/components-lib/menu-button-controller.ts @@ -1,4 +1,4 @@ -import type { StyleInfo } from 'lit/directives/style-map'; +import type { StyleInfo } from 'lit/directives/style-map.js'; import type { CameraManager } from '../camera-manager/manager'; import type { CallManager } from '../card-controller/call/manager'; diff --git a/src/components-lib/ptz/ptz-controller.ts b/src/components-lib/ptz/ptz-controller.ts index ab2496fd..de834c76 100644 --- a/src/components-lib/ptz/ptz-controller.ts +++ b/src/components-lib/ptz/ptz-controller.ts @@ -7,7 +7,6 @@ import type { PTZControlsConfig, PTZControlType, } from '../../config/schema/common/controls/ptz.js'; -import type { HomeAssistant } from '../../ha/types.js'; import type { Interaction } from '../../types.js'; import { createPTZControlsAction, @@ -20,7 +19,6 @@ export class PTZController { private _host: HTMLElement; private _config: PTZControlsConfig | null = null; - private _hass: HomeAssistant | null = null; private _cameraManager: CameraManager | null = null; private _cameraID: string | null = null; diff --git a/src/components/carousel.ts b/src/components/carousel.ts index 21a29c25..c41539b6 100644 --- a/src/components/carousel.ts +++ b/src/components/carousel.ts @@ -1,7 +1,3 @@ -import type { - CreatePluginType, - LoosePluginType, -} from 'embla-carousel/components/Plugins'; import { html, LitElement, @@ -18,14 +14,10 @@ import carouselStyle from '../scss/carousel.scss'; import { CarouselController, type CarouselDirection, + type EmblaCarouselPlugins, } from '../utils/embla/carousel-controller'; import { getTextDirection } from '../utils/text-direction'; -export type EmblaCarouselPlugins = CreatePluginType< - LoosePluginType, - Record ->[]; - @customElement('advanced-camera-card-carousel') export class AdvancedCameraCardCarousel extends LitElement { @property({ attribute: true, reflect: true }) diff --git a/src/components/select.ts b/src/components/select.ts index b6e3b37a..1355752d 100644 --- a/src/components/select.ts +++ b/src/components/select.ts @@ -51,7 +51,6 @@ export class AdvancedCameraCardSelect extends ScopedRegistryHost(LitElement) { @property({ attribute: true, type: Boolean }) public clearable?: boolean = false; - private _previouslyReportedValue?: SelectValues; private _refSelect: Ref = createRef(); static elementDefinitions = { diff --git a/src/utils/basic.ts b/src/utils/basic.ts index 6ccbc252..a3a8146e 100644 --- a/src/utils/basic.ts +++ b/src/utils/basic.ts @@ -4,7 +4,7 @@ import { differenceInSeconds, format, } from 'date-fns'; -import type { StyleInfo } from 'lit/directives/style-map'; +import type { StyleInfo } from 'lit/directives/style-map.js'; import { isEqualWith, mergeWith, round, uniq } from 'lodash-es'; import { AdvancedCameraCardError } from '../types'; diff --git a/src/utils/embla/carousel-controller.ts b/src/utils/embla/carousel-controller.ts index 168f9728..82a6003f 100644 --- a/src/utils/embla/carousel-controller.ts +++ b/src/utils/embla/carousel-controller.ts @@ -1,9 +1,8 @@ -import EmblaCarousel, { type EmblaCarouselType } from 'embla-carousel'; +import EmblaCarousel, { + type EmblaCarouselType, + type EmblaPluginType, +} from 'embla-carousel'; import { WheelGesturesPlugin } from 'embla-carousel-wheel-gestures'; -import type { - CreatePluginType, - LoosePluginType, -} from 'embla-carousel/components/Plugins'; import { isEqual } from 'lodash-es'; import type { TransitionEffect } from '../../config/schema/common/transition-effect.js'; @@ -16,7 +15,7 @@ export interface CarouselSelected { element: HTMLElement; } -type EmblaCarouselPlugins = CreatePluginType>[]; +export type EmblaCarouselPlugins = EmblaPluginType[]; export type CarouselDirection = 'vertical' | 'horizontal'; diff --git a/tests/ha/registry/entity/mock.ts b/tests/ha/registry/entity/mock.ts index 973ad926..a20c95e5 100644 --- a/tests/ha/registry/entity/mock.ts +++ b/tests/ha/registry/entity/mock.ts @@ -7,7 +7,6 @@ import type { HomeAssistant } from '../../../../src/ha/types'; export class EntityRegistryManagerMock implements EntityRegistryManager { private _cache = new EntityCache(); - private _fetchedEntityList = false; constructor(data?: Entity[]) { data?.forEach((entity) => { diff --git a/tests/utils/embla/test-utils.ts b/tests/utils/embla/test-utils.ts index 52e15735..cf23f2df 100644 --- a/tests/utils/embla/test-utils.ts +++ b/tests/utils/embla/test-utils.ts @@ -1,5 +1,4 @@ -import type { EmblaCarouselType, EmblaEventType } from 'embla-carousel'; -import type { EngineType } from 'embla-carousel/components/Engine'; +import type { EmblaCarouselType, EmblaEventType, EngineType } from 'embla-carousel'; import { vi } from 'vitest'; import { mock } from 'vitest-mock-extended'; diff --git a/tsconfig.json b/tsconfig.json index 8177daaf..1353f18c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,11 +2,12 @@ "compilerOptions": { "target": "es2021", "module": "es2020", - "moduleResolution": "node", + "moduleResolution": "bundler", "verbatimModuleSyntax": true, + "isolatedModules": true, "lib": ["es2021", "dom", "dom.iterable"], "noEmit": true, - "noErrorTruncation": false, + "noUnusedLocals": true, "noUnusedParameters": true, "noImplicitReturns": true, "noFallthroughCasesInSwitch": true, @@ -15,8 +16,11 @@ "skipLibCheck": true, "resolveJsonModule": true, "experimentalDecorators": true, + // Lit's @property installs an accessor on the prototype. Class field + // semantics would define an own property on each instance that shadows it, + // so property writes would no longer trigger a render. + "useDefineForClassFields": false, "esModuleInterop": true, - "sourceMap": true, "plugins": [ { "name": "ts-lit-plugin", diff --git a/tsconfig.prune.json b/tsconfig.prune.json new file mode 100644 index 00000000..4024e545 --- /dev/null +++ b/tsconfig.prune.json @@ -0,0 +1,11 @@ +{ + // ts-prune analyzes with its own bundled TypeScript 4.5, which predates the + // "bundler" resolution mode. It does not recognize the value and falls back to a + // mode that cannot resolve directory imports, which makes every index.ts barrel + // look unimported and its exports look unused. Give it a mode it understands. + // Related: https://github.com/dermotduffy/advanced-camera-card/issues/2593 + "extends": "./tsconfig.json", + "compilerOptions": { + "moduleResolution": "node" + } +}