mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
fix(less): type definitions on options and rootFileInfo (#29631)
* fix(less): type definitions on options and rootFileInfo Signed-off-by: Richard Lea <chigix@zoho.com> * fix(less): addition to tests including newly defined options Signed-off-by: Richard Lea <chigix@zoho.com> * fix(less): support number for math option Signed-off-by: Richard Lea <chigix@zoho.com>
This commit is contained in:
committed by
Sheetal Nandi
parent
8328afe0bb
commit
03dadc776c
Vendored
+57
-3
@@ -1,18 +1,29 @@
|
||||
// Type definitions for LESS
|
||||
// Type definitions for LESS 3.x
|
||||
// Project: http://lesscss.org/
|
||||
// Definitions by: Tom Hasner <https://github.com/thasner>
|
||||
// Pranay Prakash <https://github.com/pranaygp>
|
||||
// Daniel Waxweiler <https://github.com/dwaxweiler>
|
||||
// Richard Lea <https://github.com/chigix>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace Less {
|
||||
// https://github.com/less/less.js/blob/master/lib/less/import-manager.js#L10
|
||||
interface RootFileInfo {
|
||||
/** whether to adjust URL's to be relative */
|
||||
rewriteUrls?: boolean;
|
||||
/** full resolved filename of current file */
|
||||
filename: string;
|
||||
relativeUrls: boolean;
|
||||
/** path to append to normal URLs for this node */
|
||||
rootpath: string;
|
||||
/** path to the current file, absolute */
|
||||
currentDirectory: string;
|
||||
/** absolute path to the entry file */
|
||||
entryPath: string;
|
||||
/** filename of the base file */
|
||||
rootFilename: string;
|
||||
/** whether the file should not be output and only output parts that are referenced */
|
||||
reference: boolean;
|
||||
}
|
||||
|
||||
class PluginManager {
|
||||
@@ -59,11 +70,54 @@ declare namespace Less {
|
||||
contents: { [fileName: string]: string };
|
||||
}
|
||||
|
||||
/**
|
||||
* Reference to:
|
||||
* * https://github.com/less/less.js/blob/master/bin/lessc
|
||||
* * http://lesscss.org/usage/#less-options
|
||||
*
|
||||
* @interface Options
|
||||
*/
|
||||
interface Options {
|
||||
sourceMap?: SourceMapOption;
|
||||
/** Filename of the main file to be passed to less.render() */
|
||||
filename?: string;
|
||||
/** The locations for less looking for files in @import rules */
|
||||
paths?: string[];
|
||||
/** True, if run the less parser and just reports errors without any output. */
|
||||
lint?: boolean;
|
||||
/** Pre-load global Less.js plugins */
|
||||
plugins?: Plugin[];
|
||||
rootFileInfo?: RootFileInfo;
|
||||
/** @deprecated If true, compress using less built-in compression. */
|
||||
compress?: boolean;
|
||||
strictImports?: boolean;
|
||||
/** If true, allow imports from insecure https hosts. */
|
||||
insecure?: boolean;
|
||||
depends?: boolean;
|
||||
maxLineLen?: number;
|
||||
/** @deprecated If false, No color in compiling. */
|
||||
color?: boolean;
|
||||
/** @deprecated False by default. */
|
||||
ieCompat?: boolean;
|
||||
/** @deprecated If true, enable evaluation of JavaScript inline in `.less` files. */
|
||||
javascriptEnabled?: boolean;
|
||||
/** Whether output file information and line numbers in compiled CSS code. */
|
||||
dumpLineNumbers?: "comment" | string;
|
||||
/** Add a path to every generated import and url in output css files. */
|
||||
rootpath?: string;
|
||||
/** Math mode options for avoiding symbol conficts on math expressions. */
|
||||
math?: 'always' | 'strict' | 'parens-division' | 'parens' | 'strict-legacy' | number;
|
||||
/** If true, stops any warnings from being shown. */
|
||||
silent?: boolean;
|
||||
/** Without this option, Less attempts to guess at the output unit when it does maths. */
|
||||
strictUnits?: boolean;
|
||||
/** Defines a variable that can be referenced by the file. */
|
||||
globalVars?: {
|
||||
[key: string] : string,
|
||||
};
|
||||
/** Puts Var declaration at the end of base file. */
|
||||
modifyVars?: {
|
||||
[key: string] : string,
|
||||
};
|
||||
}
|
||||
|
||||
interface RenderError {
|
||||
@@ -109,7 +163,7 @@ interface LessStatic {
|
||||
refresh(reload?: boolean, modifyVars?: { [variable: string]: string }, clearFileCache?: boolean): Promise<Less.RefreshOutput>;
|
||||
|
||||
version: number[];
|
||||
|
||||
|
||||
watch(): void;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,8 +30,47 @@ var myPlugin: Less.Plugin = {
|
||||
}
|
||||
};
|
||||
|
||||
/** Reference to:
|
||||
* https://github.com/less/less.js/blob/master/lib/less/default-options.js
|
||||
*/
|
||||
var options: Less.Options = {
|
||||
plugins: [myPlugin]
|
||||
plugins: [myPlugin],
|
||||
/** Tells less to generate a sourcemap. */
|
||||
sourceMap: {},
|
||||
/* Inline Javascript - @plugin still allowed */
|
||||
javascriptEnabled: false,
|
||||
/* Outputs a makefile import dependency list to stdout. */
|
||||
depends: false,
|
||||
/** (DEPRECATED) This does not utilise all the tricks of css compression. */
|
||||
compress: false,
|
||||
/* Runs the less parser and just reports errors without any output. */
|
||||
lint: false,
|
||||
/** Less will look for the file in @import rules through locations here. */
|
||||
paths: [],
|
||||
/* color output in the terminal */
|
||||
color: true,
|
||||
/** See: https://github.com/less/less.js/issues/656 */
|
||||
strictImports: false,
|
||||
/* Allow Imports from Insecure HTTPS Hosts */
|
||||
insecure: true,
|
||||
/** Add a path to every generated import and url in your css */
|
||||
rootpath: '',
|
||||
/**
|
||||
* How to process math
|
||||
* 0 always - eagerly try to solve all operations
|
||||
* 1 parens-division - require parens for division "/"
|
||||
* 2 parens | strict - require parens for all operations
|
||||
* 3 strict-legacy - legacy strict behavior (super-strict)
|
||||
* https://github.com/less/less.js/blob/master/lib/less/constants.js#L2
|
||||
* https://github.com/less/less.js/blob/master/lib/less/utils.js#L54
|
||||
*/
|
||||
math: 0,
|
||||
/* Guess at the output unit when it does maths. */
|
||||
strictUnits: false,
|
||||
/** Put declaration at the top of base less file. */
|
||||
globalVars: null,
|
||||
/** Put the declaration at the end of base file. */
|
||||
modifyVars: null
|
||||
};
|
||||
|
||||
less.render("h1 { background: red; }", options);
|
||||
|
||||
Reference in New Issue
Block a user