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

Add browser.d.ts and check for existence of Error.captureStackTrace() #2144

Merged
merged 7 commits into from Apr 20, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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