Skip to content

Fix TypeScript typechecking not working #1002

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion gi-types
Submodule gi-types deleted from 396fe1
1 change: 1 addition & 0 deletions src/langs/typescript/template/gi-types
Submodule gi-types added at e70b49
7 changes: 5 additions & 2 deletions src/langs/typescript/template/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
59 changes: 13 additions & 46 deletions src/langs/typescript/types/ambient.d.ts
Original file line number Diff line number Diff line change
@@ -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
/// <reference path="../template/gi-types/index.d.ts" />

// 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<string, Function | GObject.Object>): 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<string, Function | GObject.Object>): void;
// };

// global workbench object
declare const workbench: any;
Loading