Skip to content

Commit

Permalink
πŸ“¦ [RUMF-1168] update typescript (#1368)
Browse files Browse the repository at this point in the history
* πŸ“¦ [RUMF-1168] update typescript

* πŸ“¦ [RUMF-1168] update ts-loader

* πŸ“¦ [RUMF-1168] update ts-node

* πŸ“¦ [RUMF-1168] fix developer extension typings

To fix developer extension typings, this commit update some sub-dependencies.

* πŸ‘Œ simplify error condition
  • Loading branch information
BenoitZugmeyer authored Mar 2, 2022
1 parent b52da4f commit bb2e40f
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 101 deletions.
1 change: 0 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,3 @@ updates:
# typescript: RUMF-1168
- dependency-name: 'ts-loader'
- dependency-name: 'ts-node'
- dependency-name: 'typescript'
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,18 @@
"replace-in-file": "6.3.2",
"sinon": "9.2.4",
"terser-webpack-plugin": "5.1.1",
"ts-loader": "8.0.18",
"ts-node": "9.1.1",
"ts-loader": "9.2.6",
"ts-node": "10.6.0",
"tsconfig-paths-webpack-plugin": "3.5.1",
"typescript": "4.1.5",
"typescript": "4.6.2",
"webdriverio": "6.1.4",
"webpack": "5.28.0",
"webpack-cli": "4.5.0",
"webpack-dev-middleware": "4.1.0"
},
"resolutions": {
"**/bumbag/lodash": "4.17.21",
"**/bumbag/reakit": "1.3.11",
"ansi-regex": "5.0.1"
}
}
4 changes: 2 additions & 2 deletions packages/core/src/browser/xhrObservable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ function createXhrObservable() {
return observable
}

function openXhr(this: XMLHttpRequest, method: string, url: string) {
function openXhr(this: XMLHttpRequest, method: string, url: string | URL) {
xhrContexts.set(this, {
state: 'open',
method,
url: normalizeUrl(url),
url: normalizeUrl(url.toString()),
})
}

Expand Down
16 changes: 5 additions & 11 deletions packages/core/src/tools/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -574,23 +574,17 @@ export function combine(...sources: any[]): unknown {
export type TimeoutId = ReturnType<typeof setTimeout>

export function requestIdleCallback(callback: () => void, opts?: { timeout?: number }) {
interface BrowserWindow extends Window {
requestIdleCallback: (callback: () => void, opts?: { timeout?: number }) => number
cancelIdleCallback: (handle?: number) => void
}
const browserWindow = window as unknown as BrowserWindow

// Use 'requestIdleCallback' when available: it will throttle the mutation processing if the
// browser is busy rendering frames (ex: when frames are below 60fps). When not available, the
// fallback on 'requestAnimationFrame' will still ensure the mutations are processed after any
// browser rendering process (Layout, Recalculate Style, etc.), so we can serialize DOM nodes
// efficiently.
if (browserWindow.requestIdleCallback) {
const id = browserWindow.requestIdleCallback(monitor(callback), opts)
return () => browserWindow.cancelIdleCallback(id)
if (window.requestIdleCallback) {
const id = window.requestIdleCallback(monitor(callback), opts)
return () => window.cancelIdleCallback(id)
}
const id = browserWindow.requestAnimationFrame(monitor(callback))
return () => browserWindow.cancelAnimationFrame(id)
const id = window.requestAnimationFrame(monitor(callback))
return () => window.cancelAnimationFrame(id)
}

export function removeDuplicates<T>(array: T[]) {
Expand Down
2 changes: 1 addition & 1 deletion packages/logs/src/domain/trackNetworkError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ function readLimitedAmountOfBytes(

function readMore() {
reader.read().then(
monitor((result: ReadableStreamReadResult<Uint8Array>) => {
monitor((result: ReadableStreamDefaultReadResult<Uint8Array>) => {
if (result.done) {
onDone()
return
Expand Down
6 changes: 4 additions & 2 deletions packages/rum/src/domain/segmentCollection/deflateWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function workerCodeFn() {
type: 'initialized',
})
break
case 'write':
case 'write': {
const additionalRawSize = pushData(data.data)
self.postMessage({
type: 'wrote',
Expand All @@ -34,7 +34,8 @@ function workerCodeFn() {
additionalRawSize,
})
break
case 'flush':
}
case 'flush': {
const additionalRawSize = data.data ? pushData(data.data) : 0
deflate.push('', constants.Z_FINISH)
self.postMessage({
Expand All @@ -47,6 +48,7 @@ function workerCodeFn() {
deflate = new Deflate()
rawSize = 0
break
}
}
})
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function onInitialized(worker: DeflateWorker) {
}
}

function onError(error: ErrorEvent | Error | string) {
function onError(error: unknown) {
if (state.status === DeflateWorkerStatus.Loading) {
display.error('Session Replay recording failed to start: an error occurred while creating the Worker:', error)
if (error instanceof Event || (error instanceof Error && includes(error.message, 'Content Security Policy'))) {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/lib/framework/httpServers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ async function instantiateServer(): Promise<http.Server> {
try {
return await instantiateServerOnPort(port)
} catch (error) {
if (error.code === 'EADDRINUSE') {
if ((error as NodeJS.ErrnoException).code === 'EADDRINUSE') {
continue
}
throw error
Expand Down
Loading

0 comments on commit bb2e40f

Please sign in to comment.