From 1119ad2d8194a433eee5e9f391aaed0af436cc4b Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 19 Jun 2017 13:00:47 -0700 Subject: [PATCH] More fixes for 2.4. Not all for weak types: 2.4 also has been inference for generics, which finds more errors as well. --- types/angular/index.d.ts | 4 ++++ types/browserify/index.d.ts | 33 +++++++++++++++++---------- types/bunyan-config/index.d.ts | 19 ++++++++++++++- types/hapi/v8/hapi-tests.ts | 10 -------- types/js-data/v1/js-data-tests.ts | 2 +- types/sequelize/v3/index.d.ts | 1 + types/sequelize/v3/sequelize-tests.ts | 1 - 7 files changed, 45 insertions(+), 25 deletions(-) diff --git a/types/angular/index.d.ts b/types/angular/index.d.ts index d0e2d978dc..2692f3929d 100644 --- a/types/angular/index.d.ts +++ b/types/angular/index.d.ts @@ -1846,6 +1846,10 @@ declare namespace angular { * different in Angular 1 there is no direct mapping and care should be taken when upgrading. */ $postLink?(): void; + + // IController implementations frequently do not implement any of its methods. + // A string indexer indicates to TypeScript not to issue a weak type error in this case. + [s: string]: any; } /** diff --git a/types/browserify/index.d.ts b/types/browserify/index.d.ts index 6d03c76efe..5e2c3e86d7 100644 --- a/types/browserify/index.d.ts +++ b/types/browserify/index.d.ts @@ -36,13 +36,22 @@ interface FileOptions { // for each file in a bundle. type InputFile = string | NodeJS.ReadableStream | FileOptions; +/** + * Core options pertaining to a Browserify instance, extended by user options + */ +interface CustomOptions { + /** + * Custom properties can be defined on Options. + * These options are forwarded along to module-deps and browser-pack directly. + */ + [propName: string]: any; + /** the directory that Browserify starts bundling from for filenames that start with .. */ + basedir?: string; +} /** * Options pertaining to a Browserify instance. */ -interface Options { - // Custom properties can be defined on Options. - // These options are forwarded along to module-deps and browser-pack directly. - [propName: string]: any; +interface Options extends CustomOptions { // String, file object, or array of those types (they may be mixed) specifying entry file(s). entries?: InputFile | InputFile[]; // an array which will skip all require() and global parsing for each file in the array. @@ -115,32 +124,32 @@ interface BrowserifyObject extends NodeJS.EventEmitter { * If file is an array, each item in file will be externalized. * If file is another bundle, that bundle's contents will be read and excluded from the current bundle as the bundle in file gets bundled. */ - external(file: string[], opts?: { basedir?: string }): BrowserifyObject; - external(file: string, opts?: { basedir?: string }): BrowserifyObject; + external(file: string[], opts?: CustomOptions): BrowserifyObject; + external(file: string, opts?: CustomOptions): BrowserifyObject; external(file: BrowserifyObject): BrowserifyObject; /** * Prevent the module name or file at file from showing up in the output bundle. * Instead you will get a file with module.exports = {}. */ - ignore(file: string, opts?: { basedir?: string }): BrowserifyObject; + ignore(file: string, opts?: CustomOptions): BrowserifyObject; /** * Prevent the module name or file at file from showing up in the output bundle. * If your code tries to require() that file it will throw unless you've provided another mechanism for loading it. */ - exclude(file: string, opts?: { basedir?: string }): BrowserifyObject; + exclude(file: string, opts?: CustomOptions): BrowserifyObject; /** * Transform source code before parsing it for require() calls with the transform function or module name tr. * If tr is a function, it will be called with tr(file) and it should return a through-stream that takes the raw file contents and produces the transformed source. * If tr is a string, it should be a module name or file path of a transform module */ - transform(tr: string, opts?: T): BrowserifyObject; - transform(tr: (file: string, opts: T) => NodeJS.ReadWriteStream, opts?: T): BrowserifyObject; + transform(tr: string, opts?: T): BrowserifyObject; + transform(tr: (file: string, opts: T) => NodeJS.ReadWriteStream, opts?: T): BrowserifyObject; /** * Register a plugin with opts. Plugins can be a string module name or a function the same as transforms. * plugin(b, opts) is called with the Browserify instance b. */ - plugin(plugin: string, opts?: T): BrowserifyObject; - plugin(plugin: (b: BrowserifyObject, opts: T) => any, opts?: T): BrowserifyObject; + plugin(plugin: string, opts?: T): BrowserifyObject; + plugin(plugin: (b: BrowserifyObject, opts: T) => any, opts?: T): BrowserifyObject; /** * Reset the pipeline back to a normal state. This function is called automatically when bundle() is called multiple times. * This function triggers a 'reset' event. diff --git a/types/bunyan-config/index.d.ts b/types/bunyan-config/index.d.ts index 49b642eaa1..0ff84fd9d2 100644 --- a/types/bunyan-config/index.d.ts +++ b/types/bunyan-config/index.d.ts @@ -7,6 +7,23 @@ declare module "bunyan-config" { import * as bunyan from "bunyan"; + interface StreamConfiguration { + name: string, + params?: { + host: string, + port: number + } + } + + interface Stream { + type?: string; + level?: bunyan.LogLevel; + path?: string; + stream?: string | StreamConfiguration + closeOnExit?: boolean; + period?: string; + count?: number; + } /** * Configuration. @@ -14,7 +31,7 @@ declare module "bunyan-config" { */ interface Configuration { name: string; - streams?: bunyan.Stream[]; + streams?: Stream[]; level?: string | number; stream?: NodeJS.WritableStream; serializers?: {}; diff --git a/types/hapi/v8/hapi-tests.ts b/types/hapi/v8/hapi-tests.ts index 585e58e100..ee8af0d335 100644 --- a/types/hapi/v8/hapi-tests.ts +++ b/types/hapi/v8/hapi-tests.ts @@ -124,15 +124,5 @@ server.route([{ } }]); -// Implict handler -server.route({ - method: 'GET', - path: '/hello6', - handler: function (request, reply) { - request.log('info', { route: '/hello' }, Date.now()); - reply('hello world'); - } -}); - // Start the server server.start(); diff --git a/types/js-data/v1/js-data-tests.ts b/types/js-data/v1/js-data-tests.ts index 0832f066d9..69a056b081 100644 --- a/types/js-data/v1/js-data-tests.ts +++ b/types/js-data/v1/js-data-tests.ts @@ -30,7 +30,7 @@ User.find(1).then(function (user:IUser) { var user:IUser = User.createInstance({name: 'John'}); var store = new JSData.DS(); -var User2 = store.defineResource('user'); +var User2 = store.defineResource('user'); var user:IUser = User2.inject({id: 1, name: 'John'}); var user2:IUser = User2.inject({id: 1, age: 30}); diff --git a/types/sequelize/v3/index.d.ts b/types/sequelize/v3/index.d.ts index 1a3ce50d0c..1d062cd1da 100644 --- a/types/sequelize/v3/index.d.ts +++ b/types/sequelize/v3/index.d.ts @@ -3130,6 +3130,7 @@ declare namespace sequelize { */ include?: Array | IncludeOptions>; + all?: boolean | string; } /** diff --git a/types/sequelize/v3/sequelize-tests.ts b/types/sequelize/v3/sequelize-tests.ts index 9dcfd3e80b..78a89ed2d4 100644 --- a/types/sequelize/v3/sequelize-tests.ts +++ b/types/sequelize/v3/sequelize-tests.ts @@ -904,7 +904,6 @@ User.findOne( { where : { id : 1 }, attributes : ['id', ['username', 'name']] } User.findOne( { where : { id : 1 }, attributes : ['id'] } ); User.findOne( { where : { username : 'foo' }, logging : function( ) { } } ); User.findOne( { limit : 10 } ); -User.findOne( { include : [1] } ); User.findOne( { where : { title : 'homework' }, include : [User] } ); User.findOne( { where : { name : 'environment' }, include : [{ model : User, as : 'PrivateDomain' }] } ); User.findOne( { where : { username : 'foo' }, transaction : t } ).then( ( p ) => p );