From 700679e528fe0c7615d9df6a197271b99230958e Mon Sep 17 00:00:00 2001 From: Tommy Date: Sat, 24 Feb 2024 00:33:05 -0600 Subject: [PATCH] Add `ts18046` to known errors (#211) --- source/lib/compiler.ts | 1 + source/lib/interfaces.ts | 1 + source/test/fixtures/expect-error/values/index.test-d.ts | 4 +++- source/test/fixtures/expect-error/values/package.json | 7 ++++++- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/source/lib/compiler.ts b/source/lib/compiler.ts index 02a9537e..0535bcfd 100644 --- a/source/lib/compiler.ts +++ b/source/lib/compiler.ts @@ -57,6 +57,7 @@ const expectErrorDiagnosticCodesToIgnore = new Set([ DiagnosticCode.RuntimeWillInvokeDecoratorWithXArgumentsButDecoratorExpectsAtLeastY, DiagnosticCode.AcceptsTooFewArgumentsToBeUsedAsDecoratorHere, DiagnosticCode.PropertyDoesNotExistOnTypeDidYouMean, + DiagnosticCode.ErrorIsOfTypeUnknown, ]); type IgnoreDiagnosticResult = 'preserve' | 'ignore' | Location; diff --git a/source/lib/interfaces.ts b/source/lib/interfaces.ts index 46b22071..0feb0216 100644 --- a/source/lib/interfaces.ts +++ b/source/lib/interfaces.ts @@ -66,6 +66,7 @@ export enum DiagnosticCode { MemberCannotHaveOverrideModifierBecauseItIsNotDeclaredInBaseClass = 4113, MemberMustHaveOverrideModifier = 4114, NewExpressionTargetLackingConstructSignatureHasAnyType = 7009, + ErrorIsOfTypeUnknown = 18046, } export interface Diagnostic { diff --git a/source/test/fixtures/expect-error/values/index.test-d.ts b/source/test/fixtures/expect-error/values/index.test-d.ts index 16a94c6c..7b1f5b09 100644 --- a/source/test/fixtures/expect-error/values/index.test-d.ts +++ b/source/test/fixtures/expect-error/values/index.test-d.ts @@ -13,7 +13,9 @@ try { expectError(foo.bar = 'quux'); expectError(foo.quux); } -} catch {} +} catch (error) { + expectError(error.code); +} expectError(hasProperty({name: 1})); diff --git a/source/test/fixtures/expect-error/values/package.json b/source/test/fixtures/expect-error/values/package.json index de6dc1db..52316ed6 100644 --- a/source/test/fixtures/expect-error/values/package.json +++ b/source/test/fixtures/expect-error/values/package.json @@ -1,3 +1,8 @@ { - "name": "foo" + "name": "foo", + "tsd": { + "compilerOptions": { + "useUnknownInCatchVariables": true + } + } }