New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ts-auto-guard

Package Overview
Dependencies
Maintainers
2
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-auto-guard - npm Package Compare versions

Comparing version 1.0.0-alpha.25 to 1.0.0-alpha.26

2

lib/index.js

@@ -398,3 +398,3 @@ "use strict";

}
if (type.getText() === 'any') {
if (type.getText() === 'any' || type.getText() === 'unknown') {
return null;

@@ -401,0 +401,0 @@ }

{
"name": "ts-auto-guard",
"version": "1.0.0-alpha.25",
"version": "1.0.0-alpha.26",
"description": "Generate type guard functions from TypeScript interfaces",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/rhys-vdw/ts-auto-guard",

@@ -1344,1 +1344,55 @@ import test from 'tape'

)
testProcessProject(
'Deals with unknown type as it would any',
{
'test.ts': `
/** @see {isTestType} ts-auto-guard:type-guard */
export interface TestType {
[index: string]: unknown
}
`,
},
{
'test.ts': null,
'test.guard.ts': `
import { TestType } from "./test";
export function isTestType(obj: any, _argumentName?: string): obj is TestType {
return (
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
Object.entries(obj)
.every(([key, _value]) => (typeof key === "string"))
)
}
`,
}
)
testProcessProject(
'Deals with unknown type as it would any',
{
'test.ts': `
/** @see {isTestType} ts-auto-guard:type-guard */
export interface TestType {
test: unknown
}
`,
},
{
'test.ts': null,
'test.guard.ts': `
import { TestType } from "./test";
export function isTestType(obj: any, _argumentName?: string): obj is TestType {
return (
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function")
)
}
`,
}
)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc