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.

[RFC] Enable type checking for tests

See original GitHub issue

Proposal

Delete this line in tsconfig.json:

image

Reasoning

  • This will allow the typescript compiler to check for type errrors in test files, which is extra armour on top of the tests themselves.

  • I can imagine API changes that don’t cause a test to fail but might still cause the test’s code to be an out-of-date usage example for that particular API.

  • The vscode TS plugin currently doesn’t work properly in test files because it has the default contextless TS config applied, rather than our own tsconfig.json file. This means that, e.g. absolute import paths show up as errors, but work fine when run under jest:

    image

    And of course if you choose to write test code that would fail type checking, you get other red squiggly lines that just add noise.

    image

Exceptions

Sometimes we don’t care about types, or they get in the way. I would therefore recommend use of any or @ts-ignore or even .js files if our setup supports that?

How

Turning type-checking on for test files and running tsc introduces 243 errors. It would be a big old PR to fix them all in one go. So I’d recommend doing it in a staggered way:

  1. Turn on type-checking for tests
  2. Fix a handful of erroring test files
  3. If there are still erroring test files left over then turn off type-checking for tests
  4. Submit PR
  5. If there are still erroring test files left over then go to 1.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
ds300commented, Sep 11, 2018

I’m going to resolve this RFC now

Resolution

We decided to do it.

Level of Support

2: Positive feedback.

Next Steps

We will implement it. I’ll start doing chunks in my 20% time. Anyone who wants to help out, please do! 🙏

0reactions
damassicommented, Oct 25, 2018
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Configure & Test RFC Connection in SAP – SM59
This tutorial is divided into 4 sections. Step 1: Setup an RFC connection. Step 2: Trusted RFC connection. Step 3: Testing an RFC...
Read more >
Standard Program/Function module to test RFC connection
Hi Any standard function module to check whether RFC connection is working, before I say I execute something on a remote system apart...
Read more >
[RFC] Setting up Mypy type checking for TVM codebase
Mypy is a static type checker for Python. It is run as a separate tool (like a linter) that looks over your codebase...
Read more >
RFC 3696: Application Techniques for Checking and ...
This type of test, most commonly involving syntax checks or application of other ... occasionally, extended URI forms (see Section 4)) may enable...
Read more >
PHP RFC: Scalar Type Declarations
Unlike parameter type declarations, the type checking mode used for return types depends on the file where the function is defined, not where ......
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