Files
obsidian-excalidraw-plugin/tsconfig.json
zsviczianandClaude Sonnet 5 8d06fe1ee2 Fix @excalidraw/common type resolution, eliminating a huge any-collapse
@zsviczian/excalidraw's bundled .d.ts files import bare-specifier
@excalidraw/common|element|math|utils, packages this plugin never
depends on (confirmed the same gap exists in upstream's own published
@excalidraw/excalidraw, not a fork-specific bug). Every value that
touched one of those unresolvable imports -- Theme, BinaryFileData.id,
most of AppState, large parts of ExcalidrawElement -- silently
collapsed to any.

Fixed via tsconfig.json paths redirecting all four specifiers (bare
and subpath) into @zsviczian/excalidraw's own already-vendored type
copies under node_modules/@zsviczian/excalidraw/types/ -- zero
version-drift risk since it's literally the same files, and no new
dependency needed. (A first attempt using an external @excalidraw/element
devDependency was reverted: its independently-versioned types
structurally disagreed with this package's own bundled ExcalidrawElement,
producing false-positive mismatches.)

Fixed all 117 real, previously-masked compile errors this surfaced
across 18 files, smallest to largest, each verified with a build
before moving on. Two were genuine pre-existing bugs, not type gaps:

- ExcalidrawView.ts addFiles(): isDark was assigned the literal theme
  string instead of a boolean comparison; !!isDark on any non-empty
  string is always true, so every image loaded through that fallback
  path had been treated as dark-themed regardless of actual theme.
- ExcalidrawView.ts getSelectedTextElement(): the grouped-text-element
  branch cast the originally-selected (possibly non-text) element
  instead of the text element the same branch had already found two
  lines above, silently returning undefined text for non-text
  selections.

getViewColorPalette()'s Array.isArray check, initially flagged as
dead code guarding an impossible shape, turned out to be correct:
AppState.colorPalette's declared ColorPaletteCustom type describes
the record-shaped settings input, but the fork flattens it to a color
list by the time it reaches AppState. Fixed as a documented bridge
cast once confirmed against the fork's own type source, not a logic
change.

Confirmed via a git-stash ESLint diff against the prior commit: 411 ->
229 findings (44% fewer), zero files regressing. Build, lib, and
node --check all pass clean with zero remaining diagnostics.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-14 15:22:52 +02:00

50 lines
2.4 KiB
JSON

{
"compilerOptions": {
"sourceMap": false,
"module": "es2020",
"target": "es2022", //min es2017 because script engine requires for async execution and min es2018 for named capture groups
"allowJs": false,
"noImplicitAny": true,
"types": ["node"],
"paths": {
"src/*": ["./src/*"],
// @zsviczian/excalidraw's bundled .d.ts files import bare-specifier
// @excalidraw/common|element|math|utils (an upstream monorepo-split
// artifact present in @excalidraw/excalidraw's own published types too)
// that this plugin never depends on, collapsing everything downstream
// to `any`. The package already vendors its own exact-match copies of
// all four under node_modules/@zsviczian/excalidraw/types/ (it has to,
// to be self-contained), so redirecting there guarantees zero version
// drift -- no external devDependency needed. Type-checking only; never
// reaches the runtime bundle. (An external @excalidraw/element devDependency
// was tried first and reverted: its independently-versioned types
// structurally disagreed with this package's own bundled ExcalidrawElement,
// producing false-positive mismatches between two same-named-but-different types.)
"@excalidraw/common": ["./node_modules/@zsviczian/excalidraw/types/common/src/index"],
"@excalidraw/common/*": ["./node_modules/@zsviczian/excalidraw/types/common/src/*"],
"@excalidraw/element": ["./node_modules/@zsviczian/excalidraw/types/element/src/index"],
"@excalidraw/element/*": ["./node_modules/@zsviczian/excalidraw/types/element/src/*"],
"@excalidraw/math": ["./node_modules/@zsviczian/excalidraw/types/math/src/index"],
"@excalidraw/math/*": ["./node_modules/@zsviczian/excalidraw/types/math/src/*"],
"@excalidraw/utils": ["./node_modules/@zsviczian/excalidraw/types/utils/src/index"],
"@excalidraw/utils/*": ["./node_modules/@zsviczian/excalidraw/types/utils/src/*"],
"@excalidraw/excalidraw/*": ["./node_modules/@zsviczian/excalidraw/types/excalidraw/*"]
},
"moduleResolution": "node",
"esModuleInterop": true,
"importHelpers": true,
"resolveJsonModule": true,
"lib": [
"dom",
"scripthost",
"es2022",
"DOM.Iterable"
],
"jsx": "react",
},
"include": [
"**/*.ts",
"**/*.tsx", "src/shared/Dialogs/OpenDrawing.ts",
"src/types/types.d.ts",
]
}