Skip to content

How can I guard interface argument type of function type? #4704

@mizunashi-mana

Description

@mizunashi-mana
// test.ts

interface A {
  a: string;
}
interface B extends A {
  b: string;
}
const a = (a: B) => a.b;
const b = (a: (a: A) => string) => a({a: "param a"});
console.log(b(a));

This is valid typescript code.
But, of course:

$ tsc test.ts
$ node test.js
undefined
$

Is this bug?
Or my misunderstanding?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions