-
Notifications
You must be signed in to change notification settings - Fork 847
Closed
Description
Steps to reproduce
Prepare:
interface ApiResponse {
downloads: number;
start: string;
end: string;
package: string;
}
/**
* Fetch the number of downloads for a given npm package in the last month.
* @param packageName The name of the npm package to fetch download data for.
* @returns A promise that resolves to the number of downloads in the last month.
* @throws {TypeError} If the fetch request fails or returns a non-OK status.
*/
export async function fetchDownloadsLastMonth(packageName: string): Promise<number> {
const response = await fetch(`https://api.npmjs.org/downloads/point/last-month/${packageName}`);
if (!response.ok) {
throw new TypeError(`Failed to fetch data: ${response.status} ${response.statusText}`);
}
return (await response.json() as ApiResponse).downloads;
}Almost all of the above code is generated by Copilot inline completion (slop).
- Remove
TypeErrorin the brackets after@throws - Type "
Ty" at the same place
Behavior with typescript@6.0
"TypeError" appears in the IntelliSense and you can select it.
Behavior with tsgo
"TypeError" does not appear in the IntelliSense.

Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels