Appearance
Types and IDE autocomplete
Guess‑Rater provides TypeScript declaration files (.d.ts) to improve developer experience in modern editors.
You do not need to use TypeScript to benefit from this.
What typings provide
Type declarations enable:
- IDE auto‑completion
- inline documentation (hover)
- validation of options
- safer configuration
- better discoverability of the API
This works in editors such as:
- VS Code
- WebStorm
- IntelliJ
- any editor using TypeScript language services
Autocomplete for functions
When typing:
js
rate(Your editor should display:
- function signature
- expected parameters
- return type
Example:
js
rate(
leftInput: string,
rightInput: string,
options?: RateOptions
)Autocomplete for algorithms
When typing:
js
algorithm:Your editor should suggest:
levenshteinjaroWinklertokenSorttokenSethybrid
This prevents typos and invalid values.
Autocomplete for normalization
When typing:
js
normalize: {Your editor should suggest:
caseSensitiveremoveAccentsremovePunctuationpunctuationStrategytrimcollapseWhitespacereplacementsremoveWordssortTokens
Each option includes inline documentation explaining its purpose.
Autocomplete with explain mode
When using explain: true, return types change.
Example:
js
const result = rate('John Smith', 'Smith John', {
explain: true
})The editor should know that result is an object with:
scorematchnormalizedLeftnormalizedRightdetails
This helps avoid mistakes such as comparing an object directly to a number.
isMatch overload behavior
The isMatch() helper is typed to reflect its behavior:
- returns
booleanby default - returns a detailed object when
explain: trueis provided
This allows correct autocomplete depending on usage.
createMatcher typing
A matcher instance exposes typed methods:
matcher.rate()matcher.isMatch()matcher.rankCandidates()matcher.findBestMatch()matcher.normalize()
Each method has proper parameter and return types.
Common troubleshooting
Autocomplete not working
If autocomplete does not appear:
- Make sure the package is installed correctly
- Restart your editor
- In VS Code:
- Command palette
- Run “TypeScript: Restart TS Server”
Why this matters
Typings turn Guess‑Rater from a simple utility into a safe, discoverable, self‑documenting API.
They reduce runtime errors and make configuration easier to understand.
Key idea
The code runs in JavaScript.
The typings exist only to help you write better code.