-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path21868.ts
More file actions
18 lines (14 loc) · 817 Bytes
/
21868.ts
File metadata and controls
18 lines (14 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Issue #21868: Function with no parameters incorrectly assignable to function type expecting parameters
// https://github.com/microsoft/TypeScript/issues/21868
// This should be an error because the function type expects a parameter
// but the implementation completely ignores it
const some: ((arg: string) => boolean) = () => true;
// Another example of the same issue
const processor: ((data: string, index: number) => void) = () => {
console.log("Processing without using any parameters");
};
// This is problematic because callers expect the function to use the parameters
function callProcessor(fn: (data: string, index: number) => void) {
fn("important data", 42); // Parameters are ignored by the implementation
}
callProcessor(processor); // Should error - processor ignores required parameters