diff --git a/deno.json b/deno.json index 36385ead8..dbf953361 100644 --- a/deno.json +++ b/deno.json @@ -20,6 +20,7 @@ }, "lint": { "rules": { + "include": ["verbatim-module-syntax"], "exclude": ["no-explicit-any", "no-sloppy-imports"] }, "exclude": [ diff --git a/deno.lock b/deno.lock index 80aae771a..f0e71f097 100644 --- a/deno.lock +++ b/deno.lock @@ -27,19 +27,19 @@ "npm:@viz-js/viz@^3.3.1": "3.8.0", "npm:allotment@^1.20.0": "1.20.2_react@18.3.1_react-dom@18.3.1__react@18.3.1", "npm:circular-json@~0.5.9": "0.5.9", - "npm:code-block-writer@^13.0.2": "13.0.2", + "npm:code-block-writer@^13.0.3": "13.0.3", "npm:glob@^10.3.10": "10.4.5", "npm:lz-string@^1.4.4": "1.5.0", - "npm:monaco-editor@0.44": "0.44.0", + "npm:monaco-editor@~0.52.2": "0.52.2", "npm:react-dom@^18.2.0": "18.3.1_react@18.3.1", - "npm:react-monaco-editor@0.55.0": "0.55.0_@types+react@18.3.5_monaco-editor@0.44.0_react@18.3.1", + "npm:react-monaco-editor@0.56.2": "0.56.2_@types+react@18.3.5_monaco-editor@0.52.2_react@18.3.1", "npm:react-spinners@~0.13.6": "0.13.8_react@18.3.1_react-dom@18.3.1__react@18.3.1", "npm:react-treeview@~0.4.7": "0.4.7_react@18.3.1", "npm:react@^18.2.0": "18.3.1", "npm:ts-factory-code-generator-generator@0.7": "0.7.0", - "npm:ts-morph@23": "23.0.0", - "npm:typescript@5.0.2": "5.0.2", - "npm:vite-plugin-monaco-editor@^1.1.0": "1.1.0_monaco-editor@0.44.0", + "npm:ts-morph@25": "25.0.0", + "npm:typescript@5.7.2": "5.7.2", + "npm:vite-plugin-monaco-editor@^1.1.0": "1.1.0_monaco-editor@0.52.2", "npm:vite@^5.2.9": "5.4.3_@types+node@20.16.2" }, "jsr": { @@ -468,16 +468,15 @@ "dependencies": [ "fast-glob", "minimatch@5.1.6", - "mkdirp@1.0.4", + "mkdirp", "path-browserify" ] }, - "@ts-morph/common@0.24.0": { - "integrity": "sha512-c1xMmNHWpNselmpIqursHeOHHBTIsJLbB+NuovbTTRCNiTLEr/U9dbJ8qy0jd/O2x5pc3seWuOUN5R2IoOTp8A==", + "@ts-morph/common@0.26.0": { + "integrity": "sha512-/RmKAtctStXqM5nECMQ46duT74Hoig/DBzhWXGHcodlDNrgRbsbwwHqSKFNbca6z9Xt/CUWMeXOsC9QEN1+rqw==", "dependencies": [ "fast-glob", "minimatch@9.0.5", - "mkdirp@3.0.1", "path-browserify" ] }, @@ -639,8 +638,8 @@ "code-block-writer@11.0.3": { "integrity": "sha512-NiujjUFB4SwScJq2bwbYUtXbZhBSlY6vYzm++3Q6oC+U+injTqfPYFK8wS9COOmb2lueqp0ZRB4nK1VYeHgNyw==" }, - "code-block-writer@13.0.2": { - "integrity": "sha512-XfXzAGiStXSmCIwrkdfvc7FS5Dtj8yelCtyOf2p2skCAfvLd6zu0rGzuS9NSCO3bq1JKpFZ7tbKdKlcd5occQA==" + "code-block-writer@13.0.3": { + "integrity": "sha512-Oofo0pq3IKnsFtuHqSF7TqBfr71aeyZDVJ0HpmqB7FBM2qEigL0iPONSCZSO9pE9dZTAxANe5XHG9Uy0YMv8cg==" }, "color-convert@1.9.3": { "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", @@ -876,11 +875,8 @@ "mkdirp@1.0.4": { "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==" }, - "mkdirp@3.0.1": { - "integrity": "sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==" - }, - "monaco-editor@0.44.0": { - "integrity": "sha512-5SmjNStN6bSuSE5WPT2ZV+iYn1/yI9sd4Igtk23ChvqB7kDk9lZbB9F5frsuvpB+2njdIeGGFf2G4gbE6rCC9Q==" + "monaco-editor@0.52.2": { + "integrity": "sha512-GEQWEZmfkOGLdd3XK8ryrfWz3AIP8YymVXiPHEdewrUq7mh0qrKrfHLNCXcbB6sTnMLnOZ3ztSiKcciFUkIJwQ==" }, "ms@2.1.3": { "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" @@ -946,8 +942,8 @@ "react-is@16.13.1": { "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" }, - "react-monaco-editor@0.55.0_@types+react@18.3.5_monaco-editor@0.44.0_react@18.3.1": { - "integrity": "sha512-GdEP0Q3Rn1dczfKEEyY08Nes5plWwIYU4sWRBQO0+jsQWQsKMHKCC6+hPRwR7G/4aA3V/iU9jSmWPzVJYMVFSQ==", + "react-monaco-editor@0.56.2_@types+react@18.3.5_monaco-editor@0.52.2_react@18.3.1": { + "integrity": "sha512-Tp5U3QF9h92Cuf0eIhGd8Jyef8tPMlEJC2Dk1GeuR/hj6WoFn8AgjVX/2dv+3l5DvpMUpAECcFarc3eFKTBZ5w==", "dependencies": [ "@types/react", "monaco-editor", @@ -1094,15 +1090,15 @@ "code-block-writer@11.0.3" ] }, - "ts-morph@23.0.0": { - "integrity": "sha512-FcvFx7a9E8TUe6T3ShihXJLiJOiqyafzFKUO4aqIHDUCIvADdGNShcbc2W5PMr3LerXRv7mafvFZ9lRENxJmug==", + "ts-morph@25.0.0": { + "integrity": "sha512-ERPTUVO5qF8cEGJgAejGOsCVlbk8d0SDyiJsucKQT5XgqoZslv0Qml+gnui6Yy6o+uQqw5SestyW2HvlVtT/Sg==", "dependencies": [ - "@ts-morph/common@0.24.0", - "code-block-writer@13.0.2" + "@ts-morph/common@0.26.0", + "code-block-writer@13.0.3" ] }, - "typescript@5.0.2": { - "integrity": "sha512-wVORMBGO/FAs/++blGNeAVdbNKtIh1rbBL2EyQ1+J9lClJ93KiiKe8PmFIVdXhHcyv44SL9oglmfeSsndo0jRw==" + "typescript@5.7.2": { + "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==" }, "undici-types@6.19.8": { "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==" @@ -1123,7 +1119,7 @@ "react-dom" ] }, - "vite-plugin-monaco-editor@1.1.0_monaco-editor@0.44.0": { + "vite-plugin-monaco-editor@1.1.0_monaco-editor@0.52.2": { "integrity": "sha512-IvtUqZotrRoVqwT0PBBDIZPNraya3BxN/bfcNfnxZ5rkJiGcNtO5eAOWWSgT7zullIAEqQwxMU83yL9J5k7gww==", "dependencies": [ "monaco-editor" @@ -1184,18 +1180,18 @@ "npm:@viz-js/viz@^3.3.1", "npm:allotment@^1.20.0", "npm:circular-json@~0.5.9", - "npm:code-block-writer@^13.0.2", + "npm:code-block-writer@^13.0.3", "npm:glob@^10.3.10", "npm:lz-string@^1.4.4", - "npm:monaco-editor@0.44", + "npm:monaco-editor@~0.52.2", "npm:react-dom@^18.2.0", - "npm:react-monaco-editor@0.55.0", + "npm:react-monaco-editor@0.56.2", "npm:react-spinners@~0.13.6", "npm:react-treeview@~0.4.7", "npm:react@^18.2.0", "npm:ts-factory-code-generator-generator@0.7", - "npm:ts-morph@23", - "npm:typescript@5.0.2", + "npm:ts-morph@25", + "npm:typescript@5.7.2", "npm:vite-plugin-monaco-editor@^1.1.0", "npm:vite@^5.2.9" ] diff --git a/package.json b/package.json index f225cbc29..e7f677fea 100644 --- a/package.json +++ b/package.json @@ -12,15 +12,15 @@ "@viz-js/viz": "^3.3.1", "allotment": "^1.20.0", "circular-json": "^0.5.9", - "code-block-writer": "^13.0.2", + "code-block-writer": "^13.0.3", "lz-string": "^1.4.4", - "monaco-editor": "^0.44.0", + "monaco-editor": "^0.52.2", "react": "^18.2.0", "react-dom": "^18.2.0", - "react-monaco-editor": "0.55.0", + "react-monaco-editor": "0.56.2", "react-spinners": "^0.13.6", "react-treeview": "^0.4.7", - "ts-morph": "^23.0.0" + "ts-morph": "^25.0.0" }, "devDependencies": { "@types/circular-json": "^0.4.0", @@ -32,7 +32,7 @@ "@vitejs/plugin-react": "^4.2.1", "glob": "^10.3.10", "ts-factory-code-generator-generator": "^0.7.0", - "typescript": "5.0.2", + "typescript": "5.7.2", "vite": "^5.2.9", "vite-plugin-monaco-editor": "^1.1.0" } diff --git a/scripts/analyzers/TsAnalyzer.ts b/scripts/analyzers/TsAnalyzer.ts index 333e1ea43..256c01770 100644 --- a/scripts/analyzers/TsAnalyzer.ts +++ b/scripts/analyzers/TsAnalyzer.ts @@ -1,4 +1,4 @@ -import { Project, Symbol, Type } from "ts-morph"; +import { Project, type Symbol, type Type } from "ts-morph"; export class TsAnalyzer { private readonly tsSymbol: Symbol; diff --git a/src/AppContext.tsx b/src/AppContext.tsx index 51cd8656b..8382271cf 100644 --- a/src/AppContext.tsx +++ b/src/AppContext.tsx @@ -4,12 +4,12 @@ import { compilerVersionCollection, getCompilerApi, hasLoadedCompilerApi, - ScriptKind, - ScriptTarget, + type ScriptKind, + type ScriptTarget, } from "./compiler/index.js"; -import { CodeEditorTheme } from "./components/index.js"; +import type { CodeEditorTheme } from "./components/index.js"; import { appReducer, deriveEditorTheme } from "./reducers/index.js"; -import { ApiLoadingState, StoreState } from "./types/index.js"; +import { ApiLoadingState, type StoreState } from "./types/index.js"; import { sleep, StateSaver, UrlSaver } from "./utils/index.js"; const initialScriptTarget: ScriptTarget = 99 /* Latest */; diff --git a/src/actions/index.tsx b/src/actions/index.tsx index e4da11d9b..14796d578 100644 --- a/src/actions/index.tsx +++ b/src/actions/index.tsx @@ -1,6 +1,6 @@ -import { CompilerApi, Node } from "../compiler/index.js"; +import type { CompilerApi, Node } from "../compiler/index.js"; import { actions as constants } from "../constants/index.js"; -import { ApiLoadingState, OptionsState } from "../types/index.js"; +import type { ApiLoadingState, OptionsState } from "../types/index.js"; export interface SetCode { type: constants.SET_CODE; diff --git a/src/compiler/CompilerApi.ts b/src/compiler/CompilerApi.ts index 2708ddf5e..87d4b8c1d 100644 --- a/src/compiler/CompilerApi.ts +++ b/src/compiler/CompilerApi.ts @@ -1,5 +1,18 @@ -import * as ts from "typescript"; -import { CompilerPackageNames } from "./compilerVersions.generated.js"; +import type * as ts from "typescript"; +import type { CompilerPackageNames } from "./compilerVersions.generated.js"; + +export declare enum FlowFlags { + TrueCondition, + FalseCondition, + Start, + Assignment, + BranchLabel, + LoopLabel, + Call, + SwitchClause, + Shared, + Referenced, +} export interface CompilerApi { createSourceFile: typeof ts.createSourceFile; @@ -15,7 +28,7 @@ export interface CompilerApi { ObjectFlags: typeof ts.ObjectFlags; SymbolFlags: typeof ts.SymbolFlags; TypeFlags: typeof ts.TypeFlags; - FlowFlags: typeof ts.FlowFlags; + FlowFlags: typeof FlowFlags; // Internal enum CheckFlags: object; // Internal enum @@ -48,4 +61,13 @@ export type TypeFlags = ts.TypeFlags; export type SyntaxKind = ts.SyntaxKind; export type CompilerHost = ts.CompilerHost; export type CommentRange = ts.CommentRange; -export type FlowNode = ts.FlowNode; + +export interface FlowNode { + id?: object; + node?: { + getText(): string; + }; + antecedents: FlowNode[]; + flags: FlowFlags; + getText(): string; +} diff --git a/src/compiler/convertOptions.test.ts b/src/compiler/convertOptions.test.ts index 573b0135c..6f56c85d3 100644 --- a/src/compiler/convertOptions.test.ts +++ b/src/compiler/convertOptions.test.ts @@ -1,6 +1,6 @@ import { expect } from "@std/expect"; import { Theme } from "../types/index.js"; -import { CompilerApi } from "./CompilerApi.js"; +import type { CompilerApi } from "./CompilerApi.js"; import { convertOptions } from "./convertOptions.js"; function getCompilerApi(scriptKind: any, scriptTarget: any) { diff --git a/src/compiler/convertOptions.ts b/src/compiler/convertOptions.ts index 7b08eb31c..7c4311fa8 100644 --- a/src/compiler/convertOptions.ts +++ b/src/compiler/convertOptions.ts @@ -1,5 +1,5 @@ -import { OptionsState } from "../types/index.js"; -import { CompilerApi, ScriptKind, ScriptTarget } from "./CompilerApi.js"; +import type { OptionsState } from "../types/index.js"; +import type { CompilerApi, ScriptKind, ScriptTarget } from "./CompilerApi.js"; export function convertOptions(apiFrom: CompilerApi | undefined, apiTo: CompilerApi, options: OptionsState) { if (apiFrom == null || apiFrom === apiTo) { diff --git a/src/compiler/createSourceFile.ts b/src/compiler/createSourceFile.ts index 34d817bc8..f8ca69d0c 100644 --- a/src/compiler/createSourceFile.ts +++ b/src/compiler/createSourceFile.ts @@ -1,5 +1,5 @@ import { assertNever } from "../utils/index.js"; -import { +import type { CompilerApi, CompilerHost, CompilerOptions, diff --git a/src/compiler/getChildrenFunction.ts b/src/compiler/getChildrenFunction.ts index afe54cc51..4924a598c 100644 --- a/src/compiler/getChildrenFunction.ts +++ b/src/compiler/getChildrenFunction.ts @@ -1,6 +1,6 @@ import { TreeMode } from "../types/index.js"; import { assertNever } from "../utils/index.js"; -import { Node, SourceFile } from "./CompilerApi.js"; +import type { Node, SourceFile } from "./CompilerApi.js"; export function getChildrenFunction(mode: TreeMode, sourceFile: SourceFile) { switch (mode) { diff --git a/src/compiler/getCompilerApi.ts b/src/compiler/getCompilerApi.ts index de04d0582..a093576ee 100644 --- a/src/compiler/getCompilerApi.ts +++ b/src/compiler/getCompilerApi.ts @@ -1,6 +1,6 @@ import { importCompilerApi, importLibFiles } from "./compiler.generated.js"; -import { CompilerApi } from "./CompilerApi.js"; -import { CompilerPackageNames } from "./compilerVersions.generated.js"; +import type { CompilerApi } from "./CompilerApi.js"; +import type { CompilerPackageNames } from "./compilerVersions.generated.js"; const compilerTypes: { [name: string]: Promise } = {}; const compilerTypesLoaded: { [name: string]: true } = {}; diff --git a/src/compiler/getDescendantAtRange.ts b/src/compiler/getDescendantAtRange.ts index 2feed8d0b..1c1d8da0a 100644 --- a/src/compiler/getDescendantAtRange.ts +++ b/src/compiler/getDescendantAtRange.ts @@ -1,5 +1,5 @@ -import { TreeMode } from "../types/index.js"; -import { CompilerApi, Node, SourceFile } from "./CompilerApi.js"; +import type { TreeMode } from "../types/index.js"; +import type { CompilerApi, Node, SourceFile } from "./CompilerApi.js"; import { getChildrenFunction } from "./getChildrenFunction.js"; import { getStartSafe } from "./getStartSafe.js"; diff --git a/src/compiler/getFactoryCodeGenerator.ts b/src/compiler/getFactoryCodeGenerator.ts index a71c9658a..a80e02de6 100644 --- a/src/compiler/getFactoryCodeGenerator.ts +++ b/src/compiler/getFactoryCodeGenerator.ts @@ -1,5 +1,5 @@ -import { FactoryCodeGenerator, getGenerateFactoryCodeFunction } from "./compiler.generated.js"; -import { CompilerPackageNames } from "./compilerVersions.generated.js"; +import { type FactoryCodeGenerator, getGenerateFactoryCodeFunction } from "./compiler.generated.js"; +import type { CompilerPackageNames } from "./compilerVersions.generated.js"; const cache: { [packageName: string]: Promise } = {}; const hasLoadedVersion: { [packageName: string]: true } = {}; diff --git a/src/compiler/getStartSafe.ts b/src/compiler/getStartSafe.ts index 48ff7f439..25f6047de 100644 --- a/src/compiler/getStartSafe.ts +++ b/src/compiler/getStartSafe.ts @@ -1,4 +1,4 @@ -import { Node, SourceFile } from "./CompilerApi.js"; +import type { Node, SourceFile } from "./CompilerApi.js"; export function getStartSafe(node: Node, sourceFile: SourceFile) { // workaround for compiler api bug with getStart(sourceFile, true) (see PR #35029 in typescript repo) diff --git a/src/components/CodeEditor.tsx b/src/components/CodeEditor.tsx index 19edc58ff..1254c74bf 100644 --- a/src/components/CodeEditor.tsx +++ b/src/components/CodeEditor.tsx @@ -1,6 +1,6 @@ import type * as monacoEditorForTypes from "monaco-editor"; import React from "react"; -import * as ReactMonacoEditorForTypes from "react-monaco-editor"; +import type * as ReactMonacoEditorForTypes from "react-monaco-editor"; import type { EditorDidMount } from "react-monaco-editor"; import { LineAndColumnComputer } from "../utils/index.js"; import { Spinner } from "./Spinner.js"; @@ -170,7 +170,7 @@ export class CodeEditor extends React.Component{props.text}; diff --git a/src/components/FactoryCodeEditor.tsx b/src/components/FactoryCodeEditor.tsx index 98597c399..ba850d762 100644 --- a/src/components/FactoryCodeEditor.tsx +++ b/src/components/FactoryCodeEditor.tsx @@ -1,6 +1,6 @@ import { useEffect, useState } from "react"; -import { FactoryCodeGenerator, getFactoryCodeGenerator } from "../compiler/index.js"; -import { CompilerState } from "../types/index.js"; +import { type FactoryCodeGenerator, getFactoryCodeGenerator } from "../compiler/index.js"; +import type { CompilerState } from "../types/index.js"; import { Box } from "../utils/index.js"; import { CodeEditor } from "./CodeEditor.js"; import { Spinner } from "./Spinner.js"; diff --git a/src/components/FlowNodeGraph.tsx b/src/components/FlowNodeGraph.tsx index 6a79bab75..c39d9c467 100644 --- a/src/components/FlowNodeGraph.tsx +++ b/src/components/FlowNodeGraph.tsx @@ -1,9 +1,8 @@ -import { instance as vizJsInstance, Viz } from "@viz-js/viz"; +import { instance as vizJsInstance, type Viz } from "@viz-js/viz"; import React from "react"; -import { FlowFlags, FlowNode } from "typescript"; import { useAppContext } from "../AppContext.js"; -import { CompilerApi } from "../compiler/index.js"; +import type { CompilerApi, FlowFlags, FlowNode } from "../compiler/index.js"; import { enumUtils } from "../utils/index.js"; export interface FlowNodeGraphProps { @@ -16,6 +15,7 @@ function quoted(txt: string): string { } function getFlagText(api: CompilerApi, flags: FlowFlags) { + const { FlowFlags } = api; // These are optimizations, not semantic flags. flags = flags & ~(FlowFlags.Shared | FlowFlags.Referenced); switch (flags) { diff --git a/src/components/Options.tsx b/src/components/Options.tsx index 5a3226d48..c43be56d8 100644 --- a/src/components/Options.tsx +++ b/src/components/Options.tsx @@ -1,14 +1,15 @@ -import React, { useRef, useState } from "react"; +import type React from "react"; +import { useRef, useState } from "react"; import { - CompilerApi, - CompilerPackageNames, + type CompilerApi, + type CompilerPackageNames, compilerVersionCollection, - ScriptKind, - ScriptTarget, + type ScriptKind, + type ScriptTarget, } from "../compiler/index.js"; import { useOnClickOutside } from "../hooks/index.js"; -import { OptionsState } from "../types/index.js"; -import { Theme, TreeMode } from "../types/index.js"; +import type { OptionsState } from "../types/index.js"; +import { type Theme, TreeMode } from "../types/index.js"; import { enumUtils } from "../utils/index.js"; import { ExternalLink } from "./ExternalLink.js"; diff --git a/src/components/PropertiesViewer.tsx b/src/components/PropertiesViewer.tsx index 8d0f6fe16..a9063c11c 100644 --- a/src/components/PropertiesViewer.tsx +++ b/src/components/PropertiesViewer.tsx @@ -1,20 +1,20 @@ import CircularJson from "circular-json"; import { useEffect, useState } from "react"; import { - CommentRange, - CompilerApi, - FlowNode, + type CommentRange, + type CompilerApi, + type FlowNode, getPublicApiInfo, getStartSafe, - Node, - PublicApiInfo, - Signature, - SourceFile, - Symbol, - Type, - TypeChecker, + type Node, + type PublicApiInfo, + type Signature, + type SourceFile, + type Symbol, + type Type, + type TypeChecker, } from "../compiler/index.js"; -import { BindingTools, CompilerState } from "../types/index.js"; +import type { BindingTools, CompilerState } from "../types/index.js"; import { enumUtils, getSyntaxKindName } from "../utils/index.js"; import { ErrorBoundary } from "./ErrorBoundary.js"; import { FlowNodeGraph } from "./FlowNodeGraph.js"; diff --git a/src/components/ToolTippedText.tsx b/src/components/ToolTippedText.tsx index 5f692927e..97d4fc3b8 100644 --- a/src/components/ToolTippedText.tsx +++ b/src/components/ToolTippedText.tsx @@ -1,4 +1,5 @@ -import React, { useState } from "react"; +import type React from "react"; +import { useState } from "react"; export interface ToolTippedTextProps { text: string; diff --git a/src/components/TreeViewer.tsx b/src/components/TreeViewer.tsx index e6a4d860c..752275efe 100644 --- a/src/components/TreeViewer.tsx +++ b/src/components/TreeViewer.tsx @@ -1,7 +1,7 @@ import { useLayoutEffect } from "react"; import TreeView from "react-treeview"; -import { CompilerApi, getChildrenFunction, Node, SourceFile } from "../compiler/index.js"; -import { TreeMode } from "../types/index.js"; +import { type CompilerApi, getChildrenFunction, type Node, type SourceFile } from "../compiler/index.js"; +import type { TreeMode } from "../types/index.js"; import { getSyntaxKindName } from "../utils/index.js"; export interface TreeViewerProps { @@ -29,7 +29,7 @@ export function TreeViewer(props: TreeViewerProps) { }, [selectedNode]); return
{renderNode(sourceFile, getChildrenFunction(mode, sourceFile))}
; - function renderNode(node: Node, getChildren: (node: Node) => Node[]): JSX.Element { + function renderNode(node: Node, getChildren: (node: Node) => readonly Node[]): JSX.Element { const children = getChildren(node); const className = "nodeText" + (node === selectedNode ? " selected" : ""); const kindName = getSyntaxKindName(api, node.kind); diff --git a/src/reducers/index.tsx b/src/reducers/index.tsx index db3ce0315..288c2834a 100644 --- a/src/reducers/index.tsx +++ b/src/reducers/index.tsx @@ -1,8 +1,8 @@ -import { AllActions } from "../actions/index.js"; -import { CompilerApi, CompilerPackageNames, convertOptions, createSourceFile } from "../compiler/index.js"; -import { CodeEditorTheme } from "../components/index.js"; +import type { AllActions } from "../actions/index.js"; +import { type CompilerApi, type CompilerPackageNames, convertOptions, createSourceFile } from "../compiler/index.js"; +import type { CodeEditorTheme } from "../components/index.js"; import { actions as actionNames } from "./../constants/index.js"; -import { OptionsState, StoreState } from "../types/index.js"; +import type { OptionsState, StoreState } from "../types/index.js"; import { Theme } from "../types/index.js"; import { UrlSaver } from "../utils/index.js"; diff --git a/src/types/index.tsx b/src/types/index.tsx index 47546c517..af873b852 100644 --- a/src/types/index.tsx +++ b/src/types/index.tsx @@ -1,4 +1,4 @@ -import { +import type { CompilerApi, CompilerPackageNames, Node, diff --git a/src/utils/LineAndColumnComputer.ts b/src/utils/LineAndColumnComputer.ts index 11b396b9b..39099c24f 100644 --- a/src/utils/LineAndColumnComputer.ts +++ b/src/utils/LineAndColumnComputer.ts @@ -1,5 +1,5 @@ import * as arrayUtils from "./arrayUtils.js"; -import { createLineNumberAndColumns, LineNumberAndColumn } from "./createLineNumberAndColumns.js"; +import { createLineNumberAndColumns, type LineNumberAndColumn } from "./createLineNumberAndColumns.js"; /** An efficient way to compute the line and column of a position in a string. */ export class LineAndColumnComputer { diff --git a/src/utils/__tests/createLineNumberAndColumns.test.ts b/src/utils/__tests/createLineNumberAndColumns.test.ts index 501dff583..dafeecda6 100644 --- a/src/utils/__tests/createLineNumberAndColumns.test.ts +++ b/src/utils/__tests/createLineNumberAndColumns.test.ts @@ -1,5 +1,5 @@ import { expect } from "@std/expect"; -import { createLineNumberAndColumns, LineNumberAndColumn } from "../createLineNumberAndColumns.js"; +import { createLineNumberAndColumns, type LineNumberAndColumn } from "../createLineNumberAndColumns.js"; Deno.test("createLineNumberAndColumns", async (t) => { function doTest(text: string, expected: LineNumberAndColumn[]) { diff --git a/src/utils/getSyntaxKindName.ts b/src/utils/getSyntaxKindName.ts index 16fbcf64a..75f20c345 100644 --- a/src/utils/getSyntaxKindName.ts +++ b/src/utils/getSyntaxKindName.ts @@ -1,4 +1,4 @@ -import { CompilerApi, SyntaxKind } from "../compiler/index.js"; +import type { CompilerApi, SyntaxKind } from "../compiler/index.js"; export function getSyntaxKindName(api: CompilerApi, kind: SyntaxKind) { return getKindCacheForApi(api)[kind];