Skip to content

Support for checking arguments with interface type #3

@greghornby

Description

@greghornby

Currently it seems you can only check if the argument is an object, it would be nice to be able to check the properties of an interface. For example, this code should throw an error but it doesn't. And instead it just prints "Hello undefined"

import {CheckParams, Check} from 'runtime-type-checks';

interface Person {
    name: string;
    age: number;
}

class Test {

    constructor() {

    }

    @CheckParams() Hello(person: Person): string {
        return `Hello ${person.name}`
    }
}

var instance = new Test();
console.log(instance.Hello(<any>{a: 5}));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions