From 114db77cd94a2ba96d2a3bceaf687296efd58129 Mon Sep 17 00:00:00 2001 From: Tommy Date: Sun, 5 Mar 2023 22:13:48 -0600 Subject: [PATCH] Add diagnostic for TS error 2707 (#173) --- source/lib/compiler.ts | 1 + source/lib/interfaces.ts | 1 + source/test/fixtures/expect-error/generics/index.d.ts | 2 ++ source/test/fixtures/expect-error/generics/index.test-d.ts | 4 +++- 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/source/lib/compiler.ts b/source/lib/compiler.ts index d34476a8..34ddaaf2 100644 --- a/source/lib/compiler.ts +++ b/source/lib/compiler.ts @@ -22,6 +22,7 @@ const expectErrordiagnosticCodesToIgnore = new Set([ DiagnosticCode.TypeIsNotAssignableToOtherType, DiagnosticCode.TypeDoesNotSatisfyTheConstraint, DiagnosticCode.GenericTypeRequiresTypeArguments, + DiagnosticCode.GenericTypeRequiresBetweenXAndYTypeArugments, DiagnosticCode.ExpectedArgumentsButGotOther, DiagnosticCode.ExpectedAtLeastArgumentsButGotOther, DiagnosticCode.NoOverloadExpectsCountOfArguments, diff --git a/source/lib/interfaces.ts b/source/lib/interfaces.ts index 775dea97..363a5fa3 100644 --- a/source/lib/interfaces.ts +++ b/source/lib/interfaces.ts @@ -26,6 +26,7 @@ export enum DiagnosticCode { AwaitExpressionOnlyAllowedWithinAsyncFunction = 1308, TopLevelAwaitOnlyAllowedWhenModuleESNextOrSystem = 1378, GenericTypeRequiresTypeArguments = 2314, + GenericTypeRequiresBetweenXAndYTypeArugments = 2707, TypeIsNotAssignableToOtherType = 2322, TypeDoesNotSatisfyTheConstraint = 2344, PropertyDoesNotExistOnType = 2339, diff --git a/source/test/fixtures/expect-error/generics/index.d.ts b/source/test/fixtures/expect-error/generics/index.d.ts index 487b40ec..e43e27eb 100644 --- a/source/test/fixtures/expect-error/generics/index.d.ts +++ b/source/test/fixtures/expect-error/generics/index.d.ts @@ -6,3 +6,5 @@ export default one; export function two(foo: T1): T1; export function two(foo: T1, bar: T2): T3; + +export type Three = [T1, T2, T3]; 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 284689dc..dc181493 100644 --- a/source/test/fixtures/expect-error/generics/index.test-d.ts +++ b/source/test/fixtures/expect-error/generics/index.test-d.ts @@ -1,8 +1,10 @@ import {expectError} from '../../../..'; -import one, {two} from '.'; +import one, {two, type Three} from '.'; expectError(one(true, true)); expectError(one(1, 2)); expectError(two(1, 'bar')); + +expectError('');