Skip to content

Commit 2b13cf3

Browse files
vixaliensonnyp
andauthored
Add typechecking for TypeScript (#946)
Co-authored-by: Sonny <sonny@fastmail.net>
1 parent afea0a5 commit 2b13cf3

File tree

17 files changed

+69
-75
lines changed

17 files changed

+69
-75
lines changed

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@
77
[submodule "blueprint-compiler"]
88
path = blueprint-compiler
99
url = https://gitlab.gnome.org/jwestman/blueprint-compiler.git
10+
[submodule "src/langs/typescript/template/gi-types"]
11+
path = src/langs/typescript/gi-types
12+
url = https://gitlab.gnome.org/BrainBlasted/gi-typescript-definitions.git
13+
branch = nightly

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ unit:
6161
test: unit lint
6262
./build-aux/fun workbench-cli ci demos/src/Welcome
6363

64-
ci: setup test
64+
ci: setup build test
6565
./build-aux/fun workbench-cli ci demos/src/*
6666

6767
# Note that if you have Sdk extensions installed they will be used

src/PanelCode.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export default function PanelCode({
99
builder,
1010
previewer,
1111
session: { settings, file },
12+
langs,
1213
}) {
1314
const panel_code = builder.get_object("panel_code");
1415
const button_code = builder.get_object("button_code");
@@ -59,7 +60,9 @@ export default function PanelCode({
5960
}
6061

6162
if (panel.language.toLowerCase() === "typescript") {
62-
setupTypeScriptProject(file).catch(console.error);
63+
setupTypeScriptProject(file, langs.typescript.document).catch(
64+
console.error,
65+
);
6366
}
6467
}
6568
switchLanguage();

src/common.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,7 @@ export const languages = [
128128
document: null,
129129
default_file: "main.ts",
130130
index: 4,
131-
language_server: [
132-
"biome",
133-
"lsp-proxy",
134-
// src/meson.build installs biome.json there
135-
GLib.getenv("FLATPAK_ID")
136-
? `--config-path=${pkg.pkgdatadir}`
137-
: `--config-path=src/langs/typescript`,
138-
],
131+
language_server: ["typescript-language-server", "--stdio"],
139132
formatting_options: {
140133
...formatting_options,
141134
tabSize: 2,

src/langs/typescript/TypeScriptDocument.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export class TypeScriptDocument extends Document {
88
super(...args);
99

1010
this.lspc = setup({ document: this });
11+
this.code_view.lspc = this.lspc;
1112
}
1213

1314
async format() {
@@ -25,10 +26,6 @@ export class TypeScriptDocument extends Document {
2526
},
2627
});
2728

28-
// Biome doesn't support diff - it just returns one edit
29-
// we don't want to loose the cursor position so we use this
30-
const state = this.code_view.saveState();
3129
applyTextEdits(text_edits, this.buffer);
32-
await this.code_view.restoreState(state);
3330
}
3431
}

src/langs/typescript/biome.json

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/langs/typescript/gi-types

Submodule gi-types added at 396fe14

src/langs/typescript/meson.build

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
configure_file(
2+
input: 'template/tsconfig.json',
3+
output: 'tsconfig.json',
4+
install_dir: join_paths(pkgdatadir, 'langs/typescript/template/'),
5+
configuration: bin_conf,
6+
)
7+
8+
install_data(
9+
['types/ambient.d.ts'],
10+
install_dir: join_paths(pkgdatadir, 'langs/typescript'),
11+
preserve_path: true,
12+
)
13+
14+
install_subdir('gi-types', install_dir: join_paths(pkgdatadir, 'langs/typescript'))

src/langs/typescript/template/meson.build

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/langs/typescript/template/tsconfig.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,15 @@
66
// currently supported by the latest GJS
77
"target": "ESNext",
88
"outDir": "compiled_javascript",
9+
"baseUrl": ".",
910
"paths": {
10-
"gi://*": ["./types/gi-module.d.ts"]
11-
}
11+
"*": ["*", "@pkgdatadir@/langs/typescript/gi-types/*"]
12+
},
13+
"skipLibCheck": true
1214
},
13-
"include": ["main.ts", "types/ambient.d.ts", "types/gi-module.d.ts"]
15+
"include": [
16+
"main.ts",
17+
"@pkgdatadir@/langs/typescript/types/ambient.d.ts",
18+
"@pkgdatadir@/langs/typescript/gi-types/gi.d.ts"
19+
]
1420
}

0 commit comments

Comments
 (0)