Skip to content

Instantly share code, notes, and snippets.

@arayaryoma
Last active June 14, 2024 07:44
Show Gist options
  • Save arayaryoma/b3e3808574730ec85f139991fb05d785 to your computer and use it in GitHub Desktop.
Save arayaryoma/b3e3808574730ec85f139991fb05d785 to your computer and use it in GitHub Desktop.
[TOO OLD, ARCHIVED] 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
}
}
@arayaryoma
Copy link
Author

I looked at this gist for the first time in six years, but we don't need it anymore.
nanoid provides d.ts now. https://github.com/ai/nanoid/blob/main/index.d.ts

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