Skip to content

Commit 1dede04

Browse files
Jakob Schlanstedtwerererer
authored andcommitted
docs(note_create): further clarify type system
1 parent 652dc1e commit 1dede04

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

apps/client/src/services/note_create.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,23 @@ import type { CKTextEditor } from "@triliumnext/ckeditor5";
1313
import dateNoteService from "../services/date_notes.js";
1414

1515
/**
16-
* Creating notes through note_create can have multiple kinds of valid
17-
* arguments. This type hierarchy is checking if the arguments are correct.
18-
* Later the functions of note_create are overloaded based to reflect these types,
19-
* which define valid arguments.
16+
* The `note_create` function can be called with multiple valid combinations
17+
* of arguments. This type hierarchy defines and enforces which combinations
18+
* are valid at compile time.
2019
*
21-
* Theoretically: If the typechecking returns no errors, then the inputs
22-
* create a valid state, given that the types are defined correctly.
23-
* Through the Curry–Howard correspondence, this acts as a proof system
24-
* proving that the arguments will produce a correct state at compile time.
25-
* That means when typescript does type-checks, then the arguments will
26-
* definitely represent a valid state.
20+
* The function overloads later in `note_create` correspond to these types,
21+
* ensuring that each variant of note creation accepts only the correct
22+
* set of arguments.
2723
*
28-
* To represent the theoretical bases `type` is used instead of `interface`
24+
* Theoretically: If type checking produces no errors, then the provided
25+
* arguments represent a valid state — assuming the types below are defined
26+
* correctly. Through the Curry–Howard correspondence, this type system
27+
* effectively acts as a proof system: a successful type check serves as a
28+
* compile-time proof that the arguments of `create_note` can only produce
29+
* a valid state.
30+
*
31+
* To align with its theoretical foundation in type theory (via the
32+
* Curry–Howard correspondence), `type` is used instead of `interface`
2933
*
3034
* * Hierarchy of general to specific categories(hypernyms -> hyponyms):
3135
*
@@ -44,7 +48,7 @@ import dateNoteService from "../services/date_notes.js";
4448

4549
/**
4650
* this is the shared basis for all types. Every other type is child (hyponym)
47-
* of it (domain hypernym).
51+
* of it (Its the domain hypernym).
4852
*/
4953
type CreateNoteEntity = {
5054
target: CreateNoteTarget;

0 commit comments

Comments
 (0)