From e893265e64d2657d9c34a5f7f3c8061b70669290 Mon Sep 17 00:00:00 2001 From: mark1russell7 <39885340+mark1russell7@users.noreply.github.com> Date: Mon, 30 Nov 2026 05:15:25 -0500 Subject: [PATCH] fix(types): type the long-poll timer without the NodeJS namespace The declaration of LongPoll.currentBatchTimer was NodeJS.Timeout. Only @types/node declares the NodeJS namespace, so a project with no @types/node and skipLibCheck off fails with TS2503 when it imports these types. A JSDoc type on the field gives ReturnType | null, which fits browsers and Node.js. Co-Authored-By: Claude Opus 5.5 --- assets/js/phoenix/longpoll.js | 1 + priv/static/types/longpoll.d.ts | 3 ++- priv/static/types/longpoll.d.ts.map | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/assets/js/phoenix/longpoll.js b/assets/js/phoenix/longpoll.js index 517bf0f2ca..f594f41c95 100644 --- a/assets/js/phoenix/longpoll.js +++ b/assets/js/phoenix/longpoll.js @@ -29,6 +29,7 @@ export default class LongPoll { this.reqs = new Set() this.awaitingBatchAck = false this.currentBatch = null + /** @type {ReturnType | null} */ this.currentBatchTimer = null this.batchBuffer = [] this.onopen = function (){ } // noop diff --git a/priv/static/types/longpoll.d.ts b/priv/static/types/longpoll.d.ts index 5abaf8294b..50f8196f7e 100644 --- a/priv/static/types/longpoll.d.ts +++ b/priv/static/types/longpoll.d.ts @@ -7,7 +7,8 @@ export default class LongPoll { reqs: Set; awaitingBatchAck: boolean; currentBatch: any[] | null; - currentBatchTimer: NodeJS.Timeout | null; + /** @type {ReturnType | null} */ + currentBatchTimer: ReturnType | null; batchBuffer: any[]; onopen: () => void; onerror: () => void; diff --git a/priv/static/types/longpoll.d.ts.map b/priv/static/types/longpoll.d.ts.map index 6aa98bbe12..5b5cc51902 100644 --- a/priv/static/types/longpoll.d.ts.map +++ b/priv/static/types/longpoll.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"longpoll.d.ts","sourceRoot":"","sources":["../../../assets/js/phoenix/longpoll.js"],"names":[],"mappings":"AAiBA;IAEE,2CAsBC;IAlBG,8BAAmE;IAErE,cAAoB;IACpB,WAAiB;IACjB,uBAAyB;IACzB,eAAqB;IACrB,0BAA6B;IAC7B,2BAAwB;IACxB,yCAA6B;IAC7B,mBAAqB;IACrB,mBAA4B;IAC5B,oBAA6B;IAC7B,sBAA+B;IAC/B,oBAA6B;IAC7B,kBAAoD;IACpD,cAA0C;IAK5C,sCAKC;IAED,mBAEC;IAED,2DAGC;IAED,kBAGC;IAED,oBAA2G;IAE3G,aAiEC;IAMD,sBAaC;IAED,gDAkBC;IAED,mDAYC;IAED,sFAWC;CACF"} \ No newline at end of file +{"version":3,"file":"longpoll.d.ts","sourceRoot":"","sources":["../../../assets/js/phoenix/longpoll.js"],"names":[],"mappings":"AAiBA;IAEE,2CAuBC;IAnBG,8BAAmE;IAErE,cAAoB;IACpB,WAAiB;IACjB,uBAAyB;IACzB,eAAqB;IACrB,0BAA6B;IAC7B,2BAAwB;IACxB,mDAAmD;IACnD,mBADW,UAAU,CAAC,OAAO,UAAU,CAAC,GAAG,IAAI,CAClB;IAC7B,mBAAqB;IACrB,mBAA4B;IAC5B,oBAA6B;IAC7B,sBAA+B;IAC/B,oBAA6B;IAC7B,kBAAoD;IACpD,cAA0C;IAK5C,sCAKC;IAED,mBAEC;IAED,2DAGC;IAED,kBAGC;IAED,oBAA2G;IAE3G,aAiEC;IAMD,sBAaC;IAED,gDAkBC;IAED,mDAYC;IAED,sFAWC;CACF"} \ No newline at end of file