Created
May 3, 2018 08:14
-
-
Save arayaryoma/b3e3808574730ec85f139991fb05d785 to your computer and use it in GitHub Desktop.
How to use nanoid with TypeScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import nanoid from 'nanoid'; | |
console.log(nanoid()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// types/nanoid.d.ts | |
declare module 'nanoid' { | |
export default function nanoid(size?: number): string; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"compilerOptions": { | |
"target": "es5", | |
"module": "commonjs", | |
"lib": [ | |
"es2015", | |
"dom" | |
], | |
"strict": true, | |
"typeRoots": [ | |
"types", | |
"node_modules/@types" | |
], | |
"esModuleInterop": true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Doesn't seems to work with nanoid v5.0.3