Socket
Socket
Sign inDemoInstall

expect-type

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

expect-type - npm Package Compare versions

Comparing version 0.12.0 to 0.13.0

12

CHANGELOG.json

@@ -5,2 +5,14 @@ {

{
"version": "0.13.0",
"tag": "expect-type_v0.13.0",
"date": "Sat, 16 Oct 2021 13:17:24 GMT",
"comments": {
"minor": [
{
"comment": "Fix constructor parameter comparison (#245)"
}
]
}
},
{
"version": "0.11.0",

@@ -7,0 +19,0 @@ "tag": "expect-type_v0.11.0",

9

CHANGELOG.md
# Change Log - expect-type
This log was last generated on Tue, 29 Jun 2021 08:48:24 GMT and should not be manually modified.
This log was last generated on Sat, 16 Oct 2021 13:17:24 GMT and should not be manually modified.
## 0.13.0
Sat, 16 Oct 2021 13:17:24 GMT
### Minor changes
- Fix constructor parameter comparison (#245)
## 0.11.0

@@ -6,0 +13,0 @@ Tue, 29 Jun 2021 08:48:24 GMT

@@ -20,6 +20,15 @@ export declare type Not<T extends boolean> = T extends true ? false : true;

*/
declare type DeepBrand<T> = IsAny<T> extends true ? Secret : T extends string | number | boolean | symbol | bigint | null | undefined ? T : T extends (...args: infer P) => infer R ? {
export declare type DeepBrand<T> = Or<[IsNever<T>, IsAny<T>, IsUnknown<T>]> extends true ? {
type: 'special';
never: IsNever<T>;
any: IsAny<T>;
unknown: IsUnknown<T>;
} : T extends string | number | boolean | symbol | bigint | null | undefined ? {
type: 'primitive';
value: T;
} : T extends (...args: infer P) => infer R ? {
type: 'function';
params: DeepBrand<P>;
return: DeepBrand<R>;
constructorParams: DeepBrand<ConstructorParams<T>>;
} : {

@@ -33,2 +42,3 @@ type: 'object';

optional: OptionalKeys<T>;
constructorParams: DeepBrand<ConstructorParams<T>>;
};

@@ -35,0 +45,0 @@ export declare type RequiredKeys<T> = Extract<{

@@ -0,0 +0,0 @@ "use strict";

6

package.json
{
"name": "expect-type",
"version": "0.12.0",
"version": "0.13.0",
"keywords": [

@@ -27,4 +27,4 @@ "typescript",

"lint": "rig eslint --cache .",
"prepack": "rushx lint && rig permalink",
"postpack": "rig unpermalink && git status",
"prepack": "rig permalink",
"postpack": "rig unpermalink",
"test": "rig jest"

@@ -31,0 +31,0 @@ },

@@ -364,2 +364,30 @@ # expect-type

```
Distinguish between classes with different constructors:
```typescript
class A {
value: number
constructor(a: 1) {
this.value = a
}
}
class B {
value: number
constructor(b: 2) {
this.value = b
}
}
expectTypeOf<typeof A>().not.toEqualTypeOf<typeof B>()
class C {
value: number
constructor(c: 1) {
this.value = c
}
}
expectTypeOf<typeof A>().toEqualTypeOf<typeof C>()
```
<!-- codegen:end -->

@@ -417,2 +445,2 @@

- built into existing tooling. No extra build step, cli tool, IDE extension, or lint plugin is needed. Just import the function and start writing tests. Failures will be at compile time - they'll appear in your IDE and when you run `tsc`.
- small implementation with no dependencies. <200 lines of code - [take a look!](https://github.com/mmkal/ts/tree/43cf60b/packages/expect-type/src/index.ts) (tsd, for comparison, is [2.6MB](https://bundlephobia.com/result?p=tsd@0.13.1) because it ships a patched version of typescript).
- small implementation with no dependencies. <200 lines of code - [take a look!](https://github.com/mmkal/ts/tree/b4bb636/packages/expect-type/src/index.ts) (tsd, for comparison, is [2.6MB](https://bundlephobia.com/result?p=tsd@0.13.1) because it ships a patched version of typescript).

@@ -23,6 +23,14 @@ export type Not<T extends boolean> = T extends true ? false : true

*/
type DeepBrand<T> = IsAny<T> extends true // avoid `any` matching `unknown`
? Secret
export type DeepBrand<T> = Or<[IsNever<T>, IsAny<T>, IsUnknown<T>]> extends true // avoid `any`/`unknown`/`never` matching
? {
type: 'special'
never: IsNever<T>
any: IsAny<T>
unknown: IsUnknown<T>
}
: T extends string | number | boolean | symbol | bigint | null | undefined
? T
? {
type: 'primitive'
value: T
}
: T extends (...args: infer P) => infer R // avoid functions with different params/return values matching

@@ -33,2 +41,3 @@ ? {

return: DeepBrand<R>
constructorParams: DeepBrand<ConstructorParams<T>>
}

@@ -41,2 +50,3 @@ : {

optional: OptionalKeys<T>
constructorParams: DeepBrand<ConstructorParams<T>>
}

@@ -43,0 +53,0 @@

Sorry, the diff of this file is not supported yet

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