JustSamuel / ts-mailcow-api

TypeScript wrapper for the mailcow API.
3 stars 0 forks source link

Bug: Type error in MailcowException #4

Closed SachsenspieltCoding closed 1 day ago

SachsenspieltCoding commented 2 years ago

Hey, I tried to use your wrapper for my Next JS project and found out that there is a type error in the MailcowExpection class in src/types.ts It throws an error message when building the project:

./node_modules/ts-mailcow-api/src/types.ts:1369:3
Type error: Property 'message' has no initializer and is not definitely assigned in the constructor.

  1367 |    * The error message provided by Mailcow.
  1368 |    */
> 1369 |   message: string;
       |   ^
  1370 | }
  1371 | 
  1372 | /**
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Also, when I open the file in WebStorm, it marks the line as an error. Don't know really where the problem is, but it looks like that it has to be changed in the wrapper itself. So, maybe you can give it a look?

Appreciate your work, Best regards

JustSamuel commented 1 year ago

Hey, sorry for the long wait!

It doesn't give an error for me. What version of typescript are you using / what is the target and module in your tsconfig? Since I think this is because of different configs and not a problem with the code itself.

SachsenspieltCoding commented 1 year ago

Hey, no problem :)

This is my tsconfig.json: I changed nothing so it should be the default auto-generated config of the next js project creation tool.

{
  "compilerOptions": {
    "target": "es5",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true
  },
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
  "exclude": ["node_modules"]
}

My TypeScript version is 4.8.4

JustSamuel commented 1 year ago

Ahh, the problem is most likely the es5 target since the project is set to es2015.

SachsenspieltCoding commented 1 year ago

I just tested it out and yes, you're quite right. There is a problem with mine tsconfig.json It is important to set "strictNullChecks": false, otherwise there will be the copiler error. The target/module isn't the problem I think