Skip to content

Commit

Permalink
Add TypeScript type definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
SamVerschueren committed Dec 19, 2022
1 parent b3710c4 commit c345b4c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
15 changes: 15 additions & 0 deletions index.d.ts
@@ -0,0 +1,15 @@
/**
Decodes a Uniform Resource Identifier (URI) component previously created by `encodeURIComponent()`
or by a similar routine.
@param encodedURI - An encoded component of a URI.
@returns The decoded URI component.
@example
```
decodeUriComponent('st%C3%A5le')
//=> 'ståle'
```
*/
export default function decodeUriComponent(encodedURI: string): string;
4 changes: 4 additions & 0 deletions index.test-d.ts
@@ -0,0 +1,4 @@
import {expectType} from 'tsd';
import decodeUriComponent from './index.js';

expectType<string>(decodeUriComponent('st%C3%A5le'));
20 changes: 14 additions & 6 deletions package.json
Expand Up @@ -9,19 +9,21 @@
"email": "sam.verschueren@gmail.com",
"url": "github.com/SamVerschueren"
},
"type": "module",
"exports": {
"types": "./index.d.ts",
"default": "./index.js"
},
"engines": {
"node": ">=14.16"
},
"scripts": {
"test": "xo && nyc ava",
"test": "xo && nyc ava && tsd",
"coveralls": "nyc report --reporter=text-lcov | coveralls"
},
"type": "module",
"exports": {
"default": "./index.js"
},
"files": [
"index.js"
"index.js",
"index.d.ts"
],
"keywords": [
"decode",
Expand All @@ -36,6 +38,12 @@
"ava": "^5.1.0",
"coveralls": "^3.1.1",
"nyc": "^15.1.0",
"tsd": "^0.25.0",
"xo": "^0.53.1"
},
"tsd": {
"compilerOptions": {
"module": "node16"
}
}
}

0 comments on commit c345b4c

Please sign in to comment.