pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/paperclover/ts-lie-detector

ossorigen="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/primer-9e07ff8eaaaff3a3.css" /> GitHub - paperclover/ts-lie-detector: runtime assertion for typescript code. (mirror repo, PRs accepted) · GitHub
Skip to content

paperclover/ts-lie-detector

Repository files navigation

TypeScript Lie Detector

STATUS: Not ready for usage at all. Please monitor TSLD's Issue Tracker

A problem with current TypeScript is all types are given as-is, with no way to truly tell if those types are correct. Lie Detector instruments your codebase with many runtime checks to verify the soundness of your codebase.

Obvious sources of "lies" in TypeScript include the as clause and non-null assertions (postfix ! operator):

export function sample(param: string | number | boolean, flag?: number) {
  if (typeof param === "string") {
    // unexpected behavior if `flag` is `undefined`
    return flag!.toFixed(2);
  }

  // unexpected behavior if `param` is `boolean`
  return (param as number).toFixed();
}

In addition to the two commented lies, TypeScript Lie Detector also sees that sample could be called by external code without type-checking, so it validates the parameters are sound.

In many cases, proper type narrowing is better than runtime assertions, but the narrowing system in TypeScript can only get so far.

Usage

Contributions

This repository accepts pull requests to either its main repository on Forgejo as well as the GitHub Mirror. Until Forgejo has a federated issue tracker, bugs can be reported on GitHub Discussions or sent over email to git@paperclover.net

About

runtime assertion for typescript code. (mirror repo, PRs accepted)

Resources

Stars

Watchers

Forks

Contributors

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy