Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

type-plus

Package Overview
Dependencies
Maintainers
1
Versions
169
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

type-plus - npm Package Compare versions

Comparing version 1.30.1 to 1.31.0

2

lib/assertType.d.ts

@@ -0,1 +1,2 @@

import { UnionKeys } from './UnionKeys';
/**

@@ -20,2 +21,3 @@ * assert the subject satisfies the specified type T

var isNever: (value: never) => void;
var hasProperty: <T, P extends UnionKeys<T>>(value: T, prop: P) => asserts value is T & Record<P, T[P]>;
}

@@ -22,0 +24,0 @@ /**

@@ -22,2 +22,4 @@ "use strict";

assertType.isNever = noop;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
assertType.hasProperty = function hasProperty(value, prop) { };
// assertType.hasProperty = <T>(value: T, propertyName: KeyTypes)

@@ -24,0 +26,0 @@ function noop() { return; }

@@ -0,1 +1,2 @@

import { UnionKeys } from './UnionKeys';
/**

@@ -20,2 +21,3 @@ * assert the subject satisfies the specified type T

var isNever: (value: never) => void;
var hasProperty: <T, P extends UnionKeys<T>>(value: T, prop: P) => asserts value is T & Record<P, T[P]>;
}

@@ -22,0 +24,0 @@ /**

@@ -19,2 +19,4 @@ /**

assertType.isNever = noop;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
assertType.hasProperty = function hasProperty(value, prop) { };
// assertType.hasProperty = <T>(value: T, propertyName: KeyTypes)

@@ -21,0 +23,0 @@ function noop() { return; }

2

package.json
{
"name": "type-plus",
"version": "1.30.1",
"version": "1.31.0",
"description": "Provides additional types for `typescript`.",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/unional/type-plus",

@@ -103,2 +103,3 @@ # type-plus

- `assertType.noXXX(value)`: ensure typeof `value` does not contain `XXX`. i.e. cannot assign `XXX` to `value`.
- `assertType.hasProperty(value, prop)`: assert `value` has property `prop`. This will pick the correct union type.
- `typeAssert.*` (deprecated) replaced by `assertType`.

@@ -105,0 +106,0 @@ - `typeAssertion<T>()`: creates a type assertion function of type `T`

@@ -171,1 +171,16 @@ import { assertType, typeAssertion } from '.';

})
describe('hasProperty', () => {
type X = { name: string } & ({ a: 1 } | { b: 2 })
const x: X = { name: 'n', a: 1 } as any
assertType.hasProperty(x, 'a')
expect(x.a).toBe(1)
const y: X = { name: 'n', b: 2 } as any
assertType.hasProperty(y, 'b')
expect(y.b).toBe(2)
});

@@ -0,1 +1,3 @@

import { UnionKeys } from './UnionKeys'
/**

@@ -20,2 +22,6 @@ * assert the subject satisfies the specified type T

assertType.isNever = noop as (value: never) => void
// eslint-disable-next-line @typescript-eslint/no-unused-vars
assertType.hasProperty = function hasProperty<T, P extends UnionKeys<T>>(value: T, prop: P): asserts value is T & Record<P, T[P]> { }
// assertType.hasProperty = <T>(value: T, propertyName: KeyTypes)

@@ -22,0 +28,0 @@ function noop() { return }

Sorry, the diff of this file is not supported yet

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