From ebf13df7b849a8c403ff88d65ae7c764d2367b45 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 7 Mar 2025 17:34:45 -0800 Subject: [PATCH 1/2] Consistently use the base type of literals (like in the original code). --- internal/checker/relater.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/checker/relater.go b/internal/checker/relater.go index 87c4269351..e99e0c1a88 100644 --- a/internal/checker/relater.go +++ b/internal/checker/relater.go @@ -4699,24 +4699,24 @@ func (r *Relater) reportRelationError(message *diagnostics.Message, source *Type case diagnostics.Excessive_complexity_comparing_types_0_and_1, diagnostics.Excessive_stack_depth_comparing_types_0_and_1, diagnostics.The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1: - if r.chainArgsMatch(sourceType, targetType) { + if r.chainArgsMatch(generalizedSourceType, targetType) { return } // Suppress if next message is a missing property message for source and target and we're not // reporting on interface implementation case diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2: - if !isInterfaceImplementationMessage(message) && r.chainArgsMatch(nil, sourceType, targetType) { + if !isInterfaceImplementationMessage(message) && r.chainArgsMatch(nil, generalizedSourceType, targetType) { return } // Suppress if next message is a missing property message for source and target and we're not // reporting on interface implementation case diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more, diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2: - if !isInterfaceImplementationMessage(message) && r.chainArgsMatch(sourceType, targetType) { + if !isInterfaceImplementationMessage(message) && r.chainArgsMatch(generalizedSourceType, targetType) { return } } - r.reportError(message, sourceType, targetType) + r.reportError(message, generalizedSourceType, targetType) } func (r *Relater) reportError(message *diagnostics.Message, args ...any) { From 0e722c6ecb565f4630a316b19c5dab1736defb36 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 7 Mar 2025 17:35:17 -0800 Subject: [PATCH 2/2] Accepted baselines. --- .../reference/compiler/simpleTestMultiFile.errors.txt | 8 ++++---- .../reference/compiler/simpleTestSingleFile.errors.txt | 4 ++-- .../reference/tscWatch/noEmit/semantic-errors.js | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/testdata/baselines/reference/compiler/simpleTestMultiFile.errors.txt b/testdata/baselines/reference/compiler/simpleTestMultiFile.errors.txt index 87a0d9fe1c..4a2119b564 100644 --- a/testdata/baselines/reference/compiler/simpleTestMultiFile.errors.txt +++ b/testdata/baselines/reference/compiler/simpleTestMultiFile.errors.txt @@ -1,13 +1,13 @@ -/src/bar.ts(1,7): error TS2322: Type '1' is not assignable to type 'string'. -/src/foo.ts(1,7): error TS2322: Type '""' is not assignable to type 'number'. +/src/bar.ts(1,7): error TS2322: Type 'number' is not assignable to type 'string'. +/src/foo.ts(1,7): error TS2322: Type 'string' is not assignable to type 'number'. ==== /src/foo.ts (1 errors) ==== const x: number = ""; ~ -!!! error TS2322: Type '""' is not assignable to type 'number'. +!!! error TS2322: Type 'string' is not assignable to type 'number'. ==== /src/bar.ts (1 errors) ==== const y: string = 1; ~ -!!! error TS2322: Type '1' is not assignable to type 'string'. \ No newline at end of file +!!! error TS2322: Type 'number' is not assignable to type 'string'. \ No newline at end of file diff --git a/testdata/baselines/reference/compiler/simpleTestSingleFile.errors.txt b/testdata/baselines/reference/compiler/simpleTestSingleFile.errors.txt index 012053821b..b58141bc77 100644 --- a/testdata/baselines/reference/compiler/simpleTestSingleFile.errors.txt +++ b/testdata/baselines/reference/compiler/simpleTestSingleFile.errors.txt @@ -1,7 +1,7 @@ -simpleTestSingleFile.ts(1,7): error TS2322: Type '""' is not assignable to type 'number'. +simpleTestSingleFile.ts(1,7): error TS2322: Type 'string' is not assignable to type 'number'. ==== simpleTestSingleFile.ts (1 errors) ==== const x: number = ""; ~ -!!! error TS2322: Type '""' is not assignable to type 'number'. \ No newline at end of file +!!! error TS2322: Type 'string' is not assignable to type 'number'. \ No newline at end of file diff --git a/testdata/baselines/reference/tscWatch/noEmit/semantic-errors.js b/testdata/baselines/reference/tscWatch/noEmit/semantic-errors.js index a81aceb13f..9ddf6af8f0 100644 --- a/testdata/baselines/reference/tscWatch/noEmit/semantic-errors.js +++ b/testdata/baselines/reference/tscWatch/noEmit/semantic-errors.js @@ -141,7 +141,7 @@ CompilerOptions::{ Output:: -a.ts(1,7): error TS2322: Type '"hello"' is not assignable to type 'number'. +a.ts(1,7): error TS2322: Type 'string' is not assignable to type 'number'. Found 1 error in a.ts:1 @@ -194,7 +194,7 @@ Output:: Edit:: introduce error Output:: -a.ts(1,7): error TS2322: Type '"hello"' is not assignable to type 'number'. +a.ts(1,7): error TS2322: Type 'string' is not assignable to type 'number'. Found 1 error in a.ts:1 @@ -209,7 +209,7 @@ const a: number = "hello" Edit:: emit when error Output:: -a.ts(1,7): error TS2322: Type '"hello"' is not assignable to type 'number'. +a.ts(1,7): error TS2322: Type 'string' is not assignable to type 'number'. Found 1 error in a.ts:1 @@ -228,7 +228,7 @@ Found 1 error in a.ts:1 Edit:: no emit run when error Output:: -a.ts(1,7): error TS2322: Type '"hello"' is not assignable to type 'number'. +a.ts(1,7): error TS2322: Type 'string' is not assignable to type 'number'. Found 1 error in a.ts:1