-
Notifications
You must be signed in to change notification settings - Fork 52
2.1.0 - incorrect TypeScript exports resulting in TypeError #75
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
Comments
Hi @jan-molak. Thanks for the report. What I'm going to do here is revert the change (done in afc0a4c) and use The motivation for this change was to fix #45 — I'd prefer to support a single way to invoke Does this work for you? |
Sure, sounds great! Thanks for getting back to me so quickly 👍🏻 |
@eriwen |
Pinned versions of error-stack-parser and stackframe as per stacktracejs/error-stack-parser#75
@eriwen import StackFrame from "stackframe"; This results in the following error:
I'd suggest making the following change to - import StackFrame from "stackframe";
+ import StackFrame = require("stackframe"); |
Ah, sorry about that @jan-molak. |
Hey @eriwen - apologies for being a pain, but it seems like v2.1.3 has fixed the issue with the in v2.1.3, error-stack-parser.d.ts: import StackFrame = require("stackframe"); // this is fine now
declare namespace ErrorStackParser {
export type {StackFrame};
/**
* Given an Error object, extract the most information from it.
*
* @param {Error} error object
* @return {Array} of StackFrames
*/
export function parse(error: Error): StackFrame[];
}
- export default ErrorStackParser;
+ export = ErrorStackParser |
Hi @eriwen and many thanks for your work on
error-stack-parser
!It looks like v2.1.0 has introduced a bug in TypeScript exports, preventing consumers of
error-stack-parser
from using the library in the intended way.If you have a look at line 18 in
error-stack-parser.d.ts
in this diff:Type definitions changed in v2.1.0 suggest one should import
ErrorStackParser
using the default export as follows:which is different from v2.0.7, where we'd import the module like this:
However, the change doesn't seem to have been applied to the associated JavaScript code, which still uses the more traditional
module.exports = ErrorStackParser
export.This means that importing the default export, as per the type definitions, results in
undefined
and aTypeError
:Your Environment
Possible Workaround
Ignore the type definitions and use a var require instead:
Possible Solution
If possible, I'd suggest reverting the change to
error-stack-parser.d.ts
:Or, if you prefer to use default exports, the associated JavaScript code would need to change to use
If using the default export, I'd also suggest bumping the major version number, since this change is not backwards compatible.
The text was updated successfully, but these errors were encountered: