question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can not compile ts due to error with getter method

See original GitHub issue

I’m using node 17.0.1 with typescript version 4.4.4. and I can no longer run my project after I include the import statement for the library.

import { PKPass } from 'passkit-generator';

I went into the node_modules folder of my project and had a look directly into the code of PKPass.d.ts. My IDE showed the following error on line 124 in the getter method for the type:

The return type of a 'get' accessor must be assignable to its 'set' accessor type Type 'undefined' is not assignable to type 'PassTypesProps'.

After having removed | undefined from this line, the project was running again. However I am trying to use the library in a docker container where I can not manipulate the node_modules directly, so this is not a fix for me. Is there some typescript setting I’m missing? How else can I avoid this error?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
alexandercerutticommented, Dec 22, 2021

@Johannes-Vitt I think it is related to strict: true. Do you mind to attempt remove it and let me know if it gets solved? I usually don’t use it because it is… too strict sometimes.

Otherwise I’ll check this evening (GMT+1).

0reactions
alexandercerutticommented, Dec 22, 2021

@Johannes-Vitt I’ll make a review of code with strict mode enabled, but if you want to leverage strict features, I suggest you to enable single flags (at least, for me often it is enough).

Closing this meanwhile 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why are my getter/setter not compiling in TypeScript?
The getter is marked as incorrect because of the setter, that is, if the latter is removed, then the getter is OK. The...
Read more >
Google TypeScript Style Guide
Getters and setters for class members may be used. The getter method must be a pure function (i.e., result is consistent and has...
Read more >
How to use getters/setters in TypeScript ? - GeeksforGeeks
In TypeScript, there are two supported methods getter and setter to access and set the class members. In this very short article, ...
Read more >
Documentation - TypeScript 3.9
If you've been stuck on older versions of TypeScript due to issues around Promise s, ... error: Type 'number' is not assignable to...
Read more >
9 essential VS Code extensions for TypeScript - LogRocket Blog
You know that JS is an interpreter language, so each error is encountered at runtime only because there's no compilation phase.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found