From 4874667de9cb229d6b14f1fb46d48f4f4089aa20 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 15 Jun 2017 11:46:46 -0700 Subject: [PATCH 1/2] Fix primitive weak type errors These weak type errors were not caught in TS 2.4 RC. The final TS 2.4 will catch weak type errors with primitives, so this PR fixes those now-caught errors. --- types/arcgis-js-api/arcgis-js-api-tests.ts | 2 +- types/auth0-js/auth0-js-tests.ts | 2 +- types/browser-sync/browser-sync-tests.ts | 2 +- types/chai/chai-tests.ts | 2 +- types/chart.js/index.d.ts | 3 +++ types/execa/execa-tests.ts | 2 +- types/extended-listbox/extended-listbox-tests.ts | 2 +- types/fabric/fabric-tests.ts | 2 +- types/facebook-pixel/facebook-pixel-tests.ts | 5 ++++- types/flexslider/flexslider-tests.ts | 6 +++--- types/form-data/form-data-tests.ts | 2 +- types/gulp-shell/gulp-shell-tests.ts | 2 +- types/hapi/index.d.ts | 4 ++++ types/hapi/test/route/validate.ts | 2 +- types/heredatalens/index.d.ts | 2 +- types/heremaps/index.d.ts | 2 +- types/homeworks/tsconfig.json | 4 ++-- types/jquery.pnotify/jquery.pnotify-tests.ts | 6 +++--- types/jquery.tipsy/jquery.tipsy-tests.ts | 6 +++--- types/jqueryui/index.d.ts | 1 + types/knockout/index.d.ts | 1 + types/node/node-tests.ts | 2 +- types/ramda/index.d.ts | 4 ++-- types/randomstring/index.d.ts | 2 +- types/react-addons-update/index.d.ts | 2 +- types/react-router/test/MemoryRouter.tsx | 2 +- types/react/test/index.ts | 2 +- types/rx.wamp/rx.wamp-tests.ts | 6 +++--- types/sipml/sipml-tests.ts | 2 +- types/svg-sprite/index.d.ts | 2 +- types/zeroclipboard/index.d.ts | 12 +++++++++++- 31 files changed, 59 insertions(+), 37 deletions(-) diff --git a/types/arcgis-js-api/arcgis-js-api-tests.ts b/types/arcgis-js-api/arcgis-js-api-tests.ts index d5dfb99406..d2b961df66 100644 --- a/types/arcgis-js-api/arcgis-js-api-tests.ts +++ b/types/arcgis-js-api/arcgis-js-api-tests.ts @@ -15,7 +15,7 @@ class MapController { }); this.map = new Map({ - basemap: "topo" + basemap: { title: "topo" } }); let view = new MapView({ diff --git a/types/auth0-js/auth0-js-tests.ts b/types/auth0-js/auth0-js-tests.ts index 8b81e6f7b2..e3e30167c0 100644 --- a/types/auth0-js/auth0-js-tests.ts +++ b/types/auth0-js/auth0-js-tests.ts @@ -175,7 +175,7 @@ authentication.buildAuthorizeUrl({ connection_scope: 'scope1,scope2' }); -authentication.buildLogoutUrl('asdfasdfds'); +authentication.buildLogoutUrl({ clientID: 'asdfasdfds' }); authentication.buildLogoutUrl(); authentication.userInfo('abcd1234', (err, data) => { //user info retrieved diff --git a/types/browser-sync/browser-sync-tests.ts b/types/browser-sync/browser-sync-tests.ts index 43d68326ea..c20f27236a 100644 --- a/types/browser-sync/browser-sync-tests.ts +++ b/types/browser-sync/browser-sync-tests.ts @@ -82,7 +82,7 @@ var has = browserSync.has("My server"); var bs = browserSync.create(); bs.init({ - server: "./app" + server: { index: "./app" } }); bs.reload(); diff --git a/types/chai/chai-tests.ts b/types/chai/chai-tests.ts index 85e16c4f63..69353163cd 100644 --- a/types/chai/chai-tests.ts +++ b/types/chai/chai-tests.ts @@ -1343,7 +1343,7 @@ suite('assert', () => { assert.lengthOf([1, 2, 3], 3); assert.lengthOf('foobar', 6); assert.lengthOf('foobar', 5); - assert.lengthOf(1, 5); + assert.lengthOf({ length: 1 }, 5); }); test('match', () => { diff --git a/types/chart.js/index.d.ts b/types/chart.js/index.d.ts index ec8a7c0c03..bc352735a9 100644 --- a/types/chart.js/index.d.ts +++ b/types/chart.js/index.d.ts @@ -263,6 +263,9 @@ declare namespace Chart { borderDash?: any[]; borderDashOffset?: number; borderJoinStyle?: string; + capBezierPoints?: boolean; + fill?: 'zero' | 'top' | 'bottom' | boolean; + stepped?: boolean; } export interface ChartPointOptions { diff --git a/types/execa/execa-tests.ts b/types/execa/execa-tests.ts index 7d5e21e4b4..fd7428d1ae 100644 --- a/types/execa/execa-tests.ts +++ b/types/execa/execa-tests.ts @@ -45,7 +45,7 @@ execa.shell('echo unicorns') { let result: string; result = execa.shellSync('foo').stderr; - result = execa.shellSync('noop', ['foo']).stdout; + result = execa.shellSync('noop', { cwd: 'foo' }).stdout; result = execa.shellSync('foo').stderr; result = execa.shellSync('noop foo').stdout; diff --git a/types/extended-listbox/extended-listbox-tests.ts b/types/extended-listbox/extended-listbox-tests.ts index 4d03ada74e..e3dcba4735 100644 --- a/types/extended-listbox/extended-listbox-tests.ts +++ b/types/extended-listbox/extended-listbox-tests.ts @@ -46,7 +46,7 @@ var id: string = instance.addItem("Test2"); var item: ListboxItem = {}; item.selected = true; item.disabled = false; -item.childItems = ["Test4"]; +item.childItems = [{ text: "Test4" }]; item.groupHeader = false; item.id = "ouetioreit"; item.index = 0; diff --git a/types/fabric/fabric-tests.ts b/types/fabric/fabric-tests.ts index 9966e081d8..5e51bb8035 100644 --- a/types/fabric/fabric-tests.ts +++ b/types/fabric/fabric-tests.ts @@ -547,7 +547,7 @@ function sample8() { if (!fabric.Canvas.supports('toDataURL')) { alert('This browser doesn\'t provide means to serialize canvas to an image'); } else { - window.open(canvas.toDataURL('png')); + window.open(canvas.toDataURL({ format: 'png' })); } }; diff --git a/types/facebook-pixel/facebook-pixel-tests.ts b/types/facebook-pixel/facebook-pixel-tests.ts index c26c8b109d..7a3ab59df1 100644 --- a/types/facebook-pixel/facebook-pixel-tests.ts +++ b/types/facebook-pixel/facebook-pixel-tests.ts @@ -13,7 +13,10 @@ fbq('track', 'Purchase', purchaseParam); // Custom event (can only be used for audience building) -var custom_params = {custom_param: 'custom_value'}; +var custom_params = { + custom_param: 'custom_value', + content_type: 'product' +}; fbq('trackCustom', 'MyCustomEvent', custom_params); // Reach customers that viewed a product in the 'Shoes' category diff --git a/types/flexslider/flexslider-tests.ts b/types/flexslider/flexslider-tests.ts index 591e874262..ef1514e593 100644 --- a/types/flexslider/flexslider-tests.ts +++ b/types/flexslider/flexslider-tests.ts @@ -73,10 +73,10 @@ $(window).load(function() { function ready(player_id: any) { var froogaloop = $(player_id); froogaloop.on('play', function(data) { - $('.flexslider').flexslider("pause"); + $('.flexslider').flexslider({ pauseText: "pause" }); }); froogaloop.on('pause', function(data) { - $('.flexslider').flexslider("play"); + $('.flexslider').flexslider({ playText: "play" }); }); } -}); \ No newline at end of file +}); diff --git a/types/form-data/form-data-tests.ts b/types/form-data/form-data-tests.ts index 6d1b9d6cb9..93457df3be 100644 --- a/types/form-data/form-data-tests.ts +++ b/types/form-data/form-data-tests.ts @@ -18,7 +18,7 @@ import * as ImportUsingES6Syntax from 'form-data'; () => { var form = new FormData(); - http.request('http://nodejs.org/images/logo.png', function (response) { + http.request({ path: 'http://nodejs.org/images/logo.png' }, function (response) { form.append('my_field', 'my value'); form.append('my_buffer', new Buffer(10)); form.append('my_logo', response); diff --git a/types/gulp-shell/gulp-shell-tests.ts b/types/gulp-shell/gulp-shell-tests.ts index 581808670c..17357d6c70 100644 --- a/types/gulp-shell/gulp-shell-tests.ts +++ b/types/gulp-shell/gulp-shell-tests.ts @@ -35,5 +35,5 @@ gulp.task('lint', shell.task('eslint ' + paths.js.join(' '))); gulp.task('default', gulp.parallel('coverage', 'lint')); gulp.task('watch', function () { - gulp.watch(paths.js, ['default']) + gulp.watch(paths.js) }); diff --git a/types/hapi/index.d.ts b/types/hapi/index.d.ts index efce9f3dc4..f0ed602864 100644 --- a/types/hapi/index.d.ts +++ b/types/hapi/index.d.ts @@ -678,6 +678,10 @@ export interface CatboxServerCacheConfiguration extends Catbox.PolicyOptions { * [See docs](https://hapijs.com/api/16.1.1#servercacheprovisionoptions-callback) example code includes use of `name` option. But server.cache.provision of `options` says "same as the server cache configuration options.". */ name?: string; + /** + * Additional options to be passed to the Catbox strategy + */ + [s: string]: any; } /** diff --git a/types/hapi/test/route/validate.ts b/types/hapi/test/route/validate.ts index f579bff8a8..cb5c5527ee 100644 --- a/types/hapi/test/route/validate.ts +++ b/types/hapi/test/route/validate.ts @@ -25,7 +25,7 @@ let config: Hapi.RouteAdditionalConfigurationOptions = { }, }; -interface CustomValidationOptions { +interface CustomValidationOptions extends Joi.ValidationOptions { myOption: number; } diff --git a/types/heredatalens/index.d.ts b/types/heredatalens/index.d.ts index 9b3ff44431..0c68c88a45 100644 --- a/types/heredatalens/index.d.ts +++ b/types/heredatalens/index.d.ts @@ -181,7 +181,7 @@ declare namespace H { * @param service {H.datalens.Service} - Data Lens REST API service * @param options {H.datalens.QueryProvider.Options=} - Configures source query and data accessibility parameters */ - constructor(data: H.datalens.Service.Data, options?: H.map.provider.Provider.Options); + constructor(data: H.datalens.Service.Data, options?: H.datalens.QueryProvider.Options); /** * Updates the query ID to be used in the next call of the Data Lens REST API. diff --git a/types/heremaps/index.d.ts b/types/heremaps/index.d.ts index bfdd353dd3..839083ab63 100644 --- a/types/heremaps/index.d.ts +++ b/types/heremaps/index.d.ts @@ -4462,7 +4462,7 @@ declare namespace H { normal?: H.service.MapType; satellite?: H.service.MapType; terrain?: H.service.MapType; - [key: string]: H.service.MapType; + [key: string]: H.service.MapType | undefined; } } diff --git a/types/homeworks/tsconfig.json b/types/homeworks/tsconfig.json index 65f6fc4f01..c9dd45d7cd 100644 --- a/types/homeworks/tsconfig.json +++ b/types/homeworks/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6" + "es6", "dom" ], "noImplicitAny": true, "noImplicitThis": true, @@ -19,4 +19,4 @@ "index.d.ts", "homeworks-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/jquery.pnotify/jquery.pnotify-tests.ts b/types/jquery.pnotify/jquery.pnotify-tests.ts index f1b8ffb73e..fa4f008ef9 100644 --- a/types/jquery.pnotify/jquery.pnotify-tests.ts +++ b/types/jquery.pnotify/jquery.pnotify-tests.ts @@ -21,9 +21,9 @@ function test_pnotify() { text: 'I don\'t have a shadow. (It\'s cause I\'m a vampire or something. Or is that reflections...)', shadow: false }); - new PNotify('Check me out! I\'m a notice.'); + // new PNotify('Check me out! I\'m a notice.'); - new PNotify(Math.round(Math.random() * 9999)); + // new PNotify(Math.round(Math.random() * 9999)); new PNotify({ title: 'PIcon Notice', @@ -216,7 +216,7 @@ function test_pnotify() { icon: "fa fa-bars", delay: 20000, history: false, - stack: false + stack: {} }); var type = "error"; diff --git a/types/jquery.tipsy/jquery.tipsy-tests.ts b/types/jquery.tipsy/jquery.tipsy-tests.ts index 09ba7f2d68..8a0591e137 100644 --- a/types/jquery.tipsy/jquery.tipsy-tests.ts +++ b/types/jquery.tipsy/jquery.tipsy-tests.ts @@ -22,8 +22,8 @@ $(function() { $('#focus-example [title]').tipsy({trigger: 'focus', gravity: 'w'}); }); -function onclickExample1() { $("#manual-example a[rel=tipsy]").tipsy("show"); return false; } -function onclickExample2() { $("#manual-example a[rel=tipsy]").tipsy("hide"); return false; } +function onclickExample1() { $("#manual-example a[rel=tipsy]").tipsy({ title: "show" }); return false; } +function onclickExample2() { $("#manual-example a[rel=tipsy]").tipsy({ title: "hide" }); return false; } $('#manual-example a[rel=tipsy]').tipsy({trigger: 'manual'}); -$('a.live-tipsy').tipsy({live: true}); \ No newline at end of file +$('a.live-tipsy').tipsy({live: true}); diff --git a/types/jqueryui/index.d.ts b/types/jqueryui/index.d.ts index d74cc76c66..3935c80468 100644 --- a/types/jqueryui/index.d.ts +++ b/types/jqueryui/index.d.ts @@ -1804,6 +1804,7 @@ interface JQuery { tabs(methodName: 'load', index: number): void; tabs(methodName: 'refresh'): void; tabs(methodName: 'widget'): JQuery; + tabs(methodName: 'select', index: number): JQuery; tabs(methodName: string): JQuery; tabs(options: JQueryUI.TabsOptions): JQuery; tabs(optionLiteral: string, optionName: string): any; diff --git a/types/knockout/index.d.ts b/types/knockout/index.d.ts index 570d0ee830..40464a3bd8 100644 --- a/types/knockout/index.d.ts +++ b/types/knockout/index.d.ts @@ -154,6 +154,7 @@ interface KnockoutBindingHandler { update?: (element: any, valueAccessor: () => any, allBindingsAccessor?: KnockoutAllBindingsAccessor, viewModel?: any, bindingContext?: KnockoutBindingContext) => void; options?: any; preprocess?: (value: string, name: string, addBindingCallback?: (name: string, value: string) => void) => string; + [s: string]: any; } interface KnockoutBindingHandlers { diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index 35260b138b..1752683835 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -981,7 +981,7 @@ namespace http_tests { } { - var request = http.request('http://0.0.0.0'); + var request = http.request({ path: 'http://0.0.0.0' }); request.once('error', function() { }); request.setNoDelay(true); request.abort(); diff --git a/types/ramda/index.d.ts b/types/ramda/index.d.ts index 4d6be6138f..18c707f127 100644 --- a/types/ramda/index.d.ts +++ b/types/ramda/index.d.ts @@ -202,8 +202,8 @@ declare namespace R { * A function that returns the first argument if it's falsy otherwise the second argument. Note that this is * NOT short-circuited, meaning that if expressions are passed they are both evaluated. */ - and(fn1: T, val2: boolean|any): boolean; - and(fn1: T): (val2: boolean|any) => boolean; + and(fn1: T, val2: boolean|any): boolean; + and(fn1: T): (val2: boolean|any) => boolean; /** * Returns true if at least one of elements of the list match the predicate, false otherwise. diff --git a/types/randomstring/index.d.ts b/types/randomstring/index.d.ts index e683cef6b7..173b311465 100644 --- a/types/randomstring/index.d.ts +++ b/types/randomstring/index.d.ts @@ -11,7 +11,7 @@ declare namespace Randomstring { capitalization?: string; } - function generate(options?: GenerateOptions): string; + function generate(options?: GenerateOptions | number): string; } declare module "randomstring" { diff --git a/types/react-addons-update/index.d.ts b/types/react-addons-update/index.d.ts index 76f5b32d3c..0729aaf1e0 100644 --- a/types/react-addons-update/index.d.ts +++ b/types/react-addons-update/index.d.ts @@ -19,7 +19,7 @@ declare module 'react' { [key: string]: UpdateSpec; } - type UpdateSpec = UpdateSpecCommand | UpdateSpecPath; + type UpdateSpec = number[][] | UpdateSpecCommand | UpdateSpecPath; interface UpdateArraySpec extends UpdateSpecCommand { $push?: any[]; diff --git a/types/react-router/test/MemoryRouter.tsx b/types/react-router/test/MemoryRouter.tsx index 7d947e436e..99aa385bd5 100644 --- a/types/react-router/test/MemoryRouter.tsx +++ b/types/react-router/test/MemoryRouter.tsx @@ -13,7 +13,7 @@ const initialRouterEntries = [ ]; const MemoryRouterExample = () => ( - +
  • Home
  • diff --git a/types/react/test/index.ts b/types/react/test/index.ts index f0fee7a00b..fc042d881c 100644 --- a/types/react/test/index.ts +++ b/types/react/test/index.ts @@ -11,7 +11,7 @@ import TestUtils = require("react-addons-test-utils"); import TransitionGroup = require("react-addons-transition-group"); import update = require("react-addons-update"); -interface Props { +interface Props extends React.Attributes { hello: string; world?: string; foo: number; diff --git a/types/rx.wamp/rx.wamp-tests.ts b/types/rx.wamp/rx.wamp-tests.ts index 178c8d5e14..16c036f0a3 100644 --- a/types/rx.wamp/rx.wamp-tests.ts +++ b/types/rx.wamp/rx.wamp-tests.ts @@ -8,7 +8,7 @@ function nodeJS(session: autobahn.Session) { } function connection() { - var connectionSubscription = Rx.Observable.fromConnection("ws://localhost:9000") + var connectionSubscription = Rx.Observable.fromConnection({ url: "ws://localhost:9000" }) .subscribe(session => console.log("A new session was created")); //Close our current connection and don't retry @@ -32,11 +32,11 @@ function subscribe_to_topics(session: autobahn.Session, options: autobahn.ISubsc } function new_in_version3(onResult: Rx.Observer) { - Rx.Observable.subscribeAsObservable(Rx.Observable.fromConnection("ws://myconnectionurl:9090"), "wamp.my.foo", undefined, onResult); + Rx.Observable.subscribeAsObservable(Rx.Observable.fromConnection({ url: "ws://myconnectionurl:9090" }), "wamp.my.foo", undefined, onResult); } function new_in_version5(fooObserver: Rx.Observer) { - var connection = Rx.Observable.fromConnection("ws://myconnectionurl:9090"); + var connection = Rx.Observable.fromConnection({ url: "ws://myconnectionurl:9090" }); //You can subscribe to as many items as you want var subscriber = diff --git a/types/sipml/sipml-tests.ts b/types/sipml/sipml-tests.ts index e88f11f0ff..a335d33dd0 100644 --- a/types/sipml/sipml-tests.ts +++ b/types/sipml/sipml-tests.ts @@ -34,7 +34,7 @@ var eventsListener = (e:any)=> { } function createSipStack(){ - sipStack = new SIPml.Stack('blaat'); + sipStack = new SIPml.Stack({ display_name: 'blaat' }); sipStack = new SIPml.Stack({ realm: 'example.org', // mandatory: domain name impi: 'bob', // mandatory: authorization name (IMS Private Identity) diff --git a/types/svg-sprite/index.d.ts b/types/svg-sprite/index.d.ts index df6108242c..fd63d3f37b 100644 --- a/types/svg-sprite/index.d.ts +++ b/types/svg-sprite/index.d.ts @@ -243,7 +243,7 @@ declare namespace sprite { defs?: DefsAndSymbolSpecificModeConfig | boolean; symbol?: DefsAndSymbolSpecificModeConfig | boolean; stack?: ModeConfig | boolean; - [customConfigName: string]: ModeConfig; + [customConfigName: string]: ModeConfig | boolean; } interface ModeConfig { diff --git a/types/zeroclipboard/index.d.ts b/types/zeroclipboard/index.d.ts index 2600359826..4bcf25f62a 100644 --- a/types/zeroclipboard/index.d.ts +++ b/types/zeroclipboard/index.d.ts @@ -329,13 +329,13 @@ declare namespace ZC { * @param {string} eventType * @param {EventListener} listener */ - off(eventType: string, listener: EventListenerOrEventListenerObject): void; off(eventType: "ready", listener: EventListenerOrEventListenerObject): void; off(eventType: "beforecopy", listener: EventListenerOrEventListenerObject): void; off(eventType: "copy", listener: EventListenerOrEventListenerObject): void; off(eventType: "aftercopy", listener: EventListenerOrEventListenerObject): void; off(eventType: "destroy", listener: EventListenerOrEventListenerObject): void; off(eventType: "error", listener: EventListenerOrEventListenerObject): void; + off(eventType: string, listener: EventListenerOrEventListenerObject): void; /** * Remove a set of eventType to listener function/object mappings. * @param {EventListener} listenerObj @@ -348,6 +348,16 @@ declare namespace ZC { destroy?: EventListenerOrEventListenerObject; error?: EventListenerOrEventListenerObject; }): void; + /** + * Remove a set of eventType to listener function/object mappings. + */ + off(eventType: "ready"): void; + off(eventType: "beforecopy"): void; + off(eventType: "copy"): void; + off(eventType: "aftercopy"): void; + off(eventType: "destroy"): void; + off(eventType: "error"): void; + off(eventType: string): void; /** * Remove ALL listener functions/objects for ALL registered event types. */ From 755c104c947a476af0fd68569c52c43ccb2ce1a5 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 15 Jun 2017 16:36:24 -0700 Subject: [PATCH 2/2] Fix types in express-serve-static-core and webpack-dev-middleware express-serve-static-core had the wrong type for a string indexer. webpack-dev-middleware tests needed to wrap an argument in an array. --- types/express-serve-static-core/index.d.ts | 2 +- types/webpack-dev-middleware/webpack-dev-middleware-tests.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/types/express-serve-static-core/index.d.ts b/types/express-serve-static-core/index.d.ts index e9c136e7ea..5d1b17b47a 100644 --- a/types/express-serve-static-core/index.d.ts +++ b/types/express-serve-static-core/index.d.ts @@ -201,7 +201,7 @@ interface Request extends http.IncomingMessage, Express.Request { header(name: string): string | undefined; - headers: { [key: string]: string | undefined; }; + headers: { [key: string]: string | string[]; }; /** * Check if the given `type(s)` is acceptable, returning diff --git a/types/webpack-dev-middleware/webpack-dev-middleware-tests.ts b/types/webpack-dev-middleware/webpack-dev-middleware-tests.ts index 3764a6b9aa..a4b1d57822 100644 --- a/types/webpack-dev-middleware/webpack-dev-middleware-tests.ts +++ b/types/webpack-dev-middleware/webpack-dev-middleware-tests.ts @@ -27,7 +27,7 @@ webpackDevMiddlewareInstance = webpackDevMiddleware(compiler, { }); const app = express(); -app.use(webpackDevMiddlewareInstance); +app.use([webpackDevMiddlewareInstance]); webpackDevMiddlewareInstance.close(); webpackDevMiddlewareInstance.invalidate();