Closed
Description
TypeScript Version: 3.9.2
Search Terms: interface, function types
Expected behavior:
- Compiler error if overloads are not supported
foo
is resolved tonumber
,string
,null
type
Actual behavior: foo
becomes any
on a
& b
Parameter 'foo' implicitly has an 'any' type.
Related Issues: N/A
Code
interface A {
(foo: string): string
(foo: number): number
}
interface B extends A {
(foo: null): null
}
const a: A = (foo) => foo
const b: B = (foo) => foo
console.log(a, b)
Output
"use strict";
const a = (foo) => foo;
const b = (foo) => foo;
console.log(a, b);
Compiler Options
{
"compilerOptions": {
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": true,
"strictBindCallApply": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"alwaysStrict": true,
"esModuleInterop": true,
"declaration": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"moduleResolution": 2,
"target": "ES2017",
"jsx": "React",
"module": "ESNext"
}
}
Playground Link: Provided