From 36aff2c1ee9cf9d02087bbf42632a077556c1ca6 Mon Sep 17 00:00:00 2001 From: Angelo Verlain Date: Sat, 22 Mar 2025 13:07:25 +0000 Subject: [PATCH 1/5] chore: upgrade gi-types --- .gitmodules | 4 ++-- gi-types | 1 - src/langs/typescript/template/gi-types | 1 + 3 files changed, 3 insertions(+), 3 deletions(-) delete mode 160000 gi-types create mode 160000 src/langs/typescript/template/gi-types diff --git a/.gitmodules b/.gitmodules index 02339e69e..a9a93d042 100644 --- a/.gitmodules +++ b/.gitmodules @@ -8,6 +8,6 @@ path = blueprint-compiler url = https://gitlab.gnome.org/jwestman/blueprint-compiler.git [submodule "src/langs/typescript/template/gi-types"] - path = gi-types + path = src/langs/typescript/template/gi-types url = https://gitlab.gnome.org/BrainBlasted/gi-typescript-definitions.git - branch = nightly + branch = main diff --git a/gi-types b/gi-types deleted file mode 160000 index 396fe1471..000000000 --- a/gi-types +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 396fe147142e28a921f0745eff1a562c7a551843 diff --git a/src/langs/typescript/template/gi-types b/src/langs/typescript/template/gi-types new file mode 160000 index 000000000..e70b4992a --- /dev/null +++ b/src/langs/typescript/template/gi-types @@ -0,0 +1 @@ +Subproject commit e70b4992aa71f5298c4a98f0e9e42b7761601c5b From 4ef4e5793505c364d4d777714a4e0490ff570db3 Mon Sep 17 00:00:00 2001 From: Angelo Verlain Date: Sat, 22 Mar 2025 13:11:06 +0000 Subject: [PATCH 2/5] chore: fix template index path --- src/langs/typescript/template/tsconfig.json | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/langs/typescript/template/tsconfig.json b/src/langs/typescript/template/tsconfig.json index 2fc945907..0fbcd0817 100644 --- a/src/langs/typescript/template/tsconfig.json +++ b/src/langs/typescript/template/tsconfig.json @@ -8,13 +8,16 @@ "outDir": "compiled_javascript", "baseUrl": ".", "paths": { - "*": ["*", "@pkgdatadir@/langs/typescript/gi-types/*"] + "*": [ + "*", + "@pkgdatadir@/langs/typescript/gi-types/*" + ] }, "skipLibCheck": true }, "include": [ "main.ts", "@pkgdatadir@/langs/typescript/types/ambient.d.ts", - "@pkgdatadir@/langs/typescript/gi-types/gi.d.ts" + "@pkgdatadir@/langs/typescript/gi-types/index.d.ts" ] } From 3834927bd63b3e04cb502ea7ffed09eda9d8a47d Mon Sep 17 00:00:00 2001 From: Angelo Verlain Date: Sat, 22 Mar 2025 13:11:36 +0000 Subject: [PATCH 3/5] chore: add the correct types to workbench global ambient --- src/langs/typescript/types/ambient.d.ts | 59 ++++++------------------- 1 file changed, 13 insertions(+), 46 deletions(-) diff --git a/src/langs/typescript/types/ambient.d.ts b/src/langs/typescript/types/ambient.d.ts index e1d519f27..dc229fa8d 100644 --- a/src/langs/typescript/types/ambient.d.ts +++ b/src/langs/typescript/types/ambient.d.ts @@ -1,50 +1,17 @@ -// import Adw from "gi://Adw"; -// import Gtk from "gi://Gtk?version=4.0"; -// import GObject from "gi://GObject"; - -// additional type declarations for GJS +/// -// additional GJS log utils -declare function print(...args: any[]): void; -declare function log(...args: any[]): void; - -// GJS pkg global -declare const pkg: { - version: string; - name: string; -}; +import Adw from "gi://Adw"; +import Gtk from "gi://Gtk?version=4.0"; +// import GObject from "gi://GObject"; -// old GJS global imports -// used like: imports.format.printf("..."); -declare module imports { - // format import - const format: { - format(this: String, ...args: any[]): string; - printf(fmt: string, ...args: any[]): string; - vprintf(fmt: string, args: any[]): string; +declare global { + const workbench: { + window: Adw.ApplicationWindow; + application: Adw.Application; + builder: Gtk.Builder; + template: string; + resolve(path: string): string; + preview(object: Gtk.Widget): void; + // build(params: Record): void; }; } - -// gettext import -declare module "gettext" { - export function gettext(id: string): string; - export function ngettext( - singular: string, - plural: string, - n: number, - ): string; -} - -// TODO: uncomment correct typings after we switch to `ts-for-gir` -// declare const workbench: { -// window: Adw.ApplicationWindow; -// application: Adw.Application; -// builder: Gtk.Builder; -// template: string; -// resolve(path: string): string; -// preview(object: Gtk.Widget): void; -// build(params: Record): void; -// }; - -// global workbench object -declare const workbench: any; From 98b5e759986f53c0e04367fae2c48870520f02ce Mon Sep 17 00:00:00 2001 From: Sonny Piers Date: Fri, 18 Apr 2025 14:38:16 +0200 Subject: [PATCH 4/5] cli: Do not attempt to run TypeScript files --- src/cli/javascript.js | 6 +++--- src/cli/typescript.js | 5 +++-- src/cli/vala.js | 2 +- src/langs/typescript/types/ambient.d.ts | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/cli/javascript.js b/src/cli/javascript.js index 67e6cf84a..b24ffe62a 100644 --- a/src/cli/javascript.js +++ b/src/cli/javascript.js @@ -20,9 +20,9 @@ export default async function javascript({ const text = await diagnose({ file, lspc, languageId }); await checkFile({ - lspc: lspc, - file: file, - lang: getLanguage("javascript"), + lspc, + file, + lang: getLanguage(languageId), uri: file.get_uri(), }); diff --git a/src/cli/typescript.js b/src/cli/typescript.js index 46ee5489a..4d27ffe9d 100644 --- a/src/cli/typescript.js +++ b/src/cli/typescript.js @@ -45,8 +45,9 @@ export default async function typescript({ preview() {}, }; - await import(`file://${file.get_path()}`); - print(" ✅ runs"); + // TODO: Support running TypeScript files by compiling them first + // await import(`file://${file.get_path()}`); + // print(" ✅ runs"); await lspc._notify("textDocument/didClose", { textDocument: { diff --git a/src/cli/vala.js b/src/cli/vala.js index f5bbefb1d..f52f0c85b 100644 --- a/src/cli/vala.js +++ b/src/cli/vala.js @@ -50,7 +50,7 @@ export default async function vala({ file, lspc, demo_dir }) { await checkFile({ lspc, file, - lang: getLanguage("vala"), + lang: getLanguage(languageId), uri: file.get_uri(), }); diff --git a/src/langs/typescript/types/ambient.d.ts b/src/langs/typescript/types/ambient.d.ts index dc229fa8d..8384d888f 100644 --- a/src/langs/typescript/types/ambient.d.ts +++ b/src/langs/typescript/types/ambient.d.ts @@ -2,7 +2,7 @@ import Adw from "gi://Adw"; import Gtk from "gi://Gtk?version=4.0"; -// import GObject from "gi://GObject"; +import GObject from "gi://GObject"; declare global { const workbench: { @@ -12,6 +12,6 @@ declare global { template: string; resolve(path: string): string; preview(object: Gtk.Widget): void; - // build(params: Record): void; + build(params: Record): void; }; } From 4562b8d7cfcc54e77bd72c0d4bf5beea36692b0a Mon Sep 17 00:00:00 2001 From: Sonny Piers Date: Fri, 18 Apr 2025 14:49:40 +0200 Subject: [PATCH 5/5] f --- src/cli/typescript.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cli/typescript.js b/src/cli/typescript.js index 4d27ffe9d..929ab34c9 100644 --- a/src/cli/typescript.js +++ b/src/cli/typescript.js @@ -1,6 +1,7 @@ /* eslint-disable no-restricted-globals */ import { getLanguage } from "../common.js"; +import { setupTypeScriptProject } from "../langs/typescript/typescript.js"; import { checkFile, getCodeObjectIds, diagnose, Interrupt } from "./util.js"; const languageId = "typescript"; @@ -17,6 +18,8 @@ export default async function typescript({ }) { print(` ${file.get_path()}`); + await setupTypeScriptProject(file.get_parent(), { lspc }); + const text = await diagnose({ file, lspc, languageId }); await checkFile({