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/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..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({
@@ -45,8 +48,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/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
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"
]
}
diff --git a/src/langs/typescript/types/ambient.d.ts b/src/langs/typescript/types/ambient.d.ts
index e1d519f27..8384d888f 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
+import Adw from "gi://Adw";
+import Gtk from "gi://Gtk?version=4.0";
+import GObject from "gi://GObject";
-// 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;
-};
-
-// 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;