Skip to content

Commit

Permalink
Add support for checkFlags enum (#118)
Browse files Browse the repository at this point in the history
Also adds support for clicking on a collapsed tree view label to expand
it rather than having to click on the small arrow next to the label.
  • Loading branch information
Gerrit0 authored Mar 23, 2023
1 parent 6c38b3b commit d3ed6d6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions site/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,7 @@ a:visited {
.propertiesViewer .array > .value {
padding-left: 7px;
}

.treeViewLabel {
cursor: pointer;
}
2 changes: 2 additions & 0 deletions site/src/compiler/CompilerApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export interface CompilerApi {
SymbolFlags: typeof ts.SymbolFlags;
TypeFlags: typeof ts.TypeFlags;
FlowFlags: typeof ts.FlowFlags;
// Internal enum
CheckFlags: {};
tsAstViewer: {
packageName: CompilerPackageNames;
cachedSourceFiles: { [name: string]: SourceFile | undefined };
Expand Down
6 changes: 4 additions & 2 deletions site/src/components/LazyTreeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ import TreeView from "react-treeview";

export interface LazyTreeViewProps {
defaultCollapsed: boolean;
nodeLabel: React.ReactNode;
nodeLabel: string | undefined;
getChildren: () => JSX.Element;
}

export function LazyTreeView(props: LazyTreeViewProps) {
const [isCollapsed, setIsCollapsed] = useState(props.defaultCollapsed);

return <TreeView nodeLabel={props.nodeLabel} collapsed={isCollapsed} onClick={toggleState}>{isCollapsed ? undefined : props.getChildren()}</TreeView>;
const label = <span className="treeViewLabel" onClick={toggleState}>{props.nodeLabel}</span>

return <TreeView nodeLabel={label} collapsed={isCollapsed} onClick={toggleState}>{isCollapsed ? undefined : props.getChildren()}</TreeView>;

function toggleState() {
setIsCollapsed(!isCollapsed);
Expand Down
4 changes: 4 additions & 0 deletions site/src/components/PropertiesViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,10 @@ function getCustomValueDiv(context: Context, key: string, value: any, parent: an
if (isTsSymbol(parent) && key === "flags") {
return getEnumFlagElement(context.api.SymbolFlags, value);
}
// TS pre-5.0 puts this on the symbol, TS 5.0 puts it on a plain "links" object
if (key === "checkFlags" && typeof value === "number") {
return getEnumFlagElement(context.api.CheckFlags, value);
}
if (isFlowNode(parent) && key === "flags") {
return getEnumFlagElement(context.api.FlowFlags, value);
}
Expand Down

0 comments on commit d3ed6d6

Please sign in to comment.