microsoft / microsoft/TypeScript

Add Command-Line Syntax-Only Validation

Open
#37,634 0 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Awaiting More Feedback Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

Search Terms

Keywords I searched:

  • Syntax
  • Validation

Suggestion

I would like to see a command line option that makes tsc only validate the syntax of TypeScript (and possibly JavaScript) files within the project, but does not perform type checking. It would not emit any files.

Use Cases

  • (My current use case) TypeScript generated by code generation programs that skips generation of certain symbols, or needs to import symbols from other modules where those modules may not be available yet, so their types cannot be known. The generated files would almost always have type-related errors that cannot reliably be automatically fixed, so just validation of the syntax alone would be helpful.
  • Certain CI/CD workflows could benefit from the lower overhead of just checking syntax only in large projects for every commit, and only performing type checking for commits that are expected to result in a build.

Examples

The command

tsc --noTypeCheck index.ts

could return the normal errors and exit code that it would if the syntax were incorrect, but never check typing.

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the tsc command-line entry point and review how syntax diagnostics, type checking, and emitting are currently selected. Define the option's supported file modes and verify that it reports syntax errors with the normal exit status while suppressing type checking and output.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
cli, compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.