Skip to content

Commit

Permalink
feat: add browser.d.ts and check for existence of Error.captureStackT…
Browse files Browse the repository at this point in the history
…race() (#2144)
  • Loading branch information
codetheweb committed Apr 20, 2022
1 parent d9fa18c commit 6192990
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions browser.d.ts
@@ -0,0 +1,5 @@
import {YargsFactory} from './build/lib/yargs-factory';

declare const Yargs: ReturnType<typeof YargsFactory>;

export default Yargs;
4 changes: 3 additions & 1 deletion lib/yerror.ts
Expand Up @@ -2,6 +2,8 @@ export class YError extends Error {
name = 'YError';
constructor(msg?: string | null) {
super(msg || 'yargs error');
Error.captureStackTrace(this, YError);
if (Error.captureStackTrace) {
Error.captureStackTrace(this, YError);
}
}
}
4 changes: 4 additions & 0 deletions package.json
Expand Up @@ -16,6 +16,10 @@
"import": "./helpers/helpers.mjs",
"require": "./helpers/index.js"
},
"./browser": {
"import": "./browser.mjs",
"types": "./browser.d.ts"
},
"./yargs": [
{
"require": "./yargs"
Expand Down

0 comments on commit 6192990

Please sign in to comment.