Address PR comments

This commit is contained in:
Filip Sodić 2024-12-20 11:00:37 +01:00
parent e8badd27b3
commit ae52cd259c
4 changed files with 14 additions and 13 deletions

View File

@ -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:

View File

@ -92,7 +92,7 @@ function makeDeclsArray(decls: {
return Object.values(decls).flatMap((decl) => [...decl])
}
function mapToDecls<T, const DeclType extends AppSpec.Decl['declType']>(
function mapToDecls<T, DeclType extends AppSpec.Decl['declType']>(
configs: Map<string, T>,
type: DeclType,
configToDeclValue: (

View File

@ -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

View File

@ -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