Repository navigation
Check every declaration against what lib.ts compiles to; fix two that differed - #58
Merged
Merged
Conversation
… differed
scripts\check_declarations.ps1 compiles a program against the declarations
(src as the default library) and src\lib.ts on its own, and compares each
function's signature in the two: a program calls a function by its declared
type, and lib.ts defines it with its own. Spellings of one signature (int and
s32, a void result and none, `T | null` of a pointer and T) count as the same.
tests.ps1 runs it first. Of 326 functions it found two:
- String.startsWith was declared with no result: a call had no value
(`const r = s.startsWith("he")` left `r` unresolved), while lib.ts returns
a boolean.
- MatchResults' constructor was declared without its `hasIndices` parameter,
so a call passed its last argument where lib.ts reads `hasIndices`.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Number.toStringreturned nothing whilelib.d.tssaid it returns astring, and nothing caught that until a program printing its result crashed (fixed in #56). This PR adds a check for that whole class of bug, and fixes the two declarations it found.The check:
scripts/check_declarations.ps1A program calls a library function through its declared type, while
lib.tsdefines the function with its own type. The script compares the two for every function:srcis used as the default library through a temporary junction, so the check sees the working tree, not the last build.src/lib.tson its own, asbuild_core.batdoes.Some spellings describe the same signature and count as equal:
intands32, avoidresult and no result, andT | nullversusTfor a class or opaque pointer. It checks 326 functions in about a second.tests.ps1runs it first, so a declaration that drifts from the code fails the run.Two declarations it found
String.startsWithwas declared with no return type, so a call had no value:const r = s.startsWith("he")leftrunresolved.lib.tsreturns aboolean. The new test istests/string_object_starts_with.ts.MatchResults' constructor was declared without itshasIndicesparameter, so a call passed its last argument wherelib.tsreadshasIndices.Tests
DefaultLib release JIT: gc 181/181, rc and none 180 with 1 skipped, own 170 with 11 skipped.
check_declarations.ps1passes. It is Windows-only, because it uses a junction andpwsh, sotests.shdoes not run it.🤖 Generated with Claude Code