tiny-slug ships no types. Write a declaration so import { slugify } from "tiny-slug" is fully typed.
The package exports one function, slugify(text, options?), which returns a string. options can have separator (a string) and lower (a boolean). There's no @types/tiny-slug. The shorthand declaration in types/tiny-slug.d.ts silences the import error, but everything from the package is any. Replace it with a declaration that types the function and exports its options type as SlugifyOptions.
{ "name": "tiny-slug", "version": "2.1.0", "main": "index.js" }
exports.slugify = function slugify(text, options = {}) {
const separator = options.separator ?? "-";
const slug = text.trim().split(/[^A-Za-z0-9]+/).filter(Boolean).join(separator);
return options.lower === false ? slug : slug.toLowerCase();
};
import { slugify } from "tiny-slug";
console.log(slugify("Hello World")); // "hello-world"
declare module "tiny-slug";The answer
Write it yourself first. Then compare it with a reference solution and the checks it passes.
Checking your sign-in…