From 151a035327d95db5952fa4204d38bf7a018214b1 Mon Sep 17 00:00:00 2001 From: William Hilton Date: Thu, 7 Jan 2021 14:42:50 -0500 Subject: [PATCH] output typings for bin/utils.js --- .gitignore | 3 ++- bin/callback.js | 1 + bin/utils.js | 9 ++++++--- package.json | 4 ++-- tsconfig.json | 6 +++--- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 5f6c423e..7bfbca7a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ dist node_modules -tmp \ No newline at end of file +tmp +*.d.ts diff --git a/bin/callback.js b/bin/callback.js index b0e49e5c..7e9bdc47 100644 --- a/bin/callback.js +++ b/bin/callback.js @@ -1,3 +1,4 @@ +// @ts-nocheck const http = require('http') const CALLBACK_URL = process.env.CALLBACK_URL ? new URL(process.env.CALLBACK_URL) : null diff --git a/bin/utils.js b/bin/utils.js index c49c7637..ef7e03d1 100644 --- a/bin/utils.js +++ b/bin/utils.js @@ -1,3 +1,4 @@ +// @ts-nocheck const Y = require('yjs') const syncProtocol = require('y-protocols/dist/sync.cjs') const awarenessProtocol = require('y-protocols/dist/awareness.cjs') @@ -223,9 +224,11 @@ const send = (doc, conn, m) => { const pingTimeout = 30000 /** - * @param {any} conn - * @param {any} req - * @param {any} opts + * @param {WebSocket} conn + * @param {import('http').IncomingMessage} req + * @param {object} [opts] + * @param {string} [opts.docName] + * @param {boolean} [opts.gc] */ exports.setupWSConnection = (conn, req, { docName = req.url.slice(1).split('?')[0], gc = true } = {}) => { conn.binaryType = 'arraybuffer' diff --git a/package.json b/package.json index d7d8f32f..9a08dc4b 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Websockets provider for Yjs", "main": "./dist/y-websocket.cjs", "module": "./src/y-websocket.js", - "types": "./dist/src/y-websocket.d.ts", + "types": "./src/y-websocket.d.ts", "sideEffects": false, "funding": { "type": "GitHub Sponsors ❤", @@ -15,7 +15,7 @@ "dist": "rm -rf dist && rollup -c && tsc", "lint": "standard && tsc", "test": "npm run lint", - "preversion": "npm run lint && npm run dist && test -e dist/src/y-websocket.d.ts && test -e dist/y-websocket.cjs" + "preversion": "npm run lint && npm run dist && test -e src/y-websocket.d.ts && test -e dist/y-websocket.cjs" }, "bin": { "y-websocket-server": "./bin/server.js" diff --git a/tsconfig.json b/tsconfig.json index f263390d..5e0805a4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,8 +10,8 @@ // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ // "sourceMap": true, /* Generates corresponding '.map' file. */ // "outFile": "./", /* Concatenate and emit output to single file. */ - "outDir": "./dist", /* Redirect output structure to the directory. */ - "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "outDir": "./", /* Redirect output structure to the directory. */ + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ // "composite": true, /* Enable project compilation */ // "removeComments": true, /* Do not emit comments to output. */ // "noEmit": true, /* Do not emit outputs. */ @@ -58,5 +58,5 @@ // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ // "maxNodeModuleJsDepth": 5 }, - "include": ["./src/y-websocket.js"] + "include": ["./src/y-websocket.js", "./bin/utils.js"] }