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 types #20

Merged
merged 1 commit into from
Sep 16, 2024
Merged

Add types #20

merged 1 commit into from
Sep 16, 2024

Conversation

nick-kang
Copy link
Contributor

No description provided.

@eliottvincent eliottvincent merged commit 5ffe027 into crisp-oss:master Sep 16, 2024
3 checks passed
@eliottvincent
Copy link
Member

Now released as version v1.7.0: https://www.npmjs.com/package/email-forward-parser/v/1.7.0

Thanks!

@nick-kang nick-kang deleted the nick-kang/add-types branch September 16, 2024 09:14
@eliottvincent
Copy link
Member

Hello @nick-kang

While running npx tsc on a project using this library, we have the following error:

Screen Shot 2024-10-03 at 10 42 18@2x

The code is pretty simple:

var EmailForwardParser  = require("email-forward-parser");

this.__email_forward_parser = new EmailForwardParser();

I haven't deeply checked it yet, any idea what would cause it?

@nick-kang
Copy link
Contributor Author

On mobile rn, but my guess is that you'd have to add "constructor()" into the class definition.

@eliottvincent
Copy link
Member

Yes we tried both constructor() and constructor() {}, no luck.

@nick-kang
Copy link
Contributor Author

It likely has to do with how tsconfig is setup. The library has been compiling fine on my end. Try importing as default like here: ajv-validator/ajv#2204

@eliottvincent
Copy link
Member

eliottvincent commented Oct 4, 2024

Ok this makes the npx tsc succeed, but throws the following error when we run the code:

this.__email_forward_parser = new EmailForwardParser.default();
                                  ^

TypeError: EmailForwardParser.default is not a constructor

Because obviously, there is no default exported.

This is what our tsconfig.json looks like:

{
  "compilerOptions": {
    "allowJs": true,
    "checkJs": true,
    "target": "es6",
    "types": ["node"],
    "moduleResolution": "NodeNext",
    "declaration": true,
    "outDir": "dist",
    "declarationMap": true
  },
  "include": ["src/**/*"]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants