Here is how you generate TypeScript declaration files for the various platform GIRs (Gtk4, Adw, GObject, etc..) and other dependencies used by Workbench (Libportal/Xdp, Jsonrpc, Shumate, Vte, etc..).
Due to current limitations (workbenchdev/Workbench#980), you cannot directly generate the types from within Workbench's sandbox automatically.
First enter the Build Terminal. On VSCode you can easily do this by pressing
Ctrl+P
then selecting Flatpak: Enter Build Terminal
.
You can also enter Workbench Terminal using the following command:
flatpak run --command=bash --filesystem=$(pwd) re.sonny.Workbench.Devel
Then you can copy all the GIRs build from Workbench
mkdir -p workbench-girs
cp /app/share/gir-1.0/* workbench-girs
FLATPAK_ENABLE_SDK_EXT=node20,typescript flatpak run --share=network --command=bash --filesystem=$(pwd) org.gnome.Sdk//master
# Enable the node20 and typescript SDK extensions
source /usr/lib/sdk/node20/enable.sh
export PATH=/usr/lib/sdk/typescript/bin:$PATH
YARN_GLOBAL_DIR=/tmp/yarn-global
export PATH="$YARN_GLOBAL_DIR/node_modules/.bin:$PATH"
yarn --global-folder $YARN_GLOBAL_DIR global add @ts-for-gir/cli@4.0.0-beta.16
ts-for-gir generate -g workbench-girs/ -g /usr/share/gir-1.0/ -o workbench-types/ --ignoreVersionConflicts