@@ -67,10 +67,13 @@ const compilerOpts = {};
6767const env = createVirtualTypeScriptEnvironment (system , [], ts , compilerOpts );
6868```
6969
70- 2 . Install the sync extension:
70+ 2 . Install the facet and the sync extension:
7171
72- This extension powers the rest: when you make changes in your
73- editor, this mirrors them to the TypeScript environment using
72+ The facet configures the rest of the extensions
73+ with the right path and environment.
74+
75+ When you make changes in your
76+ editor, the sync extension mirrors them to the TypeScript environment using
7477` createFile ` and ` updateFile ` in the TypeScript compiler.
7578
7679_ Note, also, that we're supplying a path._ These extensions
@@ -81,7 +84,7 @@ as well as the `env` parameter which should be your TypeScript
8184environment.
8285
8386``` ts
84- import { tsSync } from " @valtown/codemirror-ts" ;
87+ import { tsSync , tsFacet } from " @valtown/codemirror-ts" ;
8588
8689let env = " index.ts" ;
8790
@@ -92,7 +95,8 @@ let editor = new EditorView({
9295 typescript: true ,
9396 jsx: true ,
9497 }),
95- tsSync ({ env , path }),
98+ tsFacet .of ({ env , path }),
99+ tsSync (),
96100 ],
97101 parent: document .querySelector (" #editor" ),
98102});
@@ -105,7 +109,7 @@ like this and added to the `extensions` array in the setup
105109of your CodeMirror instance.
106110
107111``` ts
108- tsLinter ({ env , path } );
112+ tsLinter ();
109113```
110114
111115This uses the [ @codemirror/lint ] ( https://codemirror.net/docs/ref/#lint )
@@ -122,7 +126,7 @@ sources, we expose a [`CompletionSource`](https://codemirror.net/docs/ref/#autoc
122126
123127``` ts
124128autocompletion ({
125- override: [tsAutocomplete ({ env , path } )],
129+ override: [tsAutocomplete ()],
126130});
127131```
128132
@@ -135,10 +139,7 @@ a `CompletionContext` parameter._
135139The hover definition can be used like the following:
136140
137141``` ts
138- tsHover ({
139- env ,
140- path ,
141- });
142+ tsHover ();
142143```
143144
144145Which automatically uses a default renderer. However, you can
@@ -147,8 +148,6 @@ to render custom UI if you want to, using the `renderTooltip` option.
147148
148149``` ts
149150tsHover ({
150- env ,
151- path ,
152151 renderTooltip : (info : HoverInfo ) => {
153152 const div = document .createElement (" div" );
154153 if (info .quickInfo ?.displayParts ) {
@@ -236,15 +235,13 @@ that accept the `worker` instead of `env` as an argument.
236235
237236``` ts
238237[
239- tsSyncWorker ({ worker , path }),
240- tsLinterWorker ({ worker , path }),
238+ tsFacetWorker .of ({ worker , path }),
239+ tsSyncWorker (),
240+ tsLinterWorker (),
241241 autocompletion ({
242- override: [tsAutocompleteWorker ({ worker , path })],
243- }),
244- tsHoverWorker ({
245- worker ,
246- path ,
242+ override: [tsAutocompleteWorker ()],
247243 }),
244+ tsHoverWorker (),
248245];
249246```
250247
0 commit comments