Skip to content

Commit

Permalink
Merge pull request #53 from artyom-ar/main
Browse files Browse the repository at this point in the history
fix issue #50, add subtype of constrait
  • Loading branch information
yoavbls authored Apr 29, 2023
2 parents fed2989 + fe2a541 commit 90ab9b5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/format/formatDiagnosticMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const formatDiagnosticMessage = (
.replaceAll(/^'"[^"]*"'$/g, formatTypeScriptBlock)
// Format types
.replaceAll(
/(type|type alias|interface|module|file|file name|method's) '(.*?)'(?=[\s.])/gi,
/(type|type alias|interface|module|file|file name|method's|subtype of constraint) '(.*?)'(?=[\s(.|,)])/gi,
(_, p1: string, p2: string) => formatTypeOrModuleBlock(_, p1, p2, format)
)
// Format reversed types
Expand Down
6 changes: 6 additions & 0 deletions src/test/suite/errorMessageMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,10 @@ Type '(newIds: number[]) => void' is not assignable to type '(selectedId: string
Type 'string' is not assignable to type 'number'.
`;

const errorWithComma = d`
Argument of type '{ filters: Filters; } & T' is not assignable to parameter of type 'T & F'.
Type '{ filters: Filters; } & T' is not assignable to type 'F'.
'{ filters: Filters; } & T' is assignable to the constraint of type 'F', but 'F' could be instantiated with a different subtype of constraint '{ filters: Filters; }'.
`;

("Property 'user' is missing in type '{ person: { username: string; email: string; }; }' but required in type '{ user: { name: string; email: `${string}@${string}.${string}`; age: number; }; }'.");

0 comments on commit 90ab9b5

Please sign in to comment.