diff --git a/autoprefixer-core/autoprefixer-core-tests.ts b/autoprefixer-core/autoprefixer-core-tests.ts new file mode 100644 index 000000000..9ff4e7695 --- /dev/null +++ b/autoprefixer-core/autoprefixer-core-tests.ts @@ -0,0 +1,9 @@ +/// +import autoprefixer = require("autoprefixer-core"); + +var css: string; + +var prefixed = autoprefixer.process(css).css; + +var processor = autoprefixer({ browsers: ['> 1%', 'IE 7'], cascade: false }); +console.log(processor.info()); diff --git a/autoprefixer-core/autoprefixer-core.d.ts b/autoprefixer-core/autoprefixer-core.d.ts new file mode 100644 index 000000000..905447acf --- /dev/null +++ b/autoprefixer-core/autoprefixer-core.d.ts @@ -0,0 +1,44 @@ +// Type definitions for Autoprefixer Core 5.1.11 +// Project: https://github.com/postcss/autoprefixer-core +// Definitions by: Asana +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "autoprefixer-core" { + interface Config { + browsers?: string[]; + cascade?: boolean; + remove?: boolean; + } + + interface Options { + from?: string; + to?: string; + safe?: boolean; + map?: { + inline?: boolean; + prev?: string | Object; + } + } + + interface Result { + css: string; + map: string; + opts: Options; + } + + interface Processor { + postcss: any; + info(): string; + process(css: string, opts?: Options): Result; + } + + interface Exports { + (config: Config): Processor; + postcss: any; + info(): string; + process(css: string, opts?: Options): Result; + } + + var exports: Exports; + export = exports; +} diff --git a/node-sass/node-sass-tests.ts b/node-sass/node-sass-tests.ts new file mode 100644 index 000000000..a7c1477cb --- /dev/null +++ b/node-sass/node-sass-tests.ts @@ -0,0 +1,71 @@ +/// +import sass = require('node-sass'); +sass.render({ + file: '/path/to/myFile.scss', + data: 'body{background:blue; a{color:black;}}', + importer: function(url, prev, done) { + // url is the path in import as is, which libsass encountered. + // prev is the previously resolved path. + // done is an optional callback, either consume it or return value synchronously. + // this.options contains this options hash, this.callback contains the node-style callback + someAsyncFunction(url, prev, function(result) { + done({ + file: result.path, // only one of them is required, see section Sepcial Behaviours. + contents: result.data + }); + }); + // OR + var result = someSyncFunction(url, prev); + return { file: result.path, contents: result.data }; + }, + includePaths: ['lib/', 'mod/'], + outputStyle: 'compressed' +}, function(error, result) { // node-style callback from v3.0.0 onwards + if (error) { + console.log(error.status); // used to be "code" in v2x and below + console.log(error.column); + console.log(error.message); + console.log(error.line); + } + else { + console.log(result.css.toString()); + + console.log(result.stats); + + console.log(result.map.toString()); + // or better + console.log(JSON.stringify(result.map)); // note, JSON.stringify accepts Buffer too + } +}); +// OR +var result = sass.renderSync({ + file: '/path/to/file.scss', + data: 'body{background:blue; a{color:black;}}', + outputStyle: 'compressed', + outFile: '/to/my/output.css', + sourceMap: true, // or an absolute or relative (to outFile) path + importer: function(url, prev, done) { + // url is the path in import as is, which libsass encountered. + // prev is the previously resolved path. + // done is an optional callback, either consume it or return value synchronously. + // this.options contains this options hash + someAsyncFunction(url, prev, function(result) { + done({ + file: result.path, // only one of them is required, see section Sepcial Behaviours. + contents: result.data + }); + }); + // OR + var result = someSyncFunction(url, prev); + return { file: result.path, contents: result.data }; + }, +}); + +console.log(result.css); +console.log(result.map); +console.log(result.stats); + +function someAsyncFunction(url: string, prev: string, callback: (result: { path: string; data: string }) => void): void {} +function someSyncFunction(url: string, prev: string): { path: string; data: string} { + return null; +} diff --git a/node-sass/node-sass.d.ts b/node-sass/node-sass.d.ts new file mode 100644 index 000000000..09ea71d4e --- /dev/null +++ b/node-sass/node-sass.d.ts @@ -0,0 +1,56 @@ +// Type definitions for Node Sass +// Project: https://github.com/sass/node-sass +// Definitions by: Asana +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "node-sass" { + interface Importer { + (url: string, prev: string, done: (data: { file: string; contents: string; }) => void): void; + } + + interface Options { + file?: string; + data?: string; + importer?: Importer | Importer[]; + functions?: { [key: string]: Function }; + includePaths?: string[]; + indentedSyntax?: boolean; + indentType?: string; + indentWidth?: number; + linefeed?: string; + omitSourceMapUrl?: boolean; + outFile?: string; + outputStyle?: string; + precision?: number; + sourceComments?: boolean; + sourceMap?: boolean | string; + sourceMapContents?: boolean; + sourceMapEmbed?: boolean; + sourceMapRoot?: boolean; + } + + interface SassError extends Error { + message: string; + line: number; + column: number; + status: number; + file: string; + } + + interface Result { + css: Buffer; + map: Buffer; + stats: { + entry: string; + start: number; + end: number; + duration: number; + includedFiles: string[]; + } + } + + export function render(options: Options, callback: (err: SassError, result: Result) => any): void; + export function renderSync(options: Options): Result; +}