Skip to content

Add .d.tycl declaration files for external library type definitions#2

Merged
tamurashingo merged 5 commits into
mainfrom
external-libs
Mar 16, 2026
Merged

Add .d.tycl declaration files for external library type definitions#2
tamurashingo merged 5 commits into
mainfrom
external-libs

Conversation

@tamurashingo

Copy link
Copy Markdown
Owner

Add .d.tycl declaration files for typing external libraries not written in TyCL, similar to TypeScript's .d.ts files.

  • Introduce tycl-declarations/ directory convention for project-local declarations and ~/.config/tycl/declarations/ for user-global declarations, with
    automatic discovery and loading
  • Integrate declaration loading into transpile, type check (check-file), and LSP server initialization flows
  • Add sample CL standard library declarations in sample/tycl-declarations/ demonstrating type error detection for external function calls
  • Document usage, discovery paths, and limitations (canonical package names, </> symbol restriction) in README

Introduce a mechanism similar to TypeScript's .d.ts files, allowing
users to declare types for external libraries not written in TyCL.
Declaration files are automatically discovered from tycl-declarations/
directories (project-local) and ~/.config/tycl/declarations/ (global).
check-file was missing the find-and-load-declarations call,
so .d.tycl type declarations were not available during
standalone type checking (e.g. tycl check, check-all).
- Use canonical package name (common-lisp) instead of nickname (cl)
  in declaration file to match type checker's package resolution
- Remove CL functions with &rest/&optional/&key parameters that
  cause false positive argument count errors
- Add type annotations to math.tycl arithmetic results to resolve
  :number -> num (integer) downcast warnings
Add find-and-load-declarations call to handle-initialize so that
.d.tycl type declarations are available for diagnostics in the editor.
@tamurashingo tamurashingo merged commit aaf93c3 into main Mar 16, 2026
2 checks passed
@tamurashingo tamurashingo deleted the external-libs branch March 19, 2026 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant