Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ksxnodemodules/static-type-assert
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.0.1
Choose a base ref
...
head repository: ksxnodemodules/static-type-assert
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v4.0.0
Choose a head ref
  • 11 commits
  • 10 files changed
  • 1 contributor

Commits on Jun 19, 2019

  1. Create FUNDING.yml

    KSXGitHub authored Jun 19, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    79a18b3 View commit details

Commits on May 14, 2020

  1. Install TypeScript as dev

    KSXGitHub committed May 14, 2020
    Copy the full SHA
    adb6177 View commit details
  2. Create tests

    KSXGitHub committed May 14, 2020
    Copy the full SHA
    f49a72e View commit details
  3. Use standard exports

    KSXGitHub committed May 14, 2020
    Copy the full SHA
    f245ad7 View commit details
  4. Use sane-fmt

    KSXGitHub committed May 14, 2020
    Copy the full SHA
    9b829d1 View commit details
  5. Create tsconfig.json

    KSXGitHub committed May 14, 2020
    Copy the full SHA
    cd9cc0d View commit details
  6. Install sane-fmt

    KSXGitHub committed May 14, 2020
    Copy the full SHA
    64466f1 View commit details
  7. Create test:tsc

    KSXGitHub committed May 14, 2020
    Copy the full SHA
    1aa9d49 View commit details
  8. Create github workflow

    KSXGitHub committed May 14, 2020
    Copy the full SHA
    9d66291 View commit details
  9. Add event

    KSXGitHub committed May 14, 2020
    Copy the full SHA
    938e7eb View commit details
  10. v4.0.0

    KSXGitHub committed May 14, 2020
    Copy the full SHA
    34549de View commit details
Showing with 199 additions and 16 deletions.
  1. +12 −0 .github/FUNDING.yml
  2. +54 −0 .github/workflows/test.yaml
  3. +1 −0 .gitignore
  4. +2 −0 .npmignore
  5. +10 −14 index.d.ts
  6. +4 −1 index.js
  7. +11 −1 package.json
  8. +83 −0 pnpm-lock.yaml
  9. +12 −0 test.ts
  10. +10 −0 tsconfig.json
12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2, KSXGitHub]
patreon: # Replace with a single Patreon username
open_collective: hoang-van-khai
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: ksxgithub
otechie: # Replace with a single Otechie username
custom: # Replace with a single custom sponsorship URL
54 changes: 54 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Test

on:
- push
- pull_request

jobs:
tsc:
name: Type Check

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
node:
- 14.1.0
pnpm:
- 4.11.1

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.vars.node }}
- name: Cache PNPM store
uses: actions/cache@v1.1.2
with:
path: ~/.pnpm-store
key: pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
pnpm-
- name: Install pnpm
uses: pnpm/action-setup@v1.2.0
with:
version: ${{ matrix.pnpm }}
run_install: 'true'
- name: Type Check
run: |
pnpm run test:tsc
fmt:
name: Code Style
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: KSXGitHub/github-actions-sane-fmt@0.2.22
with:
args: |
- --details=diff
- index.d.ts
- index.js
- test.ts
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
/.vscode
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
shrinkwrap.yaml
renovate.*
test.ts
/.vscode
24 changes: 10 additions & 14 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -2,19 +2,15 @@ import {
Extends,
Compare,
Equal,
NotEqual
NotEqual,
} from 'typescript-compare'

declare function assert<Type> (value: Type, ...values: Type[]): typeof assert

declare namespace assert {
function isTrue<Type extends true> (_?: Type): typeof assert
function isFalse<Type extends false> (_?: Type): typeof assert
function extension<A, B> (expect: Extends<A, B>): typeof assert
function compare<A, B> (expect: Compare<A, B>): typeof assert
function strictCompare<A, B> (expect: Compare.Strict<A, B>): typeof assert
function equality<A, B> (expect: Equal<A, B>): typeof assert
function inequality<A, B> (expect: NotEqual<A, B>): typeof assert
}

export = assert
export declare function assert<Type>(value: Type, ...values: Type[]): void
export declare function isTrue<Type extends true>(_?: Type): void
export declare function isFalse<Type extends false>(_?: Type): void
export declare function extension<A, B>(expect: Extends<A, B>): void
export declare function compare<A, B>(expect: Compare<A, B>): void
export declare function strictCompare<A, B>(expect: Compare.Strict<A, B>): void
export declare function equality<A, B>(expect: Equal<A, B>): void
export declare function inequality<A, B>(expect: NotEqual<A, B>): void
export default assert
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -8,5 +8,8 @@ module.exports = Object.assign(assert, {
compare: assert,
strictCompare: assert,
equality: assert,
inequality: assert
inequality: assert,
default: assert,
})

Object.defineProperty(assert, '__esModule', { value: true })
12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "static-type-assert",
"version": "3.0.1",
"version": "4.0.0",
"description": "Asserting type with help of TypeScript compiler",
"main": "index.js",
"repository": {
@@ -18,9 +18,19 @@
"url": "https://github.com/ksxnodemodules/static-type-assert/issues"
},
"homepage": "https://github.com/ksxnodemodules/static-type-assert#readme",
"scripts": {
"fmt": "sane-fmt --write index.d.ts index.js test.ts",
"test:tsc": "tsc --noEmit",
"test:fmt": "sane-fmt index.d.ts index.js test.ts",
"test": "pnpm run test:tsc && pnpm run test:fmt"
},
"dependencies": {
"typescript-compare": "^0.0.2"
},
"devDependencies": {
"@sane-fmt/wasm32-wasi": "^0.2.22",
"typescript": "~3.9.2"
},
"peerDependencies": {
"typescript": "^3.0.3"
}
83 changes: 83 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import assert from './index'

assert<123>(123)
assert<123>(123, 123)
assert<123>(123, 123, 123)

// @ts-expect-error
assert<123>()
// @ts-expect-error
assert<123>(456)
// @ts-expect-error
assert<123>(123, 123, 123, 456, 123)
10 changes: 10 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"strict": true,
"target": "ES2018",
"module": "CommonJS",
"moduleResolution": "Node",
"esModuleInterop": true,
"noEmit": true
}
}