mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-05 20:02:05 +08:00
feat(require-from-string): initial commit
This commit is contained in:
27
types/require-from-string/index.d.ts
vendored
Normal file
27
types/require-from-string/index.d.ts
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
// Type definitions for require-from-string 1.2
|
||||
// Project: https://github.com/floatdrop/require-from-string
|
||||
// Definitions by: Ika <https://github.com/ikatyang>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/**
|
||||
* Load module from string in Node.
|
||||
*/
|
||||
declare function requireFromString(code: string, options?: requireFromString.Options): any;
|
||||
declare function requireFromString(code: string, filename?: string, options?: requireFromString.Options): any;
|
||||
|
||||
declare namespace requireFromString {
|
||||
interface Options {
|
||||
/**
|
||||
* List of `paths`, that will be appended to module `paths`.
|
||||
* Useful when you want to be able require modules from these paths.
|
||||
*/
|
||||
appendPaths?: string[];
|
||||
/**
|
||||
* List of `paths`, that will be preppended to module `paths`.
|
||||
* Useful when you want to be able require modules from these paths.
|
||||
*/
|
||||
prependPaths?: string[];
|
||||
}
|
||||
}
|
||||
|
||||
export = requireFromString;
|
||||
9
types/require-from-string/require-from-string-tests.ts
Normal file
9
types/require-from-string/require-from-string-tests.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import requireFromString = require('require-from-string');
|
||||
|
||||
const moduleA1 = requireFromString('module.exports = 123');
|
||||
|
||||
const moduleA2 = requireFromString('module.exports = 123', { appendPaths: ['some-path'] });
|
||||
|
||||
const moduleB1 = requireFromString('module.exports = { a: 1, b: 2, c: 3 }', 'abc.js');
|
||||
|
||||
const moduleB2 = requireFromString('module.exports = { a: 1, b: 2, c: 3 }', 'abc.js', { prependPaths: ['some-path'] });
|
||||
15
types/require-from-string/tsconfig.json
Normal file
15
types/require-from-string/tsconfig.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": ["index.d.ts", "require-from-string-tests.ts"]
|
||||
}
|
||||
1
types/require-from-string/tslint.json
Normal file
1
types/require-from-string/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user