Skip to content

Commit 193b682

Browse files
Merge pull request #109 from Digital-Alchemy-TS/typeStability
Type stability
2 parents 77a465b + 87bd728 commit 193b682

4 files changed

Lines changed: 57 additions & 27 deletions

File tree

apps/client/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
},
1717
"dependencies": {
1818
"@code-glue/paradigm": "workspace:^",
19-
"@monaco-editor/react": "^4.7.0",
19+
"@monaco-editor/react": "4.7.0",
2020
"@tiltshift/valtio-factory": "2.0.3",
21-
"@typescript/ata": "^0.9.8",
22-
"monaco-editor": "^0.54.0",
21+
"@typescript/ata": "0.9.8",
22+
"monaco-editor": "0.55.1",
2323
"monaco-prettier": "^1.0.0",
2424
"nuqs": "^2.8.3",
2525
"prettier": "^3.7.4",

apps/client/src/components/Editor/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ export const Editor: React.FC = () => {
9696
automaticLayout: true,
9797
occurrencesHighlight: "off",
9898
scrollBeyondLastLine: false,
99+
quickSuggestions: {
100+
strings: true,
101+
},
102+
codeLens: false,
99103
},
100104

101105
...(path && { path }),

apps/client/src/components/Editor/init.ts

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import jsonWorker from "monaco-editor/esm/vs/language/json/json.worker?worker"
77
import tsWorker from "monaco-editor/esm/vs/language/typescript/ts.worker?worker"
88
import { configureMonacoPrettier } from "monaco-prettier"
99
import { createHighlighter } from "shiki"
10-
import ts from "typescript"
10+
import * as ts from "typescript"
1111
import { subscribe } from "valtio"
1212

1313
import { appConfig } from "@/config"
@@ -32,10 +32,10 @@ self.MonacoEnvironment = {
3232
}
3333

3434
// # Configure TypeScript compiler options
35-
monaco.languages.typescript.typescriptDefaults.setCompilerOptions({
36-
target: monaco.languages.typescript.ScriptTarget.Latest,
37-
moduleResolution: monaco.languages.typescript.ModuleResolutionKind.NodeJs,
38-
module: monaco.languages.typescript.ModuleKind.CommonJS,
35+
monaco.typescript.typescriptDefaults.setCompilerOptions({
36+
target: monaco.typescript.ScriptTarget.Latest,
37+
moduleResolution: monaco.typescript.ModuleResolutionKind.NodeJs,
38+
module: monaco.typescript.ModuleKind.CommonJS,
3939
moduleDetection: 3, // Allow automations to have the same var names without TS complaining. https://github.com/microsoft/monaco-editor/issues/2976
4040
allowNonTsExtensions: true,
4141
allowSyntheticDefaultImports: true,
@@ -85,7 +85,7 @@ const unsubscribe = subscribe(store.apiStatus, () => {
8585
const editorSupport = store.editorSupport
8686
const header = editorSupport.automationHeader
8787

88-
monaco.languages.typescript.typescriptDefaults.addExtraLib(
88+
monaco.typescript.typescriptDefaults.addExtraLib(
8989
`${header}`,
9090
"file:///globals.ts",
9191
)
@@ -116,10 +116,7 @@ const unsubscribe = subscribe(store.apiStatus, () => {
116116
break
117117
}
118118

119-
monaco.languages.typescript.typescriptDefaults.addExtraLib(
120-
code,
121-
filePath,
122-
)
119+
monaco.typescript.typescriptDefaults.addExtraLib(code, filePath)
123120
},
124121
},
125122
fetcher: async (url) => {
@@ -158,6 +155,23 @@ const unsubscribe = subscribe(store.apiStatus, () => {
158155
}
159156
})
160157

158+
// Prevent Monaco from auto-creating models when navigating to type definitions
159+
// This is a workaround for https://github.com/microsoft/monaco-editor/issues/2813
160+
const originalCreateModel = monaco.editor.createModel
161+
monaco.editor.createModel = function (value, language, uri, ...args) {
162+
// If Monaco tries to create a model for a file we've already added as extraLib, skip it
163+
if (uri?.path.includes("node_modules")) {
164+
/**
165+
* We return null here instead of an empty model because
166+
* this way monaco will remove the peak and goto definition links entirely.
167+
* If an empty model is provided, these links exist, but go to a blank file.
168+
*/
169+
// biome-ignore lint/suspicious/noExplicitAny: while types say you can't create a model this way, it works and provides the best possible UI.
170+
return null as any
171+
}
172+
return originalCreateModel.call(this, value, language, uri, ...args)
173+
}
174+
161175
// Load Monaco via the loader
162176
loader.config({ monaco })
163177
loader.init()

yarn.lock

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -582,15 +582,15 @@ __metadata:
582582
dependencies:
583583
"@biomejs/biome": "npm:2.3.5"
584584
"@code-glue/paradigm": "workspace:^"
585-
"@monaco-editor/react": "npm:^4.7.0"
585+
"@monaco-editor/react": "npm:4.7.0"
586586
"@shikijs/monaco": "npm:^3.19.0"
587587
"@tiltshift/valtio-factory": "npm:2.0.3"
588588
"@types/node": "npm:^22.10.2"
589589
"@types/react": "npm:^19.2.0"
590590
"@types/react-dom": "npm:^19.2.0"
591-
"@typescript/ata": "npm:^0.9.8"
591+
"@typescript/ata": "npm:0.9.8"
592592
"@vitejs/plugin-react": "npm:^5.0.4"
593-
monaco-editor: "npm:^0.54.0"
593+
monaco-editor: "npm:0.55.1"
594594
monaco-prettier: "npm:^1.0.0"
595595
nuqs: "npm:^2.8.3"
596596
prettier: "npm:^3.7.4"
@@ -2646,7 +2646,7 @@ __metadata:
26462646
languageName: node
26472647
linkType: hard
26482648

2649-
"@monaco-editor/react@npm:^4.7.0":
2649+
"@monaco-editor/react@npm:4.7.0":
26502650
version: 4.7.0
26512651
resolution: "@monaco-editor/react@npm:4.7.0"
26522652
dependencies:
@@ -5668,6 +5668,13 @@ __metadata:
56685668
languageName: node
56695669
linkType: hard
56705670

5671+
"@types/trusted-types@npm:^2.0.7":
5672+
version: 2.0.7
5673+
resolution: "@types/trusted-types@npm:2.0.7"
5674+
checksum: 10/8e4202766a65877efcf5d5a41b7dd458480b36195e580a3b1085ad21e948bc417d55d6f8af1fd2a7ad008015d4117d5fdfe432731157da3c68678487174e4ba3
5675+
languageName: node
5676+
linkType: hard
5677+
56715678
"@types/unist@npm:*, @types/unist@npm:^3.0.0":
56725679
version: 3.0.3
56735680
resolution: "@types/unist@npm:3.0.3"
@@ -5939,7 +5946,7 @@ __metadata:
59395946
languageName: node
59405947
linkType: hard
59415948

5942-
"@typescript/ata@npm:^0.9.8":
5949+
"@typescript/ata@npm:0.9.8":
59435950
version: 0.9.8
59445951
resolution: "@typescript/ata@npm:0.9.8"
59455952
peerDependencies:
@@ -7822,10 +7829,15 @@ __metadata:
78227829
languageName: node
78237830
linkType: hard
78247831

7825-
"dompurify@npm:3.1.7":
7826-
version: 3.1.7
7827-
resolution: "dompurify@npm:3.1.7"
7828-
checksum: 10/dc637a064306f83cf911caa267ffe1f973552047602020e3b6723c90f67962813edf8a65a0b62e8c9bc13fcd173a2691212a3719bc116226967f46bcd6181277
7832+
"dompurify@npm:3.2.7":
7833+
version: 3.2.7
7834+
resolution: "dompurify@npm:3.2.7"
7835+
dependencies:
7836+
"@types/trusted-types": "npm:^2.0.7"
7837+
dependenciesMeta:
7838+
"@types/trusted-types":
7839+
optional: true
7840+
checksum: 10/51b7866fb834ee62d6c415f41ece5ce11db7b463f60a822932a1f832573a40b98be7715550298690e7647988fbe086db1098bda9b10548b3166fc975eb9bd849
78297841
languageName: node
78307842
linkType: hard
78317843

@@ -11996,13 +12008,13 @@ __metadata:
1199612008
languageName: node
1199712009
linkType: hard
1199812010

11999-
"monaco-editor@npm:^0.54.0":
12000-
version: 0.54.0
12001-
resolution: "monaco-editor@npm:0.54.0"
12011+
"monaco-editor@npm:0.55.1":
12012+
version: 0.55.1
12013+
resolution: "monaco-editor@npm:0.55.1"
1200212014
dependencies:
12003-
dompurify: "npm:3.1.7"
12015+
dompurify: "npm:3.2.7"
1200412016
marked: "npm:14.0.0"
12005-
checksum: 10/654aa19e8ed859627f8c545026e41955fd015eeac4a26330a5176b955e0afbcd590bbfba06fa9f22fa1bc97d7a33100059e26c754f9541b64d753379a6396711
12017+
checksum: 10/73836b612a923342001b8cbb459aad0de486c94672fb7cf9d28bdafed9f3b7523d5aba510d9f8e7d24476a5aacf0d3a5c0cdc520ed4764f6f89f8cf5ba8d9329
1200612018
languageName: node
1200712019
linkType: hard
1200812020

0 commit comments

Comments
 (0)