From ae52cd259c128b60ec59a52fc7313a603753915e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Sodi=C4=87?= Date: Fri, 20 Dec 2024 11:00:37 +0100 Subject: [PATCH] Address PR comments --- waspc/packages/wasp-config/src/appSpec.ts | 9 +++++---- .../wasp-config/src/mapUserSpecToAppSpecDecls.ts | 2 +- waspc/packages/wasp-config/src/userApi.ts | 14 +++++++------- waspc/tools/install_packages_to_data_dir.sh | 2 +- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/waspc/packages/wasp-config/src/appSpec.ts b/waspc/packages/wasp-config/src/appSpec.ts index 2006040b4..374211951 100644 --- a/waspc/packages/wasp-config/src/appSpec.ts +++ b/waspc/packages/wasp-config/src/appSpec.ts @@ -221,11 +221,12 @@ export type WebSocket = { } /** - * We want to explicitly set all optional (Maybe) AppSpec fields to `undefined` - * (instead of using an optional field with a questionmark). + * We use this type for fields that are optional (Maybe) in AppSpec. + * We do this instead of `someField?:` because we want TypeScript to force us + * to explicitly set the field to `undefined`. * - * Doing so doesn't change any functionality and ensures (at compile-time) we - * don't forget to include an existing optional field in a declaration object. + * This way, if the AppSpec changes on the Haskell side, we won't forget to + * implement a proper mapping in TypeScript. * * For example, let's say `bar` is optional (both for the user and for the app * spec). This would be the correct mapping code: diff --git a/waspc/packages/wasp-config/src/mapUserSpecToAppSpecDecls.ts b/waspc/packages/wasp-config/src/mapUserSpecToAppSpecDecls.ts index 7ca8cd527..f61153115 100644 --- a/waspc/packages/wasp-config/src/mapUserSpecToAppSpecDecls.ts +++ b/waspc/packages/wasp-config/src/mapUserSpecToAppSpecDecls.ts @@ -92,7 +92,7 @@ function makeDeclsArray(decls: { return Object.values(decls).flatMap((decl) => [...decl]) } -function mapToDecls( +function mapToDecls( configs: Map, type: DeclType, configToDeclValue: ( diff --git a/waspc/packages/wasp-config/src/userApi.ts b/waspc/packages/wasp-config/src/userApi.ts index 903cfa144..02291b58e 100644 --- a/waspc/packages/wasp-config/src/userApi.ts +++ b/waspc/packages/wasp-config/src/userApi.ts @@ -6,7 +6,7 @@ import { GET_USER_SPEC } from './_private.js' export class App { #userSpec: UserSpec; - // NOTE: Using a non-public symbol gives us a pacakge-private property. + // NOTE: Using a non-public symbol gives us a package-private property. // It's not that important to hide it from the users, but we still don't want // user's IDE to suggest it during autocompletion. [GET_USER_SPEC]() { @@ -100,13 +100,13 @@ export type AppConfig = { export type ExtImport = | { - import: string - from: AppSpec.ExtImport['path'] - } + import: string + from: AppSpec.ExtImport['path'] + } | { - importDefault: string - from: AppSpec.ExtImport['path'] - } + importDefault: string + from: AppSpec.ExtImport['path'] + } export type ServerConfig = { setupFn?: ExtImport diff --git a/waspc/tools/install_packages_to_data_dir.sh b/waspc/tools/install_packages_to_data_dir.sh index 3f5bc2daa..ce5894a99 100755 --- a/waspc/tools/install_packages_to_data_dir.sh +++ b/waspc/tools/install_packages_to_data_dir.sh @@ -11,7 +11,7 @@ for package in $(ls "$dir/../packages"); do if [[ -d "$package_dir" ]]; then # We're only installing the dependencines here to verify that the build # works, that's why the node_modules folder is removed immediately after. - # The real dependency installatino happens in Haskell. + # The real dependency installation happens in Haskell. echo "Installing $package ($package_dir)" cd "$package_dir" npm install