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.

Replace any by unknown in definition files

See original GitHub issue

Since the new unknown type was added, it makes sense to replace a lot (if not all) usage of any in the definition files with unknown. For example:

Array.isArray(a: unknown): a is unknown[];
JSON.parse(a: string): unknown;

However, this change will cause many errors in projects currently using the fact that the returned types are not type-checked. This means that the change could be controversial.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:51
  • Comments:16 (8 by maintainers)

github_iconTop GitHub Comments

felixfbeckercommented, Aug 27, 2019

This is one of the biggest blind spots regarding type safety in big codebases. You can warn against using explicit any with linting, but you can’t change the types of all the declaration files

evmarcommented, Feb 5, 2020

@RyanCavanaugh now that you’ve backed off from strictAny, would you reconsider this? The original use case here (which motivated strictAny in the first place) would still be pretty valuable.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to replace unknown values inside a file in python
As suggested by @Barmar, use a regex to replace your text: import re PAT = re.compile('image: ".*\.png"') with open('readme.json') as inp, ...
Read more >
Use the Find and Replace dialog box to change data
In the Find What box, type your search value. To replace data, type a replacement string in the Replace With box. Note: Do...
Read more >
kubectl replace - Kubernetes
Replace a resource by filename or stdin. JSON and YAML formats are accepted. If replacing an existing resource, the complete resource spec must...
Read more >
Dependency resolution - Parcel
As Parcel builds your source code, it discovers dependencies, which allow code to be broken into separate files and reused in multiple places....
Read more >
Documentation - Module Resolution - TypeScript
json named types to mirror the purpose of "main" - the compiler will use it to find the “main” definition file to consult....
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 Post

No results found

github_iconTop Related Hashnode Post

No results found