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.14 to 1.0.0-alpha.15

2

lib/index.js

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

project = new ts_morph_1.Project({
addFilesFromTsConfig: paths.length === 0,
skipAddingFilesFromTsConfig: paths.length !== 0,
tsConfigFilePath: tsConfigFilePath,

@@ -475,0 +475,0 @@ });

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

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

"dependencies": {
"@ts-morph/common": "^0.6.0",
"@ts-morph/common": "^0.7.3",
"@types/command-line-args": "^5.0.0",

@@ -30,3 +30,3 @@ "@types/command-line-usage": "^5.0.1",

"lodash": "^4.17.20",
"ts-morph": "^8.1.2",
"ts-morph": "^9.1.0",
"tsconfig": "^7.0.0"

@@ -33,0 +33,0 @@ },

@@ -9,3 +9,3 @@ import { each, pull } from 'lodash'

return new Project({
addFilesFromTsConfig: false,
skipAddingFilesFromTsConfig: true,
compilerOptions: { strict: true },

@@ -176,3 +176,3 @@ useInMemoryFileSystem: true,

testProcessProject(
'generates type guards for properties with spaces',
'generates type guards for interface properties with spaces',
{

@@ -203,2 +203,82 @@ 'test.ts': `

testProcessProject(
'generates type guards for type properties with spaces',
{
'test.ts': `
/** @see {isFoo} ts-auto-guard:type-guard */
export type Foo = {
"foo 1": number,
"bar 2": string
}`,
},
{
'test.guard.ts': `
import { Foo } from "./test";
export function isFoo(obj: any, _argumentName?: string): obj is Foo {
return (
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
typeof obj["foo 1"] === "number" &&
typeof obj["bar 2"] === "string"
)
}`,
}
)
testProcessProject(
'generates type guards for interface properties with dashes',
{
'test.ts': `
/** @see {isFoo} ts-auto-guard:type-guard */
export interface Foo {
"foo-1": number,
"bar-2": string
}`,
},
{
'test.guard.ts': `
import { Foo } from "./test";
export function isFoo(obj: any, _argumentName?: string): obj is Foo {
return (
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
typeof obj["foo-1"] === "number" &&
typeof obj["bar-2"] === "string"
)
}`,
}
)
// Commented out since this is a bug that should be fixed.
// testProcessProject(
// 'generates type guards for type properties with dashes',
// {
// 'test.ts': `
// /** @see {isFoo} ts-auto-guard:type-guard */ /**
// export type Foo = {
// "foo-1": number,
// "bar-2": string
// }`,
// },
// {
// 'test.guard.ts': `
// import { Foo } from "./test";
// export function isFoo(obj: any, _argumentName?: string): obj is Foo {
// return (
// (obj !== null &&
// typeof obj === "object" ||
// typeof obj === "function") &&
// typeof obj["foo-1"] === "number" &&
// typeof obj["bar-2"] === "string"
// )
// }`,
// }
// )
testProcessProject(
'generates type guards for properties with spaces in types instead of interfaces',

@@ -205,0 +285,0 @@ {

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