Skip to content

Commit

Permalink
Remove support for tsconfig.alias.json
Browse files Browse the repository at this point in the history
  • Loading branch information
JumpLink committed Feb 28, 2024
1 parent e7a0691 commit 346b811
Show file tree
Hide file tree
Showing 34 changed files with 20 additions and 234 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@ jobs:
run: sudo apt-get --yes install build-essential gobject-introspection libgirepository1.0-dev libcairo2 libcairo2-dev
- run: yarn install
- run: yarn run build
- run: NODE_OPTIONS=--max_old_space_size=9216 yarn run build:types:local
- run: NODE_OPTIONS=--max_old_space_size=9216 yarn run validate:types:local
- run: NODE_OPTIONS=--max_old_space_size=9216 yarn run build:types:packages
- run: NODE_OPTIONS=--max_old_space_size=9216 yarn run validate:types:packages
6 changes: 0 additions & 6 deletions examples/gjs/gio-2-cat-alias/.ts-for-girrc.json

This file was deleted.

14 changes: 0 additions & 14 deletions examples/gjs/gio-2-cat-alias/esbuild.js

This file was deleted.

37 changes: 0 additions & 37 deletions examples/gjs/gio-2-cat-alias/main.ts

This file was deleted.

28 changes: 0 additions & 28 deletions examples/gjs/gio-2-cat-alias/package.json

This file was deleted.

19 changes: 0 additions & 19 deletions examples/gjs/gio-2-cat-alias/tsconfig.json

This file was deleted.

6 changes: 0 additions & 6 deletions examples/gjs/gio-2-cat-alias/tsconfig.types.json

This file was deleted.

1 change: 0 additions & 1 deletion examples/gjs/gio-2-cat-promisify/.ts-for-girrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
"modules": ["Gio-2.0"],
"noNamespace": false,
"outdir": "./@types",
"generateAlias": true,
"promisify": true
}
2 changes: 1 addition & 1 deletion examples/gjs/gio-2-dbus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build:types": "yarn ts-for-gir generate Gio-2.0 --generateAlias",
"build:types": "yarn ts-for-gir generate Gio-2.0",
"build:app": "yarn node esbuild.js",
"build": "yarn build:types && yarn build:app",
"start": "yarn build && yarn start:server",
Expand Down
1 change: 0 additions & 1 deletion examples/gjs/gio-2-dbus/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"extends": "./tsconfig.alias.json",
"compilerOptions": {
"lib": ["ESNext"],
"types": [],
Expand Down
2 changes: 1 addition & 1 deletion examples/gjs/gio-2-list-model/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build:types": "yarn ts-for-gir generate Gtk-4.0 --generateAlias",
"build:types": "yarn ts-for-gir generate Gtk-4.0",
"build:app": "yarn node esbuild.js",
"build": "yarn build:types && yarn build:app",
"start:app": "gjs -m dist/main.js",
Expand Down
2 changes: 1 addition & 1 deletion examples/gjs/glib-2-variant/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build:types": "yarn ts-for-gir generate GLib-2.0 Gio-2.0 --generateAlias",
"build:types": "yarn ts-for-gir generate GLib-2.0 Gio-2.0",
"build:app": "yarn node esbuild.js",
"build": "yarn build:types && yarn build:app",
"start:app": "gjs -m dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion examples/gjs/gtk-3-browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"watch": "yarn build:app --watch",
"build": "yarn build:types && yarn build:app",
"build:app": "yarn clear:ts && webpack --config webpack.config.cjs --env production",
"build:types": "yarn ts-for-gir generate Gtk-3.0 Pango-1.0 WebKit2-4.0 --generateAlias",
"build:types": "yarn ts-for-gir generate Gtk-3.0 Pango-1.0 WebKit2-4.0",
"clear:types": "rm -rf ./@types",
"clear:ts": "rm -rf ./dist",
"clear": "yarn clear:ts && yarn clear:types",
Expand Down
2 changes: 1 addition & 1 deletion examples/gjs/gtk-3-calc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build:types": "yarn ts-for-gir generate Gtk-3.0 --generateAlias",
"build:types": "yarn ts-for-gir generate Gtk-3.0",
"build:app": "yarn node esbuild.js",
"build": "yarn build:types && yarn build:app",
"start:app": "gjs -m dist/main.js",
Expand Down
2 changes: 1 addition & 1 deletion examples/gjs/gtk-3-gettext/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build:types": "yarn ts-for-gir generate Gtk-3.0 --generateAlias",
"build:types": "yarn ts-for-gir generate Gtk-3.0",
"build:app": "yarn node esbuild.js",
"build": "yarn build:types && yarn build:app",
"start:app": "gjs -m dist/main.js",
Expand Down
2 changes: 1 addition & 1 deletion examples/gjs/gtk-3-hello-2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build:types": "yarn ts-for-gir generate Gtk-3.0 --generateAlias",
"build:types": "yarn ts-for-gir generate Gtk-3.0",
"build:app": "yarn node esbuild.js",
"build": "yarn build:types && yarn build:app",
"start:app": "gjs -m dist/main.js",
Expand Down
2 changes: 1 addition & 1 deletion examples/gjs/gtk-3-template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build:types": "yarn ts-for-gir generate Gtk-3.0 --generateAlias",
"build:types": "yarn ts-for-gir generate Gtk-3.0",
"build:app": "yarn node esbuild.js",
"build": "yarn build:types && yarn build:app",
"start:app": "gjs -m dist/main.js",
Expand Down
2 changes: 1 addition & 1 deletion examples/gjs/gtk-3-webkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build:types": "yarn ts-for-gir generate WebKit2-4.0 --generateAlias",
"build:types": "yarn ts-for-gir generate WebKit2-4.0",
"build:app": "yarn node esbuild.js",
"build": "yarn build:types && yarn build:app",
"start:app": "gjs -m dist/main.js",
Expand Down
2 changes: 1 addition & 1 deletion examples/gjs/gtk-4-application/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build:types": "yarn ts-for-gir generate Gtk-4.0 --generateAlias",
"build:types": "yarn ts-for-gir generate Gtk-4.0",
"build:app": "yarn node esbuild.js",
"build": "yarn build:types && yarn build:app",
"start:app": "gjs -m dist/main.js",
Expand Down
2 changes: 1 addition & 1 deletion examples/gjs/gtk-4-custom-widget/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build:types": "yarn ts-for-gir generate Gtk-4.0 Gdk-4.0 Graphene-1.0 --generateAlias",
"build:types": "yarn ts-for-gir generate Gtk-4.0 Gdk-4.0 Graphene-1.0",
"build:app": "yarn node esbuild.js",
"build": "yarn build:types && yarn build:app",
"start:app": "gjs -m dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion examples/gjs/gtk-4-list-store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build:types": "yarn ts-for-gir generate Gtk-4.0 --generateAlias",
"build:types": "yarn ts-for-gir generate Gtk-4.0",
"build:app": "yarn node esbuild.js",
"build": "yarn build:types && yarn build:app",
"start:app": "gjs -m dist/main.js",
Expand Down
2 changes: 1 addition & 1 deletion examples/gjs/gtk-4-template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build:types": "yarn ts-for-gir generate Gtk-4.0 --generateAlias",
"build:types": "yarn ts-for-gir generate Gtk-4.0",
"build:app": "yarn node esbuild.js",
"build": "yarn build:types && yarn build:app",
"start:app": "gjs -m dist/main.js",
Expand Down
2 changes: 1 addition & 1 deletion examples/gjs/soup-3-http/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build:types": "yarn ts-for-gir generate Soup-3.0 --generateAlias",
"build:types": "yarn ts-for-gir generate Soup-3.0",
"build:app": "yarn node esbuild.js",
"build": "yarn build:types && yarn build:app",
"start:server": "gjs -m dist/http-server.js",
Expand Down
2 changes: 1 addition & 1 deletion examples/gjs/soup-3-websocket/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build:types": "yarn ts-for-gir generate Soup-3.0 --generateAlias",
"build:types": "yarn ts-for-gir generate Soup-3.0",
"build:client": "yarn node esbuild.js",
"build": "yarn build:types && yarn build:client",
"start:client": "gjs -m dist/main.js",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"validate": "yarn workspaces foreach -v --all --parallel run validate",
"validate:types": "yarn workspaces foreach -v --all --parallel run validate:types",
"validate:examples": "yarn workspaces foreach -v --all --parallel run validate:app",
"validate:types:local": "tsc --project tsconfig.json",
"validate:types:packages": "tsc --project tsconfig.json",
"clear": "yarn clear:build && yarn clear:types",
"clear:build": "yarn workspaces foreach -v --include '@ts-for-gir/*' run clear:build",
"clear:types": "rimraf ./@types",
Expand Down
51 changes: 1 addition & 50 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ Options:
[string] [default: false]
--fixConflicts Fix Inheritance and implementation type conflict
s [string] [default: true]
-a, --generateAlias Generate an alias tsconfig file to support GJS E
SM module imports [string] [default: false]
--promisify Generate promisified functions for async/finish
calls [string] [default: true]
--npmScope Scope of the generated NPM packages
Expand Down Expand Up @@ -277,7 +275,7 @@ Note that ignoring a module will prevent ts-for-gir from generating types for th
`ts-for-gir` supports two build types for generating the types: `"lib"` and `"types"`.
* If `"lib"` is specified, `.js` files are generated as well as `.d.ts`, this is useful for some bundlers that expect a `.js` file. Some bundlers are also able to generate the import of this file only once, even if it occurs multiple times in your code.
* If `"types"` is specified, only `.d.ts` files are generated. In this mode it is recommended to add the generated `"@types/gjs.d.ts"` and `"@types/ambient.d.ts"` under `"include"` in the `tsconfig` to make the generated types known in your project. If you have problems to use imports in `ESM` format, you can also enable the `generateAlias` option and extend your `tsconfig` from the generated `"tsconfig.alias.json"`.
* If `"types"` is specified, only `.d.ts` files are generated. In this mode it is recommended to add the generated `"@types/gjs.d.ts"` and `"@types/ambient.d.ts"` under `"include"` in the `tsconfig` to make the generated types known in your project.
### moduleType
The `moduleType` CLI option determines the format in which the generated JavaScript files should be exported. The option takes either `"esm"` or `"cjs"` as its value, with `"esm"` being the default.
Expand Down Expand Up @@ -389,50 +387,6 @@ The `fixConflicts` CLI option is used to resolve type conflicts between the GObj
> If you have found an issue with the `fixConflicts` CLI option, we encourage you to report it. Reporting issues helps improve the quality of `ts-for-gir` and makes it a better tool for everyone.
### generateAlias
The `generateAlias` CLI option, when active, generates an alias `tsconfig.alias.json` file to support ESM module imports in GJS. This is particularly useful if you want to import GIR modules in your GJS code using the `'gi://...'` syntax. The generated `tsconfig.alias.json` file will contain the necessary path aliases to enable TypeScript to properly resolve the imported modules, allowing for improved code editor functionality, such as type checking and code completion.
The generateAlias option is particularly useful for GJS applications, as it allows you to import GIR modules using the standard ESM syntax, rather than having to use the global imports object.
You can extend the generated `tsconfig.alias.json` file in your main tsconfig.json file by setting the extends field to `./tsconfig.alias.json`.
```json
// tsconfig.alias.json
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"gi://Gio?version=2.0": ["./@types/gio-2.0.d.ts"],
"gi://Gio": ["./@types/gio-2.0.d.ts"],
"gi://GObject?version=2.0": ["./@types/gobject-2.0.d.ts"],
"gi://GObject": ["./@types/gobject-2.0.d.ts"],
"gi://GLib?version=2.0": ["./@types/glib-2.0.d.ts"],
"gi://GLib": ["./@types/glib-2.0.d.ts"]
}
},
"include": ["./@types/*.ts"]
}
```
```json
// tsconfig.json
{
"extends": "./tsconfig.alias.json",
"compilerOptions": {
"lib": ["ESNext"],
"types": [],
"target": "ESNext",
"module": "ESNext"
},
"include": ["@types/gjs.d.ts"],
"files": [
"main.ts",
]
}
```
> The example in [examples/gjs/gio-2-cat-alias](https://github.com/gjsify/ts-for-gir/tree/main/examples/gjs/gio-2-cat-alias) demonstrates the usage of the generateAlias option. This example shows how to use the generated tsconfig.alias.json file in a GJS project and provides a clear understanding of how this option can be used in practice.
# package
The `--package` option of ts-for-gir is used to package the generated TypeScript type definitions into an NPM package. The generated package can be easily installed and used in other TypeScript projects via `npm install`.
Expand Down Expand Up @@ -486,9 +440,6 @@ Alternatively, you can also use the pre-generated NPM packages for this, so you
> The advantage of self-generated types is that you generate the types exactly for your locally installed library version. However, we try to keep the pre-generated NPM packages as up to date as possible.
### Alias
If for some reason you don't want to or can't generate NPM packages, you can instead use the [`--generateAlias`](#generatealias) CLI option. This way you can also use imports in the `gi://` syntax with the generated types.
To use ambient modules, the `ambient.d.ts` file must be imported either in the code like `import '@girs/gjs/ambient'` or by adding an entry to the `includes` property in the `tsconfig` file. The `ambient.d.ts` file is automatically generated.
```json
Expand Down
Loading

0 comments on commit 346b811

Please sign in to comment.