Migrating exteions to Gnome45 in TypeScript


I was looking at extension gTile (GitHub - gTile/gTile: A window tiling extension for Gnome. This is the new official home of the vibou.gTile extension.).

The extension uses TypeScript, and moving to the ESM styled imports breaks, as TypeScript is not able to resolve GJS imports, e.g.
import {Extension, gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js';

This can be somewhat circumvented by omitting the imports from TS-checks with
// @ts-ignore
but for any code, that extends an imported class, e.g. the Extension in the previous example, this is a problem, as TS can’t find that class.

I did stumble upon an older TS conversation, but this does not take fully Gnome45 restrictions into account AFAIK.

@mmstick Have you had any luck with Gnome45 TS support?

1 Like

add this to any file with.d.ts extension.

declare module 'resource://*';

You can also map module URLs to declaration files, which I find simpler than ambient modules.

See https://github.com/swsnr/gnome-shell-extension-typescript-template/blob/bb8a11ed161dad67efdfbf99851b4b74cf09a117/tsconfig.json#L8 for an example.

You can also use GitHub - gjsify/ts-for-gir: TypeScript type definition generator for GObject introspection interfaces to automatically generate types for all introspected libraries.

Had the same issue, I had fat-fingered the bodge wiring in ts-config.

After updating TS to ~5.2, running gir to gen the types and adding them to the path spec, my include for TS files wasn’t picking up files.

Expanded the glob and everything was fine.

// before 
  "include": [
// after
  "include": [


This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.