@bedard/types
Advanced tools
Comparing version 0.7.0 to 0.8.0
# Changelog | ||
## 0.8.0 | ||
- Removed build step, node module will expose src files directly. | ||
- [`Transparent<T>`](https://github.com/scottbedard/types#transparentt) | ||
## 0.7.0 | ||
@@ -4,0 +8,0 @@ |
@@ -9,7 +9,3 @@ { | ||
"@types/jest": "^27.0.2", | ||
"copyfiles": "^2.4.1", | ||
"jest": "^27.2.1", | ||
"rollup": "^2.56.3", | ||
"rollup-plugin-delete": "^2.0.0", | ||
"rollup-plugin-ts": "^1.4.2", | ||
"ts-jest": "^27.0.5", | ||
@@ -20,4 +16,2 @@ "typescript": "^4.4.3" | ||
"license": "MIT", | ||
"main": "dist/index.js", | ||
"module": "dist/index.esm.js", | ||
"name": "@bedard/types", | ||
@@ -29,5 +23,2 @@ "repository": { | ||
"scripts": { | ||
"build": "rollup -c", | ||
"copy-dts": "copyfiles -u 1 \"src/**/*.d.ts\" dist", | ||
"postbuild": "npm run copy-dts", | ||
"publish:ci": "node ./scripts/publish.js", | ||
@@ -38,3 +29,3 @@ "test:clear": "jest --clearCache", | ||
}, | ||
"version": "0.7.0" | ||
"version": "0.8.0" | ||
} |
# `@bedard/types` | ||
[](https://github.com/scottbedard/types/actions/workflows/test.yml) | ||
[](https://david-dm.org/scottbedard/types) | ||
[](https://david-dm.org/scottbedard/types?type=dev) | ||
[](https://www.npmjs.com/package/@bedard/types) | ||
@@ -56,2 +54,3 @@ [](https://github.com/scottbedard/types/blob/main/LICENSE) | ||
- [`SymmetricDifference<A, B>`](#symmetricdifferencea-b) | ||
- [`Transparent<T>`](#transparentt) | ||
- [`ValueOf<T>`](#valueoft) | ||
@@ -124,3 +123,3 @@ - [`Without<A, B>`](#withouta-b) | ||
Types `true` if `A` and `B` are equal. This is mainly used with [`Expect`](#expect) to verify that types are working as expected. See [`NotEqual`](#notequal) for the inverse of this type. | ||
Types `true` if `A` and `B` are equal. This is mainly used with [`Expect`](#expectt) to verify that types are working as expected. See [`NotEqual`](#notequala-b) for the inverse of this type. | ||
@@ -135,3 +134,3 @@ ```ts | ||
Verify that `T` is `true`. This allows for assertions to be made using the type system. See [`Equal`](#equal) and [`NotEqual`](#notequal) for more usage examples. | ||
Verify that `T` is `true`. This allows for assertions to be made using the type system. See [`Equal`](#equala-b) and [`NotEqual`](#notequala-b) for more usage examples. | ||
@@ -270,3 +269,3 @@ ```ts | ||
Types `true` if `A` does not equal `B`. This type is mainly used with [`Expect`](#expect) to verify that types are working as expected. See [`Equal`](#equal) for the inverse of this type. | ||
Types `true` if `A` does not equal `B`. This type is mainly used with [`Expect`](#expectt) to verify that types are working as expected. See [`Equal`](#equala-b) for the inverse of this type. | ||
@@ -427,2 +426,12 @@ ```ts | ||
### `Transparent<T>` | ||
A type that does not encode any additional data. This type the inverse of [`Opaque<T>`](#opaquet-token). | ||
```ts | ||
import { Transparent } from '@bedard/types' | ||
type NonOpaqueString = Transparent<string> | ||
``` | ||
### `ValueOf<T>` | ||
@@ -429,0 +438,0 @@ |
@@ -13,3 +13,3 @@ const exec = require('child_process').execSync | ||
exec('npm run build && npm publish') | ||
exec('npm publish') | ||
} | ||
@@ -16,0 +16,0 @@ |
@@ -1,3 +0,1 @@ | ||
import { Alphabet } from './utils' | ||
import { Equal } from './Equal' | ||
import { Last } from './Last' | ||
@@ -4,0 +2,0 @@ import { Split } from './Split' |
@@ -22,3 +22,3 @@ export { AllEqual } from './AllEqual' | ||
export { NotEqual } from './NotEqual' | ||
export { Opaque } from './Opaque' | ||
export { Opaque, Transparent } from './Opaque' | ||
export { PascalCase } from './PascalCase' | ||
@@ -40,4 +40,3 @@ export { PascalCaseKeys } from './PascalCaseKeys' | ||
export { XOR } from './XOR' | ||
export * from './utils' | ||
export const version = '0.7.0' | ||
export const version = '0.8.0' |
declare const tag: unique symbol | ||
/** | ||
* Opaque type `T` with an optional `Token`. | ||
* Opaque type `T` that encodes an additional `Token`. | ||
* | ||
@@ -12,1 +12,6 @@ * @example | ||
export type Opaque<T, Token = unknown> = T & { [tag]: Token } | ||
/** | ||
* Transparent type `T` that does not encode additional information. | ||
*/ | ||
export type Transparent<T> = T & { [tag]?: never } |
@@ -1,2 +0,2 @@ | ||
import { Opaque } from './index' | ||
import { Opaque, Transparent } from './index' | ||
@@ -30,2 +30,13 @@ describe('Opaque', () => { | ||
}) | ||
it('transparent', () => { | ||
const foo: Transparent<string> = 'foo' | ||
const bar = 'bar' as Opaque<string> | ||
// @ts-expect-error | ||
const baz: Transparent<string> = bar | ||
// @ts-expect-error | ||
const qux: Transparent<string> = 6 | ||
}) | ||
}) |
{ | ||
"compilerOptions": { | ||
"baseUrl": "src", | ||
"declaration": true, | ||
"declarationDir": "./dist", | ||
"esModuleInterop": true, | ||
@@ -10,3 +8,2 @@ "module": "es6", | ||
"noImplicitAny": true, | ||
"outDir": "./dist", | ||
"paths": { | ||
@@ -21,3 +18,2 @@ "@/*": ["*"], | ||
"exclude": [ | ||
"dist", | ||
"node_modules", | ||
@@ -24,0 +20,0 @@ "scripts", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
4
469
48433
87
1180