Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade TS to 5.6.2 #574

Merged
merged 1 commit into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions packages/vscode-extension/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// Place your settings in this file to overwrite default and user settings.
{
"files.exclude": {
"out": false // set this to true to hide the "out" folder with the compiled JS files
},
"search.exclude": {
"out": true // set this to false to include "out" folder in search results
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off",
"cmake.configureOnOpen": false
"files.exclude": {
"out": false // set this to true to hide the "out" folder with the compiled JS files
},
"search.exclude": {
"out": true // set this to false to include "out" folder in search results
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off",
"cmake.configureOnOpen": false,
"typescript.tsdk": "node_modules/typescript/lib"
}
9 changes: 5 additions & 4 deletions packages/vscode-extension/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion packages/vscode-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@
"watch:extension": "vite",
"package": "rm -rf dist/ && npm run build:dist",
"lint": "eslint src --ext ts && npm exec prettier --check src",
"typecheck": "tsc --noEmit",
"format": "prettier --write --list-different src",
"build:tests": "tsc --project tsconfig.test.json",
"test": "npm run build:extension-code && npm run build:webview && npm run build:tests && vscode-test"
Expand Down Expand Up @@ -433,7 +434,7 @@
"sinon": "^18.0.0",
"source-map": "^0.8.0-beta.0",
"ts-loader": "^9.5.1",
"typescript": "^4.1.3",
"typescript": "^5.6.2",
"url-loader": "^4.1.1",
"uuid": "^9.0.1",
"vite": "^5.0.8",
Expand Down
26 changes: 7 additions & 19 deletions packages/vscode-extension/src/debugging/logFormatting.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
import util from "util";
import { CDPSubType, CDPValueType } from "./cdp";
import { CDPRemoteObject } from "./cdp";

export interface CDPRemoteObject {
type: CDPValueType;
subtype?: CDPSubType;
className?: string;
value?: any;
objectId?: number;
description?: string;
}

function format(anything: any) {
function format(anything: unknown) {
const formatted = util.inspect(anything, {
showHidden: false,
depth: Infinity,
Expand All @@ -25,10 +16,9 @@ function format(anything: any) {
return formatted;
}

export async function formatMessage(args: [CDPRemoteObject]): Promise<string> {
let result: string = "";
const mappedArgs = await Promise.all(
args.map((arg, index) => {
export async function formatMessage(args: CDPRemoteObject[]): Promise<string> {
return args
.map((arg) => {
switch (arg.type) {
case "object":
return format(arg.description || "[Object]");
Expand All @@ -37,12 +27,10 @@ export async function formatMessage(args: [CDPRemoteObject]): Promise<string> {
case "boolean":
return arg.value;
case "undefined":
return format(arg.value);
return format(undefined);
case "function":
return format(arg.description || "[Function]");
}
})
);

return mappedArgs.join(" ");
.join(" ");
}
11 changes: 1 addition & 10 deletions packages/vscode-extension/src/utilities/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,19 +158,10 @@ function isPidRunning(pid: number) {
}
}

export async function downdloadFile(url: string, destination: string) {
const stream = fs.createWriteStream(destination);
const { body } = await fetch(url);
if (!body) {
throw new Error(`Unexpected error during the file download from ${url}.`);
}
await finished(Readable.fromWeb(body as ReadableStream).pipe(stream));
}

async function calculateFileMD5(filePath: string, hash: Hash) {
const BUFFER_SIZE = 8192;
const fd = fs.openSync(filePath, "r");
const buffer = Buffer.alloc(BUFFER_SIZE);
const buffer = new Uint8Array(BUFFER_SIZE);

try {
let bytesRead;
Expand Down
11 changes: 6 additions & 5 deletions packages/vscode-extension/src/utilities/throttle.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
export function throttle<T extends (...args: any[]) => any>(
func: T,
limitMs: number
): (...args: [...Parameters<T>, force?: boolean]) => ReturnType<T> {
type AnyFn = (...args: any[]) => any;
type ArgsWithForce<T extends AnyFn> = [...args: Parameters<T>, force?: boolean];
type WithForce<T extends AnyFn> = (...args: ArgsWithForce<T>) => ReturnType<T>;

export function throttle<T extends AnyFn>(func: T, limitMs: number): WithForce<T> {
let timeout: NodeJS.Timeout | null = null;
let recentArgs: any;

return function (...args: any) {
const force = args[args.length - 1] === true; // Check if the last argument is true (force flag)

if (force) {
if (timeout != null) {
if (timeout !== null) {
clearTimeout(timeout);
}
timeout = null;
Expand Down
Loading