ts-pattern
Advanced tools
Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "ts-pattern", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Typescript pattern matching library", | ||
@@ -10,3 +10,5 @@ "main": "lib/index.js", | ||
"prepare": "npm run test && npm run clean && npm run build", | ||
"test": "jest" | ||
"test:values": "jest", | ||
"test:types": "tsc --project tests/tsconfig.json", | ||
"test": "npm run test:types && npm run test:values" | ||
}, | ||
@@ -13,0 +15,0 @@ "repository": { |
@@ -382,2 +382,18 @@ import { match, __, Pattern } from '../src'; | ||
}); | ||
it('should narrow down the value type based on type guard', () => { | ||
let n = 20; | ||
const res = match<number, boolean>(n) | ||
.when( | ||
(x): x is 13 => x === 13, | ||
(x) => { | ||
const inferenceCheck: 13 = x; | ||
return true; | ||
} | ||
) | ||
.otherwise(() => false) | ||
.run(); | ||
const inferenceCheck: boolean = res; | ||
}); | ||
}); | ||
@@ -384,0 +400,0 @@ |
{ | ||
"compilerOptions": { | ||
"strict": true | ||
} | ||
"strict": true, | ||
"downlevelIteration": true, | ||
"noEmit": true | ||
}, | ||
"exclude": ["src/"] | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32660
898