Clean up internal type usages

This commit is contained in:
2023-09-02 21:02:50 +02:00
parent 41830bbca5
commit ad59f07d2b
14 changed files with 176 additions and 22 deletions

View File

@@ -12,9 +12,10 @@ export class DestroyController implements ReactiveController {
/** Public variables */
public readonly destroy = this.destroy$.asObservable();
/** constructor & lifecylce */
/** constructor & lifecycle */
constructor(host: ReactiveControllerHost) {
(this._host = host).addController(this);
this._host = host;
this._host.addController(this);
}
public hostDisconnected() {

View File

@@ -1,10 +1,25 @@
import { noChange } from 'lit';
import { AsyncDirective, directive } from 'lit/async-directive.js';
import { Observable, Subject, tap } from 'rxjs';
class Async extends AsyncDirective {
/** Private variables */
private readonly destroy$ = new Subject<void>();
/** Protected variables */
/** Public variables */
/** constructor & lifecycle */
protected override disconnected(): void {
super.disconnected();
this.destroy$.next();
this.destroy$.complete();
}
/** Public methods */
render(observable: Observable<unknown>) {
observable
.pipe(
@@ -17,12 +32,9 @@ class Async extends AsyncDirective {
return noChange;
}
protected override disconnected(): void {
super.disconnected();
/** Protected methods */
this.destroy$.next();
this.destroy$.complete();
}
/** Private methods */
}
export const asyncDirective = directive(Async);

View File

@@ -0,0 +1,42 @@
{
"extends": [
"../../../.eslintrc.json"
],
"ignorePatterns": [
"!**/*"
],
"overrides": [
{
"files": [
"*.ts",
"*.tsx",
"*.js",
"*.jsx"
],
"rules": {}
},
{
"files": [
"*.ts",
"*.tsx"
],
"rules": {}
},
{
"files": [
"*.js",
"*.jsx"
],
"rules": {}
},
{
"files": [
"*.json"
],
"parser": "jsonc-eslint-parser",
"rules": {
"@nx/dependency-checks": "error"
}
}
]
}

View File

@@ -0,0 +1,13 @@
# _internal-types
This library was generated with [Nx](https://nx.dev).
## Building
Run `nx build _internal-types` to build the library.

View File

@@ -0,0 +1,10 @@
{
"name": "@z-elements/_internal/types",
"version": "0.0.1",
"dependencies": {
"tslib": "^2.3.0"
},
"type": "commonjs",
"main": "./src/index.js",
"typings": "./src/index.d.ts"
}

View File

@@ -0,0 +1,35 @@
{
"name": "_internal-types",
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/_internal/types/src",
"projectType": "library",
"targets": {
"build": {
"executor": "@nx/js:tsc",
"outputs": [
"{options.outputPath}"
],
"options": {
"outputPath": "dist/libs/_internal/types",
"main": "libs/_internal/types/src/index.ts",
"tsConfig": "libs/_internal/types/tsconfig.lib.json",
"assets": [
"libs/_internal/types/*.md"
]
}
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": [
"{options.outputFile}"
],
"options": {
"lintFilePatterns": [
"libs/_internal/types/**/*.ts",
"libs/_internal/types/package.json"
]
}
}
},
"tags": []
}

View File

@@ -0,0 +1 @@
export * from './lib/lit'

View File

@@ -0,0 +1,5 @@
import { ReactiveControllerHost as LitReactiveControllerHost } from 'lit';
export type ReactiveControllerHost<T> = LitReactiveControllerHost & {
[K in keyof T]: T[K];
};

View File

@@ -0,0 +1,19 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
}
]
}

View File

@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../dist/out-tsc",
"declaration": true,
"types": ["node"]
},
"include": ["src/**/*.ts"],
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
}