TypeStat icon indicating copy to clipboard operation
TypeStat copied to clipboard

Warn or error on semantic diagnostics when creating a program

Open JoshuaKGoldberg opened this issue 4 years ago • 0 comments

🚀 Feature Request

It'd be nice to know when there are TypeScript program/semantic/etc. diagnostics before running, instead of just getting relatively poor quality fixes?

Existing Behavior

I've had troubles getting types working properly with third party definitions: first in the wrestling that spawned #758+#759, then later in tests where I'd forgotten to enable compiler options like "jsx": "react" & "esmoduleInterop": true when working with import React from "react";. Nothing told me there was anything wrong until I explicitly ran request.program.services.getSemanticDiagnostics(someNode.getSourceFile());

Change Proposal

Maybe warn on them before running? Maybe error out instead of executing in tests, or even in general CLI usage?

Note that some (even many) diagnostics are expected in e.g. tests that add in missing props, types, etc. So part of this would would need to be filtering existing diagnostics for the ones that aren't expected.

I wonder if #759 could be reverted after this change...

JoshuaKGoldberg avatar Dec 06 '20 13:12 JoshuaKGoldberg