Skip to content

Commit 4b3240d

Browse files
authored
🤖 Merge PR DefinitelyTyped#72266 [is-errno-exception] Add types for package by @sosoba
1 parent bd80e9f commit 4b3240d

File tree

5 files changed

+66
-0
lines changed

5 files changed

+66
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*
2+
!**/*.d.ts
3+
!**/*.d.cts
4+
!**/*.d.mts
5+
!**/*.d.*.ts
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/// <reference types="node" />
2+
3+
/**
4+
* Assert that argument are Exception
5+
*/
6+
export function isErrnoException(e: unknown): e is NodeJS.ErrnoException;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"private": true,
3+
"name": "@types/is-errno-exception",
4+
"version": "1.2.9999",
5+
"projects": [
6+
"https://github.com/sosoba/is-errno-exception.git"
7+
],
8+
"type": "module",
9+
"exports": "./index.d.ts",
10+
"dependencies": {
11+
"@types/node": "*"
12+
},
13+
"devDependencies": {
14+
"@types/is-errno-exception": "workspace:."
15+
},
16+
"owners": [
17+
{
18+
"name": "Sławomir Osoba",
19+
"githubUsername": "sosoba"
20+
},
21+
{
22+
"name": "Borys Malinowski",
23+
"githubUsername": "coigmalinowski"
24+
}
25+
]
26+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { isErrnoException } from "is-errno-exception";
2+
3+
try {
4+
new URL("unknown");
5+
} catch (e) {
6+
if (isErrnoException(e) && e.code === "ERR_MODULE_NOT_FOUND") {
7+
console.warn(e.code.toLocaleUpperCase());
8+
}
9+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"compilerOptions": {
3+
"module": "node16",
4+
"lib": [
5+
"es6",
6+
"dom"
7+
],
8+
"noImplicitAny": true,
9+
"noImplicitThis": true,
10+
"strictNullChecks": true,
11+
"strictFunctionTypes": true,
12+
"types": [],
13+
"noEmit": true,
14+
"forceConsistentCasingInFileNames": true
15+
},
16+
"files": [
17+
"index.d.ts",
18+
"test/is-errno-exception.ts"
19+
]
20+
}

0 commit comments

Comments
 (0)