tcmts.core.test.hash

Server

analyze (source: string) => Analysis
analyzeTsx (source: string) => Analysis
dir string
Where the tests write the files they analyze: an ES module package.
fakeReact (root: string) => void
A minimal React for JSX: the automatic runtime's types, pinned at a version.
hashes (src: string) => { [k: string]: string; }
project (files: Record<string, string>) => { [k: string]: ProjectDef; }

Shared

n number

Tests

testComputedKeysNameValues () => void
A computed key names a value, inside a type too: `readonly [evaluate]: …` uses the unique symbol `evaluate`, not the type of that name beside it (Effect's `evaluate`, `TypeId`).
testDefaultExportOfADefinitionIsUsedByName () => void
An imported module's `export default types` names a definition it declares: a default import of the module is a use of that definition.
testDependenciesAreReferencedByHash () => void
Dependencies are referenced by hash, so the name a dependency is referenced by doesn't matter.
testDynamicImportIsAPinnedDependency () => void
Dynamic import() of a package is a pinned external dependency.
testFunctionNamesAreHashedValueNamesAreNot () => void
A value's own name is not part of its hash, a function's is (it's observable as .name).
testGlobalsAndLocalsAreDistinguished () => void
Globals and locals with the same name are distinguished.
testImmediatelyInvokedFunctionsRunNow () => void
A function called where it's written runs as its definition is initialized: what it uses is needed then (Effect's `Base = (() => { … Base.prototype = proto … })()`), unlike what a function body called later uses.
testImportCyclesBecomeHashCycles () => void
Import cycles between files become hash cycles.
testJsxComponentTagsAreReferencesByHash () => void
JSX: a component tag is a reference by hash, marked as rendered rather than called.
testJsxLayoutDoesntCountKeptTextDoes () => void
JSX: layout between tags doesn't count, text React keeps does; the runtime is pinned.
testLineageSaltsSeparateIdenticalCode () => void
A lineage salt gives identical code separate identities.
testLiteralSpellingIsNormalized () => void
Literal spelling is normalized, values are not.
testLocalNamesAreAlphaRenamable () => void
Local names are alpha-renamable unless they become a runtime name.
testLocalRenamesAndFormattingKeepTheHash () => void
Local renames, formatting, comments and export do not change the hash.
testMutualRecursionHashesAsACycle () => void
Mutually recursive definitions hash as a cycle, independent of source order.
testNamespaceImportsLeaveTypesToTheirNames () => void
A namespace import has no type: in a type position its name is the file's own type of that name, or the global one, as TypeScript reads it (`Iterable<T>` beside `import * as Iterable`, `interface Scope` beside `import type * as Scope`); `Ns.Member` is still the module's. A doc example naming the namespace import leaves it as written.
testOptionalChildrenAreLabelledBySlot () => void
Optional children are labelled by slot.
testPackageReexportsHashAsImports () => void
A package's export used through a project module that re-exports it (`export * from "pkg"`, `export { x } from "pkg"`, `export * as ns from "pkg"`) hashes as an import of it from the package.
testPackagesArePinnedByCompatibleRange () => void
Packages are pinned by compatible range, and the exact version checked against is reported.
testParameterSchemasCheckNetworkArguments () => Promise<void>
Parameter schemas check arguments arriving from the network.
testParameterSchemasStaySmall () => void
A type a parameter reaches by several routes is written once (shared, and still checked wherever it's used), and an object that must hold a function can't arrive as data, so it's described as that alone: Effect's schema nodes, each with a `getParser` method and reached a hundred ways, made schemas of megabytes before.
testRedundantParensDontChangeTheHash () => void
Parentheses a formatter adds around an optional chain don't change a hash; ones that change what the chain does (it goes on after them) do.
testSetupStatementsJoinTheirConstant () => void
A top-level statement that only writes into one constant declared above it (filling a table, freezing it) goes with that constant: one definition, its statements run and hashed together, in a scratch file as in an import. Anything else stays refused: a statement writing into nothing (a call), into two constants, or into something not the file's; and what a function in it does later doesn't count.
testShorthandPropertiesHashLikeExplicitOnes () => void
Shorthand and explicit property forms hash the same.
testSplittingAcrossFilesKeepsHashes () => void
Splitting code across files and re-exporting through barrels does not change hashes.
testTypesAndPropertyNamesAreHashed () => void
Types and property names are part of the hash.
testTypesOnlyDeclarationsMergeByName () => void
Declarations that exist only in types merge with a type or class of their name into one definition, as TypeScript merges them (Effect's interfaces each have a namespace of types beside them), in a scratch file as in an import; the stored code reads back as the same definition.
testUnsupportedConstructsAreRejected () => void
Unsupported constructs are rejected with a reason.
testWatchExpressionsAreKeptApart () => void
Watch expressions are analyzed but kept apart from definitions.