Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: fix
packages:
- "@typespec/playground"
---

Guard against diagnostic reported without a target
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,18 @@ const DiagnosticItem: FunctionComponent<DiagnosticItemProps> = ({ diagnostic, on
};

const DiagnosticTargetLink = memo(({ target }: { target: DiagnosticTarget | typeof NoTarget }) => {
if (target === undefined) {
return (
<span title="Diagnostic didn't report a target. This is a bug on the emitter.">
No target
</span>
);
}
if (typeof target === "symbol") {
return <span></span>;
}
const location = getSourceLocation(target);

const file = location.file.path === "/test/main.tsp" ? "" : `${location.file.path}:`;
const { line, character } = location.file.getLineAndCharacterOfPosition(location.pos);
return (
Expand Down
Loading