microsoft / microsoft/TypeScript

Add an option to ignore type checking for certain files

Open
#52,325 2 comments 57 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

In Discussion Suggestion
Dominant language
Go
Stars
111k
Forks
14.4k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

Suggestion

🔍 Search Terms

Ignore files directories type checking

✅ Viability 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, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

Add an option like

nocheck: ["external-files/**"]

for tsconfig.json that effectively works like adding // @ts-nocheck to each and every matching file.

📃 Motivating Example

"Do you have a problem with types in files by external authors and have no way to solve it? Have you begged and asked for a fix only to be ignored? Now you can add "nocheck" to tsconfig.json and ignore the problems you cannot solve."

💻 Use Cases

The skipLibCheck option in tsconfig.json allows us to deal with problems in types in dependencies by not performing checks on those files. In our case (Vaadin) we also get dependencies from other locations (Java jar files) and they will not end up in node_modules because other tools like Vite assume that dependencies inside node_modules will not change and thus will not hot deploy changes from there. So the files get put in another folder, let's say external-files/**.

We however have the same problem that skipLibCheck to my understanding tries to solve: Sometimes the TS author either just writes incorrect TS that still works or she is using less strict options in tsconfig.json (e.g. other author uses noUnusedLocals": false and project uses noUnusedLocals": true). This leads to problems when including the TS files in another project and compiling that: the project won't compile even though it would work perfectly well.

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 by reviewing tsconfig.json option handling and the existing skipLibCheck behavior described in the issue. Define how a nocheck glob such as external-files/** would select files and how completion is verified by ensuring matching files no longer produce type-checking errors.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.