Fixed problem with using static BrowserSync functions on an instance causing a runtime error

This commit is contained in:
Joe Skeen
2015-09-30 08:07:12 -06:00
parent 596a8af137
commit de62c43264
2 changed files with 26 additions and 16 deletions
+3 -1
View File
@@ -79,9 +79,11 @@ bs.init({
bs.reload();
function browserSyncInit(): typeof browserSync {
function browserSyncInit() {
var browser = browserSync.create();
browser.init();
console.log(browser.name);
console.log(browserSync.name);
return browser;
}
var browser = browserSyncInit();
+23 -15
View File
@@ -316,24 +316,32 @@ declare module "browser-sync" {
fn: (match: string) => string;
}
interface BrowserSync {
(config?: Options, callback?: (err: Error, bs: Object) => any): void;
/**
* Create a Browsersync instance
* @param name an identifier that can used for retrieval later
*/
create(name?: string): BrowserSync;
/**
* Get a single instance by name. This is useful if you have your build scripts in separate files
* @param name the identifier used for retrieval
*/
get(name: string): BrowserSync;
interface BrowserSyncStatic extends BrowserSyncInstance {
/**
* Start the Browsersync service. This will launch a server, proxy or start the snippet mode
* depending on your use-case.
*/
init(config?: Options, callback?: (err: Error, bs: Object) => any): void;
(config?: Options, callback?: (err: Error, bs: Object) => any): BrowserSyncInstance;
/**
* Create a Browsersync instance
* @param name an identifier that can used for retrieval later
*/
create(name?: string): BrowserSyncInstance;
/**
* Get a single instance by name. This is useful if you have your build scripts in separate files
* @param name the identifier used for retrieval
*/
get(name: string): BrowserSyncInstance;
}
interface BrowserSyncInstance {
/** the name of this instance of browser-sync */
name: string;
/**
* Start the Browsersync service. This will launch a server, proxy or start the snippet mode
* depending on your use-case.
*/
init(config?: Options, callback?: (err: Error, bs: Object) => any): BrowserSyncInstance;
/**
* Reload the browser
* The reload method will inform all browsers about changed files and will either cause the browser
@@ -400,7 +408,7 @@ declare module "browser-sync" {
paused: boolean;
}
const browserSync: BrowserSync;
const browserSync: BrowserSyncStatic;
export = browserSync;
}