mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Add types for interpret
This commit is contained in:
parent
adda202607
commit
89f8981d79
26
types/interpret/index.d.ts
vendored
Normal file
26
types/interpret/index.d.ts
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
// Type definitions for interpret 1.1
|
||||
// Project: https://github.com/tkellen/node-interpret
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
export interface Hook {
|
||||
(m: { extensions: string } | NodeModule): any;
|
||||
install(m?: { extension: string; [key: string]: any }): void;
|
||||
}
|
||||
|
||||
export type RegisterFn = (hook: Hook) => void;
|
||||
|
||||
export interface ExtensionDescriptor {
|
||||
module: string;
|
||||
register: RegisterFn;
|
||||
}
|
||||
|
||||
export type Extension = string | ExtensionDescriptor | Array<string | ExtensionDescriptor>;
|
||||
export interface Extensions {
|
||||
[extension: string]: Extension | null;
|
||||
}
|
||||
|
||||
export const extensions: Extensions;
|
||||
export const jsVariants: Extensions;
|
||||
50
types/interpret/interpret-tests.ts
Normal file
50
types/interpret/interpret-tests.ts
Normal file
@ -0,0 +1,50 @@
|
||||
import { extensions, jsVariants, Extensions } from 'interpret';
|
||||
|
||||
// $ExpectType Extensions
|
||||
extensions;
|
||||
// $ExpectType Extensions
|
||||
jsVariants;
|
||||
|
||||
const myExts: Extensions = {
|
||||
'.babel.js': [
|
||||
{
|
||||
module: 'babel-register',
|
||||
register(hook) {
|
||||
hook({ extensions: '.js' });
|
||||
},
|
||||
},
|
||||
],
|
||||
'.co': 'coco',
|
||||
'.coffee': ['coffeescript/register', 'coffee-script/register', 'coffeescript', 'coffee-script'],
|
||||
'.esm.js': {
|
||||
module: 'esm',
|
||||
register(hook) {
|
||||
const esmLoader = hook(module);
|
||||
require.extensions['.js'] = esmLoader('module')._extensions['.js'];
|
||||
},
|
||||
},
|
||||
'.js': null,
|
||||
'.jsx': [
|
||||
{
|
||||
module: 'node-jsx',
|
||||
register(hook) {
|
||||
hook.install({ extension: '.jsx', harmony: true });
|
||||
},
|
||||
},
|
||||
],
|
||||
'.toml': {
|
||||
module: 'toml-require',
|
||||
register(hook) {
|
||||
hook.install();
|
||||
},
|
||||
},
|
||||
'.ts': [
|
||||
'typescript-require',
|
||||
{
|
||||
module: '@babel/register',
|
||||
register(hook) {
|
||||
hook({ extensions: '.ts' });
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
23
types/interpret/tsconfig.json
Normal file
23
types/interpret/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"interpret-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/interpret/tslint.json
Normal file
1
types/interpret/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user