-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improvements to type relation errors (#4357)
fix #3291 Changes: 1. Figure out the most accurate location for the diagnostic 2. If diagnostic target a child node of the base diagnostic target then emit diagnostic directly there 3. Otherwise emit back at the root(or closest child node) and build stack of error message Example the following would now emit the error on a ```ts const b = #{ prop: #{a: "abc"}}; const a: {prop: {}} = b; ``` ``` Type '{ prop: { a: "abc" } }' is not assignable to type '{ prop: {} }' Type '{ a: "abc" }' is not assignable to type '{}' Object value may only specify known properties, and 'a' does not exist in type '{}'. ``` Previously the error would have been in the complete wrong place <img width="271" alt="image" src="https://github.com/user-attachments/assets/c403d1ec-3611-4ad6-87b0-2e0a075dc1c5">
- Loading branch information
1 parent
89e19ef
commit 03d4fca
Showing
6 changed files
with
388 additions
and
136 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
.chronus/changes/type-relation-improvements-2024-8-6-13-13-15.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking | ||
changeKind: feature | ||
packages: | ||
- "@typespec/compiler" | ||
--- | ||
|
||
Improvements to type relation errors: Show stack when it happens in a nested property otherwise show up in the correct location. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.