import { SemVar } from 'validated-types';
type IsRecursiveCall = SemVar<boolean, 'isRecursiveCall'>
type IsInternalCall = SemVar<boolean, 'isInternalCall'>;
function myFunc(isRecursiveCall: IsRecursiveCall, isInternalCall: IsInternalCall) {
console.log(isRecursiveCall.value);
console.log(isInternalCall.value);
}
// Only this will succeed
myFunc(new SemVar('isRecursiveCall', false), new SemVar('isInternalCall', true));
// These will fail during compilation
myFunc(new SemVar('isInternalCall', true), new SemVar('isRecursiveCall', false));
myFunc(true, true);
myFunc(new SemVar('isSomethingElse', true), new SemVar('isInternalCall', true));
myFunc(new SemVar('isRecursiveCall', false), new SemVar('isSomethingElse', true));
myFunc(new SemVar('isSomethingElse', true), new SemVar('isSomethingElse', true));
Semantic types and variables
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.