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.

Strict type-checking on a per-file basis "@ts-strict"

See original GitHub issue

Search Terms

strict per file

Suggestion

Currently in the process of converting a moderate-sized javascript project to typescript. Would love to be able to enable strict type-checks on a per-file basis.

Use Cases

Enabling strict mode for the entire project is a daunting task that presents a barrier to adoption (and using typescript without strict mode turned on is like locking the doors on a convertible…it’s probably better than nothing, but it’s not gonna keep you safe).

Examples

//@ts-strict

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. new expression-level syntax)

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:328
  • Comments:28 (2 by maintainers)

github_iconTop GitHub Comments

31reactions
artursvondacommented, Dec 18, 2018

Would love to see this feature implemented as well. We have quite sizeable project and going “all strict” is not an option right now.

30reactions
kamkrycommented, May 26, 2021

While there are no built-in features like this in Typescript, we’ve created typescript-strict-plugin which allows you to turn on strict-mode in specific files or routes. Hope it helps!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Controlling Type Checking Strictness in TypeScript
There is a TypeScript compiler option called strict . This turns on a set of type checking rules and is referred to as...
Read more >
Documentation - tsc CLI Options - TypeScript
Flag Type Default ‑‑allowJs boolean false ‑‑allowUmdGlobalAccess boolean false ‑‑allowUnreachableCode boolean
Read more >
How strict is Typescript's strict mode? - DEV Community ‍ ‍
According to the docs, when Typescript strict mode is set to on, it will validate your code using the strict type rules under...
Read more >
Controlling type checking strictness | Learn TypeScript
The starter project has a compiler option switch on called strict . This turns on a set of type checking rules and is...
Read more >
TypeScript -- force strong strict typed mode for all? - Reddit
With the strict options enabled, you are still required to specify the type in situations where it cannot be inferred (type of function...
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