diff --git a/source/lib/compiler.ts b/source/lib/compiler.ts index 12e5fcf4..7f7515ca 100644 --- a/source/lib/compiler.ts +++ b/source/lib/compiler.ts @@ -24,6 +24,8 @@ const expectErrordiagnosticCodesToIgnore = new Set([ DiagnosticCode.TypeDoesNotSatisfyTheConstraint, DiagnosticCode.GenericTypeRequiresTypeArguments, DiagnosticCode.ExpectedArgumentsButGotOther, + DiagnosticCode.NoOverloadExpectsCountOfArguments, + DiagnosticCode.NoOverloadExpectsCountOfTypeArguments, DiagnosticCode.NoOverloadMatches, DiagnosticCode.PropertyMissingInType1ButRequiredInType2, DiagnosticCode.TypeHasNoPropertiesInCommonWith, diff --git a/source/lib/interfaces.ts b/source/lib/interfaces.ts index 160cbf97..e8e08eab 100644 --- a/source/lib/interfaces.ts +++ b/source/lib/interfaces.ts @@ -34,8 +34,10 @@ export enum DiagnosticCode { ExpressionNotCallable = 2349, OnlyVoidFunctionIsNewCallable = 2350, ExpressionNotConstructable = 2351, + NoOverloadExpectsCountOfArguments = 2575, ThisContextOfTypeNotAssignableToMethodOfThisType = 2684, PropertyMissingInType1ButRequiredInType2 = 2741, + NoOverloadExpectsCountOfTypeArguments = 2743, NoOverloadMatches = 2769, NewExpressionTargetLackingConstructSignatureHasAnyType = 7009, } diff --git a/source/test/fixtures/expect-error/functions/index.d.ts b/source/test/fixtures/expect-error/functions/index.d.ts index acd85899..154f84ae 100644 --- a/source/test/fixtures/expect-error/functions/index.d.ts +++ b/source/test/fixtures/expect-error/functions/index.d.ts @@ -6,6 +6,11 @@ declare const one: { export default one; +export const two: { + (foo: string): string; + (foo: string, bar: string, baz: string): string; +}; + export const three: { (foo: '*'): string; (foo: 'a' | 'b'): string; diff --git a/source/test/fixtures/expect-error/functions/index.js b/source/test/fixtures/expect-error/functions/index.js index d858d09d..88de192a 100644 --- a/source/test/fixtures/expect-error/functions/index.js +++ b/source/test/fixtures/expect-error/functions/index.js @@ -1,3 +1,11 @@ module.exports.default = (foo, bar) => foo + bar; +module.exports.two = (foo, bar, baz) => { + if (foo!= null && bar != null && baz != null) { + return foo + bar + baz; + } else { + return foo; + } +}; + exports.three = (foo) => 'a'; diff --git a/source/test/fixtures/expect-error/functions/index.test-d.ts b/source/test/fixtures/expect-error/functions/index.test-d.ts index 3d4da8a3..b42506cd 100644 --- a/source/test/fixtures/expect-error/functions/index.test-d.ts +++ b/source/test/fixtures/expect-error/functions/index.test-d.ts @@ -1,8 +1,10 @@ import {expectError} from '../../../..'; -import one, {three} from '.'; +import one, {two, three} from '.'; expectError(one(true, true)); expectError(one('foo', 'bar')); +expectError(two('foo', 'bar')); + // Produces multiple type checker errors in a single `expectError` assertion expectError(three(['a', 'bad'])); diff --git a/source/test/fixtures/expect-error/generics/index.d.ts b/source/test/fixtures/expect-error/generics/index.d.ts index f558eb76..487b40ec 100644 --- a/source/test/fixtures/expect-error/generics/index.d.ts +++ b/source/test/fixtures/expect-error/generics/index.d.ts @@ -3,3 +3,6 @@ declare const one: { }; export default one; + +export function two(foo: T1): T1; +export function two(foo: T1, bar: T2): T3; diff --git a/source/test/fixtures/expect-error/generics/index.js b/source/test/fixtures/expect-error/generics/index.js index f17717f5..78dadca0 100644 --- a/source/test/fixtures/expect-error/generics/index.js +++ b/source/test/fixtures/expect-error/generics/index.js @@ -1,3 +1,11 @@ module.exports.default = (foo, bar) => { return foo + bar; }; + +exports.two = (foo, bar) => { + if (foo != null && bar != null) { + return bar; + } else { + return foo; + } +}; diff --git a/source/test/fixtures/expect-error/generics/index.test-d.ts b/source/test/fixtures/expect-error/generics/index.test-d.ts index e4742ab1..284689dc 100644 --- a/source/test/fixtures/expect-error/generics/index.test-d.ts +++ b/source/test/fixtures/expect-error/generics/index.test-d.ts @@ -1,6 +1,8 @@ import {expectError} from '../../../..'; -import one from '.'; +import one, {two} from '.'; expectError(one(true, true)); expectError(one(1, 2)); + +expectError(two(1, 'bar'));