Skip to content

Instantly share code, notes, and snippets.

@arayaryoma
Created May 3, 2018 08:14
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arayaryoma/b3e3808574730ec85f139991fb05d785 to your computer and use it in GitHub Desktop.
Save arayaryoma/b3e3808574730ec85f139991fb05d785 to your computer and use it in GitHub Desktop.
How to use nanoid with TypeScript
import nanoid from 'nanoid';
console.log(nanoid());
// types/nanoid.d.ts
declare module 'nanoid' {
export default function nanoid(size?: number): string;
}
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"lib": [
"es2015",
"dom"
],
"strict": true,
"typeRoots": [
"types",
"node_modules/@types"
],
"esModuleInterop": true
}
}
@virajp
Copy link

virajp commented Nov 30, 2023

Doesn't seems to work with nanoid v5.0.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment