Skip to content

Commit 8c82b34

Browse files
authored
👮 Type check and type alignment (#2561)
1 parent 27ca6ef commit 8c82b34

File tree

7 files changed

+25
-17
lines changed

7 files changed

+25
-17
lines changed

.changeset/shaggy-zebras-repair.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'myst-cli': patch
3+
---
4+
5+
Update `ws` version in package to match actual and align types.

.changeset/wild-rice-pump.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'myst-to-docx': patch
3+
---
4+
5+
Removing `@ts-expect` rules in favour of typed checks

package-lock.json

Lines changed: 9 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/myst-cli/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
"uuid": "^8.3.2",
110110
"vfile": "^5.3.5",
111111
"which": "^3.0.1",
112-
"ws": "^8.9.0",
112+
"ws": "^8.18.1",
113113
"xml-js": "^1.6.11",
114114
"zod": "^3.23.8"
115115
},
@@ -124,7 +124,7 @@
124124
"@types/picomatch": "^4.0.2",
125125
"@types/uuid": "^8.3.4",
126126
"@types/which": "^3.0.0",
127-
"@types/ws": "^8.5.5",
127+
"@types/ws": "^8.18.1",
128128
"concurrently": "^8.2.0"
129129
}
130130
}

packages/myst-cli/src/build/site/start.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export async function startContentServer(session: ISession, opts?: ServerOptions
6363
noServer: true,
6464
path: '/socket',
6565
});
66-
const connections: Record<string, WebSocket.WebSocket> = {};
66+
const connections: Record<string, WebSocket> = {};
6767

6868
wss.on('connection', function connection(ws) {
6969
const id = nanoid();

packages/myst-to-docx/src/plugin.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ export const plugin: Plugin<[Options], Root, VFile> = function (opts) {
1111
const state = new DocxSerializer(file, opts);
1212
state.renderChildren(node);
1313
const doc = createDocFromState(state);
14-
// @ts-expect-error document is not defined in node
15-
if (typeof document === 'undefined') {
14+
if (typeof (globalThis as any).document === 'undefined') {
1615
file.result = Packer.toBuffer(doc);
1716
} else {
1817
file.result = Packer.toBlob(doc);

packages/myst-to-docx/src/utils.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,9 @@ export function getImageWidth(width?: number | string, maxWidth = MAX_DOCX_IMAGE
9696
async function getImageDimensions(
9797
file: Blob | Buffer,
9898
): Promise<{ width: number; height: number } | undefined> {
99-
// @ts-expect-error Image is not defined
100-
if (typeof Image === 'undefined') return undefined;
99+
if (typeof (globalThis as any).Image === 'undefined') return undefined;
101100
return new Promise((resolve, reject) => {
102-
// @ts-expect-error Image not defined
103-
const img = new Image();
101+
const img = new (globalThis as any).Image();
104102
// the following handler will fire after a successful loading of the image
105103
img.onload = () => {
106104
const { naturalWidth: width, naturalHeight: height } = img;

0 commit comments

Comments
 (0)