-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Description
TypeScript Version: 3.9.0-dev.20200215
Search Terms: callable interface
Code
// callable interface
interface Accepted {
(): void;
foo: string;
}
function rejected() { }
rejected.foo = "";
rejected.bar = "";
function check(a: Accepted) { }
// desired: should reject unknown properties
// fail: accepts unknown properties
check(rejected);concrete example
interface ForwardRefRenderFunction<T, P = {}> {
(props: P, ref: Ref<T>): ReactElement | null;
displayName?: string;
}
function forwardRef<T, P = {}>(render: ForwardRefRenderFunction<T, P>): ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>;
function Component() {
return null;
}
Component.propTypes = {}
// should be rejected since `propTypes` aren't supported and add a runtime warning
forwardRef(Component);Expected behavior:
- unknown properties on functions are rejected
Actual behavior:
- unknown properties are accepted
Playground Link:
Related Issues:
Metadata
Metadata
Assignees
Labels
No labels