Skip to content

Instantly share code, notes, and snippets.

@dimaslanjaka
Last active May 31, 2022 01:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dimaslanjaka/e7fc4c8778cdef48e1799de74a0c8949 to your computer and use it in GitHub Desktop.
Save dimaslanjaka/e7fc4c8778cdef48e1799de74a0c8949 to your computer and use it in GitHub Desktop.
How to use require in typescript
export default function anyFunc() {
return 'hello world';
}
/// <reference path="./require.d.ts" />
// hanya untuk type
import func from './func';
console.log(require<typeof func>('./func'));
/**
* env~node require mirror
* @author Dimas Lanjaka <dimaslanjaka@gmail.com> (https://www.webmanajemen.com)
*/
declare function require<T = any>(name: string): T;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment