diff --git a/packages/create-jitar/src/index.ts b/packages/create-jitar/src/index.ts index a9c70a4f..91d94d1f 100644 --- a/packages/create-jitar/src/index.ts +++ b/packages/create-jitar/src/index.ts @@ -35,7 +35,7 @@ async function execute() const argTargetDir = formatTargetDir(argv._[0]); const argTemplate = argv.template || argv.t; - let targetDir = argTargetDir || defaultTargetDir; + let targetDir = argTargetDir ?? defaultTargetDir; const getProjectName = () => targetDir === '.' ? path.basename(path.resolve()) @@ -54,7 +54,7 @@ async function execute() initial: defaultTargetDir, onState: (state) => { - targetDir = formatTargetDir(state.value) || defaultTargetDir; + targetDir = formatTargetDir(state.value) ?? defaultTargetDir; }, }, { diff --git a/packages/create-jitar/templates/lit/src/my-element.ts b/packages/create-jitar/templates/lit/src/my-element.ts index e942d53b..862fb8b1 100644 --- a/packages/create-jitar/templates/lit/src/my-element.ts +++ b/packages/create-jitar/templates/lit/src/my-element.ts @@ -29,7 +29,7 @@ export class MyElement extends LitElement ` } - static styles = css` + static readonly styles = css` :host { max-width: 1280px; margin: 0 auto; diff --git a/packages/create-jitar/templates/svelte/src/main.ts b/packages/create-jitar/templates/svelte/src/main.ts index 073d283b..e2b2c334 100644 --- a/packages/create-jitar/templates/svelte/src/main.ts +++ b/packages/create-jitar/templates/svelte/src/main.ts @@ -2,7 +2,7 @@ import './app.css' import App from './App.svelte' const app = new App({ - target: document.getElementById('app') as HTMLElement, + target: document.getElementById('app'), }) export default app \ No newline at end of file diff --git a/packages/reflection/src/models/ReflectionClass.ts b/packages/reflection/src/models/ReflectionClass.ts index 10e788b9..b8148f40 100644 --- a/packages/reflection/src/models/ReflectionClass.ts +++ b/packages/reflection/src/models/ReflectionClass.ts @@ -125,23 +125,21 @@ export default class ReflectionClass extends ReflectionMember { const declaration = this.getDeclaration(name); - return (declaration !== undefined && declaration.isPublic) - || this.hasGetter(name); + return declaration?.isPublic || this.hasGetter(name); } canWrite(name: string): boolean { const declaration = this.getDeclaration(name); - return (declaration !== undefined && declaration.isPublic) - || this.hasSetter(name); + return declaration?.isPublic || this.hasSetter(name); } canCall(name: string): boolean { const funktion = this.getFunction(name); - return funktion !== undefined && funktion.isPublic; + return funktion?.isPublic ?? false; } toString(): string diff --git a/packages/reflection/src/parser/Parser.ts b/packages/reflection/src/parser/Parser.ts index e0a5fc90..3f9a7ba1 100644 --- a/packages/reflection/src/parser/Parser.ts +++ b/packages/reflection/src/parser/Parser.ts @@ -89,7 +89,7 @@ export default class Parser throw new UnexpectedParseResult('an import definition'); } - return model as ReflectionImport; + return model; } parseExport(code: string): ReflectionExport @@ -101,7 +101,7 @@ export default class Parser throw new UnexpectedParseResult('an export definition'); } - return model as ReflectionExport; + return model; } parseDeclaration(code: string): ReflectionDeclaration @@ -113,7 +113,7 @@ export default class Parser throw new UnexpectedParseResult('a declaration definition'); } - return model as ReflectionDeclaration; + return model; } parseFunction(code: string): ReflectionFunction @@ -126,7 +126,7 @@ export default class Parser throw new UnexpectedParseResult('a function definition'); } - return model as ReflectionFunction; + return model; } parseClass(code: string): ReflectionClass @@ -139,7 +139,7 @@ export default class Parser throw new UnexpectedParseResult('a class definition'); } - return model as ReflectionClass; + return model; } #parseScope(tokenList: TokenList): ReflectionScope @@ -175,7 +175,7 @@ export default class Parser { const next = tokenList.next; - if (next !== undefined && next.hasValue(Operator.ARROW)) + if (next?.hasValue(Operator.ARROW)) { return this.#parseArrowFunction(tokenList, isAsync); } @@ -216,7 +216,7 @@ export default class Parser { const next = this.#peekAfterBlock(tokenList, Group.OPEN, Group.CLOSE); - if (next !== undefined && next.hasValue(Operator.ARROW)) + if (next?.hasValue(Operator.ARROW)) { return this.#parseArrowFunction(tokenList, isAsync); } @@ -393,7 +393,7 @@ export default class Parser token = tokenList.step(); // Read away the name - if (token !== undefined && token.hasValue(Keyword.FROM)) + if (token?.hasValue(Keyword.FROM)) { token = tokenList.step(); // Read away the FROM keyword @@ -419,7 +419,7 @@ export default class Parser let from: string | undefined = undefined; let token = tokenList.current; - if (token !== undefined && token.hasValue(Keyword.FROM)) + if (token?.hasValue(Keyword.FROM)) { token = tokenList.step(); // Read away the FROM keyword from = token.value; diff --git a/packages/serialization/src/serializers/ClassSerializer.ts b/packages/serialization/src/serializers/ClassSerializer.ts index bbc5aff1..2e94cb41 100644 --- a/packages/serialization/src/serializers/ClassSerializer.ts +++ b/packages/serialization/src/serializers/ClassSerializer.ts @@ -6,7 +6,6 @@ import ClassNotFound from '../errors/ClassNotFound.js'; import InvalidClass from '../errors/InvalidClass.js'; import ClassLoader from '../interfaces/ClassLoader.js'; import Loadable from '../types/Loadable.js'; -import FlexObject from '../types/serialized/SerializableObject.js'; import SerializableObject from '../types/serialized/SerializableObject.js'; import SerializedClass from '../types/serialized/SerializedClass.js'; @@ -50,8 +49,8 @@ export default class ClassSerializer extends ValueSerializer const name = clazz.name; const source = (clazz as Loadable).source; - const args: FlexObject = await this.#serializeConstructor(model, parameterNames, object); - const fields: FlexObject = await this.#serializeFields(model, parameterNames, object); + const args: SerializableObject = await this.#serializeConstructor(model, parameterNames, object); + const fields: SerializableObject = await this.#serializeFields(model, parameterNames, object); return { serialized: true, name: name, source: source, args: args, fields: fields }; } @@ -64,16 +63,16 @@ export default class ClassSerializer extends ValueSerializer return parameters.map(parameter => parameter.name); } - async #serializeConstructor(model: ReflectionClass, includeNames: string[], object: object): Promise + async #serializeConstructor(model: ReflectionClass, includeNames: string[], object: object): Promise { - const args: FlexObject = {}; + const args: SerializableObject = {}; for (const name of includeNames) { // Constructor parameters that can't be read make it impossible to fully reconstruct the object. const objectValue = model.canRead(name) - ? await this.serializeOther((object as FlexObject)[name]) + ? await this.serializeOther((object as SerializableObject)[name]) : undefined; args[name] = objectValue; @@ -82,9 +81,9 @@ export default class ClassSerializer extends ValueSerializer return args; } - async #serializeFields(model: ReflectionClass, excludeNames: string[], object: object): Promise + async #serializeFields(model: ReflectionClass, excludeNames: string[], object: object): Promise { - const fields: FlexObject = {}; + const fields: SerializableObject = {}; for (const property of model.writable) { @@ -97,7 +96,7 @@ export default class ClassSerializer extends ValueSerializer continue; } - fields[name] = await this.serializeOther((object as FlexObject)[name]); + fields[name] = await this.serializeOther((object as SerializableObject)[name]); } return fields; @@ -130,7 +129,7 @@ export default class ClassSerializer extends ValueSerializer return instance; } - async #deserializeConstructor(clazz: Function, args: FlexObject): Promise + async #deserializeConstructor(clazz: Function, args: SerializableObject): Promise { const model = reflector.fromClass(clazz, true); const constructor = model.getFunction('constructor'); @@ -150,7 +149,7 @@ export default class ClassSerializer extends ValueSerializer { if (loadable.source === undefined) { - return (globalThis as FlexObject)[loadable.name]; + return (globalThis as SerializableObject)[loadable.name]; } return this.#classLoader.loadClass(loadable); diff --git a/packages/serialization/src/serializers/ErrorSerializer.ts b/packages/serialization/src/serializers/ErrorSerializer.ts index 640d1ece..dd18ae09 100644 --- a/packages/serialization/src/serializers/ErrorSerializer.ts +++ b/packages/serialization/src/serializers/ErrorSerializer.ts @@ -14,7 +14,7 @@ export default class ErrorSerializer extends ValueSerializer return false; } - const error = value as Object; + const error = value; return error.constructor === Error || error.constructor === EvalError @@ -52,7 +52,7 @@ export default class ErrorSerializer extends ValueSerializer { const clazz = (globalThis as Record)[object.type] as (new () => Error); - const error = new clazz() as Error; + const error = new clazz(); error.stack = object.stack; error.message = object.message; error.cause = object.cause; diff --git a/packages/server-nodejs/src/configuration/StandaloneConfiguration.ts b/packages/server-nodejs/src/configuration/StandaloneConfiguration.ts index b8f9c41f..916e72e9 100644 --- a/packages/server-nodejs/src/configuration/StandaloneConfiguration.ts +++ b/packages/server-nodejs/src/configuration/StandaloneConfiguration.ts @@ -2,7 +2,6 @@ import { z } from 'zod'; import ProcedureRuntimeConfiguration from './ProcedureRuntimeConfiguration'; -import { override } from 'prompts'; export const standaloneSchema = z .object({ diff --git a/packages/server-nodejs/src/controllers/RPCController.ts b/packages/server-nodejs/src/controllers/RPCController.ts index 7e49261e..352e551e 100644 --- a/packages/server-nodejs/src/controllers/RPCController.ts +++ b/packages/server-nodejs/src/controllers/RPCController.ts @@ -311,7 +311,7 @@ export default class RPCController return 500; } - const errorClass = (error as Object).constructor as Function; + const errorClass = error.constructor; if (this.#isClassType(errorClass, BAD_REQUEST_NAME)) return 400; if (this.#isClassType(errorClass, UNAUTHORIZED_NAME)) return 401; diff --git a/packages/server-nodejs/src/errors/ConversionError.ts b/packages/server-nodejs/src/errors/ConversionError.ts index 2efa6025..667dd8b7 100644 --- a/packages/server-nodejs/src/errors/ConversionError.ts +++ b/packages/server-nodejs/src/errors/ConversionError.ts @@ -1,8 +1,5 @@ export default class ConversionError extends Error { - constructor(message: string) - { - super(message); - } + } diff --git a/packages/server-nodejs/src/utils/RuntimeConfigurator.ts b/packages/server-nodejs/src/utils/RuntimeConfigurator.ts index c94ce72c..f8f2fdc2 100644 --- a/packages/server-nodejs/src/utils/RuntimeConfigurator.ts +++ b/packages/server-nodejs/src/utils/RuntimeConfigurator.ts @@ -42,9 +42,7 @@ export default class RuntimeConfigurator await this.#buildCache(sourceLocation, cacheLocation); - const segmentNames = configuration.segments === undefined - ? await this.#getWorkerSegmentNames(fileManager) - : configuration.segments; + const segmentNames = configuration.segments ?? await this.#getWorkerSegmentNames(fileManager); const assets = configuration.assets !== undefined ? await fileManager.getAssetFiles(configuration.assets)