mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
[es6template] Add es6template types (#47959)
* Init * Finish * Do it like that * Update types/es6template/index.d.ts Co-authored-by: Sheetal Nandi <shkamat@microsoft.com> Co-authored-by: Sheetal Nandi <shkamat@microsoft.com>
This commit is contained in:
parent
bbe6764e85
commit
52a1d17879
14
types/es6template/es6template-tests.ts
Normal file
14
types/es6template/es6template-tests.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import es6template = require('es6template');
|
||||
|
||||
// This rule is disabled because the library uses ES6-looking template strings, but with normal strings.
|
||||
/* tslint:disable:no-invalid-template-strings */
|
||||
|
||||
const test1 = es6template('foo ${bar} baz ${quux}', {bar: 'BAR', quux: 'QUUX'});
|
||||
const test2 = es6template.render('Hello ${place} and ${user.name}!', {
|
||||
place: 'world',
|
||||
user: {
|
||||
name: 'Charlike'
|
||||
}
|
||||
});
|
||||
const fn = es6template.compile('Hello ${place} and ${user.name}!');
|
||||
const test3 = fn({place: 'world', user: {name: 'Charlike'}});
|
||||
16
types/es6template/index.d.ts
vendored
Normal file
16
types/es6template/index.d.ts
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
// Type definitions for es6template 1.0
|
||||
// Project: https://github.com/zalmoxisus/es6-template
|
||||
// Definitions by: Nathan Bierema <https://github.com/Methuselah96>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
interface Default {
|
||||
render: (str: string, locals: Record<string, unknown>) => string;
|
||||
|
||||
// This rule is disabled because the caller of `compile()` knows what the type of the `locals` parameter should be when
|
||||
// calling the `compile` function.
|
||||
// tslint:disable-next-line:no-unnecessary-generics
|
||||
compile: <Locals>(str: string) => ((locals: Locals) => string);
|
||||
(str: string, locals: Record<string, unknown>): string;
|
||||
}
|
||||
declare const _default: Default;
|
||||
export = _default;
|
||||
23
types/es6template/tsconfig.json
Normal file
23
types/es6template/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",
|
||||
"es6template-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/es6template/tslint.json
Normal file
1
types/es6template/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user