mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Rewriting co-views to work with TypeScript 2 stuff and fixing typing issues. (#11548)
This commit is contained in:
parent
c9c2a0f8fa
commit
e5078805b1
@ -1,13 +1,13 @@
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
/// <reference path="co-views.d.ts" />
|
||||
/// <reference types="node" />
|
||||
/// <reference types="co-views" />
|
||||
|
||||
import views = require('co-views');
|
||||
import * as views from 'co-views';
|
||||
|
||||
const render = views('views', {
|
||||
map: {
|
||||
html: 'swig'
|
||||
map: {
|
||||
html: 'swig',
|
||||
},
|
||||
default: 'jade'
|
||||
default: 'jade',
|
||||
});
|
||||
|
||||
const fileName = 'xxx'; // template file name
|
||||
|
||||
68
co-views/co-views.d.ts
vendored
68
co-views/co-views.d.ts
vendored
@ -1,68 +0,0 @@
|
||||
// Type definitions for co-views v2.1
|
||||
// Project: https://github.com/tj/co-views/
|
||||
// Definitions by: devlee <https://github.com/devlee/>
|
||||
// Definitions: https://github.com/devlee/DefinitelyTyped
|
||||
|
||||
/* =================== USAGE ===================
|
||||
|
||||
import views = require('co-views');
|
||||
const render = views('views', {
|
||||
map: {
|
||||
html: 'swig'
|
||||
},
|
||||
default: 'jade'
|
||||
});
|
||||
|
||||
=============================================== */
|
||||
|
||||
declare module "co-views" {
|
||||
|
||||
interface EngineMap {
|
||||
/**
|
||||
* use for .html files
|
||||
*/
|
||||
html: string
|
||||
}
|
||||
|
||||
interface CoViewsOptions {
|
||||
|
||||
/**
|
||||
* default extname
|
||||
*/
|
||||
ext?: string,
|
||||
|
||||
/**
|
||||
* default extname
|
||||
*/
|
||||
default?: string,
|
||||
|
||||
/**
|
||||
* engine map
|
||||
*/
|
||||
map?: EngineMap,
|
||||
|
||||
/**
|
||||
* proxy partials
|
||||
*/
|
||||
partials?: Object,
|
||||
|
||||
/**
|
||||
* cache compiled templates
|
||||
*/
|
||||
cache?: boolean,
|
||||
|
||||
/**
|
||||
* common locals data
|
||||
*/
|
||||
locals?: Object
|
||||
}
|
||||
|
||||
/**
|
||||
* Pass views `dir` and `opts` to return a render function.
|
||||
*/
|
||||
function views(dir?: string, opts?: CoViewsOptions): {
|
||||
(view: string, locals?: Object): any
|
||||
};
|
||||
|
||||
export = views;
|
||||
}
|
||||
50
co-views/index.d.ts
vendored
Normal file
50
co-views/index.d.ts
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
// Type definitions for co-views v2.1
|
||||
// Project: https://github.com/tj/co-views/
|
||||
// Definitions by: devlee <https://github.com/devlee/>, Joshua DeVinney <https://github.com/geoffreak>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace CoViews {
|
||||
|
||||
/**
|
||||
* Pass views `dir` and `opts` to return a render function.
|
||||
*/
|
||||
export interface Views {
|
||||
(dir?: string, opts?: CoViewsOptions): { (view: string, locals?: Object): any }
|
||||
}
|
||||
|
||||
export interface CoViewsOptions {
|
||||
|
||||
/**
|
||||
* default extname
|
||||
*/
|
||||
ext?: string,
|
||||
|
||||
/**
|
||||
* default extname
|
||||
*/
|
||||
default?: string,
|
||||
|
||||
/**
|
||||
* engine map
|
||||
*/
|
||||
map?: Object,
|
||||
|
||||
/**
|
||||
* proxy partials
|
||||
*/
|
||||
partials?: Object,
|
||||
|
||||
/**
|
||||
* cache compiled templates
|
||||
*/
|
||||
cache?: boolean,
|
||||
|
||||
/**
|
||||
* common locals data
|
||||
*/
|
||||
locals?: Object
|
||||
}
|
||||
}
|
||||
|
||||
declare var CoViews: CoViews.Views;
|
||||
export = CoViews;
|
||||
19
co-views/tsconfig.json
Normal file
19
co-views/tsconfig.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"co-views-tests.ts"
|
||||
]
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user