Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sluggo] Add types for sluggo #69524

Merged
merged 3 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions types/sluggo/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*
!**/*.d.ts
!**/*.d.cts
!**/*.d.mts
!**/*.d.*.ts
23 changes: 23 additions & 0 deletions types/sluggo/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
declare namespace sluggo {
interface Options {
/**
* The separator character to use. Defaults to "-".
*/
separator?: string | undefined;
/**
* A string or list of strings to permit in the output.
*/
allow?: string | string[] | undefined;
}
}

/**
* Generates a slug.
* @param input The string to generate a slug for.
* @param options Customize the slug generator's behavior.
* @returns The generated slug.
*/
declare function sluggo(input: string, options?: sluggo.Options): string;

export = sluggo;
export as namespace sluggo;
17 changes: 17 additions & 0 deletions types/sluggo/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"private": true,
"name": "@types/sluggo",
"version": "1.0.9999",
"projects": [
"https://github.com/apostrophecms/sluggo"
],
"devDependencies": {
"@types/sluggo": "workspace:."
},
"owners": [
{
"name": "Reece Dunham",
"githubUsername": "RDIL"
}
]
}
7 changes: 7 additions & 0 deletions types/sluggo/sluggo-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import sluggo = require("sluggo");

sluggo("i ♥ unicode"); // $ExpectType string

sluggo("unicode ♥ is ☢"); // $ExpectType string

sluggo("unicode ♥ is ☢", { allow: "♥" }); // $ExpectType string
19 changes: 19 additions & 0 deletions types/sluggo/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "node16",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"sluggo-tests.ts"
]
}