mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
feat(filing-cabinet): type definitions for v2.5 (#42753)
- type definitions - tests https://github.com/dependents/node-filing-cabinet#usage Thanks!
This commit is contained in:
parent
0d448d3e5d
commit
0fe2fee2ed
19
types/filing-cabinet/filing-cabinet-tests.ts
Normal file
19
types/filing-cabinet/filing-cabinet-tests.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import cabinet = require('filing-cabinet');
|
||||
|
||||
const result = cabinet({
|
||||
partial: 'somePartialPath',
|
||||
directory: 'path/to/all/files',
|
||||
filename: 'path/to/parent/file',
|
||||
ast: {},
|
||||
config: 'path/to/requirejs/config',
|
||||
webpackConfig: 'path/to/webpack/config',
|
||||
nodeModulesConfig: {
|
||||
entry: 'module',
|
||||
},
|
||||
tsConfig: 'path/to/typescript/config',
|
||||
});
|
||||
result; // $ExpectType string
|
||||
|
||||
cabinet.register('.scss', (partial, filename, directory, config) => {
|
||||
return `file.scss`;
|
||||
});
|
||||
59
types/filing-cabinet/index.d.ts
vendored
Normal file
59
types/filing-cabinet/index.d.ts
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
// Type definitions for filing-cabinet 2.5
|
||||
// Project: https://github.com/mrjoelkemp/node-filing-cabinet
|
||||
// Definitions by: Piotr Błażejewicz (Peter Blazejewicz) <https://github.com/peterblazejewicz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace cabinet {
|
||||
interface Options {
|
||||
/** the dependency path */
|
||||
partial: string;
|
||||
/** the path to all files */
|
||||
directory: string;
|
||||
/** the path to the file containing the partial */
|
||||
filename: string;
|
||||
/**
|
||||
* the parsed AST for filename
|
||||
* Useful optimization for avoiding a parse of filename
|
||||
*/
|
||||
ast?: any;
|
||||
/**
|
||||
* `requirejs` config for resolving aliased JavaScript modules
|
||||
*/
|
||||
config?: any;
|
||||
/**
|
||||
* `webpack` config for resolving aliased JavaScript modules
|
||||
*/
|
||||
webpackConfig?: any;
|
||||
/**
|
||||
* config for resolving entry file for `node_modules`.
|
||||
* This value overrides the main attribute in the `package.json` file;
|
||||
* used in conjunction with the `packageFilter` of the resolve package
|
||||
*/
|
||||
nodeModulesConfig?: any;
|
||||
/**
|
||||
* Path to a typescript configuration.
|
||||
* Could also be an object representing a pre-parsed typescript config
|
||||
*/
|
||||
tsConfig?: string | object;
|
||||
/**
|
||||
* For typescript files, whether to prefer *.js over *.d.ts
|
||||
*/
|
||||
noTypeDefinitions?: boolean;
|
||||
}
|
||||
|
||||
type Resolver = (partial: string, filename: string, directory: string, config?: any) => void;
|
||||
|
||||
/**
|
||||
* Register a custom lookup resolver for a file extension
|
||||
* If a given extension does not have a registered resolver,
|
||||
* cabinet will use a generic file resolver which is basically `require('path').join`
|
||||
* with a bit of extension defaulting logic
|
||||
* @param extension the extension of the file that should use the custom resolver (ex: '.py', '.php')
|
||||
* @param resolver A resolver of partial paths
|
||||
*/
|
||||
function register(extension: string, resolver: Resolver): void;
|
||||
}
|
||||
|
||||
declare function cabinet(options: cabinet.Options): string;
|
||||
|
||||
export = cabinet;
|
||||
23
types/filing-cabinet/tsconfig.json
Normal file
23
types/filing-cabinet/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"filing-cabinet-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/filing-cabinet/tslint.json
Normal file
1
types/filing-cabinet/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user