diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000000..390df0c3ed --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,3413 @@ +/types/abbrev/ @BendingBender +/types/ably/ @ably +/types/abs/ @AyaMorisawa +/types/absolute/ @AyaMorisawa +/types/acc-wizard/ @cyrilschumacher +/types/accepts/ @bomret +/types/accounting/ @gerich-home @chrisleck +/types/ace/ @Diullei +/types/acl/ @tkQubo +/types/acorn/ @RReverser @e-cloud +/types/actioncable/ @zhu1230 +/types/activex-adodb/ @zspitz +/types/activex-scripting/ @zspitz +/types/activex-wia/ @zspitz +/types/adal/ @mmaitre314 +/types/adm-zip/ @jvilk @abner +/types/adone/ @s0m3on3 @maxveres +/types/aframe/ @devpaul +/types/agenda/ @meirgottlieb +/types/aggregate-error/ @BendingBender +/types/alertify/ @jjeffery +/types/alexa-sdk/ @petebeegle @hoo29 @pascalwhoop @blforce +/types/alexa-voice-service/ @dolanmiu +/types/algebra.js/ @CaselIT +/types/algoliasearch/ @cbaptiste +/types/alt/ @Shearerbeard +/types/amazon-product-api/ @MattiLehtinen +/types/amcharts/ @aleksey-bykov +/types/amplify/ @joeriks +/types/amplify-deferred/ @joeriks @laurentiustamate94 +/types/amplitude-js/ @Asido +/types/amqp/ @seikho +/types/amqp-rpc/ @wokim +/types/amqplib/ @mnahkies @abreits @nfantone +/types/analytics-node/ @fongandrew +/types/angular/ @diegovilar @thorn0 @calebstdenis @leonard-thieu +/types/angular-agility/ @rolandzwaga +/types/angular-animate/ @michelsalib @adidahiya @rasch @codyschaaf +/types/angular-block-ui/ @lassebn @sclassen +/types/angular-bootstrap-calendar/ @Odrin +/types/angular-bootstrap-lightbox/ @rolandzwaga +/types/angular-breadcrumb/ @marctalary +/types/angular-clipboard/ @bradfordwagner +/types/angular-cookie/ @borislavjivkov +/types/angular-cookies/ @diegovilar @aciccarello +/types/angular-deferred-bootstrap/ @Ritzlgrmft +/types/angular-dialog-service/ @wcomartin +/types/angular-dynamic-locale/ @stephenlautier +/types/angular-environment/ @terrawheat +/types/angular-es/ @mbutsykin +/types/angular-feature-flags/ @borislavjivkov +/types/angular-file-saver/ @deenairn +/types/angular-formly/ @scatcher +/types/angular-fullscreen/ @julienpa +/types/angular-gettext/ @AkosLukacs +/types/angular-google-analytics/ @cyrilschumacher @Toxantron +/types/angular-gridster/ @jpmnteiro +/types/angular-growl-v2/ @mkp05 +/types/angular-hotkeys/ @jlz27 @reppners +/types/angular-http-auth/ @vvakame +/types/angular-httpi/ @Kukks +/types/angular-idle/ @mthamil +/types/angular-jwt/ @rerezz +/types/angular-load/ @david-gang +/types/angular-loading-bar/ @stephenlautier +/types/angular-local-storage/ @kenfdev @dona278 +/types/angular-localforage/ @reppners +/types/angular-locker/ @nkovacic +/types/angular-material/ @blbigelow @PeterHajdu @Dona278 @geertjansen +/types/angular-media-queries/ @jpmnteiro +/types/angular-meteor/ @pgrm +/types/angular-mocks/ @diegovilar @daltin +/types/angular-modal/ @paullessing +/types/angular-oauth2/ @anteriovieira +/types/angular-pdfjs-viewer/ @bastienmoulia +/types/angular-permission/ @vmishevski +/types/angular-promise-tracker/ @rufusl +/types/angular-q-spread/ @rafw87 +/types/angular-resource/ @diegovilar @miffels +/types/angular-route/ @park9140 +/types/angular-sanitize/ @diegovilar +/types/angular-scenario/ @RomanoLindano +/types/angular-scroll/ @samherrmann +/types/angular-signalr-hub/ @AdamSantaniello +/types/angular-spinner/ @Biegal +/types/angular-storage/ @mdekrey +/types/angular-strap/ @samherrmann +/types/angular-toastr/ @nkovacic @trodi +/types/angular-toasty/ @muenchdo +/types/angular-tooltips/ @leonard-thieu +/types/angular-touchspin/ @nkovacic +/types/angular-translate/ @michelsalib +/types/angular-ui-bootstrap/ @xt0rted @ry8806 +/types/angular-ui-router/ @michelsalib @matiishyn +/types/angular-ui-scroll/ @marknadig +/types/angular-ui-sortable/ @thgreasi +/types/angular-ui-tree/ @CalvinFernandez +/types/angular-websocket/ @nickveys +/types/angular-wizard/ @mjurisic @rwwilden +/types/angular-xeditable/ @jpmnteiro +/types/angular.throttle/ @reppners +/types/angularfire/ @thSoft +/types/angularlocalstorage/ @horiuchi +/types/angulartics/ @stevenfan +/types/animation-frame/ @qinfchen +/types/animejs/ @A-Babin +/types/annyang/ @hisham @theluk +/types/ansi-styles/ @brynbellomy +/types/ansicolors/ @rogierschouten +/types/any-db/ @rogierschouten +/types/any-db-transaction/ @rogierschouten +/types/anybar/ @khoomeister +/types/anydb-sql-migrations/ @spion +/types/anymatch/ @BendingBender +/types/apex.js/ @y13i +/types/aphrodite/ @asvetliakov +/types/api-error-handler/ @tkrotoff +/types/apigee-access/ @CasperSkydt +/types/app-root-path/ @shantmarouti +/types/appframework/ @kyo-ago +/types/appletvjs/ @brainded +/types/applicationinsights/ @scsouthw +/types/applicationinsights-js/ @kamilszostak +/types/arbiter/ @arash16 +/types/arcgis-js-api/v3/ @Esri +/types/arcgis-js-api/ @Esri +/types/arcgis-rest-api/ @JeffJacobson +/types/arcgis-to-geojson-utils/ @JeffJacobson +/types/archiver/ @dolanmiu @crevil +/types/archy/ @vvakame +/types/are-we-there-yet/ @brianloveswords +/types/argparse/ @arcticwaters +/types/argv/ @hookclaw +/types/array-find-index/ @samverschueren +/types/array-foreach/ @skysteve +/types/array-uniq/ @DanielRosenwasser +/types/arrify/ @wanganjun +/types/artyom.js/ @semagarcia +/types/asana/ @tkqubo +/types/ascii2mathml/ @RagibHasin +/types/asenv/ @remisery +/types/askmethat-rating/ @AlexTeixeira +/types/asn1js/ @microshine +/types/aspnet-identity-pw/ @jt000 +/types/assert-equal-jsx/ @seryl +/types/assert-plus/ @KostyaTretyak +/types/assertion-error/ @Bartvds +/types/assertsharp/ @brunolm +/types/assets-webpack-plugin/ @kryops +/types/async/ @borisyankov @kern0 @Penryn @fenying @pascalmartin +/types/async-lock/ @elisee +/types/async-polling/ @Goldsmith42 +/types/async.nexttick/ @pyrho +/types/asyncblock/ @horiuchi +/types/atmosphere/ @toedter +/types/atom/ @vvakame +/types/atom-keymap/ @enlight +/types/atpl/ @soywiz +/types/audiosprite/ @Perlmint +/types/aurelia-knockout/ @code-chris +/types/auth0/ @wbhob @westy92 @amiram +/types/auth0-angular/ @homesar +/types/auth0-js/v7/ @advancedrei +/types/auth0-js/ @adrianchia @mdurrant +/types/auth0-lock/ @carusology @goldcaddy77 +/types/auth0.widget/ @advancedrei +/types/auto-launch/ @rhysd @unindented +/types/auto-sni/ @janwo +/types/autobahn/ @darkl @valepu +/types/autobind-decorator/ @NoHomey +/types/autolinker/ @leonyu +/types/autoprefixer/ @odnamrataizem +/types/autosize/ @kingdango @keika299 @NeekSandhu +/types/awesomplete/ @webbiesdk @bmdixon @tbekolay +/types/aws-iot-device-sdk/ @niik +/types/aws-lambda/ @skarum @tobyhede @buggy @y13i @wwwy3y3 +/types/aws-serverless-express/ @threesquared @jcaffey @mattmeye +/types/aws4/ @ajcrites +/types/axel/ @ruslan-molodyko +/types/azure/ @AndrewGaspar @antiveeranna @SomaticIT +/types/azure-mobile-services-client/ @dmorosinotto +/types/azure-sb/ @Azure +/types/b_/ @outring +/types/babel-code-frame/ @mohsen1 +/types/babel-core/ @yortus @marvinhagemeister +/types/babel-generator/ @yortus @johnnyestilles +/types/babel-plugin-syntax-jsx/ @marvinhagemeister +/types/babel-template/ @yortus @marvinhagemeister +/types/babel-traverse/ @yortus @marvinhagemeister +/types/babel-types/ @yortus @baxtersa @marvinhagemeister +/types/babelify/ @TeamworkGuy2 @marvinhagemeister +/types/babylon/ @yortus @marvinhagemeister +/types/babyparse/ @cdiddy77 +/types/backbone/ @borisyankov @nvivo +/types/backbone-associations/ @craigbrett17 +/types/backbone-fetch-cache/ @delphinus35 +/types/backbone-relational/ @eirikhm +/types/backbone.layoutmanager/ @hejiang2000 +/types/backbone.localstorage/ @lgrignon +/types/backbone.marionette/ @zhamid @nvivo @sventschui +/types/backbone.paginator/ @Nyamazing +/types/backbone.radio/ @alphaleonis +/types/backgrid/ @jlujan +/types/backlog-js/ @vvatanabe +/types/baconjs/ @alexander-matsievsky @gekkio +/types/bagpipes/ @micmro +/types/barcode/ @pvomhoff +/types/bardjs/ @TepigMC +/types/base-64/ @dolanmiu +/types/base-x/ @chrootsu +/types/base16/ @alechill +/types/base64-js/ @pe8ter +/types/bases/ @harikv +/types/basic-auth/ @moonpyk @vesse +/types/batch-stream/ @drudge +/types/bazinga-translator/ @alexndlm +/types/bcrypt/ @codeanimal @IOAyman +/types/bcryptjs/ @RafaelKr +/types/bem-cn/ @selkinvitaly +/types/better-curry/ @pocesar +/types/better-sqlite3/ @Morfent +/types/bezier-easing/ @ptlis +/types/bezier-js/ @danmarshall +/types/bgiframe/ @sumegizoltan +/types/big.js/ @nycdotnet +/types/bigi/ @mhegazy +/types/bigint/ @Evgenus +/types/bignum/ @Patman64 +/types/bignumber.js/ @LaserUnicorns +/types/bigscreen/ @dduugg +/types/bind-ponyfill/ @skysteve +/types/bingmaps/ @rbrundritt +/types/bintrees/ @CjS77 +/types/bip21/ @stefanhuber +/types/bit-array/ @mudkipme +/types/bitcoinjs-lib/ @mhegazy @dlebrecht @rbuckton +/types/bittorrent-protocol/ @feross @tlaziuk +/types/bitwise-xor/ @rogierschouten +/types/bl/ @Bartvds +/types/blacklist/ @mhegazy +/types/blazy/ @julienpa +/types/blessed/ @brynbellomy +/types/blissfuljs/ @fskorzec +/types/blob-stream/ @erichillah +/types/blob-util/ @WorldMaker +/types/blocks/ @ksmigiel +/types/bloomfilter/ @slawiko +/types/blue-tape/ @sodatea +/types/bluebird/v1/ @Bartvds +/types/bluebird/v2/ @Bartvds @falsandtru +/types/bluebird/ @lhecker +/types/bluebird-global/ @d-ph +/types/bluebird-retry/ @pvomhoff +/types/blueimp-md5/ @rmartone @mkohlmyr +/types/body-parser/ @santialbo @vilic @dreampulse @blendsdk @tlaziuk +/types/bonjour/ @quentin-ol @octo-sniffle +/types/bookshelf/ @arcticwaters @vesse +/types/boom/v3/ @rogatty +/types/boom/ @rogatty @AJamesPhillips @jineshshah36 +/types/bootbox/ @vbortone @konpikwastaken @kanup @icereed @trodi @stannynuytkens +/types/bootpag/ @rdeneau +/types/bootstrap/ @borisyankov +/types/bootstrap-datepicker/ @borisyankov +/types/bootstrap-fileinput/ @CheCoxshall +/types/bootstrap-maxlength/ @danmana +/types/bootstrap-notify/ @niemyjski @mouse0270 @robert-voica +/types/bootstrap-select/ @LKay +/types/bootstrap-slider/ @dbeckwith @leonard-thieu +/types/bootstrap-switch/ @johnmbaughman +/types/bootstrap-table/ @talatbaig +/types/bootstrap-touchspin/ @albinsunnanbo +/types/bootstrap-treeview/ @jbtronics +/types/bootstrap-validator/ @BradyLiles +/types/bootstrap.paginator/ @derikwhittaker +/types/bootstrap.timepicker/ @derikwhittaker +/types/bootstrap.v3.datetimepicker/v3/ @bayitajesi +/types/bootstrap.v3.datetimepicker/ @katonap +/types/bounce.js/ @cherrry +/types/bowser/ @pocesar +/types/box2d/ @jbaldwin +/types/brace-expansion/ @BendingBender +/types/braintree-web/ @chlela +/types/breeze/ @borisyankov +/types/brorand/ @chrootsu +/types/browser-bunyan/ @PaulLockwood @kryops +/types/browser-fingerprint/ @LKay +/types/browser-harness/ @scriby +/types/browser-pack/ @TeamworkGuy2 +/types/browser-report/ @JTOne123 +/types/browser-resolve/ @marionebl +/types/browser-sync/ @joeskeen +/types/browserify/ @AndrewGaspar @jvilk @leonard-thieu +/types/bs58/ @chrootsu +/types/bson/ @horiuchi @CaselIT +/types/bucks/ @zaneli +/types/buffer-compare/ @chrootsu +/types/buffer-equal/ @Bartvds +/types/buffers/ @rhencke +/types/bufferstream/ @Bartvds +/types/bull/v2/ @bgrieder @JProgrammer +/types/bull/ @bgrieder @JProgrammer @marshall007 +/types/bunnymq/ @cyrilschumacher +/types/bunyan/ @amikhalev +/types/bunyan-blackhole/ @olivr70 +/types/bunyan-config/ @cyrilschumacher +/types/bunyan-prettystream/ @jasonswearingen @enlight +/types/bunyan-winston-adapter/ @stevehipwell +/types/busboy/ @jacobbaskin +/types/business-rules-engine/ @rsamec +/types/bwip-js/ @MugeSo +/types/byline/ @reppners +/types/bytebuffer/ @cappellin +/types/bytes/ @danny8002 +/types/c3/ @mcliment @gerinjacob @denyo +/types/cache-manager/ @GausSim +/types/cachefactory/ @vag1830 @danielmassa +/types/cal-heatmap/ @RetroChrisB +/types/callsite/ @newclear +/types/callsites/ @BendingBender +/types/calq/ @eirikhm +/types/camelcase/ @samverschueren +/types/camelcase-keys/ @mhegazy +/types/camo/ @lucasmciruzzi +/types/cannon/ @clark-stevenson +/types/canvas-gauges/ @Mikhus +/types/canvasjs/ @brutalimp +/types/capitalize/ @frederickfogerty +/types/cash/ @akvlko +/types/casperjs/ @jedmao +/types/cassandra-driver/ @Svjard +/types/catbox/ @jasonswearingen @AJamesPhillips +/types/cbor/ @pushplay +/types/ccap/ @taoqf +/types/chai/v2/ @Bartvds @AGBrown +/types/chai/ @jedmao @Bartvds @AGBrown @olivr70 @mwistrand @joshuakgoldberg @shaunluttin +/types/chai-arrays/ @clementprevot +/types/chai-as-promised/ @jt000 @Kuniwak @leonard-thieu +/types/chai-datetime/ @cliffburger +/types/chai-dom/ @mattlewis92 +/types/chai-enzyme/ @asvetliakov +/types/chai-fuzzy/ @Bartvds +/types/chai-http/ @Nemo157 @G1itcher @CaselIT +/types/chai-jquery/ @kazimanzurrashid +/types/chai-json-schema/ @ulrichheiniger +/types/chai-oequal/ @mizunashi-mana +/types/chai-spies/ @kuzn-ilya +/types/chai-string/ @nmalaguti +/types/chai-subset/ @delta62 @AGBrown +/types/chai-xml/ @jedigo +/types/chalk/ @Diullei @Bartvds @nicojs +/types/chance/ @cbowdon +/types/change-emitter/ @iskandersierra +/types/charm/ @Xananax +/types/chart.js/ @anuti @FabienLavocat @KentarouTakeda @larrybahr +/types/chartist/ @mtgibbs @psimonski +/types/chartjs/ @Steve-Fenton @FanaHOVA +/types/chayns/ @HenningKuehl +/types/check-sum/ @BendingBender +/types/checkstyle-formatter/ @mhegazy +/types/checksum/ @rogierschouten +/types/cheerio/ @blittle @wmaurer @umarniz +/types/chokidar/ @reppners @felixfbecker +/types/chosen-js/ @borisyankov @denisname +/types/chroma-js/v0/ @invliD +/types/chroma-js/ @invliD @mpacholec +/types/chrome/ @matthewkimber @otiai10 @couven92 @rreverser @sreimer15 +/types/chunked-dc/ @dbrgn +/types/circular-json/ @jpevarnek +/types/ckeditor/ @ondrejsevcik +/types/clamp-js/ @Hikariii +/types/classnames/ @adidahiya @JKillian @seansfkelley @mradamczyk @marvinhagemeister +/types/cldrjs/ @RamanBut-Husaim @gcastre +/types/clean-css/ @tkrotoff +/types/clean-stack/ @BendingBender +/types/clear-require/ @dan-j +/types/cli/ @kayahr +/types/cli-color/ @ChaosinaCan +/types/cli-table2/ @mgroenhoff +/types/client-sessions/ @netroy +/types/cliff/ @brynbellomy +/types/clipboard/ @impworks +/types/clipboard-js/ @markwongsk +/types/clipboardy/ @BendingBender +/types/clndr/ @jasperjn +/types/closure-compiler/ @mprobst +/types/cloud-env/ @Morfent +/types/cloudflare-apps/ @MartynasZilinskas +/types/co-body/ @geoffreak +/types/co-views/ @devlee @geoffreak +/types/code/ @prashaantt +/types/codemirror/ @mihailik @nrbernard +/types/codependency/ @morphatic +/types/coffeeify/ @tkQubo +/types/coinstring/ @mhegazy +/types/collections/ @scarabedore +/types/color/v0/ @LKay +/types/color/v1/ @LKay +/types/color/ @Airlun +/types/color-convert/ @Airlun +/types/color-name/ @Ailrun +/types/color-string/ @BendingBender @danmarshall +/types/colorbrewer/ @mtraynham +/types/colors/ @Bartvds @staeke +/types/com.darktalker.cordova.screenshot/ @akarienta +/types/combine-source-map/ @TeamworkGuy2 +/types/combined-stream/ @felixge @tlaziuk +/types/combokeys/ @iclanton +/types/cometd/ @derekcicerone +/types/command-line-args/ @CzBuCHi +/types/command-line-commands/ @CzBuCHi +/types/commander/ @alan-agius4 @mdezem @vvakame +/types/commangular/ @hiraash +/types/comment-json/ @Jason3S +/types/common-tags/ @zuzusik +/types/commonmark/ @nicojs @leonard-thieu +/types/compare-version/ @jpevarnek +/types/complex/ @AyaMorisawa +/types/component-emitter/ @psnider +/types/compose-function/ @denis-sokolov +/types/compressible/ @BendingBender +/types/compression/ @santialbo +/types/compression-webpack-plugin/ @dublicator +/types/concat-stream/ @jmarianer +/types/concaveman/ @DenisCarriere +/types/conf/v0/ @SamVerschueren +/types/conf/ @SamVerschueren @BendingBender +/types/confidence/ @jppellerin +/types/config/ @RWander +/types/configstore/ @ArcticLight +/types/confit/ @ethanresnick +/types/connect/ @SomaticIT +/types/connect-ensure-login/ @0x6368656174 +/types/connect-flash/ @AndreasGassmann +/types/connect-history-api-fallback/ @douglasduteil +/types/connect-livereload/ @SomaticIT +/types/connect-modrewrite/ @tinganho +/types/connect-mongo/ @Syati +/types/connect-redis/ @xstoudi @morcerf +/types/connect-slashes/ @samherrmann +/types/connect-timeout/ @cyrilschumacher +/types/console-stamp/ @ericbyers +/types/consolidate/ @soywiz @theosherry @nicolashenry +/types/consul/ @chrootsu +/types/content-disposition/ @bomret +/types/content-type/ @horiuchi @BendingBender +/types/contentful-resolve-response/ @antonkarsten +/types/contextjs/ @kernhanda +/types/continuation-local-storage/ @rath @heycalmdown @aboveyou00 +/types/convert-hrtime/ @BendingBender +/types/convert-source-map/ @AndrewGaspar @mgroenhoff @TeamworkGuy2 +/types/convict/ @Nemo157 @vesse @elyscape +/types/cookie/ @pine613 +/types/cookie-parser/ @santialbo @BendingBender +/types/cookie-session/ @borislavjivkov +/types/cookie-signature/ @lith-light-g +/types/cookie_js/ @slawiko +/types/cookies/ @WangZishi @jkeylu @BendingBender +/types/copy-paste/ @SrTobi +/types/copy-text-to-clipboard/ @BendingBender +/types/copy-webpack-plugin/ @flying-sheep +/types/cordova-ionic/ @hendrikmaus +/types/cordova-plugin-app-version/ @Ritzlgrmft +/types/cordova-plugin-background-mode/ @Lordnoname +/types/cordova-plugin-badge/ @timbru31 +/types/cordova-plugin-ble-central/ @gjunge +/types/cordova-plugin-device-name/ @larrybahr +/types/cordova-plugin-ibeacon/ @Ritzlgrmft +/types/cordova-plugin-insomnia/ @Ritzlgrmft +/types/cordova-plugin-keyboard/ @danmana +/types/cordova-plugin-mapsforge/ @rafw87 +/types/cordova-plugin-ms-adal/ @KaiWalter +/types/cordova-plugin-native-keyboard/ @lobo87 +/types/cordova-plugin-ouralabs/ @Justin-Credible +/types/cordova-plugin-qrscanner/ @bitjson @jab +/types/cordova-plugin-spinner/ @Justin-Credible +/types/cordova-plugin-statusbar/ @Xinkai +/types/cordova-plugin-vibration/ @Minishlink +/types/cordova-plugin-x-socialsharing/ @Ritzlgrmft @larrybahr +/types/cordova-sqlite-storage/ @rafw87 +/types/cordova.plugins.diagnostic/ @dpa99c +/types/cordova_app_version_plugin/ @larrybahr +/types/cordovarduino/ @hendrikmaus +/types/core-decorators/ @tkqubo +/types/core-js/ @rbuckton @mfdeveloper +/types/cote/ @makepost +/types/couchbase/ @maouida +/types/countdown/ @gjuchault +/types/country-list/ @iRoachie +/types/country-select-js/ @humrochagf +/types/cp-file/ @BendingBender +/types/cpy/ @mhegazy @BendingBender +/types/cradle/ @panuhorsmalahti +/types/crc/ @YuJianrong +/types/create-error/ @tkrotoff +/types/createjs/ @evilangelist @gyohk +/types/createjs-lib/ @evilangelist @gyohk +/types/credential/ @phuvo +/types/credit-card-type/ @LKay +/types/cron/ @horiuchi +/types/cropperjs/ @stepancar +/types/croppie/ @connor4312 +/types/crossfilter/ @schmuli @iebaker +/types/crossroads/ @diullei +/types/cryptiles/ @awendland +/types/crypto-js/ @misak113 +/types/cryptojs/ @giabao +/types/cson/ @stpettersens +/types/csprng/ @winksaville +/types/csrf/ @markis +/types/css/ @ilich +/types/css-font-loading-module/ @slikts +/types/css-modules/ @NeekSandhu +/types/cssbeautify/ @rictic +/types/csurf/ @horiuchi +/types/csv-parse/ @davidm77 @obi-jan-kenobi +/types/csv-stringify/ @rogierschouten @arjenvanderende +/types/csvtojson/ @EricByers @wcarson +/types/cucumber/v1/ @abraaoalves @jan-molak @isoung @BendingBender +/types/cucumber/ @abraaoalves @jan-molak @isoung @BendingBender +/types/currency-formatter/ @mhegazy +/types/custom-error-generator/ @thmiceli +/types/cwise/ @taoqf +/types/cwise-compiler/ @taoqf +/types/cwise-parser/ @taoqf +/types/cybozulabs-md5/ @pine613 +/types/cypress/ @ghengeveld @mikewoudenberg +/types/d3/v3/ @gustavderdrache @borisyankov +/types/d3/ @tomwanzek @gustavderdrache @borisyankov +/types/d3-array/ @gustavderdrache @borisyankov @tomwanzek +/types/d3-axis/ @tomwanzek @gustavderdrache @borisyankov +/types/d3-box/ @lk-chen +/types/d3-brush/ @tomwanzek @gustavderdrache @borisyankov +/types/d3-chord/ @tomwanzek @gustavderdrache @borisyankov +/types/d3-collection/ @tomwanzek @gustavderdrache @borisyankov +/types/d3-color/ @tomwanzek @gustavderdrache @borisyankov +/types/d3-contour/ @tomwanzek @Ledragon +/types/d3-dispatch/ @tomwanzek @gustavderdrache @borisyankov +/types/d3-drag/ @tomwanzek @gustavderdrache @borisyankov +/types/d3-dsv/ @tomwanzek @gustavderdrache @borisyankov +/types/d3-ease/ @tomwanzek @gustavderdrache @borisyankov +/types/d3-force/ @tomwanzek @gustavderdrache @borisyankov +/types/d3-format/ @tomwanzek @gustavderdrache @borisyankov +/types/d3-geo/ @Ledragon @tomwanzek @gustavderdrache @borisyankov +/types/d3-hexbin/ @uncovertruth @tomwanzek +/types/d3-hierarchy/ @tomwanzek @gustavderdrache @borisyankov +/types/d3-hsv/ @arrayjam +/types/d3-interpolate/ @tomwanzek @gustavderdrache @borisyankov +/types/d3-path/ @tomwanzek @gustavderdrache @borisyankov +/types/d3-polygon/ @tomwanzek @gustavderdrache @borisyankov +/types/d3-quadtree/ @tomwanzek @gustavderdrache @borisyankov +/types/d3-queue/ @tomwanzek @gustavderdrache @borisyankov +/types/d3-random/ @tomwanzek @gustavderdrache @borisyankov +/types/d3-request/ @Ledragon @gustavderdrache @borisyankov @tomwanzek +/types/d3-sankey/ @tomwanzek @gustavderdrache +/types/d3-scale/ @tomwanzek @gustavderdrache @borisyankov +/types/d3-scale-chromatic/ @Ledragon @gustavderdrache @borisyankov +/types/d3-selection/ @tomwanzek @gustavderdrache @borisyankov +/types/d3-selection-multi/ @gustavderdrache @borisyankov +/types/d3-shape/ @tomwanzek @gustavderdrache @borisyankov +/types/d3-time/ @tomwanzek @gustavderdrache @borisyankov +/types/d3-time-format/ @tomwanzek @gustavderdrache @borisyankov +/types/d3-timer/ @tomwanzek @gustavderdrache @borisyankov +/types/d3-tip/ @brspnnggrt +/types/d3-transition/ @tomwanzek @gustavderdrache @borisyankov +/types/d3-voronoi/ @tomwanzek @gustavderdrache @borisyankov +/types/d3-zoom/ @tomwanzek @gustavderdrache @borisyankov +/types/d3.cloud.layout/ @hansrwindhoff +/types/d3.slider/ @lk-chen +/types/d3kit/ @morphatic +/types/d3pie/ @mc-petry +/types/dagre/ @qinfchen +/types/dagre-d3/ @markwongsk +/types/dargs/ @BendingBender +/types/dat-gui/ @gyohk @sonic3d @rroylance +/types/data-driven/ @mrhen +/types/datadog-metrics/ @pushplay +/types/datatables.net/ @omidkrad @pragmatrix @denisemauldin +/types/datatables.net-buttons/ @SammyG4Free @jimhartford +/types/datatables.net-fixedheader/ @szechyjs +/types/datatables.net-rowreorder/ @baywet +/types/datatables.net-select/ @szechyjs +/types/date.format.js/ @balrob +/types/dateformat/ @aicest +/types/datejs/ @rupertavery +/types/daterangepicker/ @SirMartin @smasala +/types/db-migrate-base/ @nickiannone +/types/db-migrate-pg/ @nickiannone +/types/db.js/ @cgwrench +/types/dc/ @hansrwindhoff @mtraynham +/types/deasync/ @Sicilica +/types/debessmann/ @vkorehov +/types/debounce/ @denis-sokolov +/types/debug/ @swook @galtalmor @zamb3zi +/types/decamelize/ @samverschueren +/types/decay/ @enaeseth +/types/decimal.js/ @musicist288 +/types/decorum/ @dflor003 +/types/dedent/ @douglasduteil +/types/deep-assign/ @souldreamer +/types/deep-diff/ @ZauberNerd +/types/deep-equal/ @remojansen @janslow +/types/deep-extend/ @rhysd +/types/deep-freeze/ @Bartvds @aluanhaddad +/types/deep-freeze-strict/ @mhegazy +/types/deepmerge/ @marvinscharle +/types/defaults/ @IbtihelCHNAB +/types/define-lazy-prop/ @BendingBender +/types/defined/ @BendingBender +/types/deku/ @pocka +/types/del/v2/ @AyaMorisawa +/types/del/ @AyaMorisawa @BendingBender +/types/delaunator/ @DenisCarriere +/types/delay/ @BendingBender +/types/denodeify/ @joaomoreno +/types/deoxxa-content-type/ @pine613 +/types/depd/ @danny8002 +/types/deployjava/ @cyrilschumacher +/types/destroy/ @BendingBender +/types/destroy-on-hwm/ @BendingBender +/types/detect-browser/ @rogierschouten +/types/detect-hover/ @thomastilkema +/types/detect-indent/v0/ @Bartvds +/types/detect-indent/ @Bartvds @BendingBender +/types/detect-it/ @thomastilkema +/types/detect-newline/ @BendingBender +/types/detect-passive-events/ @thomastilkema +/types/detect-pointer/ @thomastilkema +/types/detect-port/ @lith-light-g +/types/detect-touch-events/ @thomastilkema +/types/df-visible/ @Litee +/types/dhtmlxgantt/ @mkozhukh @chriscamicas +/types/dhtmlxscheduler/ @mkozhukh +/types/di-lite/ @dcrusader +/types/diacritics/ @otociulis +/types/diff/ @vvakame +/types/diff2html/ @rtfpessoa +/types/dir-resolve/ @andy-ms +/types/discontinuous-range/ @OiCMudkips +/types/disposable-email-domains/ @geoffreak +/types/doccookies/ @jonegerton +/types/dockerode/ @seikho @nlaplante @isac322 +/types/docopt/ @giggio +/types/doctrine/ @rictic +/types/documentdb/ @NoelAbrahams @brettferdosi @ctstone @yifanwu +/types/documentdb-server/ @lith-light-g +/types/dojo/ @vansimke +/types/dom-inputevent/ @diagramatics +/types/dom4/ @adidahiya @giladgray +/types/domo/ @Steve-Fenton +/types/dompurify/ @bazuzi +/types/domready/ @dotnetnerd +/types/donna/ @vvakame +/types/dookie/ @swanest +/types/dot/ @ZombieHunter +/types/dot-object/ @nkovacic +/types/dot-prop/v2/ @samverschueren +/types/dot-prop/ @samverschueren @BendingBender +/types/dotdotdot/ @milanjaros +/types/dotenv/v2/ @borekb @enaeseth +/types/dotenv/ @jussikinnula @borekb @enaeseth +/types/dotenv-safe/ @krenor +/types/dottie/ @domarmstrong +/types/doublearray/ @mzsm +/types/doubleclick-gpt/ @johngeorgewright +/types/downloadjs/ @cwmoo740 +/types/draft-js/ @dmitryrogozhny @eelco @ghotiphud @schwers @michael-yx-wu @willisplummer +/types/draggabilly/ @jaydubu +/types/dragster/ @zskovacs +/types/dragula/ @pwelter34 @abruzzihraig +/types/dropboxjs/ @Steve-Fenton @xperiments +/types/dropkickjs/ @VorobeY1326 +/types/dropzone/v4/ @nvivo @outring @renuo @Hikariii +/types/dropzone/ @nvivo @outring @renuo @Hikariii @tedbcsgpro +/types/duplexer2/ @Goldsmith42 +/types/duplexer3/ @BendingBender +/types/durandal/ @BlueSpire +/types/dustjs-linkedin/ @mdezem +/types/dw-bxslider-4/ @namerci +/types/dwt/ @yushulx +/types/dymo-label-framework/ @thijskuipers +/types/dynatable/ @francoismassart +/types/each/ @misak113 +/types/easeljs/ @evilangelist +/types/easy-api-request/ @DeadAlready +/types/easy-jsend/ @DeadAlready +/types/easy-session/ @DeadAlready +/types/easy-table/ @nikeee +/types/easy-x-headers/ @DeadAlready +/types/easy-xapi/ @DeadAlready +/types/easy-xapi-supertest/ @DeadAlready +/types/easy-xapi-utils/ @DeadAlready +/types/easystarjs/ @borundin +/types/ebongarde-root/ @Ebongarde +/types/echarts/ @xieisabug @AntiMoron +/types/ecurve/ @mhegazy +/types/egg/ @sheperdwind +/types/egg-mock/ @sheperdwind +/types/egg.js/ @ToastHawaii +/types/ej.web.all/ @syncfusion +/types/ejs-locals/ @jt000 +/types/ejson/ @shantanubhadoria +/types/elasticsearch/ @CasperSkydt @bfsmith @ddunkin @pushplay @mlamp @ahmadferdous +/types/electron-config/ @mrfunkycold @unindented +/types/electron-debug/ @unindented +/types/electron-devtools-installer/ @gamesmaxed +/types/electron-json-storage/ @stpettersens +/types/electron-notifications/ @djpereira +/types/electron-notify/ @djpereira +/types/electron-packager/ @SomaticIT @cortopy +/types/electron-settings/v2/ @leonard-thieu +/types/electron-settings/ @icopp +/types/electron-store/ @unindented +/types/electron-window-state/ @rhysd +/types/element-ready/ @BendingBender +/types/element-resize-event/ @rogierschouten @plgregoire +/types/elm/ @thSoft +/types/email-addresses/ @johngrimsey +/types/email-templates/ @cyrilschumacher @gurisko +/types/email-validator/ @paullessing +/types/ember/v1/ @jedmao +/types/ember/ @jedmao @bttf +/types/emissary/ @vvakame +/types/emojione/ @dbrgn +/types/empower/ @vvakame +/types/emscripten/ @zakki @periklis +/types/engine.io/ @KentarouTakeda +/types/engine.io-client/ @KentarouTakeda +/types/enhanced-resolve/ @e-cloud @onigoetz +/types/ent/ @rogierschouten +/types/entities/ @aliceklipper +/types/env-to-object/ @MugeSo +/types/envify/ @tkQubo +/types/enzyme/ @MarianPalkus @NoHomey @jwbay @huhuanming @MartynasZilinskas @thovden +/types/enzyme-to-json/ @joscha +/types/eonasdan-bootstrap-datetimepicker/ @ToastHawaii +/types/epiceditor/ @borisyankov +/types/epub/ @julien-c +/types/eq.js/ @stephenlautier +/types/errorhandler/ @santialbo +/types/es6-collections/ @rbuckton +/types/es6-error/ @LKay +/types/es6-promise/ @fdecampredon @vvakame +/types/es6-promisify/ @harryshipton +/types/es6-shim/ @rbuckton +/types/es6-weak-map/ @pine +/types/escape-html/ @elisee +/types/escape-latex/ @olsio +/types/escape-string-regexp/ @kruncher +/types/escodegen/ @simondel +/types/eslint-plugin-prettier/ @ikatyang +/types/esprima/ @teppeis @RReverser +/types/esprima-walk/ @tswaters +/types/esri-leaflet/ @strajuser +/types/esri-leaflet-geocoder/ @BendingBender +/types/estraverse/ @sanex3339 +/types/estree/ @RReverser +/types/etag/ @BendingBender +/types/ethjs-signer/ @doppio +/types/eureka-js-client/ @Schnillz +/types/evaporate/ @kookster @chrisrhoden +/types/event-emitter/ @LKay +/types/event-kit/ @enlight +/types/event-loop-lag/ @rogierschouten +/types/event-stream/ @flcdrg +/types/event-to-promise/ @flying-sheep +/types/evernote/ @corps +/types/exceljs/ @rogierschouten @alitaheri +/types/execa/ @douglasduteil @BendingBender +/types/exit/ @Bartvds +/types/exit-hook/ @BendingBender +/types/exorcist/ @TeamworkGuy2 +/types/expect/ @jmreidy @merrywhether +/types/expect.js/ @teppeis +/types/expectations/ @vvakame +/types/expr-eval/ @connor4312 +/types/express/ @borisyankov +/types/express-brute/ @cyrilschumacher +/types/express-brute-memcached/ @cyrilschumacher +/types/express-brute-mongo/ @cyrilschumacher +/types/express-debug/ @federicobond +/types/express-domain-middleware/ @hookclaw +/types/express-enforces-ssl/ @kevinstubbs +/types/express-fileupload/ @Naktibalda +/types/express-flash-2/ @mathsalmi +/types/express-formidable/ @tdolsen +/types/express-graphql/ @isman-usoh @nitintutlani +/types/express-handlebars/ @stpettersens @yhaskell +/types/express-jwt/ @wokim @kacepe @Sl1MBoy +/types/express-less/ @xieyubo +/types/express-minify/ @borislavjivkov +/types/express-mung/ @cyrilschumacher +/types/express-myconnection/ @Cellule +/types/express-mysql-session/ @Akim95 +/types/express-openapi/ @mugeso +/types/express-partials/ @jt000 +/types/express-rate-limit/ @cyrilschumacher +/types/express-route-fs/ @kripod +/types/express-sanitized/ @cjbarth +/types/express-serve-static-core/ @borisyankov @19majkel94 @kacepe +/types/express-session/ @horiuchi +/types/express-unless/ @wokim +/types/extend/ @reppners +/types/extended-listbox/ @code-chris +/types/extjs/ @brian428 +/types/extract-stack/ @BendingBender +/types/extract-text-webpack-plugin/ @flying-sheep @katyo +/types/extract-zip/ @mizunashi-mana +/types/eyes/ @brynbellomy +/types/f1/ @neolwc +/types/fabric/ @oklemencic @joewashear007 @mrand01 +/types/facebook-js-sdk/ @amritk +/types/facebook-pixel/ @noctishsu +/types/faker/v3/ @Kuniwak +/types/faker/ @bensw @basp @Kuniwak +/types/falcor/ @Quramy +/types/falcor-express/ @Quramy +/types/falcor-http-datasource/ @Quramy +/types/falcor-json-graph/ @Quramy +/types/falcor-router/ @Quramy @cdhgee +/types/famous/ @borisvasilenko +/types/fancybox/ @borisyankov +/types/farbtastic/ @EnableSoftware +/types/fast-diff/ @djrenren +/types/fast-levenshtein/ @mizunashi-mana +/types/fast-stats/ @rogierschouten +/types/fastclick/ @shinnn +/types/favico.js/ @drowse314-dev-ymat +/types/fb/ @JoshStrobl +/types/fbemitter/ @kmxz +/types/featherlight/ @xStrom +/types/fecha/ @9y5 +/types/fetch-jsonp/ @tkrotoff +/types/fetch-mock/ @asvetliakov @tamird @merrywhether @chrissinclair +/types/fetch.io/ @newraina +/types/ffi/ @loyd +/types/ffmpeg-static/ @iamstevetran +/types/ffprobe-static/ @iamstevetran +/types/fibers/ @soywiz +/types/figures/ @BendingBender +/types/file-exists/ @BendingBender +/types/file-saver/ @cyrilschumacher @DaIgeb +/types/file-type/ @tcaesvk @BendingBender +/types/filenamify/ @rokt33r +/types/filesize/ @GiedriusGrabauskas +/types/fill-pdf/ @westy92 +/types/finalhandler/ @chrootsu +/types/finch/ @DavidSichau +/types/find-up/ @BendingBender +/types/findup-sync/ @Bartvds @ngbrown +/types/fingerprintjs/ @zaneli +/types/fingerprintjs2/ @curtstate +/types/firebase/ @vbortone @dsebastien @ciekawy +/types/firebase-client/ @fpsscarecrow +/types/firebase-token-generator/ @dotdotcommadot +/types/firebird/ @karak +/types/firefox/ @vvakame +/types/firmata/ @troywweber7 +/types/first-mate/ @enlight +/types/fixed-data-table/ @pepaar @stephenjelfs +/types/flat/ @chrootsu +/types/flatpickr/v2/ @UnwrittenFun +/types/flatpickr/ @UnwrittenFun @rowellx68 @wagich +/types/flexslider/ @diullei +/types/flight/ @jonathanhedren +/types/flightplan/ @borislavjivkov +/types/flipsnap/ @kubosho @gsino @mayuki +/types/flot/ @burlandm @Anticom +/types/flowjs/ @ryan10132 +/types/fluent-ffmpeg/ @tcaesvk @DingWeizhe +/types/flux/ @stkb @GiedriusGrabauskas +/types/flux-standard-action/ @tkqubo +/types/fluxxor/ @mrk21 +/types/fm-websync/ @markusmauch +/types/fontfaceobserver/ @RandScullard +/types/fontoxml/ @rolandzwaga +/types/forever-monitor/ @shuntksh +/types/forge-di/ @adamcarr +/types/form-data/ @soywiz @leonyu @BendingBender +/types/form-serializer/ @flqw +/types/format-unicorn/ @kruncher +/types/formidable/ @Nemo157 +/types/forwarded/ @BendingBender +/types/fossil-delta/ @endel +/types/foundation/ @borisyankov +/types/foundation-sites/ @samvloeberghs +/types/fpsmeter/ @alampros +/types/framebus/ @kbukum +/types/freedom/ @jpevarnek +/types/freeport/ @atd-schubert +/types/fresh/ @BendingBender +/types/frisby/ @johnny4753 +/types/from/ @Bartvds +/types/from2/ @BendingBender +/types/fromjs/ @glenndierckx +/types/fromnow/ @marinewater +/types/fs-ext/ @OguzhanE +/types/fs-extra/ @alan-agius4 @midknight41 @shiftkey +/types/fs-extra-promise/ @midknight41 @jasonswearingen @HiromiShikata +/types/fs-extra-promise-es6/ @midknight41 @jasonswearingen @geoffreak @HiromiShikata +/types/fs-finder/ @misak113 +/types/fs-mock/ @rogierschouten +/types/fs-promise/ @tarruda +/types/fsevents/ @BendingBender +/types/ftdomdelegate/ @dotnetnerd +/types/ftp/ @rogierschouten +/types/ftpd/ @rogierschouten +/types/fullcalendar/v1/ @nestalk @hasellcamargo +/types/fullcalendar/ @nestalk @hasellcamargo @panic175 +/types/fullname/ @kayahr +/types/fuse/ @smrq +/types/fusioncharts/ @rohitkr @shivarajkv +/types/fuzzaldrin/ @mhegazy +/types/fuzzaldrin-plus/ @jeancroy @jkillian +/types/fuzzyset/ @lgrignon +/types/fxn/ @charrondev +/types/gae.channel.api/ @vvakame +/types/gamequery/ @Laubi +/types/gandi-livedns/ @xstoudi +/types/gapi/ @sgtfrankieboy +/types/gapi.analytics/ @gatsbimantico +/types/gapi.auth2/ @flawless2011 +/types/gapi.calendar/ @tkrotoff +/types/gapi.drive/ @baxtersa +/types/gapi.pagespeedonline/ @sgtfrankieboy +/types/gapi.people/ @tkrotoff +/types/gapi.plus/ @tkrotoff +/types/gapi.translate/ @sgtfrankieboy +/types/gapi.urlshortener/ @sgtfrankieboy +/types/gapi.youtube/ @sgtfrankieboy +/types/gapi.youtubeanalytics/ @sgtfrankieboy +/types/gaussian/ @scttcper +/types/generic-functions/ @stpettersens +/types/generic-pool/ @jerray +/types/gently/ @bonnici +/types/geodesy/ @DenisCarriere @HandyG52 +/types/geojson/ @cobster +/types/geojson2osm/ @DenisCarriere +/types/geokdbush/ @DenisCarriere +/types/geolib/ @vvenegasv @dotnetpart +/types/geometry-dom/ @nakakura +/types/geopattern/ @Gaelan +/types/get-node-dimensions/ @vincekovacs +/types/get-stdin/ @DanielRosenwasser +/types/get-stream/ @douglasduteil @BendingBender +/types/getos/ @BendingBender +/types/gettext.js/ @jucrouzet +/types/gijgo/ @atatanasov +/types/giraffe/ @darthapo +/types/git/ @vvakame +/types/git-config/ @stpettersens +/types/git-remote-origin-url/ @janslow +/types/gl-matrix/ @mattijskneppers @tatchx +/types/gldatepicker/ @qcz +/types/glidejs/ @milanjaros +/types/glob/ @vvakame @voy +/types/glob-base/ @alan-agius4 +/types/glob-expand/ @vvakame +/types/glob-stream/ @Bartvds +/types/global-tunnel-ng/ @BendingBender +/types/globalize/ @gcastre @afromogli +/types/globalize-compiler/ @iclanton +/types/globby/ @douglasduteil +/types/globule/ @durad +/types/gm/ @ChaosinaCan +/types/go/ @NorthwoodsSoftware +/types/google-adwords-scripts/ @jafaircl +/types/google-apps-script/ @motemen +/types/google-cloud__storage/ @blove @nbperry +/types/google-earth/ @icholy +/types/google-images/ @dolanmiu +/types/google-libphonenumber/ @leonyu +/types/google-map-react/ @honzabrecka +/types/google-maps/ @DeividasBakanas @GiedriusGrabauskas +/types/google-protobuf/ @marcuslongmuir +/types/google.feeds/ @RodneyJT +/types/google.fonts/ @danmarshall +/types/google.geolocation/ @vbortone +/types/google.picker/ @grapswiz +/types/google.visualization/ @danludwig @gmoore-sjcorg @danmana @mlcheng @IvanBisultanov +/types/googlemaps/ @cgwrench @nertzy @xaolas @mrmcnerd @martincostello +/types/googlemaps.infobubble/ @Dashue +/types/got/ @BendingBender @LinusU +/types/graceful-fs/ @Bartvds +/types/graham_scan/ @hberntsen +/types/graphene-pk11/ @microshine +/types/graphite-udp/ @EricByers +/types/graphql/ @TonyPythoneer @calebmer @intellix @firede @kepennar @freiksenet +/types/graphql-date/ @enaeseth +/types/graphql-relay/ @arvitaly @nitintutlani @Grelinfo +/types/graphql-type-json/ @schfkt +/types/graphviz/ @mhfrantz +/types/gravatar/ @denis-sokolov +/types/greasemonkey/ @kotas +/types/grecaptcha/ @DethAriel +/types/gregorian-calendar/ @cwalv +/types/griddle-react/ @hodavidhara +/types/gridfs-stream/ @liorm +/types/gridstack/ @PascalSenn @ZoolWay @Sl1MBoy +/types/grunt/ @jeffmay @basarat +/types/gsap/ @codebelt @ProbablePrime +/types/gulp/ @GiedriusGrabauskas +/types/gulp-angular-templatecache/ @amanmahajan7 +/types/gulp-babel/ @AyaMorisawa +/types/gulp-batch/ @alvarollmenezes @vizeke +/types/gulp-cache/ @aravindarun +/types/gulp-cached/ @tomc974 +/types/gulp-changed/ @tomc974 +/types/gulp-cheerio/ @tkQubo +/types/gulp-coffeeify/ @tkQubo +/types/gulp-coffeelint/ @tkQubo +/types/gulp-concat/ @k-kagurazaka +/types/gulp-connect/ @andrewiggins +/types/gulp-copy/ @aravindarun +/types/gulp-csso/ @tkrotoff +/types/gulp-debug/ @tkrotoff +/types/gulp-diff/ @ikatyang +/types/gulp-dtsm/ @AyaMorisawa +/types/gulp-espower/ @tkQubo +/types/gulp-file-include/ @DanielRosenwasser +/types/gulp-filter/ @tkrotoff +/types/gulp-flatten/ @k-kagurazaka +/types/gulp-gzip/ @tkQubo +/types/gulp-help/ @tkQubo +/types/gulp-help-doc/ @Mikhus +/types/gulp-html-replace/ @peterjuras +/types/gulp-htmlmin/ @tkrotoff +/types/gulp-if/ @joeskeen +/types/gulp-inject/ @k-kagurazaka +/types/gulp-insert/ @shantmarouti +/types/gulp-install/ @peterjuras +/types/gulp-jade/ @berwyn +/types/gulp-jasmine-browser/ @tkrotoff +/types/gulp-json-editor/ @peterjuras +/types/gulp-jspm/ @peterjuras +/types/gulp-less/ @k-kagurazaka +/types/gulp-load-plugins/ @joeskeen +/types/gulp-minify-css/ @k-kagurazaka +/types/gulp-minify-html/ @tkrotoff +/types/gulp-modernizr/ @remisery +/types/gulp-newer/ @tomc974 +/types/gulp-ng-annotate/ @tkQubo +/types/gulp-nodemon/ @tkQubo +/types/gulp-plumber/ @joeskeen +/types/gulp-protractor/ @tkrotoff +/types/gulp-pug/ @remisery +/types/gulp-remember/ @tomc974 +/types/gulp-rev/ @tkrotoff +/types/gulp-rev-replace/ @tkrotoff +/types/gulp-ruby-sass/ @agnislav +/types/gulp-shell/ @tkqubo +/types/gulp-size/ @tkrotoff @remisery +/types/gulp-sort/ @joeskeen +/types/gulp-strip-debug/ @peterjuras +/types/gulp-svg-sprite/ @tkqubo +/types/gulp-task-listing/ @joeskeen +/types/gulp-tsd/ @k-kagurazaka +/types/gulp-uglify/ @ChristopherHaws @leonard-thieu +/types/gulp-useref/ @tkrotoff +/types/gulp-util/ @jedmao +/types/gulp-watch/ @tkrotoff +/types/gzip-size/ @plantain-00 +/types/h2o2/ @jasonswearingen @AJamesPhillips +/types/halfred/ @dherges +/types/halogen/ @steller +/types/hammerjs/ @milkisevil @codler +/types/handlebars/ @borisyankov +/types/handsontable/ @panesofglass @astegmaier +/types/hapi/v8/ @jasonswearingen +/types/hapi/v12/ @jasonswearingen +/types/hapi/v15/ @jasonswearingen +/types/hapi/ @jasonswearingen @AJamesPhillips +/types/hapi-auth-basic/ @AJamesPhillips +/types/hapi-auth-jwt2/ @warrenseymour +/types/hapi-decorators/ @kenhowardpdx +/types/har-format/ @micmro +/types/hard-rejection/ @BendingBender +/types/harmony-proxy/ @remojansen +/types/has-ansi/ @BendingBender +/types/hash-file/ @HiromiShikata +/types/hash-stream/ @BendingBender +/types/hasha/ @BendgingBender +/types/hasher/ @flyfishMT +/types/hashids/ @pocesar +/types/hashmap/ @outring +/types/haversine/ @screendriver +/types/he/ @sedwards2009 +/types/headroom/ @hakubo +/types/heap/ @ryan10132 +/types/heatmap.js/ @lookuptable +/types/hedron/ @dborysov +/types/hellojs/ @PavelPZ @vuorinem +/types/hellosign-embedded/ @xt0rted +/types/helmet/ @cyrilschumacher @EvanHahn @bluehatbrit +/types/heredatalens/ @denyo +/types/heremaps/ @Josh-ES @denyo +/types/highcharts/ @damianog @baltie @AlbertOzimek @hanssens +/types/highcharts-ng/ @scatcher +/types/highland/ @Bartvds @hgwood @iwllyu +/types/highlight.js/ @nikeee @sourrust +/types/hiredis/ @titan +/types/history/v2/ @sergey-buturlakin @ngbrown +/types/history/v3/ @sergey-buturlakin @ngbrown @LKay +/types/history/ @sergey-buturlakin @ngbrown @rokoroku +/types/history.js/ @borisyankov @gjunge +/types/hjson/ @crunchie84 +/types/hls.js/ @jgainfort +/types/hoek/ @prashaantt +/types/homeworks/ @KennethanCeyer +/types/hooker/ @misak113 +/types/hopscotch/ @pimterry +/types/howler/ @xperiments @tdukart +/types/hpp/ @kryops +/types/html-entities/ @xstoudi +/types/html-minifier/ @tkrotoff +/types/html-pdf/ @westy92 +/types/html-to-text/ @erykwarren +/types/html-webpack-plugin/ @deevus @bumbleblym +/types/html-webpack-template/ @bumbleblym +/types/html2canvas/ @rwhepburn @tan9 +/types/htmlbars-inline-precompile/ @chriskrycho +/types/htmlparser2/ @staticfunction +/types/htmltojsx/ @basarat +/types/http-assert/ @jkeylu +/types/http-aws-es/ @marcogrcr +/types/http-codes/ @mhegazy +/types/http-errors/ @tkrotoff @BendingBender +/types/http-proxy/ @SomaticIT +/types/http-proxy-middleware/ @zebMcCorkle @BendingBender +/types/http-status/ @misak113 +/types/http-status-codes/ @JoshMcCullough +/types/http-string-parser/ @pine613 +/types/httperr/ @yortus +/types/hubot/ @dirk +/types/hubspot-pace/ @borislavjivkov +/types/humane/ @jmvrbanac +/types/humanize-plus/ @DenisCarriere +/types/humanparser/ @MichalPodeszwa +/types/humps/ @nikeee +/types/hyco-ws/ @mrcabellom +/types/hyperscript/ @spacejack @jmfirth +/types/hypertext-application-language/ @maks3w +/types/hystrixjs/ @igorsechyn +/types/i18n/ @SomaticIT @FindQ +/types/i18next/v2/ @mxl @deerawan @GiedriusGrabauskas +/types/i18next/ @mxl @deerawan @GiedriusGrabauskas +/types/i18next-browser-languagedetector/v0/ @cyrilschumacher @GiedriusGrabauskas +/types/i18next-browser-languagedetector/ @cyrilschumacher @GiedriusGrabauskas +/types/i18next-express-middleware/ @cyrilschumacher +/types/i18next-node-fs-backend/ @cyrilschumacher +/types/i18next-sprintf-postprocessor/ @cyrilschumacher +/types/i18next-xhr-backend/ @jamuhl @GiedriusGrabauskas +/types/i2c-bus/ @101100 +/types/iban/ @cyrilschumacher +/types/ibm-mobilefirst/ @nacho4d +/types/ibm_db/ @agov +/types/icepick/ @ngbrown @tobico +/types/icheck/ @qcz +/types/iconv/ @delphinus35 +/types/iconv-lite/ @poelstra +/types/ids/ @3fd +/types/iframe-resizer/ @arminbaljic +/types/ignite-ui/ @IgniteUI +/types/image-size/ @elisee +/types/imagemagick/ @soywiz +/types/imagemagick-native/ @horiuchi +/types/imagemapster/ @delphinus35 +/types/images/ @DingWeizhe +/types/imagesloaded/ @coldacid @apexskier +/types/imap/ @psnider +/types/imap-simple/ @pushplay +/types/imgur-rest-api/ @lukewestby +/types/immutability-helper/ @seansfkelley +/types/impress/ @borisyankov +/types/in-range/ @DanielRosenwasser +/types/incremental-dom/ @basarat @lanthaler @vvakame +/types/indent-string/ @mhegazy +/types/inert/ @nycdotnet @AJamesPhillips +/types/inflected/ @dsci +/types/inflection/ @shiwano +/types/inherits/ @chrootsu +/types/ini/ @marcinporebski +/types/iniparser/ @chrootsu +/types/inline-css/ @philipisapain +/types/inline-style-prefixer/ @ahz @dpetrezselyova +/types/inquirer/ @tkQubo @ppathan +/types/insert-module-globals/ @leonard-thieu +/types/insight/ @vvakame +/types/integer/ @Morfent +/types/interact.js/ @dduugg @adidahiya @thasner +/types/intercomjs/ @spencerwi +/types/internal-ip/ @BendingBender +/types/intl/ @RagibHasin +/types/intl-messageformat/ @mhegazy +/types/intl-tel-input/ @fdnhkj @leonard-thieu +/types/into-stream/ @BendingBender +/types/intro.js/ @anahkiasen +/types/invariant/ @bennett000 +/types/inversify-devtools/ @inversify +/types/ion.rangeslider/v1/ @dduugg +/types/ion.rangeslider/ @sixinli +/types/ionic/ @spencerwi +/types/ioredis/ @chrisleck +/types/ip/ @codeanimal +/types/ip-regex/ @unindented +/types/irc/ @phillips1012 +/types/is/ @cabralRodrigo +/types/is-absolute-url/ @mhegazy +/types/is-alphanumerical/ @vutran +/types/is-archive/ @mhegazy +/types/is-array/ @pine +/types/is-binary-path/ @DanielRosenwasser +/types/is-compressed/ @mhegazy +/types/is-finite/ @mhegazy +/types/is-ip/ @coderslagoon +/types/is-my-json-valid/ @kruncher +/types/is-number/ @harryshipton +/types/is-path-cwd/ @DanielRosenwasser +/types/is-path-in-cwd/ @mhegazy +/types/is-plain-object/ @zengfenfei +/types/is-promise/ @DanielRosenwasser +/types/is-relative-url/ @mhegazy +/types/is-root/ @mhegazy +/types/is-root-path/ @mhegazy +/types/is-stream/ @me +/types/is-svg/ @BendingBender +/types/is-text-path/ @mhegazy +/types/is-url/ @RyotaMurohoshi +/types/is-url-superb/ @kryops +/types/is-windows/ @mizunashi-mana +/types/isbn-utils/ @elhaard +/types/iscroll/ @csrakowski +/types/iso-3166-2/ @sicilica +/types/iso8601-localizer/ @avielfedida +/types/isomorphic-fetch/ @toddlucas +/types/isotope-layout/ @avidenic +/types/istanbul/ @tkrotoff +/types/istanbul-middleware/ @hookclaw +/types/ityped/ @DanielRosenwasser +/types/ix.js/ @Igorbek +/types/jade/ @panuhorsmalahti +/types/jalaali-js/ @alitaheri +/types/japanese-holidays/ @syamatoo +/types/jasmine/ @borisyankov @theodorejb @davidparsson @gmoothart @lukas-zech-software +/types/jasmine-ajax/ @lgrignon +/types/jasmine-data_driven_tests/ @AnthonyMacKinnon +/types/jasmine-enzyme/ @bolatovumar +/types/jasmine-es6-promise-matchers/ @stephenlautier +/types/jasmine-expect/ @GeneralCss +/types/jasmine-fixture/ @craigbrett17 +/types/jasmine-given/ @shairez +/types/jasmine-jquery/ @gstamac +/types/jasmine-matchers/ @Bartvds +/types/jasmine-node/ @svi3c +/types/jasmine-promise-matchers/ @matthewjh +/types/jasmine_dom_matchers/ @devoto13 +/types/jasminewd2/ @sjelin +/types/java/ @jimlloyd @hrl7 +/types/java-applet/ @cyrilschumacher +/types/javascript-astar/ @ptlis +/types/javascript-bignum/ @sandersn +/types/javascript-obfuscator/ @sanex3339 +/types/javascript-state-machine/ @borisyankov @mdocter @MrBigDog2U @samael65535 @taoqf +/types/jbinary/ @tbureck +/types/jcanvas/ @rogierschouten +/types/jdataview/ @RReverser +/types/jdenticon/ @mtr +/types/jest/v16/ @NoHomey @jwbay +/types/jest/ @NoHomey @jwbay @asvetliakov @alexjoverm @epicallan @ikatyang +/types/jest-matchers/ @joscha +/types/jfs/ @tlaziuk +/types/jimp/ @Jack-Works +/types/jjv/ @Nemo157 +/types/jjve/ @Nemo157 +/types/jmespath/ @pushplay +/types/jodata/ @cgwrench +/types/johnny-five/ @nakakura +/types/joi/v6/ @Bartvds @laurence-myers @cglantschnig @DavidBR-SW +/types/joi/ @Bartvds @laurence-myers @cglantschnig @DavidBR-SW @GaelMagnan @ralekna @schfkt +/types/joigoose/ @boothwhack +/types/jointjs/ @areel @DavidDurman @DenEwout @CaselIT @ChrisMoran +/types/jpm/ @github-account-because-they-want-it +/types/jqgrid/ @lokeshpeta +/types/jqrangeslider/ @qcz +/types/jquery/v1/ @choffmeister @Steve-Fenton @Diullei @tasoili @jasons-novaleaf @seanski @Guuz @ksummerlin @basarat @nwolverson @derekcicerone @AndrewGaspar @seikichi @benjaminjackman @s093294 @JoshStrobl @DickvdBrink @King2500 @leonard-thieu +/types/jquery/v2/ @choffmeister @Steve-Fenton @Diullei @tasoili @jasons-novaleaf @seanski @Guuz @ksummerlin @basarat @nwolverson @derekcicerone @AndrewGaspar @seikichi @benjaminjackman @s093294 @JoshStrobl @DickvdBrink @King2500 @leonard-thieu +/types/jquery/ @leonard-thieu @borisyankov @choffmeister @Steve-Fenton @Diullei @tasoili @jasons-novaleaf @seanski @Guuz @ksummerlin @basarat @nwolverson @derekcicerone @AndrewGaspar @seikichi @benjaminjackman @s093294 @JoshStrobl @johnnyreilly @DickvdBrink @King2500 +/types/jquery-ajax-chain/ @humana-fragilitas +/types/jquery-alertable/ @stever +/types/jquery-backstretch/ @dkulyk +/types/jquery-cropbox/ @PerKastman +/types/jquery-deparam/ @patsissons +/types/jquery-easy-loading/ @delphinus35 +/types/jquery-editable-select/ @baywet +/types/jquery-fullscreen/ @bgrieder +/types/jquery-galleria/ @rimig +/types/jquery-handsontable/ @intelorca +/types/jquery-jsonrpcclient/ @Ty3uK +/types/jquery-knob/ @iain8 +/types/jquery-mask-plugin/ @avidenic +/types/jquery-match-height/ @kbytesys +/types/jquery-mockjax/ @laszlojakab @vladeck +/types/jquery-mousewheel/ @xt0rted +/types/jquery-param/ @patsissons +/types/jquery-sortable/ @Seltzer +/types/jquery-steps/ @jblank @nickwph +/types/jquery-timeentry/ @marknadig +/types/jquery-toastmessage-plugin/ @joeskeen +/types/jquery-truncate-html/ @abraaoalves +/types/jquery-urlparam/ @stpettersens +/types/jquery-validation-unobtrusive/ @EnableSoftware +/types/jquery.address/ @martinduparc @mardaneus86 +/types/jquery.are-you-sure/ @jonegerton +/types/jquery.autosize/ @kingdango +/types/jquery.bbq/ @sunetos +/types/jquery.bootstrap.wizard/ @niemyjski +/types/jquery.cleditor/ @pushplay +/types/jquery.clientsidelogging/ @diullei +/types/jquery.color/ @derekcicerone +/types/jquery.colorbox/ @gjunge +/types/jquery.colorpicker/ @pushplay +/types/jquery.contextmenu/ @nvivo +/types/jquery.cookie/ @RoyGoode @BenLorantfy +/types/jquery.customselect/ @adamcoulombe +/types/jquery.cycle2/ @dnadolny +/types/jquery.dropotron/ @cyrilschumacher +/types/jquery.dynatree/ @fdecampredon +/types/jquery.elang/ @sumegizoltan +/types/jquery.fancytree/ @alphaleonis @abedi-ir +/types/jquery.finger/ @maxackley +/types/jquery.flagstrap/ @felipedgarcia +/types/jquery.fullscreen/ @piraveen +/types/jquery.gridster/ @jbaldwin +/types/jquery.growl/ @yeganemehr +/types/jquery.highlight-bartaz/ @Pro +/types/jquery.jnotify/ @jamescurran +/types/jquery.joyride/ @vbortone +/types/jquery.jsignature/ @pjmagee +/types/jquery.leanmodal/ @FinelySliced +/types/jquery.livestampjs/ @vbortone +/types/jquery.notify/ @evil-shrike +/types/jquery.notifybar/ @zaneli +/types/jquery.noty/ @kingdango @thelfensdrfer +/types/jquery.payment/ @ejsmith @johnrutherford +/types/jquery.pjax/ @lijunle +/types/jquery.placeholder/ @majorsilence @EnableSoftware +/types/jquery.pnotify/ @DavidSichau @FUNExtreme +/types/jquery.postmessage/ @lijunle +/types/jquery.prettyphoto/ @pgaske +/types/jquery.qrcode/ @danmana +/types/jquery.rateit/ @gjunge +/types/jquery.rowgrid/ @vinayak-garg +/types/jquery.scrollto/ @nestalk +/types/jquery.simplemodal/ @ForNeVeR +/types/jquery.simplepagination/ @nvivo +/types/jquery.simulate/ @derekcicerone +/types/jquery.slimscroll/ @Promact +/types/jquery.soap/ @tigerxy +/types/jquery.sortelements/ @tbureck +/types/jquery.superlink/ @niemyjski +/types/jquery.tagsmanager/ @vbortone +/types/jquery.tile/ @zaneli +/types/jquery.timepicker/ @anwarjaved +/types/jquery.timer/ @JoshStrobl +/types/jquery.tinycarousel/ @csrakowski +/types/jquery.tinyscrollbar/ @csrakowski +/types/jquery.tipsy/ @bdukes +/types/jquery.tools/ @joeskeen +/types/jquery.tooltipster/ @pjmagee @VorobeY1326 @leonard-thieu @janhi +/types/jquery.total-storage/ @JeremyCBrooks +/types/jquery.transit/ @MrBigDog2U +/types/jquery.ui.datetimepicker/ @dougajmcdonald +/types/jquery.ui.layout/ @Steve-Fenton @drarmstr +/types/jquery.uniform/ @flyfishMT +/types/jquery.validation/ @fdecampredon @johnnyreilly @avidenic +/types/jquery.watermark/ @anwarjaved +/types/jquerymobile/ @borisyankov +/types/jqueryui/ @borisyankov @johnnyreilly +/types/js-base64/ @DenisCarriere +/types/js-beautify/ @JoshuaKGoldberg @hansrwindhoff +/types/js-clipper/ @omni360 +/types/js-combinatorics/ @outring +/types/js-cookie/ @theodorejb +/types/js-data/v1/ @reppners +/types/js-data/ @reppners +/types/js-data-angular/ @reppners +/types/js-data-http/ @reppners +/types/js-fixtures/ @kazimanzurrashid +/types/js-git/ @Bartvds +/types/js-md5/ @mwmccarthy +/types/js-quantities/ @wrummler +/types/js-schema/ @marcinporebski @roblabat +/types/js-search/ @guoyunhe +/types/js-to-java/ @skyitachi +/types/js-url/ @pine613 +/types/js-yaml/ @Bartvds @sclausen +/types/js.spec/ @mattbishop +/types/jsbn/ @Evgenus +/types/jscrollpane/ @qcz +/types/jsdeferred/ @minodisk +/types/jsdom/ @leonard-thieu +/types/jsen/ @vladeck +/types/jsend/ @CaselIT +/types/jsesc/ @Bartvds +/types/jsfl/ @soywiz +/types/jsforce/ @dolanmiu @netes +/types/jshamcrest/ @dharkness +/types/jsmockito/ @shiver-me-timbers +/types/jsnox/ @stkb @DovydasNavickas +/types/json-merge-patch/ @senyaarseniy +/types/json-patch/ @vvakame +/types/json-pointer/ @Bartvds +/types/json-rpc-ws/ @npenin +/types/json-schema/ @bcherny +/types/json-socket/ @svi3c +/types/json-stable-stringify/ @mhfrantz +/types/json-stringify-safe/ @BendingBender +/types/json2md/ @MartynasZilinskas +/types/jsoneditor/ @alejo90 +/types/jsoneditoronline/ @vbortone +/types/jsonminify/ @no23reason +/types/jsonnet/ @hookclaw +/types/jsonp/ @surenkov +/types/jsonpath/ @horiuchi @ikatyang +/types/jsonrpc-serializer/ @Akim95 +/types/jsonstream/ @Bartvds +/types/jsonwebtoken/ @SomaticIT @danielheim +/types/jspdf/ @amberjs +/types/jsplumb/ @shearnie +/types/jsrender/ @zakki +/types/jsrp/ @harryshipton +/types/jss/ @Ptival +/types/jssha/ @randombk @SrTobi +/types/jstimezonedetect/ @olamothe +/types/jstorage/ @dflor003 +/types/jstree/ @adaskothebeast +/types/jsts/ @StephaneAlie +/types/jsuite/ @darrenhillconsulting +/types/jsuri/ @coldacid @flqw +/types/jsurl/ @agorshkov23 +/types/jsx-chai/ @nupplaphil +/types/jszip/ @mzeiher +/types/jug/ @yevt +/types/jui/ @easylogic +/types/jui-core/ @easylogic +/types/jui-grid/ @easylogic +/types/jweixin/ @taoqf +/types/jwplayer/ @martinduparc +/types/jwt-client/ @timoteoponce +/types/jwt-decode/ @GiedriusGrabauskas @madsmadsen +/types/jwt-simple/ @kenfdev @GaelMagnan +/types/kafka-node/ @dansitu @bkim54 @sfrooster @amiram +/types/karma/ @tkrotoff +/types/karma-chai/ @JayAndCatchFire +/types/karma-chai-sinon/ @vasek17 +/types/karma-coverage/ @tkrotoff +/types/karma-fixture/ @evictor +/types/karma-jasmine/ @michelsalib +/types/katex/ @mrand01 +/types/kcors/ @Xstoudi @izayoiko +/types/kdbush/ @DenisCarriere +/types/kefir/ @AyaMorisawa +/types/kendo-ui/ @telerik +/types/keyboardjs/ @vbortone @piranha771 +/types/keycloak-js/ @eppsilon +/types/keygrip/ @jkeylu +/types/keymaster/ @nitram509 +/types/keymirror/ @jfahrenkrug +/types/keypress.js/ @rcchen +/types/keysym/ @harryshipton +/types/keytar/ @miniak @shiftkey @juturu +/types/kik-browser/ @joelday +/types/klaw/ @mceachen +/types/klaw-sync/ @shiftkey +/types/knex/ @tkQubo @baronfel +/types/knockback/ @borisyankov +/types/knockout/ @EnableSoftware @BenjaminEckardt +/types/knockout-amd-helpers/ @DavidSichau +/types/knockout-secure-binding/ @pine613 +/types/knockout-transformations/ @johnnyreilly @Nemo157 +/types/knockout.deferred.updates/ @sgaliano +/types/knockout.editables/ @borisyankov +/types/knockout.es5/ @sgaliano +/types/knockout.kogrid/ @huer12 +/types/knockout.mapper/ @BMeyerKC +/types/knockout.mapping/ @borisyankov +/types/knockout.projections/ @johnnyreilly +/types/knockout.punches/ @johnnyreilly +/types/knockout.rx/ @Igorbek +/types/knockout.validation/ @danludwig +/types/knockout.viewmodel/ @oising +/types/knockstrap/ @adaskothebeast +/types/knuddels-userapps-api/ @Knuddels +/types/ko.plus/ @conficient +/types/koa/ @DavidCai1993 @jkeylu +/types/koa-basic-auth/ @Tobias4872 +/types/koa-bodyparser/ @hellopao +/types/koa-cache-control/ @pe8ter +/types/koa-compose/ @jkeylu +/types/koa-compress/ @hellopao +/types/koa-favicon/ @hellopao +/types/koa-generic-session/ @nsimmons +/types/koa-hbs/ @jcbmln @mudkipme +/types/koa-helmet/ @me +/types/koa-json/ @brooklyndev +/types/koa-json-error/ @mudkipme +/types/koa-jwt/ @brunokrebs +/types/koa-logger/ @geoffreak +/types/koa-morgan/ @vesse +/types/koa-mount/ @amirsaber +/types/koa-passport/ @horiuchi +/types/koa-pug/ @Xstoudi +/types/koa-redis/ @nsimmons +/types/koa-route/ @migstopheles +/types/koa-router/ @hellopao @schfkt +/types/koa-send/ @pe8ter +/types/koa-session/ @kerol2r20 +/types/koa-session-minimal/ @longztian +/types/koa-static/ @hellopao +/types/koa-views/ @brooklyndev +/types/koa-websocket/ @me +/types/kolite/ @borisyankov +/types/konami.js/ @mareek +/types/kramed/ @tonicblue +/types/kss/ @giladgray +/types/kue/ @drudge @amiram @pc-jedi +/types/kuromoji/ @mzsm +/types/lab/ @prashaantt +/types/ladda/ @dflor003 @leemicw +/types/lambda-phi/ @elitechance +/types/later/ @jasond-s +/types/latinize/ @GiedriusGrabauskas +/types/launchpad/ @rictic +/types/lazy.js/ @Bartvds +/types/lazypipe/ @tomc974 +/types/ldapjs/ @cvillemure @peterkooijmans +/types/leadfoot/ @theintern +/types/leaflet/v0/ @rgripper +/types/leaflet/ @alejo90 +/types/leaflet-areaselect/ @awallat +/types/leaflet-curve/ @onikiienko +/types/leaflet-draw/ @matt-guest @reblace +/types/leaflet-editable/ @dalie +/types/leaflet-fullscreen/ @DenisCarriere +/types/leaflet-imageoverlay-rotated/ @tkleinke +/types/leaflet-label/ @Nemo157 +/types/leaflet-polylinedecorator/ @soucekv +/types/leaflet-providers/ @BendingBender +/types/leaflet.awesome-markers/v0/ @Odrin @sebek64 +/types/leaflet.awesome-markers/ @sebek64 +/types/leaflet.fullscreen/ @wcomartin +/types/leaflet.gridlayer.googlemutant/ @ernest-rhinozeros +/types/leaflet.locatecontrol/ @DenisCarriere +/types/leaflet.markercluster/ @rimig +/types/leaflet.markercluster.layersupport/ @AsamK +/types/leaflet.pm/ @tkleinke +/types/leapmotionts/ @logotype +/types/left-pad/ @Goldsmith42 +/types/less/ @thasner @pranaygp +/types/less-middleware/ @federicobond +/types/lestate/ @thelambdaparty +/types/level-sublevel/ @basp +/types/leveldown/ @tarruda +/types/levelup/ @blittle @tarruda +/types/leven/ @jmalonzo +/types/levenshtein/ @geoffreak +/types/libpq/ @Lodin +/types/libxmljs/ @fdecampredon +/types/libxslt/ @alejo90 +/types/license-checker/ @rogierschouten +/types/lime-js/ @arthur-xavier +/types/line-by-line/ @etomsen +/types/line-reader/ @stpettersens +/types/linkify-it/ @praxxis +/types/linq4js/ @morrisjdev +/types/lls/ @borislavjivkov +/types/load-json-file/ @SamVerschueren +/types/loader-runner/ @e-cloud +/types/loader-utils/ @Perlmint +/types/lobibox/ @itboy87 +/types/localforage-cordovasqlitedriver/ @thgreasi +/types/localized-countries/ @coderslagoon +/types/locate-path/ @me +/types/lockfile/v0/ @Bartvds +/types/lockfile/ @Bartvds @BendingBender +/types/lockr/ @droritos +/types/locutus/ @hookclaw +/types/lodash/v3/ @bczengel @chrootsu +/types/lodash/ @bczengel @chrootsu @stepancar @ericanderson @aj-r @ailrun +/types/lodash-es/ @stephenlautier +/types/lodash-webpack-plugin/ @bumbleblym +/types/lodash.add/ @bczengel @chrootsu @stepancar +/types/lodash.after/ @bczengel @chrootsu @stepancar +/types/lodash.ary/ @bczengel @chrootsu @stepancar +/types/lodash.assign/ @bczengel @chrootsu @stepancar +/types/lodash.assignin/ @bczengel @chrootsu @stepancar +/types/lodash.assigninwith/ @bczengel @chrootsu @stepancar +/types/lodash.assignwith/ @bczengel @chrootsu @stepancar +/types/lodash.at/ @bczengel @chrootsu @stepancar +/types/lodash.attempt/ @bczengel @chrootsu @stepancar +/types/lodash.before/ @bczengel @chrootsu @stepancar +/types/lodash.bind/ @bczengel @chrootsu @stepancar +/types/lodash.bindall/ @bczengel @chrootsu @stepancar +/types/lodash.bindkey/ @bczengel @chrootsu @stepancar +/types/lodash.camelcase/ @bczengel @chrootsu @stepancar +/types/lodash.capitalize/ @bczengel @chrootsu @stepancar +/types/lodash.castarray/ @bczengel @chrootsu @stepancar +/types/lodash.ceil/ @bczengel @chrootsu @stepancar +/types/lodash.chunk/ @bczengel @chrootsu @stepancar +/types/lodash.clamp/ @bczengel @chrootsu @stepancar +/types/lodash.clone/ @bczengel @chrootsu @stepancar +/types/lodash.clonedeep/ @bczengel @chrootsu @stepancar +/types/lodash.clonedeepwith/ @bczengel @chrootsu @stepancar +/types/lodash.clonewith/ @bczengel @chrootsu @stepancar +/types/lodash.compact/ @bczengel @chrootsu @stepancar +/types/lodash.concat/ @bczengel @chrootsu @stepancar +/types/lodash.constant/ @bczengel @chrootsu @stepancar +/types/lodash.countby/ @bczengel @chrootsu @stepancar +/types/lodash.create/ @bczengel @chrootsu @stepancar +/types/lodash.curry/ @bczengel @chrootsu @stepancar +/types/lodash.curryright/ @bczengel @chrootsu @stepancar +/types/lodash.debounce/ @bczengel @chrootsu @stepancar +/types/lodash.deburr/ @bczengel @chrootsu @stepancar +/types/lodash.defaults/ @bczengel @chrootsu @stepancar +/types/lodash.defaultsdeep/ @bczengel @chrootsu @stepancar +/types/lodash.defer/ @bczengel @chrootsu @stepancar +/types/lodash.delay/ @bczengel @chrootsu @stepancar +/types/lodash.difference/ @bczengel @chrootsu @stepancar +/types/lodash.differenceby/ @bczengel @chrootsu @stepancar +/types/lodash.differencewith/ @bczengel @chrootsu @stepancar +/types/lodash.drop/ @bczengel @chrootsu @stepancar +/types/lodash.dropright/ @bczengel @chrootsu @stepancar +/types/lodash.droprightwhile/ @bczengel @chrootsu @stepancar +/types/lodash.dropwhile/ @bczengel @chrootsu @stepancar +/types/lodash.endswith/ @bczengel @chrootsu @stepancar +/types/lodash.eq/ @bczengel @chrootsu @stepancar +/types/lodash.escape/ @bczengel @chrootsu @stepancar +/types/lodash.escaperegexp/ @bczengel @chrootsu @stepancar +/types/lodash.every/ @bczengel @chrootsu @stepancar +/types/lodash.fill/ @bczengel @chrootsu @stepancar +/types/lodash.filter/ @bczengel @chrootsu @stepancar +/types/lodash.find/ @bczengel @chrootsu @stepancar +/types/lodash.findindex/ @bczengel @chrootsu @stepancar +/types/lodash.findkey/ @bczengel @chrootsu @stepancar +/types/lodash.findlast/ @bczengel @chrootsu @stepancar +/types/lodash.findlastindex/ @bczengel @chrootsu @stepancar +/types/lodash.findlastkey/ @bczengel @chrootsu @stepancar +/types/lodash.first/ @bczengel @chrootsu @stepancar +/types/lodash.flatmap/ @bczengel @chrootsu @stepancar +/types/lodash.flatten/ @bczengel @chrootsu @stepancar +/types/lodash.flattendeep/ @bczengel @chrootsu @stepancar +/types/lodash.flattendepth/ @bczengel @chrootsu @stepancar +/types/lodash.flip/ @bczengel @chrootsu @stepancar +/types/lodash.floor/ @bczengel @chrootsu @stepancar +/types/lodash.flow/ @bczengel @chrootsu @stepancar +/types/lodash.flowright/ @bczengel @chrootsu @stepancar +/types/lodash.foreach/ @bczengel @chrootsu @stepancar +/types/lodash.foreachright/ @bczengel @chrootsu @stepancar +/types/lodash.forin/ @bczengel @chrootsu @stepancar +/types/lodash.forinright/ @bczengel @chrootsu @stepancar +/types/lodash.forown/ @bczengel @chrootsu @stepancar +/types/lodash.forownright/ @bczengel @chrootsu @stepancar +/types/lodash.frompairs/ @bczengel @chrootsu @stepancar +/types/lodash.functions/ @bczengel @chrootsu @stepancar +/types/lodash.functionsin/ @bczengel @chrootsu @stepancar +/types/lodash.get/ @bczengel @chrootsu @stepancar +/types/lodash.groupby/ @bczengel @chrootsu @stepancar +/types/lodash.gt/ @bczengel @chrootsu @stepancar +/types/lodash.gte/ @bczengel @chrootsu @stepancar +/types/lodash.has/ @bczengel @chrootsu @stepancar +/types/lodash.hasin/ @bczengel @chrootsu @stepancar +/types/lodash.head/ @bczengel @chrootsu @stepancar +/types/lodash.identity/ @bczengel @chrootsu @stepancar +/types/lodash.includes/ @bczengel @chrootsu @stepancar +/types/lodash.indexof/ @bczengel @chrootsu @stepancar +/types/lodash.initial/ @bczengel @chrootsu @stepancar +/types/lodash.inrange/ @bczengel @chrootsu @stepancar +/types/lodash.intersection/ @bczengel @chrootsu @stepancar +/types/lodash.intersectionby/ @bczengel @chrootsu @stepancar +/types/lodash.intersectionwith/ @bczengel @chrootsu @stepancar +/types/lodash.invert/ @bczengel @chrootsu @stepancar +/types/lodash.invertby/ @bczengel @chrootsu @stepancar +/types/lodash.invoke/ @bczengel @chrootsu @stepancar +/types/lodash.invokemap/ @bczengel @chrootsu @stepancar +/types/lodash.isarguments/ @bczengel @chrootsu @stepancar +/types/lodash.isarray/ @bczengel @chrootsu @stepancar +/types/lodash.isarraybuffer/ @bczengel @chrootsu @stepancar +/types/lodash.isarraylike/ @bczengel @chrootsu @stepancar +/types/lodash.isarraylikeobject/ @bczengel @chrootsu @stepancar +/types/lodash.isboolean/ @bczengel @chrootsu @stepancar +/types/lodash.isbuffer/ @bczengel @chrootsu @stepancar +/types/lodash.isdate/ @bczengel @chrootsu @stepancar +/types/lodash.iselement/ @bczengel @chrootsu @stepancar +/types/lodash.isempty/ @bczengel @chrootsu @stepancar +/types/lodash.isequal/ @bczengel @chrootsu @stepancar +/types/lodash.isequalwith/ @bczengel @chrootsu @stepancar +/types/lodash.iserror/ @bczengel @chrootsu @stepancar +/types/lodash.isfinite/ @bczengel @chrootsu @stepancar +/types/lodash.isfunction/ @bczengel @chrootsu @stepancar +/types/lodash.isinteger/ @bczengel @chrootsu @stepancar +/types/lodash.islength/ @bczengel @chrootsu @stepancar +/types/lodash.ismap/ @bczengel @chrootsu @stepancar +/types/lodash.ismatch/ @bczengel @chrootsu @stepancar +/types/lodash.ismatchwith/ @bczengel @chrootsu @stepancar +/types/lodash.isnan/ @bczengel @chrootsu @stepancar +/types/lodash.isnative/ @bczengel @chrootsu @stepancar +/types/lodash.isnil/ @bczengel @chrootsu @stepancar +/types/lodash.isnull/ @bczengel @chrootsu @stepancar +/types/lodash.isnumber/ @bczengel @chrootsu @stepancar +/types/lodash.isobject/ @bczengel @chrootsu @stepancar +/types/lodash.isobjectlike/ @bczengel @chrootsu @stepancar +/types/lodash.isplainobject/ @bczengel @chrootsu @stepancar +/types/lodash.isregexp/ @bczengel @chrootsu @stepancar +/types/lodash.issafeinteger/ @bczengel @chrootsu @stepancar +/types/lodash.isset/ @bczengel @chrootsu @stepancar +/types/lodash.isstring/ @bczengel @chrootsu @stepancar +/types/lodash.issymbol/ @bczengel @chrootsu @stepancar +/types/lodash.istypedarray/ @bczengel @chrootsu @stepancar +/types/lodash.isundefined/ @bczengel @chrootsu @stepancar +/types/lodash.isweakmap/ @bczengel @chrootsu @stepancar +/types/lodash.isweakset/ @bczengel @chrootsu @stepancar +/types/lodash.iteratee/ @bczengel @chrootsu @stepancar +/types/lodash.join/ @bczengel @chrootsu @stepancar +/types/lodash.kebabcase/ @bczengel @chrootsu @stepancar +/types/lodash.keyby/ @bczengel @chrootsu @stepancar +/types/lodash.keys/ @bczengel @chrootsu @stepancar +/types/lodash.keysin/ @bczengel @chrootsu @stepancar +/types/lodash.last/ @bczengel @chrootsu @stepancar +/types/lodash.lastindexof/ @bczengel @chrootsu @stepancar +/types/lodash.lowercase/ @bczengel @chrootsu @stepancar +/types/lodash.lowerfirst/ @bczengel @chrootsu @stepancar +/types/lodash.lt/ @bczengel @chrootsu @stepancar +/types/lodash.lte/ @bczengel @chrootsu @stepancar +/types/lodash.mapkeys/ @bczengel @chrootsu @stepancar +/types/lodash.mapvalues/ @bczengel @chrootsu @stepancar +/types/lodash.matches/ @bczengel @chrootsu @stepancar +/types/lodash.matchesproperty/ @bczengel @chrootsu @stepancar +/types/lodash.max/ @bczengel @chrootsu @stepancar +/types/lodash.maxby/ @bczengel @chrootsu @stepancar +/types/lodash.mean/ @bczengel @chrootsu @stepancar +/types/lodash.meanby/ @bczengel @chrootsu @stepancar +/types/lodash.memoize/ @bczengel @chrootsu @stepancar +/types/lodash.merge/ @bczengel @chrootsu @stepancar +/types/lodash.mergewith/ @bczengel @chrootsu @stepancar +/types/lodash.method/ @bczengel @chrootsu @stepancar +/types/lodash.methodof/ @bczengel @chrootsu @stepancar +/types/lodash.min/ @bczengel @chrootsu @stepancar +/types/lodash.minby/ @bczengel @chrootsu @stepancar +/types/lodash.mixin/ @bczengel @chrootsu @stepancar +/types/lodash.negate/ @bczengel @chrootsu @stepancar +/types/lodash.noop/ @bczengel @chrootsu @stepancar +/types/lodash.now/ @bczengel @chrootsu @stepancar +/types/lodash.nth/ @bczengel @chrootsu @stepancar +/types/lodash.ntharg/ @bczengel @chrootsu @stepancar +/types/lodash.omit/ @bczengel @chrootsu @stepancar +/types/lodash.omitby/ @bczengel @chrootsu @stepancar +/types/lodash.once/ @bczengel @chrootsu @stepancar +/types/lodash.orderby/ @bczengel @chrootsu @stepancar +/types/lodash.over/ @bczengel @chrootsu @stepancar +/types/lodash.overargs/ @bczengel @chrootsu @stepancar +/types/lodash.overevery/ @bczengel @chrootsu @stepancar +/types/lodash.oversome/ @bczengel @chrootsu @stepancar +/types/lodash.pad/ @bczengel @chrootsu @stepancar +/types/lodash.padend/ @bczengel @chrootsu @stepancar +/types/lodash.padstart/ @bczengel @chrootsu @stepancar +/types/lodash.parseint/ @bczengel @chrootsu @stepancar +/types/lodash.partial/ @bczengel @chrootsu @stepancar +/types/lodash.partialright/ @bczengel @chrootsu @stepancar +/types/lodash.partition/ @bczengel @chrootsu @stepancar +/types/lodash.pick/ @bczengel @chrootsu @stepancar +/types/lodash.pickby/ @bczengel @chrootsu @stepancar +/types/lodash.property/ @bczengel @chrootsu @stepancar +/types/lodash.propertyof/ @bczengel @chrootsu @stepancar +/types/lodash.pull/ @bczengel @chrootsu @stepancar +/types/lodash.pullall/ @bczengel @chrootsu @stepancar +/types/lodash.pullallby/ @bczengel @chrootsu @stepancar +/types/lodash.pullat/ @bczengel @chrootsu @stepancar +/types/lodash.random/ @bczengel @chrootsu @stepancar +/types/lodash.range/ @bczengel @chrootsu @stepancar +/types/lodash.rangeright/ @bczengel @chrootsu @stepancar +/types/lodash.rearg/ @bczengel @chrootsu @stepancar +/types/lodash.reduce/ @bczengel @chrootsu @stepancar +/types/lodash.reduceright/ @bczengel @chrootsu @stepancar +/types/lodash.reject/ @bczengel @chrootsu @stepancar +/types/lodash.remove/ @bczengel @chrootsu @stepancar +/types/lodash.repeat/ @bczengel @chrootsu @stepancar +/types/lodash.replace/ @bczengel @chrootsu @stepancar +/types/lodash.rest/ @bczengel @chrootsu @stepancar +/types/lodash.result/ @bczengel @chrootsu @stepancar +/types/lodash.reverse/ @bczengel @chrootsu @stepancar +/types/lodash.round/ @bczengel @chrootsu @stepancar +/types/lodash.sample/ @bczengel @chrootsu @stepancar +/types/lodash.samplesize/ @bczengel @chrootsu @stepancar +/types/lodash.set/ @bczengel @chrootsu @stepancar +/types/lodash.setwith/ @bczengel @chrootsu @stepancar +/types/lodash.shuffle/ @bczengel @chrootsu @stepancar +/types/lodash.size/ @bczengel @chrootsu @stepancar +/types/lodash.slice/ @bczengel @chrootsu @stepancar +/types/lodash.snakecase/ @bczengel @chrootsu @stepancar +/types/lodash.some/ @bczengel @chrootsu @stepancar +/types/lodash.sortby/ @bczengel @chrootsu @stepancar +/types/lodash.sortedindex/ @bczengel @chrootsu @stepancar +/types/lodash.sortedindexby/ @bczengel @chrootsu @stepancar +/types/lodash.sortedindexof/ @bczengel @chrootsu @stepancar +/types/lodash.sortedlastindex/ @bczengel @chrootsu @stepancar +/types/lodash.sortedlastindexby/ @bczengel @chrootsu @stepancar +/types/lodash.sortedlastindexof/ @bczengel @chrootsu @stepancar +/types/lodash.sorteduniq/ @bczengel @chrootsu @stepancar +/types/lodash.sorteduniqby/ @bczengel @chrootsu @stepancar +/types/lodash.split/ @bczengel @chrootsu @stepancar +/types/lodash.spread/ @bczengel @chrootsu @stepancar +/types/lodash.startcase/ @bczengel @chrootsu @stepancar +/types/lodash.startswith/ @bczengel @chrootsu @stepancar +/types/lodash.subtract/ @bczengel @chrootsu @stepancar +/types/lodash.sum/ @bczengel @chrootsu @stepancar +/types/lodash.sumby/ @bczengel @chrootsu @stepancar +/types/lodash.tail/ @bczengel @chrootsu @stepancar +/types/lodash.take/ @bczengel @chrootsu @stepancar +/types/lodash.takeright/ @bczengel @chrootsu @stepancar +/types/lodash.takerightwhile/ @bczengel @chrootsu @stepancar +/types/lodash.takewhile/ @bczengel @chrootsu @stepancar +/types/lodash.template/ @bczengel @chrootsu @stepancar +/types/lodash.throttle/ @bczengel @chrootsu @stepancar +/types/lodash.times/ @bczengel @chrootsu @stepancar +/types/lodash.toarray/ @bczengel @chrootsu @stepancar +/types/lodash.tointeger/ @bczengel @chrootsu @stepancar +/types/lodash.tolength/ @bczengel @chrootsu @stepancar +/types/lodash.tolower/ @bczengel @chrootsu @stepancar +/types/lodash.tonumber/ @bczengel @chrootsu @stepancar +/types/lodash.topairs/ @bczengel @chrootsu @stepancar +/types/lodash.topairsin/ @bczengel @chrootsu @stepancar +/types/lodash.topath/ @bczengel @chrootsu @stepancar +/types/lodash.toplainobject/ @bczengel @chrootsu @stepancar +/types/lodash.tosafeinteger/ @bczengel @chrootsu @stepancar +/types/lodash.tostring/ @bczengel @chrootsu @stepancar +/types/lodash.toupper/ @bczengel @chrootsu @stepancar +/types/lodash.transform/ @bczengel @chrootsu @stepancar +/types/lodash.trim/ @bczengel @chrootsu @stepancar +/types/lodash.trimend/ @bczengel @chrootsu @stepancar +/types/lodash.trimstart/ @bczengel @chrootsu @stepancar +/types/lodash.truncate/ @bczengel @chrootsu @stepancar +/types/lodash.unary/ @bczengel @chrootsu @stepancar +/types/lodash.unescape/ @bczengel @chrootsu @stepancar +/types/lodash.union/ @bczengel @chrootsu @stepancar +/types/lodash.unionby/ @bczengel @chrootsu @stepancar +/types/lodash.unionwith/ @bczengel @chrootsu @stepancar +/types/lodash.uniq/ @bczengel @chrootsu @stepancar +/types/lodash.uniqby/ @bczengel @chrootsu @stepancar +/types/lodash.uniqueid/ @bczengel @chrootsu @stepancar +/types/lodash.uniqwith/ @bczengel @chrootsu @stepancar +/types/lodash.unset/ @bczengel @chrootsu @stepancar +/types/lodash.unzip/ @bczengel @chrootsu @stepancar +/types/lodash.unzipwith/ @bczengel @chrootsu @stepancar +/types/lodash.update/ @bczengel @chrootsu @stepancar +/types/lodash.uppercase/ @bczengel @chrootsu @stepancar +/types/lodash.upperfirst/ @bczengel @chrootsu @stepancar +/types/lodash.values/ @bczengel @chrootsu @stepancar +/types/lodash.valuesin/ @bczengel @chrootsu @stepancar +/types/lodash.without/ @bczengel @chrootsu @stepancar +/types/lodash.words/ @bczengel @chrootsu @stepancar +/types/lodash.wrap/ @bczengel @chrootsu @stepancar +/types/lodash.xor/ @bczengel @chrootsu @stepancar +/types/lodash.xorby/ @bczengel @chrootsu @stepancar +/types/lodash.xorwith/ @bczengel @chrootsu @stepancar +/types/lodash.zip/ @bczengel @chrootsu @stepancar +/types/lodash.zipobject/ @bczengel @chrootsu @stepancar +/types/lodash.zipobjectdeep/ @bczengel @chrootsu @stepancar +/types/lodash.zipwith/ @bczengel @chrootsu @stepancar +/types/log-symbols/ @BendingBender +/types/log-update/ @BendingBender +/types/log4javascript/ @Ritzlgrmft +/types/log4js/ @armorik83 +/types/logat/ @krvikash35 +/types/logg/ @blittle +/types/loggly/ @rmartone @geoffreak +/types/loglevel/ @Pro @flqw @szmeti +/types/logrotate-stream/ @rogierschouten +/types/lokijs/ @TeamworkGuy2 +/types/lolex/ @Nemo157 @joshuakgoldberg +/types/long/ @peterkooijmans +/types/loopback/ @kattsushi +/types/loopback-boot/ @kattsushi +/types/lorem-ipsum/ @durad +/types/lory.js/ @kubosho @milkisevil +/types/loud-rejection/ @BendingBender +/types/lovefield/ @freshp86 +/types/lowdb/ @typicode +/types/lowlight/ @NoHomey +/types/lru-cache/ @Bartvds +/types/lscache/ @Chris-Martinezz +/types/ltx/ @PJakcson +/types/luaparse/ @stpettersens +/types/lunr/ @sebastian-lenz +/types/lwip/ @AyaMorisawa +/types/lz-string/ @M0ns1gn0r +/types/magic-number/ @stpettersens +/types/magicsuggest/ @leonardochaia +/types/magnet-uri/ @tlaziuk +/types/mailcheck/ @pocesar +/types/maildev/ @cyrilschumacher @zbarbuto +/types/mailgen/ @vothanhkiet @jordanfarrer +/types/mailparser/ @psnider +/types/main-bower-files/ @k-kagurazaka +/types/make-dir/ @ikatyang @BendingBender +/types/maker.js/ @danmarshall +/types/mandrill-api/ @pocesar +/types/map-obj/ @BendingBender +/types/mapbox/ @anahkiasen +/types/mapbox-gl/ @dobrud +/types/mapbox__shelf-pack/ @Perlmint +/types/mapsjs/ @davismj +/types/mariasql/ @bennett000 +/types/markdown-it/ @rapropos +/types/markdown-it-anchor/ @seryl +/types/markdown-it-container/ @hronex +/types/marked/ @worr @BendingBender +/types/marker-animate-unobtrusive/ @viskin +/types/markerclustererplus/ @enanox +/types/markitup/ @drillbits +/types/maskedinput/ @lokeshpeta +/types/masonry-layout/ @m-a-wilson @warriorrocker +/types/massive/ @swissspidy @clarenceh +/types/match-media-mock/ @asvetliakov +/types/material-design-lite/ @bradzacher +/types/material-ui/ @ngbrown @theigor @alitaheri @herrmanno @DaIgeb @allienna @schlesingermatthias @InsidersByte @artyomsv @dan-j @minodisk +/types/materialize-css/ @eriklieben @leonyu @SinghSukhdeep +/types/math3d/ @laszlojakab +/types/mathjax/ @rolandzwaga +/types/mathjs/ @siavol +/types/matter-js/ @piranha771 +/types/maxmind/ @geoffreak +/types/mcustomscrollbar/ @flurg +/types/md5/ @arcdev1 @jprogrammer +/types/mdns/ @reppners +/types/media-typer/ @BendingBender +/types/medium-editor/ @keika299 +/types/mem/ @SamVerschueren +/types/memcached/ @KentarouTakeda +/types/memoizee/ @juanpicado +/types/memory-cache/ @jedigo +/types/memory-fs/ @e-cloud +/types/memwatch-next/ @cyrilschumacher +/types/meow/ @KnisterPeter +/types/merge-descriptors/ @danny8002 +/types/merge-stream/ @k-kagurazaka +/types/merge2/ @tkrotoff @smac89 +/types/mersenne-twister/ @KentarouTakeda +/types/meshblu/ @fnipo +/types/mess/ @Nemo157 +/types/messenger/ @derekcicerone +/types/meteor/ @barbatus @fullflavedave @orefalo @dagatsoin @birkskyum @ardatan @stefanholzapfel +/types/meteor-accounts-phone/ @DAB0mB +/types/meteor-collection-hooks/ @twastvedt +/types/meteor-jboulhous-dev/ @vangorra +/types/meteor-persistent-session/ @vangorra +/types/meteor-prime8consulting-oauth2/ @vangorra +/types/meteor-publish-composite/ @vangorra +/types/meteor-roles/ @vangorra +/types/method-override/ @santialbo +/types/methods/ @cprecioso +/types/metismenu/ @onokumus @denisname +/types/metric-suffix/ @davidm77 +/types/micro/ @kaoDev +/types/microgears/ @marcusdb +/types/micromatch/ @glen-84 +/types/microrouter/ @mathieudutour +/types/microsoft-ajax/ @pjmagee +/types/microsoft-live-connect/ @jvilk +/types/microsoft-sdk-soap/ @markusmauch +/types/microsoftteams/ @OfficeDev +/types/microtime/ @vincekovacs +/types/milkcocoa/ @odangosan +/types/mime/ @jedigo +/types/mime-db/ @AJamesPhillips +/types/mime-types/ @Perlmint +/types/mimos/ @AJamesPhillips +/types/mina/ @lhk @mattanja @kant2002 +/types/minimatch/ @vvakame @shantmarouti +/types/minimist/ @Bartvds @Necroskillz @kamranayub +/types/minipass/ @BendingBender +/types/mithril/ @spacejack @andraaspar @isiahmeadows +/types/mithril-global/ @spacejack @isiahmeadows +/types/mitm/ @alejo90 +/types/mixpanel/ @hjellek +/types/mixto/ @vvakame +/types/mkdirp/ @Bartvds +/types/mkpath/ @optical +/types/mobile-detect/ @martinmcwhorter +/types/mocha/ @kazimanzurrashid @otiai10 @jt000 @enlight +/types/mocha-phantomjs/ @ErikSchierboom +/types/mock-fs/ @Nemo157 @tkqubo +/types/mock-raf/ @djpereira +/types/mock-require/ @djpereira +/types/mockdate/ @brunolm +/types/mockery/ @jt000 +/types/modernizr/ @borisyankov @theodorejb @leonyu @lucax88x @nhardy +/types/modesl/ @neeschit +/types/moment-business/ @wonbyte +/types/moment-duration-format/ @SwintDC @TwoStone @leonard-thieu +/types/moment-jalaali/ @alitaheri +/types/moment-range/ @Burgov @wilgert @franjuan @MartynasZilinskas +/types/moment-round/ @jacobbaskin +/types/moment-timezone/ @michelsalib +/types/mongodb/ @CaselIT @alanmarcell @kikar +/types/mongoose/ @simonxca @horiuchi @sindrenm @lukasz-zak +/types/mongoose-auto-increment/ @AyaMorisawa +/types/mongoose-deep-populate/ @AyaMorisawa +/types/mongoose-mock/ @jt000 +/types/mongoose-paginate/ @linusbrolin @simonxca +/types/mongoose-promise/ @simonxca +/types/mongoose-seeder/ @Crevil +/types/mongoose-sequence/ @linusbrolin +/types/mongoose-simple-random/ @me +/types/mongoose-unique-validator/ @stevehipwell +/types/monk/ @wzr1337 +/types/moo/ @deltaidea +/types/morgan/ @staticfunction +/types/morris.js/ @mareek @sindilevich +/types/mousetrap/ @qcz +/types/move-concurrently/ @mgroenhoff +/types/moviedb/ @basarat @0x6368656174 +/types/moxios/ @itoasuka +/types/mpromise/ @sgkim126 +/types/mqtt/ @PekkaPLeppanen +/types/mri/ @shiftkey @j-f1 +/types/ms/ @danny8002 +/types/msgpack-lite/ @endel @efokschaner +/types/msgpack5/ @wokim @heycalmdown +/types/msnodesql/ @borisyankov @SomaticIT +/types/msportalfx-test/ @julioct +/types/mssql/ @jaminfarr @buzinas @mrrichar @elhaard @pkeuter +/types/mu2/ @jedigo +/types/multer/ @jt000 @DavidBR-SW @mxl @hyunseob +/types/multer-gridfs-storage/v1/ @devconcept +/types/multer-gridfs-storage/ @devconcept +/types/multer-s3/ @tcaesvk +/types/multi-typeof/ @mhegazy +/types/multimatch/ @stephenlautier +/types/multiparty/ @kenfdev +/types/multiplexjs/ @KamyarNazeri +/types/murmurhash-js/ @cvle +/types/murmurhash3js/ @dlee-nvisia +/types/musicmetadata/ @Xstoudi +/types/mustache/ @markashleybell +/types/mysql/ @wjohnsto @kacepe +/types/mz/ @ThomasHickman +/types/n3/ @phreed +/types/nano/ @timjacobi +/types/nanoajax/ @nathancahill +/types/nanomsg/ @titan +/types/nanoscroller/ @zihark17 +/types/nanp/ @karn +/types/natsort/ @mgroenhoff +/types/natural/ @dmoonfire +/types/natural-sort/ @a-morales +/types/navigation/ @grahammendick +/types/navigation-react/ @grahammendick +/types/navigo/ @aersamkull +/types/nblas/ @erikgerrits +/types/nconf/ @jedigo @jmthibault +/types/ncp/ @bartvds +/types/ndarray/ @pawsong @taoqf +/types/nearley/ @deltaidea +/types/nedb/ @reppners +/types/nedb-logger/ @thisboyiscrazy +/types/needle/v0/ @bigsan +/types/needle/ @bigsan @nikeee +/types/negotiator/ @BendingBender +/types/neo4j/ @cyrilschumacher +/types/nes/ @NoHomey +/types/netmask/ @mhfrantz +/types/nexpect/ @vvakame +/types/next/ @dru89 +/types/next-redux-wrapper/ @stevegeek +/types/ng-command/ @stephenlautier +/types/ng-cordova/ @ksachdeva +/types/ng-dialog/ @stephenlautier +/types/ng-facebook/ @Crevil +/types/ng-file-upload/ @johnnyreilly @thewarpaint +/types/ng-flow/ @ryan10132 +/types/ng-grid/ @smithkl42 @rolandzwaga @kentcooper +/types/ng-i18next/ @cyrilschumacher +/types/ng-notify/ @nzamosenchuk +/types/ng-stomp/ @lpotapczuk +/types/ngbootbox/ @stpettersens +/types/ngeohash/ @erkie +/types/ngkookies/ @martinmcwhorter +/types/ngmap/ @nkovacic +/types/ngprogress/ @martinmcwhorter +/types/ngprogress-lite/ @LukeForder +/types/ngreact/ @velveret +/types/ngstorage/ @kubiq +/types/ngtoaster/ @btesser +/types/ngwysiwyg/ @patrick-mackay +/types/nightmare/ @horiuchi @samyang-au +/types/noble/ @swook @wind-rider @shantanubhadoria @lukel99 @bioball +/types/nock/ @bonnici @horiuchi +/types/nodal/ @charrondev +/types/node/v6/ @WilcoBakker +/types/node/v7/ @parambirs @RobDesideri @tellnes @WilcoBakker @Tyriar +/types/node/ @parambirs @RobDesideri @tellnes @WilcoBakker @octo-sniffle @smac89 @Flarna @mwiktorczyk @wwwy3y3 @Tyriar @DeividasBakanas +/types/node-7z/ @erkie +/types/node-array-ext/ @Beng89 +/types/node-cache/ @chrootsu @dthunell +/types/node-calendar/ @luzianz +/types/node-cleanup/ @agadar +/types/node-common-errors/ @icopp +/types/node-dir/ @panuhorsmalahti +/types/node-dogstatsd/ @chrisbobo +/types/node-emoji/ @jonestristand +/types/node-feedparser/ @cortopy +/types/node-fetch/ @torstenwerner +/types/node-fibers/ @caryhaynie +/types/node-forge/ @westy92 @flynetworks @a-k-g +/types/node-gcm/ @horiuchi +/types/node-getopt/ @kcauchy +/types/node-hid/ @mhegazy @ert78gb +/types/node-hue-api/ @fjmorel +/types/node-int64/ @x3cion +/types/node-ipc/ @arvitaly +/types/node-jsfl-runner/ @mrand01 +/types/node-json-db/ @kuzn-ilya +/types/node-mysql-wrapper/ @kataras +/types/node-notifier/ @tkQubo +/types/node-pg-migrate/ @bradleyayers +/types/node-polyglot/ @timjk +/types/node-powershell/ @rodrigoff +/types/node-ral/ @ssddi456 +/types/node-rsa/ @alitaheri +/types/node-schedule/ @cyrilschumacher @flowpl +/types/node-slack/ @tkQubo +/types/node-snap7/ @heilingbrunner +/types/node-sprite-generator/ @Perlmint +/types/node-static/ @Morfent +/types/node-statsd/ @alexturek @convoyinc +/types/node-telegram-bot-api/ @ammuench @agadar +/types/node-uuid/ @jeffmay +/types/node-validator/ @kengorab +/types/node-vault/ @YuJianrong +/types/node-waves/ @stephenlautier +/types/node-wit/ @julienduf +/types/node-xmpp-client/ @PJakcson +/types/node-xmpp-core/ @PJakcson +/types/node-zookeeper-client/ @plantain-00 +/types/node_redis/ @borisyankov +/types/nodegit/ @dolanmiu +/types/nodemailer/ @rogierschouten +/types/nodemailer-direct-transport/ @rogierschouten +/types/nodemailer-mailgun-transport/ @otociulis +/types/nodemailer-pickup-transport/ @psnider +/types/nodemailer-ses-transport/ @westy92 +/types/nodemailer-smtp-pool/ @rogierschouten +/types/nodemailer-smtp-transport/ @rogierschouten +/types/nodemailer-stub-transport/ @cyrilschumacher +/types/nodeunit/ @jedigo +/types/noisejs/ @izmhr +/types/nomnom/ @panopticoncentral +/types/nopt/ @jbondc +/types/normalize-url/ @odin3 @BendingBender +/types/notie/ @mateusdemboski +/types/notify/ @hellochar +/types/notify.js/ @bahman616 +/types/notifyjs/ @soundTricker +/types/nouislider/v7/ @acoreyj +/types/nouislider/v8/ @bleuarg +/types/nouislider/ @bleuarg @lagaffe +/types/novnc-core/ @smithkl42 @BendingBender +/types/npm/ @SomaticIT +/types/npm-package-arg/ @mgroenhoff +/types/ns-api/ @Archcry +/types/nslog/ @unindented +/types/nsqjs/ @cezaryrk +/types/number-is-nan/ @mhegazy +/types/number-to-words/ @frederickfogerty +/types/numeral/ @vbortone +/types/numjs/ @taoqf +/types/nunjucks/ @RubenSlabbert +/types/nunjucks-date/ @kruncher +/types/nvd3/ @PjMitchell +/types/nw.gui/ @xperiments +/types/nw.js/ @alirdn +/types/o.js/ @IceOnFire @bradzacher @janhommes +/types/oauth.js/ @nobuoka +/types/oauth2-server/ @vangorra @cirick +/types/oauth2orize/ @wokim @heycalmdown @stevehipwell +/types/obelisk.js/ @bdrupieski +/types/object-assign/ @chbrown +/types/object-diff/ @rogierschouten +/types/object-hash/ @misak113 +/types/object-path/ @pocesar +/types/object-refs/ @3fd +/types/oblo-util/ @Oblosys +/types/oboe/ @optical +/types/observe-js/ @herrmanno +/types/oclazyload/ @rolandzwaga +/types/odata/ @janhommes +/types/ofe/ @Morfent +/types/office-js/ @OfficeDev @LanceEA +/types/offline-js/ @cgwrench +/types/oibackoff/ @geoffreak +/types/oidc-token-manager/ @rosieks +/types/on-finished/ @czechboy0 @BendingBender +/types/on-headers/ @jjeffery @BendingBender +/types/once/ @denis-sokolov @BendingBender +/types/onetime/ @BendingBender +/types/onoff/ @marcel-ernst +/types/open/ @Bartvds +/types/opener/ @tikurahul +/types/openfin/ @chrisbarker +/types/openjscad/ @danmarshall +/types/openlayers/v2/ @bolhovsky +/types/openlayers/v3/ @osechet @matthiasdailey-ccri +/types/openlayers/ @osechet @ganlhi +/types/openstack-wrapper/ @sanjaymadane +/types/opentok/ @westy92 @CatGuardian +/types/opentype.js/ @danmarshall +/types/opn/ @shinnn @SomaticIT +/types/optics-agent/ @crevil +/types/optimist/ @soywiz @chbrown +/types/optimize-css-assets-webpack-plugin/ @odnamrataizem +/types/ora/v0/ @screendriver +/types/ora/ @basarat @screendriver @BendingBender +/types/oracledb/ @Bigous +/types/orchestrator/ @tkQubo @TeamworkGuy2 +/types/orderedmap/ @bradleyayers +/types/orientjs/ @saeedtabrizi +/types/os-homedir/ @mhegazy +/types/os-locale/v1/ @AyaMorisawa @BendingBender +/types/os-locale/ @AyaMorisawa @BendingBender +/types/os-name/ @BendingBender +/types/os-tmpdir/ @mhegazy +/types/osmosis/ @jurajkocan +/types/osmtogeojson/ @tkqubo +/types/owlcarousel/ @dpiatkowski +/types/p-all/ @BendingBender +/types/p-any/ @BendingBender +/types/p-cancelable/ @BendingBender +/types/p-debounce/ @BendingBender +/types/p-defer/ @SamVerschueren +/types/p-do-whilst/ @BendingBender +/types/p-each-series/ @BendingBender +/types/p-event/ @BendingBender +/types/p-every/ @BendingBender +/types/p-lazy/ @BendingBender +/types/p-limit/ @BendingBender +/types/p-locate/ @BendingBender +/types/p-log/ @BendingBender +/types/p-map/ @BendingBender +/types/p-map-series/ @BendingBender +/types/p-one/ @BendingBender +/types/p-props/ @BendingBender +/types/p-queue/ @BendingBender @evanshortiss +/types/p-reduce/ @BendingBender +/types/p-reflect/ @BendingBender +/types/p-retry/ @BendingBender +/types/p-series/ @BendingBender +/types/p-settle/ @natesilva +/types/p-some/ @BendingBender +/types/p-tap/ @BendingBender +/types/p-throttle/ @BendingBender +/types/p-timeout/ @BendingBender +/types/p-try/ @BendingBender +/types/p-wait-for/ @BendingBender +/types/p-whilst/ @BendingBender +/types/p2/ @clark-stevenson +/types/packery/ @piraveen @hanssens +/types/pad/ @mhegazy +/types/paho-mqtt/ @amikhalev +/types/pako/ @cappellin @calebegg +/types/papaparse/ @torpedro @rainshen49 +/types/paper/ @clark-stevenson +/types/paralleljs/ @jbaldwin +/types/parse/ @dpoetzsch @jaeggerr +/types/parse-git-config/ @leonard-thieu +/types/parse-glob/ @glen-84 +/types/parse-link-header/ @zelein +/types/parse-mockdb/ @dpoetzsch +/types/parse-torrent/ @niieani @tlaziuk +/types/parse-torrent-file/ @tlaziuk +/types/parse-unit/ @Jack-Works +/types/parseurl/ @bomret +/types/parsimmon/ @Bartvds @mizunashi-mana @bcherny @bvanreeven @leonard-thieu +/types/passport/ @horiuchi @enaeseth +/types/passport-anonymous/ @0x6368656174 +/types/passport-beam/ @AtlasDev +/types/passport-client-cert/ @warnersean +/types/passport-discord/ @kzay +/types/passport-facebook/ @staticfunction @lucasmacosta +/types/passport-facebook-token/ @rmartone +/types/passport-github/ @yasupeke +/types/passport-github2/ @yasupeke @mthmulders +/types/passport-google-oauth/ @staticfunction +/types/passport-google-oauth2/ @bluehatbrit +/types/passport-http/ @krizalys +/types/passport-http-bearer/ @isman-usoh +/types/passport-jwt/ @mugeso @alsiola +/types/passport-local/ @SomaticIT +/types/passport-local-mongoose/ @linusbrolin +/types/passport-oauth2-client-password/ @akaNightmare +/types/passport-saml/ @cjbarth +/types/passport-steam/ @kzay +/types/passport-strategy/ @liorm +/types/passport-twitter/ @staticfunction +/types/passport-unique-token/ @briman0094 @SomaticIT +/types/password-hash/ @mugeso +/types/password-hash-and-salt/ @alitaheri +/types/path-exists/v1/ @shiwano +/types/path-exists/ @shiwano @BendingBender +/types/path-is-absolute/ @mhegazy +/types/pathfinding/ @BNedry +/types/pathjs/ @lokeshpeta +/types/pathwatcher/ @vvakame +/types/pause/ @BendingBender +/types/payment/ @apare +/types/paypal-cordova-plugin/ @Justin-Credible +/types/paypal-rest-sdk/ @trainerbill +/types/pbf/ @cschwarz +/types/pdfjs-dist/ @jbaldwin +/types/pdfkit/ @erichillah +/types/pdfobject/ @nielsboogaard +/types/pebblekitjs/ @makotokw +/types/peerjs/ @nakakura +/types/pegjs/ @vvakame @SrTobi @siegebell +/types/pem/ @tony19 @DethAriel +/types/perfect-scrollbar/ @aicest @CarbonAtom +/types/persona/ @Nycto +/types/pet-finder-api/ @me +/types/pg-connection-string/ @bradleyayers +/types/pg-pool/ @aleung +/types/pg-query-stream/ @asmarques +/types/pg-types/ @waratuman +/types/pgwmodal/ @pine613 +/types/phantom/ @horiuchi @llRandom +/types/phantomcss/ @abauzac +/types/phantomjs/ @jedhunsaker @keesey +/types/phoenix/ @mciastek +/types/phone/ @DxCx +/types/phone-formatter/ @westy92 +/types/phonegap/ @borisyankov @DickvdBrink +/types/phonegap-facebook-plugin/ @Justin-Credible +/types/phonegap-nfc/ @michaeldesigaud +/types/phonegap-plugin-push/ @fredgalvao @larrybahr +/types/phonon/ @kserin +/types/photonui/ @florentpoujol +/types/photoswipe/ @hellochar +/types/physijs/ @gyohk +/types/pi-spi/ @marcel-ernst +/types/pick-weight/ @rsxdalv +/types/pickadate/ @theodorejb @leonard-thieu +/types/pidusage/ @cyrilschumacher +/types/pify/ @samverschueren +/types/pigpio/ @manerfan +/types/pikaday-time/ @Sayan751 +/types/pinkyswear/ @chances +/types/pino/v3/ @psnider +/types/pino/ @psnider @BendingBender +/types/pinterest-sdk/ @adamburmister +/types/pinyin/ @wanganjun +/types/piwik-tracker/ @lbguilherme +/types/pkijs/ @microshine +/types/platform/ @JakeH +/types/playerframework/ @ricardosabino +/types/pleasejs/ @nakakura +/types/plotly.js/ @chrisgervang @martinduparc @frederikaalund @taoqf +/types/plugapi/ @BNedry +/types/plupload/ @patrickbussmann +/types/pluralize/ @ukyo +/types/png-async/ @kanreisa +/types/podcast/ @nikeee +/types/podium/ @AJamesPhillips +/types/point-in-polygon/ @dyst5422 @kogai +/types/polylabel/ @DenisCarriere +/types/polyline/ @Kern0 +/types/polymer/ @lgrignon @laco0416 +/types/polymer-ts/ @lgrignon +/types/popcorn/ @grapswiz +/types/popper.js/ @joscha @seckardt @marcfallows +/types/portscanner/ @douglasduteil +/types/postal/ @lokeshpeta @myitcv +/types/postmark/ @benbayard +/types/pouch-redux-middleware/ @charrondev +/types/pouchdb/ @AGBrown @geppy @fredgalvao +/types/pouchdb-adapter-fruitdown/ @spaulg @geppy @fredgalvao +/types/pouchdb-adapter-http/ @spaulg @geppy @fredgalvao +/types/pouchdb-adapter-idb/ @spaulg @geppy @fredgalvao +/types/pouchdb-adapter-leveldb/ @spaulg @geppy @fredgalvao +/types/pouchdb-adapter-localstorage/ @spaulg @geppy @fredgalvao +/types/pouchdb-adapter-memory/ @spaulg @geppy @fredgalvao +/types/pouchdb-adapter-node-websql/ @spaulg @geppy @fredgalvao +/types/pouchdb-adapter-websql/ @spaulg @geppy @fredgalvao +/types/pouchdb-browser/ @spaulg @geppy @fredgalvao +/types/pouchdb-core/ @spaulg @trubit @geppy @fredgalvao @TobiasBales +/types/pouchdb-find/ @trubit +/types/pouchdb-http/ @spaulg @geppy @fredgalvao +/types/pouchdb-mapreduce/ @spaulg @geppy @fredgalvao +/types/pouchdb-node/ @spaulg @geppy @fredgalvao +/types/pouchdb-replication/ @trubit +/types/pouchdb-upsert/ @keithdmoore @hotforfeature +/types/power-assert/ @vvakame +/types/power-assert-formatter/ @vvakame +/types/precise/ @codeanimal +/types/precond/ @olsio +/types/preloadjs/ @endel +/types/prelude-ls/ @AyaMorisawa +/types/prettier/ @ikatyang +/types/pretty-bytes/ @plantain-00 +/types/pretty-ms/ @BendingBender +/types/printf/ @AluisioASG +/types/priorityqueuejs/ @geoffreak +/types/prismjs/ @eriklieben @andrewiggins +/types/private-ip/ @coderslagoon +/types/procfs-stats/ @cyrilschumacher +/types/progress/ @sebastian-lenz +/types/progressbar/ @atd-schubert +/types/progressjs/ @zaneli +/types/proj4/ @DenisCarriere +/types/proj4leaflet/ @BendingBender +/types/project-oxford/ @scsouthw +/types/promise-dag/ @OSjoerdWie +/types/promise-pg/ @coldacid +/types/promise-polyfill/ @skysteve +/types/promise-pool/ @vilic +/types/promise.prototype.finally/ @slavik57 @BendingBender +/types/promised-temp/ @rokadias +/types/promisify-node/ @borekb +/types/promisify-supertest/ @aleung +/types/prompt-sync/ @MugeSo +/types/prompt-sync-history/ @MugeSo +/types/promptly/ @danrspencer +/types/prop-types/ @DovydasNavickas +/types/properties-reader/ @Goldsmith42 +/types/prosemirror-collab/ @bradleyayers @davidka +/types/prosemirror-commands/ @bradleyayers @davidka +/types/prosemirror-history/ @bradleyayers @davidka +/types/prosemirror-inputrules/ @bradleyayers @davidka +/types/prosemirror-keymap/ @bradleyayers @davidka +/types/prosemirror-markdown/ @bradleyayers +/types/prosemirror-menu/ @davidka +/types/prosemirror-model/ @bradleyayers @davidka +/types/prosemirror-schema-basic/ @bradleyayers @davidka +/types/prosemirror-schema-list/ @bradleyayers @davidka +/types/prosemirror-state/ @bradleyayers @davidka +/types/prosemirror-transform/ @bradleyayers @davidka +/types/prosemirror-view/ @bradleyayers @davidka +/types/protobufjs/ @panuhorsmalahti +/types/protractor-browser-logs/ @rokadias +/types/protractor-helpers/ @johncant +/types/protractor-http-mock/ @Crevil +/types/proxy-addr/ @BendingBender +/types/proxyquire/ @jt000 +/types/pty.js/ @enlight +/types/public-ip/ @BendingBender +/types/pubsub-js/ @borisyankov +/types/pug/ @TonyPythoneer @19majkel94 +/types/pulltorefreshjs/ @DanielRosenwasser +/types/pump/ @tlaziuk +/types/pure-render-decorator/ @seansfkelley +/types/purl/ @danfma +/types/pusher-js/ @tkqubo +/types/pvutils/ @microshine +/types/python-shell/ @dolanmiu +/types/q/v0/ @bnemetchek @johnnyreilly +/types/q/ @bnemetchek @AndrewGaspar @johnnyreilly @mboudreau +/types/q-io/ @Bartvds +/types/q-retry/ @vilic +/types/qhistory/ @Kovensky +/types/qlik/ @RubenSlabbert @AginicX +/types/qlik-engineapi/ @konne +/types/qlik-visualizationextensions/ @konne +/types/qr-image/ @taoqf +/types/qrcode-generator/ @stefanhuber +/types/qrcode.react/ @mleko +/types/qs/ @RWander @leonyu @tehbelinda @zyml @artursvonda +/types/qtip2/ @Seltzer @leonard-thieu +/types/query-string/ @SamVerschueren @tkrotoff @huhuanming +/types/quick-lru/ @BendingBender +/types/quill/ @sumitkm @guillaume-ro-fr +/types/quixote/ @greybax +/types/qunit/v1/ @diullei +/types/qunit/ @waratuman +/types/quoted-printable/ @pushplay +/types/qwest/ @lindsayevans +/types/r-script/ @NaridaL +/types/rabbit.js/ @wokim +/types/radium/ @alexgorbatchev @nupplaphil @asvetliakov @mihe +/types/radius/ @codeanimal +/types/ramda/ @donnut @mdekrey @LiamGoodacre @mrdziuban @sbking @afharo @teves-castro @1M0reBug @hojberg +/types/random-js/ @pistacchio +/types/random-seed/ @endel +/types/random-string/ @stpettersens +/types/randomcolor/ @feitzi @BradyLiles +/types/range-parser/ @tlaziuk +/types/rangyinputs/ @ersimont +/types/raphael/ @CheCoxshall +/types/rappid/ @DenEwout +/types/ratelimiter/ @AyaMorisawa +/types/raty/ @terrawheat +/types/raven/ @scttcper @1999 +/types/raygun4js/ @xt0rted @BenjaminHarding +/types/rc/ @DanielRosenwasser +/types/rc-select/ @DenisTirilis +/types/rc-slider/ @mantasmarcinkus @mattoni +/types/rc-tree/ @johnnyreilly +/types/rcloader/ @panuhorsmalahti +/types/react/v15/ @bbenezech @pzavolinsky @digiguru @ericanderson @morcerf @tkrotoff @DovydasNavickas @onigoetz +/types/react/ @johnnyreilly @bbenezech @pzavolinsky @digiguru @ericanderson @morcerf @tkrotoff @DovydasNavickas @onigoetz @richseviora +/types/react-app/ @prakarshpandey +/types/react-autosuggest/ @nicolas-schmitt @pjo256 @robessog @tbayne +/types/react-body-classname/ @mhegazy +/types/react-bootstrap/ @walkerburgin @vsiao @danilojrr @Batbold-Gansukh @octatone @chengsieuly @katbusch +/types/react-bootstrap-date-picker/ @LKay @ssi-hu-antal-bodnar +/types/react-bootstrap-daterangepicker/ @ianks +/types/react-bootstrap-table/ @flaub @alelode +/types/react-breadcrumbs/ @KostyaEsmukov +/types/react-burger-menu/ @radziksh +/types/react-calendar-timeline/ @radziksh +/types/react-chartjs-2/ @apare @FabienLavocat +/types/react-codemirror/ @velveret @rudi-c +/types/react-color/ @LKay @markspolakovs @mntdn +/types/react-copy-to-clipboard/ @mabels +/types/react-cropper/ @stepancar +/types/react-css-modules/ @KostyaEsmukov @skirsdeda +/types/react-css-transition-replace/ @LKay +/types/react-custom-scrollbars/v3/ @David-LeBlanc-git +/types/react-custom-scrollbars/ @David-LeBlanc-git @kittimiyo +/types/react-data-grid/v1/ @SupernaviX +/types/react-data-grid/ @SupernaviX @KieranPeat @martinnov92 +/types/react-datagrid/ @stephenjelfs +/types/react-datepicker/ @radziksh @andrewBalekha @smrq @Rogach +/types/react-daterange-picker/ @uncovertruth @MartynasZilinskas +/types/react-dates/ @Artur-A +/types/react-daum-postcode/ @Sa-ryong +/types/react-dnd-html5-backend/ @oizie +/types/react-document-title/ @cleverguy25 +/types/react-dom/ @MartynasZilinskas +/types/react-dropzone/v2/ @matdube @LynxEyes @goblindegook @benbayard +/types/react-dropzone/ @matdube @LynxEyes @goblindegook @benbayard @LKay +/types/react-easy-chart/ @danzel +/types/react-event-listener/ @asvetliakov +/types/react-fa/ @flaub @patsissons @LKay +/types/react-facebook-login/ @apare @jankarres +/types/react-faux-dom/ @alitaheri @cleverguy25 +/types/react-file-input/ @dmitryrogozhny +/types/react-file-reader-input/ @dmitryrogozhny @alitaheri +/types/react-flatpickr/ @begincalendar +/types/react-flex/ @pushplay +/types/react-flexr/ @pushplay +/types/react-flip-move/ @jmhain +/types/react-fontawesome/ @timurrustamov @dublicator @vincaslt @gavingregory +/types/react-ga/ @telshin +/types/react-geosuggest/ @brmenchl +/types/react-gravatar/ @invliD +/types/react-grid-layout/ @abirkholz @alitaheri @ZheyangSong +/types/react-hamburger-menu/ @grzesie2k +/types/react-helmet/v4/ @evanbb @isman-usoh +/types/react-helmet/ @evanbb @isman-usoh @lith-light-g @sammkj @yuit +/types/react-highlight-words/ @mhegazy +/types/react-highlighter/ @oizie +/types/react-holder/ @isman-usoh +/types/react-hot-loader/ @jacekjagiello +/types/react-i18next/v1/ @KostyaEsmukov +/types/react-i18next/ @GiedriusGrabauskas +/types/react-icon-base/ @apare @LKay +/types/react-icons/ @apare +/types/react-imageloader/ @stephenjelfs +/types/react-infinite/ @rhysd +/types/react-infinite-scroller/ @Lapanti @psrebniak +/types/react-input-calendar/ @stepancar +/types/react-input-mask/ @apare +/types/react-intl/v1/ @bgrieder +/types/react-intl/ @bgrieder @cdroulers @gyzerok @tillwolff @LKay @bhouser @kristerkari +/types/react-intl-redux/ @LKay +/types/react-is-deprecated/ @seansfkelley +/types/react-joyride/ @DanielRosenwasser @bendxn +/types/react-json-pretty/ @LKay +/types/react-json-tree/ @gnestor +/types/react-jsonschema-form/ @iamdanfox @sirreal +/types/react-lazyload/ @m0a +/types/react-leaflet/ @danzel @davschne @yuit +/types/react-list/ @buptyyf +/types/react-loadable/ @Kovensky @odensc +/types/react-loader/ @artfuldev +/types/react-maskedinput/ @LKay @lavoaster @CarlosBonetti +/types/react-mdl/ @bradzacher +/types/react-measure/ @asvetliakov @marcfallows +/types/react-mixin/ @tkqubo +/types/react-modal/ @radziksh @drewnoakes @homburg @ttamminen @hallowatcher +/types/react-monaco-editor/ @jnetterf +/types/react-motion/ @stepancar @asvetliakov +/types/react-motion-slider/ @asvetliakov +/types/react-native/ @alloy @gyzerok @huhuanming @iRoachie @timwangdev @kamal +/types/react-native-collapsible/ @iRoachie +/types/react-native-communications/ @huhuanming +/types/react-native-datepicker/ @jacobbaskin +/types/react-native-drawer/ @jnbt +/types/react-native-drawer-layout/ @jmfirth +/types/react-native-elements/ @iRoachie +/types/react-native-fbsdk/ @ifiokjr +/types/react-native-fetch-blob/ @MNBuyskih +/types/react-native-fs/ @pocesar +/types/react-native-goby/ @MessageDream +/types/react-native-google-analytics-bridge/ @huhuanming @nbperry +/types/react-native-keep-awake/ @huhuanming +/types/react-native-material-design-searchbar/ @iRoachie +/types/react-native-material-ui/ @iRoachie +/types/react-native-modalbox/ @iRoachie +/types/react-native-orientation/ @MoLow +/types/react-native-scrollable-tab-view/ @CaiHuan +/types/react-native-sensor-manager/ @SahinVardar +/types/react-native-snap-carousel/ @jnbt +/types/react-native-sortable-list/ @sivolobov +/types/react-native-svg-uri/ @iRoachie +/types/react-native-swiper/ @CaiHuan @huhuanming @mhcgrq +/types/react-native-touch-id/ @huhuanming +/types/react-native-vector-icons/ @iRoachie @timwangdev +/types/react-native-video/ @huhuanming +/types/react-navigation/ @huhuanming @mhcgrq @fangpenlin @abrahambotros @petejkim @iRoachie @phanalpha @charlesfamu @timwangdev +/types/react-notification-system/ @GiedriusGrabauskas @DeividasBakanas @LKay @sztobar +/types/react-notification-system-redux/ @LKay +/types/react-onclickoutside/v5/ @LKay +/types/react-onclickoutside/ @LKay +/types/react-overlays/ @aaronbeall @vitosamson +/types/react-paginate/ @deevus @wouterhardeman @pegel03 @archy-bold +/types/react-pointable/ @istefo +/types/react-portal/ @shuntksh +/types/react-props-decorators/ @tkqubo +/types/react-recaptcha/ @mhegazy +/types/react-redux/ @tkqubo @seansfkelley @thasner @kenzierocks @clayne11 @tansongyang +/types/react-redux-i18n/ @clementdevos +/types/react-redux-toastr/ @Smiche @artyomsv @kulmajaba +/types/react-relay/ @graphcool +/types/react-responsive/ @asvetliakov +/types/react-router/v2/ @sergey-buturlakin @mrk21 @vasek17 @ngbrown @awendland @KostyaEsmukov +/types/react-router/v3/ @sergey-buturlakin @mrk21 @vasek17 @ngbrown @awendland @KostyaEsmukov @johnnyreilly @LKay @DovydasNavickas +/types/react-router/ @sergey-buturlakin @mrk21 @vasek17 @ngbrown @awendland @KostyaEsmukov @johnnyreilly @LKay @DovydasNavickas @tkrotoff @huy-nguyen @grmiade @DaIgeb @egorshulga +/types/react-router-bootstrap/ @vlesierse @LKay @olmobrutall +/types/react-router-config/ @lith-light-g +/types/react-router-dom/ @tkrotoff @huy-nguyen +/types/react-router-native/ @ezintz +/types/react-router-redux/v3/ @isman-usoh @noah79 @rosendi +/types/react-router-redux/v4/ @isman-usoh @noah79 @rosendi @LKay @DovydasNavickas +/types/react-router-redux/ @huy-nguyen @8398a7 +/types/react-scroll/ @sudoplz @GiedriusGrabauskas +/types/react-scrollbar/ @stephenjelfs +/types/react-select/ @Hesquibet @giladgray @iebaker @skirsdeda @vujevits @devrelm @MartynasZilinskas +/types/react-side-effect/ @remojansen +/types/react-sidebar/ @jeroenvervaeke +/types/react-slick/ @andrewBalekha @GiedriusGrabauskas +/types/react-smooth-scrollbar/ @asvetliakov +/types/react-sortable-hoc/ @NoHomey @charlesrey +/types/react-sortable-tree/ @wouterhardeman +/types/react-spinkit/v1/ @tkqubo @mleko @pelotom +/types/react-spinkit/ @tkqubo @mleko @pelotom @zzanol +/types/react-split-pane/ @rcchen +/types/react-sticky/ @curtisw0 +/types/react-svg-pan-zoom/ @huy-nguyen +/types/react-swf/ @stepancar +/types/react-swipe/ @DeividasBakanas +/types/react-swipeable/ @GiedriusGrabauskas @mctep +/types/react-swipeable-views/ @mxl @DeividasBakanas +/types/react-syntax-highlighter/ @NoHomey +/types/react-tabs/ @danez +/types/react-tag-input/ @Ogglas @jankarres +/types/react-tagcloud/ @wassname +/types/react-tap-event-plugin/ @mxl +/types/react-test-renderer/ @arvitaly @lochbrunner @lochbrunner @johnnyreilly +/types/react-tether/ @ryprice +/types/react-textarea-autosize/ @asvetliakov @zry656565 +/types/react-toggle/v2/ @LKay +/types/react-toggle/ @LKay +/types/react-tooltip/ @DeividasBakanas +/types/react-touch/ @grzesie2k +/types/react-transition-group/v1/ @LKay +/types/react-transition-group/ @LKay +/types/react-user-tour/ @ccancellieri +/types/react-virtual-keyboard/ @bsurai +/types/react-virtualized/ @kaoDev @guntherjh @wasd171 +/types/react-virtualized-select/ @seansfkelley +/types/react-weui/ @tairan +/types/react-widgets/ @rogierschouten @sanyatuning @frodehansen2 +/types/reactable/ @spielc +/types/reactcss/ @chrisgervang @LKay +/types/reactstrap/ @alihammad @mfal @danilobjr +/types/read/ @timjk +/types/read-package-tree/ @mgroenhoff +/types/readdir-stream/ @Bartvds +/types/readline-sync/ @jonestristand +/types/realm/ @Akim95 +/types/reapop/ @Barrokgl +/types/recaptcha/ @brentj73 +/types/recase/ @18steps +/types/recharts/ @mthmulders @rapmue +/types/recompose/ @iskandersierra @mrapogee @clayne11 +/types/reconnectingwebsocket/ @nguarracino +/types/recursive-readdir/ @elisee +/types/redis/ @soywiz @CodeAnimal @MugeSo +/types/redis-mock/ @BendingBender +/types/redis-rate-limiter/ @westy92 +/types/redis-scripto/ @westy92 +/types/redlock/v2/ @chrootsu +/types/redlock/ @chrootsu @BendingBender +/types/reduce-reducers/ @huy-nguyen +/types/redux-action/ @newraina +/types/redux-action-utils/ @tkqubo +/types/redux-actions/ @jaysoo @alexgorbatchev +/types/redux-auth-wrapper/v1/ @LKay +/types/redux-auth-wrapper/ @LKay +/types/redux-batched-subscribe/ @mDibyo +/types/redux-bootstrap/ @remojansen +/types/redux-debounced/ @seansfkelley +/types/redux-devtools/ @mc-petry +/types/redux-devtools-dock-monitor/ @mc-petry +/types/redux-devtools-log-monitor/ @mc-petry +/types/redux-doghouse/ @BendingBender +/types/redux-first-router/ @Valbrand @viggyfresh +/types/redux-form/v4/ @aikoven +/types/redux-form/v6/ @carsonf @aikoven @LKay @bancek +/types/redux-form/ @carsonf @aikoven @LKay @bancek +/types/redux-immutable/ @oizie @sebald @gavingregory +/types/redux-immutable-state-invariant/ @remojansen @highflying +/types/redux-infinite-scroll/ @silkyfray +/types/redux-localstorage/ @LKay +/types/redux-localstorage-debounce/ @LKay +/types/redux-localstorage-filter/ @LKay +/types/redux-logger/ @arusakov +/types/redux-mock-store/ @MarianPalkus +/types/redux-optimistic-ui/ @asvetliakov +/types/redux-pack/ @tansongyang +/types/redux-persist-transform-encrypt/ @LKay +/types/redux-persist-transform-filter/ @LKay +/types/redux-promise/ @molekilla @xStrom +/types/redux-promise-middleware/ @ianks +/types/redux-recycle/ @LKay +/types/redux-router/ @stepancar +/types/redux-storage/ @asvetliakov +/types/redux-ui/ @andyshuxin +/types/ref/ @loyd +/types/ref-array/ @loyd +/types/ref-struct/ @loyd +/types/ref-union/ @loyd +/types/reflect-metadata/ @rbuckton +/types/reflux/ @mauricedb +/types/relateurl/ @tkrotoff +/types/relaxed-json/ @18steps +/types/remote-redux-devtools/ @ColinEberhardt @unindented +/types/remove-markdown/ @RagibHasin +/types/replace-ext/ @DeividasBakanas +/types/request/ @soywiz @bonnici @Bartvds @joeskeen @ccurrens +/types/request-ip/ @mrhen +/types/request-promise/ @cglantschnig @joeskeen @AyaMorisawa +/types/request-promise-native/ @gustavohenke +/types/requestretry/ @EricByers +/types/require-directory/ @Igmat +/types/require-from-string/ @ikatyang +/types/requirejs/ @jbaldwin +/types/requirejs-domready/ @lefb766 +/types/resemblejs/ @pimterry +/types/resolve/ @marionebl +/types/resolve-from/ @unional +/types/response-time/ @urossmolnik @TonyPythoneer +/types/rest/ @Nemo157 +/types/restangular/ @borisyankov +/types/restful.js/ @tkqubo +/types/restify/v4/ @blittle @stevehipwell +/types/restify/ @blittle @stevehipwell +/types/restify-cors-middleware/ @dthunell +/types/restify-errors/ @stevehipwell +/types/restify-plugins/ @KostyaTretyak +/types/restler/ @cyrilschumacher +/types/resumablejs/ @DanielMcAssey +/types/rethinkdb/ @alexgorbatchev +/types/retry/ @krenor +/types/rev-hash/ @ikatyang +/types/revalidate/ @alex3165 +/types/revalidator/ @brewsoftware +/types/reveal/ @robertop87 @Nava2 +/types/rewire/ @borislavjivkov @CaselIT +/types/rfc2047/ @mugifly +/types/rheostat/ @SashaBayan @kourge +/types/rickshaw/ @niemyjski +/types/rimraf/ @soywiz @e-cloud @bash +/types/riot/ @Stubb0rn +/types/riot-api-nodejs/ @zafixlrp +/types/riot-games-api/ @xstoudi +/types/riotcontrol/ @chrootsu +/types/riotjs/ @vvakame +/types/rison/ @impworks +/types/rivets/ @TrevorDev +/types/rollup/ @flying-sheep +/types/ronomon__crypto-async/ @BendingBender +/types/rosie/ @abner +/types/roslib/ @Pro @skycoop +/types/rot-js/ @atiaxi +/types/route-parser/ @ianks @bobbuehler +/types/router5/ @sandersky +/types/routie/ @Adilson +/types/royalslider/ @csrakowski +/types/rpio/ @DominikPalo +/types/rrc/ @DeividasBakanas +/types/rrule/ @waratuman +/types/rsmq/ @MugeSo +/types/rsmq-worker/ @MugeSo +/types/rss/ @secondwtq +/types/rsvp/ @Taytay @mkohlmyr @theroncross @chriskrycho +/types/rsync/ @philippstucki +/types/rtree/ @oefirouz +/types/run-sequence/ @k-kagurazaka +/types/rvo2/ @erikvullings +/types/rx/ @Igorbek +/types/rx-angular/ @mickdelaney +/types/rx-core/ @Igorbek @mizunashi-mana +/types/rx-core-binding/ @Igorbek +/types/rx-dom/ @oliverw +/types/rx-jquery/ @Igorbek +/types/rx-lite/ @Igorbek +/types/rx-lite-aggregates/ @Igorbek +/types/rx-lite-async/ @zoetrope @Igorbek +/types/rx-lite-backpressure/ @Igorbek +/types/rx-lite-coincidence/ @Igorbek +/types/rx-lite-experimental/ @Igorbek +/types/rx-lite-joinpatterns/ @Igorbek +/types/rx-lite-testing/ @Igorbek +/types/rx-lite-time/ @Igorbek +/types/rx-lite-virtualtime/ @Igorbek +/types/rx.wamp/ @darkl +/types/s3-upload-stream/ @geoffreak +/types/safari-extension/ @luukd +/types/safari-extension-content/ @luukd +/types/safe-json-stringify/ @ericbyers +/types/safe-regex/ @mhegazy +/types/sails.io.js/ @arvitaly +/types/saml2-js/ @horiuchi +/types/saml20/ @HackerUndKoch +/types/samlp/ @horiuchi +/types/sammy/ @borisyankov @oising +/types/sandboxed-module/ @svi3c +/types/sane/ @BendingBender +/types/sanitize-filename/ @Nemo157 +/types/sanitize-html/ @rogierschouten @afshin +/types/sap__xsenv/ @mad-mike +/types/sass-graph/ @marvinhagemeister +/types/sat/ @omni360 +/types/satnav/ @DotNetNerd +/types/saywhen/ @SeanSobey +/types/scalike/ @ryoppy +/types/screenfull/ @icholy @lionelb @joelshepherd +/types/screeps-profiler/ @ramblurr +/types/scriptjs/ @ssttevee +/types/scroll-into-view/ @zivni +/types/scroller/ @borisyankov +/types/scrollreveal/ @Davidblkx +/types/scrolltofixed/ @bmdixon +/types/scrypt-async/ @xStrom +/types/seamless/ @danmana +/types/seamless-immutable/ @alex3165 @xsburg @geirsagberg +/types/seedrandom/ @kernhanda +/types/segment-analytics/ @fongandrew +/types/select2/ @borisyankov +/types/selectize/ @adidahiya @naBausch +/types/selenium-webdriver/v2/ @BillArmstrong @Kuniwak @cnishina +/types/selenium-webdriver/ @BillArmstrong @Kuniwak @cnishina @SupernaviX @bendxn +/types/semantic-ui/ @leonard-thieu +/types/semantic-ui-accordion/ @leonard-thieu +/types/semantic-ui-api/ @leonard-thieu +/types/semantic-ui-checkbox/ @leonard-thieu +/types/semantic-ui-dimmer/ @leonard-thieu +/types/semantic-ui-dropdown/ @leonard-thieu +/types/semantic-ui-embed/ @leonard-thieu +/types/semantic-ui-form/ @leonard-thieu +/types/semantic-ui-modal/ @leonard-thieu +/types/semantic-ui-nag/ @leonard-thieu +/types/semantic-ui-popup/ @leonard-thieu +/types/semantic-ui-progress/ @leonard-thieu +/types/semantic-ui-rating/ @leonard-thieu +/types/semantic-ui-search/ @leonard-thieu +/types/semantic-ui-shape/ @leonard-thieu +/types/semantic-ui-sidebar/ @leonard-thieu +/types/semantic-ui-site/ @leonard-thieu +/types/semantic-ui-sticky/ @leonard-thieu +/types/semantic-ui-tab/ @leonard-thieu +/types/semantic-ui-transition/ @leonard-thieu +/types/semantic-ui-visibility/ @leonard-thieu +/types/semaphore/ @mhfrantz +/types/semver/ @Bartvds @BendingBender @LucianBuzzo +/types/semver-diff/ @chrismbarr +/types/sencha_touch/ @brian428 +/types/send/ @MikeJerred +/types/seneca/ @psnider +/types/sequelize/v3/ @samuelneff @codeanimal @drinchev @morpheusxaut @torhal +/types/sequelize/ @samuelneff @codeanimal @drinchev @babolivier @kukoo1 @morpheusxaut +/types/sequelize-fixtures/ @cschwarz +/types/sequester/ @Strate +/types/serialize-javascript/ @lith-light-g +/types/serialport/ @codefoster +/types/serve-favicon/ @urossmolnik +/types/serve-index/ @tkrotoff +/types/serve-static/ @urossmolnik +/types/session-file-store/ @blendsdk +/types/set-cookie-parser/ @nickp10 +/types/sha1/ @arcdev1 +/types/shallowequal/ @seansfkelley +/types/shapefile/ @DenisCarriere +/types/sharedworker/ @nakakura +/types/sharepoint/ @baywet +/types/sharp/ @lith-light-g +/types/sharp-timer/ @afractal +/types/sheetify/ @toddself +/types/shell-quote/ @jason0x43 +/types/shelljs/ @nikeee @voy +/types/shipit/ @cyrilschumacher +/types/shipit-utils/ @cyrilschumacher +/types/shopify-buy/ @openminder +/types/shortid/ @stpettersens @despairblue +/types/shot/ @AJamesPhillips +/types/should/ @varju +/types/should-promised/ @devoto13 +/types/showdown/ @cbowdon @tan9 +/types/siema/ @Irmiz +/types/siesta/ @bquarmby +/types/sigmajs/ @qinfchen +/types/signalr/ @borisyankov @keesey @GiedriusGrabauskas +/types/signals/ @diullei +/types/signature_pad/ @AbubakerB +/types/simple-assign/ @NoHomey +/types/simple-cw-node/ @vvakame +/types/simple-mock/ @leonyu +/types/simple-oauth2/ @mad-mike +/types/simple-peer/ @tlaziuk +/types/simple-url-cache/ @a-lucas +/types/simple-xml/ @notVitaliy +/types/simplebar/v1/ @gregonnet @leonard-thieu +/types/simplebar/ @leonard-thieu +/types/simplemde/ @Scalesoft +/types/simplesmtp/ @rogierschouten +/types/simplestorage.js/ @axelcostaspena @mxl +/types/sinon/ @mrbigdog2u @rationull @lumaxis @nicojs @43081j +/types/sinon-as-promised/ @igrayson +/types/sinon-chai/ @kazimanzurrashid @jedmao +/types/sinon-chrome/ @pimterry +/types/sinon-express-mock/ @jpchip @tlaziuk +/types/sinon-mongoose/ @stevehipwell +/types/sinon-stub-promise/ @vintem +/types/sinon-test/ @mummybot +/types/sip.js/ @decyrus +/types/sipml/ @chookies +/types/sitemap2/ @shundy +/types/sizzle/ @leonard-thieu +/types/sjcl/ @Evgenus +/types/ski/ @AyaMorisawa +/types/skyway/ @nakakura +/types/slack-node/ @geoffreak +/types/slack-winston/ @BlueHatbRit +/types/slackify-html/ @hypexr +/types/slate-irc/ @elisee +/types/sleep/ @rajarz +/types/slickgrid/ @jbaldwin +/types/slideout/ @ToastHawaii +/types/slimerjs/ @alexwall +/types/slocket/ @BendingBender +/types/slug/ @mhegazy +/types/smart-fox-server/ @ChanceM +/types/smooth-scrollbar/ @asvetliakov +/types/smoothie/ @mikehhawley +/types/smoothscroll-polyfill/ @kryops +/types/smtp-server/ @markisme +/types/smtpapi/ @a-morales +/types/snapsvg/ @lhk @mattanja @kant2002 +/types/snazzy-info-window/ @milosd92 +/types/snekfetch/ @DarkerTV +/types/snoowrap/ @vitosamson +/types/soap/ @aleung @cagefox +/types/socket.io/ @progre @divillysausages @florentpoujol @KentarouTakeda +/types/socket.io-client/ @progre @divillysausages @florentpoujol +/types/socket.io-redis/ @nupplaphil +/types/socket.io.users/ @kataras +/types/socketio-wildcard/ @BendingBender +/types/socketty/ @Nax +/types/sockjs/ @pmccloghrylaing +/types/sockjs-client/ @vladev @arusakov @BendingBender +/types/solution-center-communicator/ @dami-gg +/types/sortablejs/ @Maw-Fox +/types/source-list-map/ @e-cloud +/types/source-map/ @MortenHoustonLudvigsen @rbuckton +/types/source-map-support/ @Bartvds @jason0x43 +/types/space-pen/ @vvakame +/types/spark-md5/ @bastienmoulia +/types/sparkly/ @BendingBender +/types/sparkpost/v1/ @geoffreak +/types/sparkpost/ @geoffreak @bondz +/types/spatialite/ @atd-schubert +/types/spdy/ @tony19 +/types/speakeasy/ @legendecas @mrOlorin +/types/speakingurl/ @Goldsmith42 +/types/spectacle/ @zmaybury +/types/spectrum/ @M-Zuber +/types/spin.js/ @borisyankov @theodorejb +/types/split/ @marcinporebski +/types/split2/ @mugeso +/types/spotify-api/ @skovmand +/types/sprintf/ @soywiz +/types/sql.js/ @Hozuki +/types/sqlite3/ @nmalaguti @dpyro +/types/sqlstring/ @marvinhagemeister +/types/squirejs/ @bradleyayers +/types/srp/ @Patman64 +/types/ss-utils/ @mythz +/types/ssh2/ @tkQubo @rbuckton +/types/ssh2-sftp-client/ @igrayson +/types/ssh2-streams/ @rbuckton +/types/sshpk/ @mabels +/types/stack-mapper/ @rogierschouten +/types/stack-trace/ @exceptionless +/types/stack-utils/ @BendingBender +/types/stacktrace-js/ @exceptionless @pilagod +/types/stale-lru-cache/ @cxcorp +/types/stampit/ @koresar +/types/stamplay-js-sdk/ @ridermansb +/types/stat-mode/ @BendingBender +/types/stats.js/ @gregolai @hberntsen +/types/statsd-client/ @peterkooijmans +/types/status-bar/ @vvakame +/types/statuses/ @tkrotoff @BendingBender +/types/steam/ @kant2002 +/types/steed/ @Paul-Isache +/types/stompjs/ @jimic +/types/storejs/ @vbortone +/types/storybook__addon-actions/ @joscha +/types/storybook__addon-knobs/ @joscha @martynaskadisa +/types/storybook__addon-links/ @joscha +/types/storybook__addon-notes/ @joscha +/types/storybook__addon-options/ @joscha +/types/storybook__react/ @joscha +/types/stream-buffers/ @Jason3S +/types/stream-meter/ @mugeso +/types/stream-series/ @k-kagurazaka +/types/stream-to-array/v0/ @Bartvds +/types/stream-to-array/ @Bartvds @BendingBender +/types/streaming-json-stringify/ @BendingBender +/types/streamjs/ @erosb +/types/strftime/ @cyrilschumacher +/types/string/ @basp +/types/string-hash/ @ethanrubio +/types/string-similarity/ @ragtime +/types/string-template/ @TonyPythoneer +/types/string_score/ @marcinporebski +/types/stringify-object/ @khoomeister +/types/strip-ansi/ @mhegazy +/types/strip-bom/ @mhegazy +/types/strip-json-comments/ @dmoonfire +/types/stripe-checkout/ @cgwrench +/types/stripe-node/ @wjohnsto @codeanimal +/types/stripe-v2/ @ejsmith @amritk @adamcmiel @jleider @galuszkak +/types/stripe-v3/ @ejsmith @amritk @adamcmiel @jleider @galuszkak +/types/striptags/ @ccitro +/types/strong-cluster-control/ @shuntksh +/types/strophe/ @DavidKDeutsch +/types/stylelint/ @alan-agius4 +/types/stylus/ @SomaticIT +/types/subsume/ @BendingBender +/types/succinct/ @EnableSoftware +/types/sudo-block/ @BendingBender +/types/suitescript/ @darrenhillconsulting +/types/sumo-logger/ @forabi +/types/superagent/ @NicoZelaya @mxl @paplorinc +/types/superagent-no-cache/ @mxl +/types/superagent-prefix/ @mxl +/types/supercluster/ @DenisCarriere +/types/supertest/ @varju +/types/supertest-as-promised/ @tkrotoff +/types/supports-color/ @mgroenhoff +/types/survey-knockout/ @andrewtelnov +/types/svg-injector/ @poke +/types/svg-pan-zoom/v2/ @Promact +/types/svg-pan-zoom/ @Yimiprod +/types/svg-sprite/ @tkqubo +/types/svg2png/ @hansrwindhoff +/types/svg4everybody/ @BendingBender +/types/svgjs.draggable/ @LiFeleSs +/types/svgjs.resize/ @jkevingutierrez +/types/swag/ @shiwano +/types/swagger-express-middleware/ @alexandreroba +/types/swagger-express-mw/ @micmro +/types/swagger-hapi/ @micmro +/types/swagger-jsdoc/ @drGrove +/types/swagger-node-runner/ @micmro +/types/swagger-parser/ @Tobias4872 @EricHenry +/types/swagger-restify-mw/ @micmro +/types/swagger-sails-hook/ @micmro +/types/swagger-schema-official/ @mohsen1 @bsouthga @nimerritt +/types/swagger-tools/ @bricka +/types/swaggerize-express/ @mugeso @nickmorton +/types/sweetalert/ @ToastHawaii +/types/swfobject/ @rou +/types/swiftclick/ @Laurence-C +/types/swig/ @CodeAnimal @soywiz +/types/swig-email-templates/ @mrhen +/types/swipe/ @kant2002 +/types/swiper/ @sgaliano @lucax88x +/types/swipeview/ @borisyankov +/types/switchery/ @bgrieder @claylaut +/types/swiz/ @jedigo +/types/sylvester/ @StephaneAlie +/types/synaptic/ @ToastHawaii @austincummings +/types/systeminformation/ @PixelcrabAT +/types/systemjs/ @ludohenin @NathanWalker @GiedriusGrabauskas +/types/table/ @evanshortiss +/types/tabtab/ @vojtechhabarta +/types/tapable/ @e-cloud +/types/tape/ @Bartvds @sodatea @DennisSchwartz +/types/tar/ @SomaticIT +/types/tedious/ @rogierschouten @cjthompson +/types/tedious-connection-pool/ @sandorfr +/types/telebot/ @mariotsi +/types/temp/ @DanielRosenwasser +/types/temp-write/ @BendingBender +/types/tempfile/ @SamVerschueren @BendingBender +/types/tempy/ @douglasduteil +/types/terminal-menu/ @aravindarun +/types/testingbot-api/ @timbru31 +/types/tether/ @adidahiya +/types/tether-drop/ @adidahiya +/types/tether-shepherd/ @mtgibbs +/types/text-buffer/ @vvakame +/types/text-encoding/ @pine613 +/types/three/ @gyohk @florentpoujol @SereznoKot @omni360 @ivoisbelongtous @piranha771 @qszhusightp @nakakura @s093294 @Pro @efokschaner +/types/thrift/ @kamek-pf +/types/throng/ @cyrilschumacher +/types/throttle/ @BendingBender +/types/through/ @AndrewGaspar +/types/through2/v0/ @Bartvds @jedmao +/types/through2/ @Bartvds @jedmao @valotas @TeamworkGuy2 +/types/through2-map/ @LucasHill +/types/tile-reduce/ @DenisCarriere +/types/tilebelt/ @DenisCarriere +/types/time-span/ @BendingBender @mdvorscak +/types/timelinejs/ @rolandzwaga +/types/timelinejs3/ @MikeMatusz +/types/timer-machine/ @dolanmiu +/types/timezone-js/ @bonnici +/types/timezonecomplete/ @rogierschouten +/types/tinder/ @pingec +/types/tinycolor2/ @M-Zuber @geertjansen @nvh +/types/tinycopy/ @vvatanabe +/types/tinymce/ @martinduparc @ipoul +/types/titanium/ @cyounkins +/types/title/ @fa7ad +/types/tldjs/ @geoffreak +/types/tmp/ @optical @Perlmint +/types/to-markdown/ @SuperPaintman +/types/to-title-case-gouch/ @stpettersens +/types/toastr/ @borisyankov +/types/tooltipster/ @stephenlautier +/types/topojson/ @ricardo-mello @chenzhutian +/types/torrent-stream/ @xstoudi +/types/touch/ @mizunashi-mana @BendingBender +/types/touch-events/ @kevinb7 +/types/tough-cookie/ @leonard-thieu +/types/traceback/ @misak113 +/types/tracking/ @pimterry +/types/transducers-js/ @colinkahn @dphilipson +/types/transducers.js/ @dphilipson +/types/traverse/ @newclear +/types/traverson/ @marcinporebski +/types/trayballoon/ @korve +/types/trim/ @skysteve +/types/trunk8/ @niemyjski +/types/tspromise/ @soywiz +/types/tunnel/ @BendingBender +/types/turf/v2/ @gcroteau +/types/turf/ @gcroteau @DenisCarriere +/types/tus-js-client/ @kevhiggins +/types/tv4/ @Bartvds @psnider +/types/tween.js/ @Amos47 @sunetos @jzarnikov +/types/tweenjs/ @evilangelist +/types/tweezer.js/ @praxxis +/types/twig/ @soywiz @enko +/types/twilio/ @nickiannone @ashleybrener +/types/twit/ @Volox +/types/twitter/ @chitoku-k +/types/twix/ @j3ko +/types/type-check/ @hansrwindhoff +/types/type-detect/ @Bartvds +/types/type-is/ @BendingBender +/types/type-name/ @armorik83 +/types/typeahead/ @igochkov @gjunge +/types/typedarray-pool/ @pawsong +/types/typescript-deferred/ @DirtyHairy +/types/tz-format/ @samverschueren +/types/ua-parser-js/ @superduper @legendecas @MeLlamoPablo +/types/uglify-js/ @tkrotoff +/types/uglifycss/ @blendsdk +/types/ui-grid/ @btesser @joeskeen +/types/ui-router-extras/ @mputters @marcel-k @LaserUnicorns +/types/ui-select/ @nkovacic +/types/uid-safe/ @geoffreak +/types/uikit/ @giovannicandido @s0x +/types/uk.co.workingedge.phonegap.plugin.launchnavigator/ @dpa99c +/types/umbraco/ @DeCareSystemsIreland +/types/umd/ @TeamworkGuy2 +/types/umzug/ @drinchev +/types/underscore/ @borisyankov @jbaldwin @ccurrens +/types/underscore-ko/ @MagicMau +/types/underscore.string/ @rygine +/types/undertaker/ @tkqubo @GiedriusGrabauskas +/types/undertaker-registry/ @GiedriusGrabauskas +/types/uniq/ @hansrwindhoff +/types/uniqid/ @me +/types/unique-hash-stream/ @BendingBender +/types/unique-random/ @Kuniwak +/types/unity-webapi/ @jmvrbanac +/types/universal-analytics/ @Bartvds @DarkerTV +/types/universal-router/ @jtmthf +/types/unorm/ @chbrown +/types/untildify/ @BendingBender +/types/unused-filename/ @BendingBender +/types/update-notifier/ @vvakame @nchen63 +/types/uppercamelcase/ @plantain-00 +/types/urbanairship-cordova/ @Justin-Credible +/types/uri-templates/ @Bartvds +/types/urijs/ @RodneyJT @xt0rted +/types/uritemplate/ @teyc +/types/url-assembler/ @wolfgang42 +/types/url-join/ @rogierschouten @devrelm +/types/url-regex/ @unindented +/types/url-template/ @marcinporebski +/types/urlrouter/ @soywiz +/types/urlsafe-base64/ @tkrotoff +/types/usage/ @pvomhoff +/types/usb/ @underscorebrody +/types/user-home/ @mhegazy +/types/useragent/ @geoffreak +/types/username/ @kayahr +/types/utf8/ @zelein +/types/util-deprecate/ @BendingBender +/types/util.promisify/ @adamvoss +/types/utils-merge/ @chrootsu +/types/uuid/ @iamolivinius @felipeochoa @cjbarth +/types/uuid-1345/ @mugeso +/types/uuid-js/ @mhegazy +/types/uuid-validate/ @HiromiShikata +/types/uuidjs/ @staxmanade +/types/uws/ @plantain-00 +/types/valdr/ @ilbertz +/types/valdr-message/ @ilbertz +/types/valerie/ @conficient +/types/valid-url/ @stevehipwell +/types/validate.js/ @HillTravis +/types/validator/ @tgfjt @chrootsu @IOAyman @louy @kacepe +/types/validatorjs/ @LKay +/types/vanilla-tilt/ @BrunnerLivio +/types/vary/ @BendingBender +/types/vast-client/ @jgainfort +/types/vec3/ @xstoudi +/types/vectorious/ @erikgerrits +/types/vega/ @pelotom +/types/velocity-animate/ @smrq +/types/verror/ @svi3c @max4t +/types/vertx3-eventbus-client/ @oddeirik +/types/vex-js/ @gdcohan +/types/vexflow/ @rquiring @sebastianhaas @bohoffi +/types/victory/ @asvetliakov @snerks @Havret +/types/video.js/ @vbortone +/types/viewability-helper/ @lironzluf +/types/viewerjs/ @lrh3321 +/types/viewporter/ @borisyankov +/types/vimeo/ @DazWilkin +/types/vimeo__player/ @denisyilmaz +/types/vinyl/v0/ @jedmao +/types/vinyl/ @vvakame @jedmao @thorn0 +/types/vinyl-buffer/ @tkQubo +/types/vinyl-fs/ @vvakame @remisery +/types/vinyl-paths/ @tkQubo +/types/virtual-dom/ @chbrown +/types/virtual-keyboard/ @bsurai +/types/vis/ @MichaelBitard @macleodbroad-wf @adripanico @seveves @kaktus40 @mmaitre314 +/types/vision/ @jasonswearingen @AJamesPhillips +/types/vitalsigns/ @cyrilschumacher +/types/vivus/ @DanielRosenwasser @lekhmanrus +/types/vkbeautify/ @sch3lp +/types/voca/ @pine +/types/voronoi-diagram/ @michaelneu +/types/vortex-web-client/ @Pro +/types/voximplant-websdk/ @aylarov +/types/vue-i18n/ @aicest +/types/vue-resource/ @kaorun343 +/types/w2ui/ @Ptival +/types/wake_on_lan/ @SrTobi +/types/wallabyjs/ @andrewconnell +/types/wallpaper/ @BendingBender +/types/wampy/ @KSDaemon +/types/warning/ @cvle +/types/watch/ @soywiz @Perlmint +/types/watchify/ @TeamworkGuy2 +/types/watchpack/ @e-cloud +/types/waterline/ @arvitaly +/types/watson-developer-cloud/ @waldo000000 +/types/waypoints/ @dominikbulaj @Koloto +/types/weapp-api/ @vargeek +/types/web-animations-js/ @kritollm +/types/web-bluetooth/ @urish +/types/webappsec-credential-management/ @iainmcgin +/types/webassembly-js-api/ @periklis +/types/webcl/ @NCARalph +/types/webcomponents.js/ @adidahiya +/types/webcrypto/ @iislucas +/types/webdriverio/ @nmalaguti @timbru31 @fsmedberg-tc @tanvirislam06 +/types/webfontloader/ @doskallemaskin +/types/webgl-ext/ @zenmumbler +/types/webgl2/ @nkemnitz +/types/webgme/ @phreed +/types/webix/ @mkozhukh +/types/webmidi/ @lostfictions +/types/webpack/ @tkqubo @bumbleblym @bcherny @tommytroylin @mohsen1 @jcreamer898 +/types/webpack-bundle-analyzer/ @kryops +/types/webpack-chain/ @eirikurn @psachs21 +/types/webpack-dev-middleware/ @bumbleblym +/types/webpack-dev-server/ @maestroh @daveparslow +/types/webpack-dotenv-plugin/ @kryops +/types/webpack-env/ @use-strict +/types/webpack-fail-plugin/ @deevus +/types/webpack-hot-middleware/ @bumbleblym +/types/webpack-merge/ @deevus +/types/webpack-notifier/ @bumbleblym +/types/webpack-sources/ @e-cloud @chriseppstein +/types/webpack-stream/ @iclanton @bumbleblym +/types/webpack-validator/ @deevus +/types/webrtc/ @nakakura +/types/websocket/ @loyd @flynetworks +/types/webspeechapi/ @saschanaz +/types/websql/ @TeamworkGuy2 +/types/webtorrent/ @niieani @tlaziuk +/types/webvr-api/ @lostfictions +/types/week/ @sindrenm +/types/weighted/ @ccitro +/types/weixin-app/ @taoqf +/types/wellknown/ @yairtawil +/types/whatwg-streams/ @saschanaz +/types/when/ @derekcicerone @Nemo157 +/types/which/ @vvakame +/types/wicg-mediasession/ @jucrouzet +/types/wiiu/ @mzsm +/types/window-or-global/ @vvakame +/types/window-size/ @pmkary +/types/windows-1251/ @RomanGolovanov +/types/windows-service/ @rogierschouten +/types/winjs/v1/ @adamhewitt627 @craigktreasure @xirzec +/types/winjs/v2/ @adamhewitt627 @craigktreasure @xirzec +/types/winjs/ @adamhewitt627 @craigktreasure @xirzec +/types/winreg/ @RX14 @BobBuehler +/types/winrt-uwp/ @saschanaz @taylor224 +/types/winston/ @bonnici @codeanimal @DABH +/types/winston-dynamodb/ @nickiannone +/types/wiring-pi/ @NoHomey +/types/wnumb/ @acoreyj +/types/wolfy87-eventemitter/ @ryiwamoto +/types/wonder-commonlib/ @yyc-git +/types/wonder-frp/ @yyc-git +/types/wonder.js/ @yyc-git +/types/wordcloud/ @joeskeen +/types/words-to-numbers/ @James-Frowen +/types/wrap-ansi/ @kayahr +/types/wreck/ @marcinporebski +/types/wrench/ @soywiz +/types/write-file-atomic/ @BendingBender +/types/write-json-file/ @DenisCarriere +/types/ws/ @loyd @elithrar +/types/wu/ @phiresky +/types/wx-js-sdk-dt/ @agasbzj +/types/x-editable/ @sirkirby +/types/xadesjs/ @microshine +/types/xdate/ @yamada28go +/types/xdg-basedir/ @tlaziuk +/types/xlsx/ @themauveavenger +/types/xml/ @YuJianrong +/types/xml-parser/ @mhfrantz +/types/xml2js/ @michelsalib @jasonrm @ccurrens @edwardhinkle +/types/xml2json/ @dolanmiu +/types/xmlbuilder/ @wallymathieu +/types/xmldoc/ @Xstoudi @ajsheehan +/types/xmldom/ @tkqubo +/types/xmlpoke/ @garthk +/types/xmltojson/ @traviscrowe +/types/xmpp__jid/ @PJakcson +/types/xregexp/ @Bartvds @jfahrenkrug @sigo +/types/xrm/v7/ @daryllabar +/types/xrm/ @6ix4our @mattngan @markusmauch @daryllabar @clownwilleatme +/types/xsd-schema-validator/ @Goldsmith42 +/types/xsockets/ @pushplay +/types/xterm/ @blink1073 @LucianBuzzo +/types/yallist/ @BendingBender +/types/yandex-money-sdk/ @chrootsu +/types/yargs/ @poelstra @mizunashi-mana @pushplay @jeffkenney +/types/yayson/ @Codesleuth +/types/ydn-db/ @yathit @gabrielmaldi +/types/yeoman-generator/ @armorik83 @janslow +/types/yeoman-test/ @ikatyang +/types/yfiles/ @yGuy +/types/yog-bigpipe/ @ssddi456 +/types/yog-log/ @ssddi456 +/types/yog2-kernel/ @ssddi456 +/types/yosay/ @armorik83 +/types/youtube/ @DazWilkin @JoshuaKGoldberg @eliotfallon213 +/types/yui/ @giabao +/types/z-schema/ @pgonzal +/types/zen-observable/ @aicest +/types/zepto/ @jbaldwin +/types/zeroclipboard/v1/ @ejsmith @niemyjski @balassy @leonyu +/types/zeroclipboard/ @ejsmith @niemyjski @balassy @leonyu +/types/zeromq/ @davemckeown @erikma +/types/zetapush-js/ @ghoullier +/types/zip.js/ @lgrignon +/types/zmq/ @davemckeown +/types/zui/ @yuanxu +/types/zynga-scroller/ @haskellcamargo diff --git a/README.md b/README.md index f6d2e5d585..4b16884273 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,7 @@ For a good example package, see [base64-js](https://github.com/DefinitelyTyped/D * First, follow advice from the [handbook](http://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html). * Formatting: Either use all tabs, or always use 4 spaces. +* `function sum(nums: number[]): number`: Use `ReadonlyArray` if a function does not write to its parameters. * `interface Foo { new(): Foo; }`: This defines a type of objects that are new-able. You probably want `declare class Foo { constructor(); }`. * `const Class: { new(): IClass; }`: @@ -143,6 +144,10 @@ For a good example package, see [base64-js](https://github.com/DefinitelyTyped/D Example where a type parameter is acceptable: `function id(value: T): T;`. Example where it is not acceptable: `function parseJson(json: string): T;`. Exception: `new Map()` is OK. +* Using the types `Function` and `Object` is almost never a good idea. In 99% of cases it's possible to specify a more specific type. Examples are `(x: number) => number` for [functions](http://www.typescriptlang.org/docs/handbook/functions.html#function-types) and `{ x: number, y: number }` for objects. If there is no certainty at all about the type, [`any`](http://www.typescriptlang.org/docs/handbook/basic-types.html#any) is the right choice, not `Object`. If the only known fact about the type is that it's some object, use the type [`object`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html#object-type), not `Object` or `{ [key: string]: any }`. +* `var foo: string | any`: + When `any` is used in a union type, the resulting type is still `any`. So while the `string` portion of this type annotation may _look_ useful, it in fact offers no additional typechecking over simply using `any`. + Depending on the intention, acceptable alternatives could be `any`, `string`, or `string | object`. #### Removing a package @@ -177,6 +182,18 @@ If a `tslint.json` turns rules off, this is because that hasn't been fixed yet. (To indicate that a lint rule truly does not apply, use `// tslint:disable rule-name` or better, `//tslint:disable-next-line rule-name`.) +To assert that an expression is of a given type, use `$ExpectType`. To assert that an expression causes a compile error, use `$ExpectError`. + +```js +// $ExpectType void +f(1); + +// $ExpectError +f("one"); +``` + +For more details, see [dtslint](https://github.com/Microsoft/dtslint#write-tests) readme. + Test by running `npm run lint package-name` where `package-name` is the name of your package. This script uses [dtslint](https://github.com/Microsoft/dtslint). @@ -186,7 +203,14 @@ This script uses [dtslint](https://github.com/Microsoft/dtslint). #### What exactly is the relationship between this repository and the `@types` packages on NPM? The `master` branch is automatically published to the `@types` scope on NPM thanks to [types-publisher](https://github.com/Microsoft/types-publisher). -This usually happens within an hour of changes being merged. + +#### I've submitted a pull request. How long until it is merged? + +It depends, but most pull requests will be merged within a week. PRs that have been approved by an author listed in the definition's header are usually merged more quickly; PRs for new definitions will take more time as they require more review from maintainers. Each PR is reviewed by a TypeScript or DefinitelyTyped team member before being merged, so please be patient as human factors may cause delays. Check the [PR Burndown Board](https://github.com/DefinitelyTyped/DefinitelyTyped/projects/3?card_filter_query=is%3Aopen) to see progress as maintainers work through the open PRs. + +#### My PR is merged; when will the `@types` NPM package be updated? + +NPM packages should update within a few hours. If it's been more than 24 hours, ping @RyanCavanaugh and @andy-ms on the PR to investigate. #### I'm writing a definition that depends on another definition. Should I use `` or an import? @@ -264,6 +288,17 @@ Also, `/// ` will not work with path mapping, so depende Types for a scoped package `@foo/bar` should go in `types/foo__bar`. Note the double underscore. +When `dts-gen` is used to scaffold a scoped package, the `paths` property has to be manually adapted in the generated +`tsconfig.json` to correctly reference the scoped package: + +```json +{ + "paths":{ + "@foo/bar": ["foo__bar"] + } +} +``` + #### The file history in GitHub looks incomplete. diff --git a/notNeededPackages.json b/notNeededPackages.json index 4a3280ccb0..457498b676 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -1,11 +1,35 @@ { "packages": [ + { + "libraryName": "3d-bin-packing", + "typingsPackageName": "3d-bin-packing", + "sourceRepoURL": "https://github.com/betterwaysystems/packer", + "asOfVersion": "1.1.3" + }, + { + "libraryName": "ag-grid", + "typingsPackageName": "ag-grid", + "sourceRepoURL": "https://github.com/ceolter/ag-grid", + "asOfVersion": "3.2.0" + }, { "libraryName": "ajv", "typingsPackageName": "ajv", "sourceRepoURL": "https://github.com/epoberezkin/ajv", "asOfVersion": "1.0.0" }, + { + "libraryName": "angular-ui-router-default", + "typingsPackageName": "angular-ui-router-default", + "sourceRepoURL": "https://github.com/nonplus/angular-ui-router-default", + "asOfVersion": "0.0.5" + }, + { + "libraryName": "angular-ui-router-uib-modal", + "typingsPackageName": "angular-ui-router-uib-modal", + "sourceRepoURL": "https://github.com/nonplus/angular-ui-router-uib-modal", + "asOfVersion": "0.0.11" + }, { "libraryName": "antd", "typingsPackageName": "antd", @@ -60,6 +84,12 @@ "sourceRepoURL": "http://www.babylonjs.com/", "asOfVersion": "2.4.1" }, + { + "libraryName": "base64url", + "typingsPackageName": "base64url", + "sourceRepoURL": "https://github.com/brianloveswords/base64url", + "asOfVersion": "2.0.0" + }, { "libraryName": "BigInteger.js", "typingsPackageName": "big-integer", @@ -252,6 +282,12 @@ "sourceRepoURL": "https://github.com/blakeembrey/is-upper-case", "asOfVersion": "1.1.2" }, + { + "libraryName": "jpush-react-native", + "typingsPackageName": "jpush-react-native", + "sourceRepoURL": "https://github.com/jpush/jpush-react-native", + "asOfVersion": "2.0.0" + }, { "libraryName": "jquery.ajaxfile", "typingsPackageName": "jquery.ajaxfile", @@ -450,6 +486,12 @@ "sourceRepoURL": "https://github.com/getsentry/raven-js", "asOfVersion": "3.10.0" }, + { + "libraryName": "raw-body", + "typingsPackageName": "raw-body", + "sourceRepoURL": "https://github.com/stream-utils/raw-body", + "asOfVersion": "2.3.0" + }, { "libraryName": "react-day-picker", "typingsPackageName": "react-day-picker", @@ -516,6 +558,30 @@ "sourceRepoURL": "https://github.com/tildeio/route-recognizer", "asOfVersion": "0.3.0" }, + { + "libraryName": "router5", + "typingsPackageName": "router5", + "sourceRepoURL": "https://github.com/router5/router5", + "asOfVersion": "5.0.0" + }, + { + "libraryName": "samchon", + "typingsPackageName": "samchon", + "sourceRepoURL": "https://github.com/samchon/framework", + "asOfVersion": "2.0.22" + }, + { + "libraryName": "samchon-framework", + "typingsPackageName": "samchon-framework", + "sourceRepoURL": "https://github.com/samchon/framework", + "asOfVersion": "2.0.21" + }, + { + "libraryName": "samchon-library", + "typingsPackageName": "samchon-library", + "sourceRepoURL": "https://github.com/samchon/framework", + "asOfVersion": "0.1.0" + }, { "libraryName": "node-scanf", "typingsPackageName": "scanf", @@ -600,6 +666,12 @@ "sourceRepoURL": "https://github.com/cbowdon/TsMonad", "asOfVersion": "0.5.0" }, + { + "libraryName": "tstl", + "typingsPackageName": "tstl", + "sourceRepoURL": "https://github.com/samchon/tstl", + "asOfVersion": "1.5.7" + }, { "libraryName": "TypeScript", "typingsPackageName": "typescript", diff --git a/package.json b/package.json index 86a97c4ba8..db67595b77 100644 --- a/package.json +++ b/package.json @@ -21,10 +21,7 @@ "lint": "dtslint types" }, "devDependencies": { - "dtslint": "Microsoft/dtslint#production", + "dtslint": "github:Microsoft/dtslint#production", "types-publisher": "Microsoft/types-publisher#production" - }, - "dependencies": { - "jslint": "^0.10.3" } } diff --git a/scripts/fix-tslint.ts b/scripts/fix-tslint.ts index 419ebcd0de..36cb23ebbd 100644 --- a/scripts/fix-tslint.ts +++ b/scripts/fix-tslint.ts @@ -39,7 +39,16 @@ function fix(config: any): any { const out: any = {}; for (const key in config) { let value = config[key]; - out[key] = value; + out[key] = key === "rules" ? fixRules(value) : value; } return out; } + +function fixRules(rules: any): any { + const out: any = {}; + for (const key in rules) { + out[key] = rules[key]; + } + return out; +} + diff --git a/types/3d-bin-packing/3d-bin-packing-tests.ts b/types/3d-bin-packing/3d-bin-packing-tests.ts deleted file mode 100644 index 8e394e46bb..0000000000 --- a/types/3d-bin-packing/3d-bin-packing-tests.ts +++ /dev/null @@ -1,50 +0,0 @@ -import packer = require("3d-bin-packing"); -import samchon = require("samchon"); - -function main(): void -{ - /////////////////////////// - // CONSTRUCT OBJECTS - /////////////////////////// - let wrapperArray: bws.packer.WrapperArray = new packer.WrapperArray(); - let instanceArray: bws.packer.InstanceArray = new packer.InstanceArray(); - - // Wrappers - wrapperArray.push - ( - new packer.Wrapper("Large", 1000, 40, 40, 15, 0), - new packer.Wrapper("Medium", 700, 20, 20, 10, 0), - new packer.Wrapper("Small", 500, 15, 15, 8, 0) - ); - - /////// - // Each Instance is repeated #15 - /////// - instanceArray.insert(instanceArray.end(), 15, new packer.Product("Eraser", 1, 2, 5)); - instanceArray.insert(instanceArray.end(), 15, new packer.Product("Book", 15, 30, 3)); - instanceArray.insert(instanceArray.end(), 15, new packer.Product("Drink", 3, 3, 10)); - instanceArray.insert(instanceArray.end(), 15, new packer.Product("Umbrella", 5, 5, 20)); - - // Wrappers also can be packed into another Wrapper. - instanceArray.insert(instanceArray.end(), 15, new packer.Wrapper("Notebook-Box", 2000, 30, 40, 4, 2)); - instanceArray.insert(instanceArray.end(), 15, new packer.Wrapper("Tablet-Box", 2500, 20, 28, 2, 0)); - - /////////////////////////// - // BEGINS PACKING - /////////////////////////// - // CONSTRUCT PACKER - let my_packer: bws.packer.Packer = new packer.Packer(wrapperArray, instanceArray); - - /////// - // PACK (OPTIMIZE) - let result: bws.packer.WrapperArray = my_packer.optimize(); - /////// - - /////////////////////////// - // TRACE PACKING RESULT - /////////////////////////// - let xml: samchon.library.XML = result.toXML(); - console.log(xml.toString()); -} - -main(); \ No newline at end of file diff --git a/types/3d-bin-packing/index.d.ts b/types/3d-bin-packing/index.d.ts deleted file mode 100644 index 8165ea513e..0000000000 --- a/types/3d-bin-packing/index.d.ts +++ /dev/null @@ -1,1383 +0,0 @@ -// Type definitions for 3d-bin-packing v1.1.2 -// Project: https://github.com/betterwaysystems/packer -// Definitions by: Jeongho Nam -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// - -declare module "3d-bin-packing" -{ - export = bws.packer; -} - -/// -/// -declare namespace bws.packer { - export import library = samchon.library; - export import protocol = samchon.protocol; - function _Test(): void; -} -declare namespace boxologic { - /** - *

An abstract instance of boxologic.

- * - *

{@link st_Instance} represents a physical, tangible instance of 3-dimension.

- * - * @author Jeongho Nam - */ - abstract class Instance { - /** - * Width of the tangible instance, length on the X-axis in 3D. - */ - width: number; - /** - * Height of the tangible instance, length on the Y-axis in 3D. - */ - height: number; - /** - * Length of the tangible instance, length on the Z-axis in 3D. - */ - length: number; - /** - * Width considering layout placement. - */ - layout_width: number; - /** - * Height considering layout placement. - */ - layout_height: number; - /** - * Length considering layout placement. - */ - layout_length: number; - /** - * Volume, Width x Height x Length. - */ - volume: number; - /** - * Construct from size members. - * - * @param width Width, length on the X-axis in 3D. - * @param height Height, length on the Y-axis in 3D. - * @param length Length, length on the Z-axis in 3D. - */ - constructor(width: number, height: number, length: number); - } -} -declare namespace boxologic { - /** - * A box, trying to pack into a {@link Pallet}. - * - * @author Bill Knechtel,
- * Migrated and Refactored by Jeongho Nam - */ - class Box extends Instance { - /** - * Coordinate-X of the box placement in a {@link Pallet}. - */ - cox: number; - /** - * Coordinate-Y of the box placement in a {@link Pallet}. - */ - coy: number; - /** - * Coordinate-Z of the box placement in a {@link Pallet}. - */ - coz: number; - /** - * Whether the {@link Box} is packed into a {@link Pallet}. - */ - is_packed: boolean; - overlapped_boxes: std.HashSet; - /** - * Construct from an instance. - * - * @param instance An instance adapts with. - */ - constructor(instance: bws.packer.Instance); - hit_test(obj: Box): boolean; - private hit_test_single(obj); - private hit_test_point(x, y, z); - } -} -/** - *

A set of programs that calculate the best fit for boxes on a pallet migrated from language C.

- * - *
    - *
  • Original Boxologic: https://github.com/exad/boxologic
  • - *
- * - * @author Bill Knechtel,
- * Migrated and Refactored by Jeongho Nam - */ -declare namespace boxologic { - /** - *

A facade class of boxologic.

- * - *

The Boxologic class dudcts the best solution of packing boxes to a pallet.

- * - *
    - *
  • Reference: https://github.com/exad/boxologic
  • - *
- * - * @author Bill Knechtel,
- * Migrated and Refactored by Jeongho Nam - */ - class Boxologic { - /** - * A Wrapper to pack instances. - */ - private wrapper; - /** - * Instances trying to put into the wrapper. - */ - private instanceArray; - /** - * Instances failed to pack by overloading. - */ - private leftInstances; - /** - * A pallet containing {@link Box boxes}. - * - * @see Wrapper - */ - private pallet; - /** - * Boxes, trying to pack into the {@link pallet}. - */ - private box_array; - /** - * Sum of all boxes' volume. - */ - private total_box_volume; - /** - *

All different lengths of {@link box_array all box} dimensions along with evaluation values.

- * - *

In other word, the layer_map stores those entries; each {@link Boxbox}'s length on each - * axis as a key (width, height or length) and evaluation value as a value. The evaluation - * value means sum of minimum gaps between the key and other {@link Box boxes}' width, height and length - *

- * - * - FOR i := 0 to box_array.size() - WHILE key IN width, length and height in box_array[i] - BEGIN - value := 0 - FOR j to box_array.size() - value += min - ( - abs(key - box_array[j].width), - abs(key - box_array[j].height), - abs(key - box_array[j].length) - ) - layer_map.insert({key, value}); - END - * - * - *
    - *
  • key: A dimension value
  • - *
  • value: Evaluation weight value for the corresponding key.
  • - *
- */ - private layer_map; - /** - * {@link List} of {@link Scrapped} instances, edges of layers under construction. - * - * @see Scrapped - * @see scrap_min_z - */ - private scrap_list; - /** - * The topology {@link Scrapped}, the edge of the current layer under construction. - * - * @see Scrapped - * @see scrap_list - */ - private scrap_min_z; - /** - * Index of the current {@link box}. - */ - private cboxi; - /** - * Candidate {@link Box.layout_width layout_width} of the {@link cboxi current box}. - */ - private cbox_layout_width; - /** - * Candidate {@link Box.layout_height layout_height} of the {@link cboxi current box}. - */ - private cbox_layout_height; - /** - * Candidate {@link Box.layout_length layout_length} of the {@link cboxi current box}. - */ - private cbox_layout_length; - /** - * Current layer's key on iteration. - */ - private layer_thickness; - /** - * Previous layer's key had iterated. - */ - private pre_layer; - /** - * Key of the unevened layer in the current packing layer. - */ - private layer_in_layer; - /** - * Little Z, gotten from {@link Scrapped.cumz cumz} in {@link min_scrap_z} - */ - private lilz; - /** - * Remained (unfilled) {@link Pallet.layout_height layout_height} of the {@link pallet}. - */ - private remain_layout_height; - /** - * Remained (unfilled) {@link Pallet.layout_length layout_length} of the {@link pallet}. - */ - private remain_layout_length; - /** - * Packed (filled) {@link Pallet.layout_height layout_height} of the {@link pallet}. - */ - private packed_layout_height; - /** - * Packed {@link Pallet.vo1lume volume} of the {@lnk pallet}. - */ - private packed_volume; - private boxi; - private bboxi; - private boxx; - private boxy; - private boxz; - private bboxx; - private bboxy; - private bboxz; - private bfx; - private bfy; - private bfz; - private bbfx; - private bbfy; - private bbfz; - /** - *

Whether the packing is on progress.

- * - *

The {@link packing} is a flag variable for terminating iterations in - * {@link iterate_orientations iterate_orientations()}, who deducts the best packing solution.

- */ - private packing; - /** - * Whether packing a layer is done. - */ - private layer_done; - /** - * Whether the current packing layer is evened. - */ - private evened; - /** - * Whether the best solution is deducted. - */ - private packing_best; - /** - * Whether the utilization degree of pallet space is 100%. - */ - private hundred_percent; - /** - * The best orientation of the pallet, which can deduct the {@link best_solution_volume}. - */ - private best_orientation; - /** - * The best layer, which can deduct the {@link best_solution_volume}. - */ - private best_layer; - /** - * The best volume, fit the best utilization degree of the pallet space. - */ - private best_solution_volume; - /** - * Construct from a wrapper and instances. - * - * @param wrapper A Wrapper to pack instances. - * @param instanceArray Instances trying to put into the wrapper. - */ - constructor(wrapper: bws.packer.Wrapper, instanceArray: bws.packer.InstanceArray); - /** - *

Encode data

- * - *

Encodes {@link bws.packer Packer}'s data to be suitable for the - * {@link boxologic Boxologic}'s parametric data.

- */ - private encode(); - /** - *

Decode data

- * - *

Decodes the Boxologic's optimization result data to be suitable for the Packer's own.

- */ - private decode(); - private inspect_validity(); - /** - *

Pack instances to the {@link wrapper}.

- * - *

The {@link Boxologic.pack} is an adaptor method between {@link bws.packer Packer} and - * {@link boxologic}. It encodes data from {@link bws.packer Packer}, deducts the best packing - * solution decodes the optimization result and returns it.

- * - *

The optimization result is returned as a {@link Pair} like below:

- *
    - *
  • first: The {@link wrapper} with packed instances.
  • - *
  • second: {@link leftInstances Left instances failed to pack} by overloading.
  • - *
- * - * @return A pair of {@link wrapper} with packed instances and - * {@link leftInstances instances failed to pack} by overloading. - */ - pack(): std.Pair; - /** - *

Execute iterations by calling proper functions.

- * - *

Iterations are done and parameters of the best solution are found.

- */ - private iterate_orientations(); - /** - * Iterate a layer. - * - * @param thickness Thickness of the iterating layer. - */ - private iterate_layer(thickness); - /** - *

Construct layers.

- * - *

Creates all possible layer heights by giving a weight value to each of them.

- */ - private construct_layers(); - /** - *

Packs the boxes found and arranges all variables and records properly.

- * - *

Update the linked list and the Boxlist[] array as a box is packed.

- */ - private pack_layer(); - /** - * Find the most proper layer height by looking at the unpacked boxes and - * the remaining empty space available. - */ - private find_layer(thickness); - /** - *

Determine the gap with the samllest z value in the current layer.

- * - *

Find the most proper boxes by looking at all six possible orientations, - * empty space given, adjacent boxes, and pallet limits.

- * - * @param hmx Maximum available x-dimension of the current gap to be filled. - * @param hy Current layer thickness value. - * @param hmy Current layer thickness value. - * @param hz Z-dimension of the current gap to be filled. - * @param hmz Maximum available z-dimension to the current gap to be filled. - */ - private find_box(hmx, hy, hmy, hz, hmz); - /** - *

Analyzes each unpacked {@link Box box} to find the best fitting one to the empty space.

- * - *

Used by {@link find_box find_box()} to analyze box dimensions.

- * - * @param x index of a {@link Box box} in the {@link box_array}. - * - * @param hmx Maximum available x-dimension of the current gap to be filled. - * @param hy Current layer thickness value. - * @param hmy Current layer thickness value. - * @param hz Z-dimension of the current gap to be filled. - * @param hmz Maximum available z-dimension to the current gap to be filled. - * - * @param dim1 X-dimension of the orientation of the box being examined. - * @param dim2 Y-dimension of the orientation of the box being examined. - * @param dim3 Z-dimension of the orientation of the box being examined. - */ - private analyze_box(index, hmx, hy, hmy, hz, hmz, dim1, dim2, dim3); - /** - * After finding each box, the candidate boxes and the condition of the layer are examined. - */ - private check_found(); - /** - * After packing of each box, 100% packing condition is checked. - */ - private volume_check(); - /** - *

Find the first to be packed gap in the layer edge.

- * - *

Determine the gap with the {@link scrap_min_z smallest z} value in the current layer.

- */ - private find_smallest_z(); - /** - *

Determine {@link box_arrray boxes}.

- * - *

Using the parameters found, packs the best solution found and reports.

- */ - private report_results(); - /** - *

Determine a {@link Box}.

- * - *

Transforms the found co-ordinate system to the one entered by the user and write them to the - * report.

- */ - private write_box_file(); - } -} -declare namespace boxologic { - /** - * A pallet containing boxes. - * - * @author Bill Knechtel,
- * Migrated and Refactored by Jeongho Nam - */ - class Pallet extends Instance { - /** - * Construct from a wrapper. - * - * @param wrapper A wrapper wrapping instances. - */ - constructor(wrapper: bws.packer.Wrapper); - /** - * Set placement orientation. - */ - set_orientation(orientation: number): void; - } -} -declare namespace boxologic { - /** - *

Cumulated lengths of current layer.

- * - *

{@link Scrapped} represents an edge of the current layer under construction.

- * - * @author Bill Knechtel,
- * Migrated and Refactored by Jeongho Nam - */ - class Scrap { - /** - * Cumulated length on the X-axis in 3D. - */ - cumx: number; - /** - * Cumulated length on the Z-axis in 3D. - */ - cumz: number; - /** - * Default Constructor. - */ - constructor(); - /** - * Initialization Constructor. - * - * @param cumx Cumulated length on the x-axis. - * @param cumz Cumulated length on the z-axis. - */ - constructor(cumx: number, cumz: number); - } -} -declare namespace bws.packer { - /** - * Bridge of {@link Packer} for {@link InstanceForm repeated instances}. - * - * @author Jeongho Nam - */ - class PackerForm extends protocol.Entity { - /** - * Form of Instances to pack. - */ - private instanceFormArray; - /** - * Type of Wrappers to be used. - */ - private wrapperArray; - /** - * Default Constructor. - */ - constructor(); - /** - * Initializer Constructor. - * - * @param instanceFormArray Form of Instances to pack. - * @param wrapperArray Type of Wrappers to be used. - */ - constructor(instanceFormArray: InstanceFormArray, wrapperArray: WrapperArray); - construct(xml: library.XML): void; - optimize(): WrapperArray; - getInstanceFormArray(): InstanceFormArray; - getWrapperArray(): WrapperArray; - TAG(): string; - toXML(): library.XML; - toPacker(): Packer; - } - /** - * An array of {@link InstanceForm} objects. - * - * @author Jeongho Nam - */ - class InstanceFormArray extends protocol.EntityArrayCollection { - /** - * Default Constructor. - */ - constructor(); - createChild(xml: library.XML): InstanceForm; - TAG(): string; - CHILD_TAG(): string; - /** - * Convert {@link InstanceForm} objects to {@link InstanceArray}. - * - * @return An array of instance containing repeated instances in {@link InstanceForm} objects. - */ - toInstanceArray(): InstanceArray; - } - /** - *

A repeated Instance.

- * - *

InstanceForm is an utility class for repeated {@link Instance}. It is designed for shrinking - * volume of network message I/O by storing {@link count repeated count}.

- * - * @author Jeongho Nam - */ - class InstanceForm extends protocol.Entity { - /** - * A duplicated Instance. - */ - private instance; - /** - * Repeated count of the {@link instance}. - */ - private count; - /** - * Default Constructor. - */ - constructor(instance?: Instance, count?: number); - /** - * @inheritdoc - */ - construct(xml: library.XML): void; - private createInstance(xml); - key(): any; - getInstance(): Instance; - getCount(): number; - setCount(val: number): void; - $name: string; - $width: string; - $height: string; - $length: string; - $count: string; - /** - * @inheritdoc - */ - TAG(): string; - /** - * @inheritdoc - */ - toXML(): library.XML; - /** - *

Repeated {@link instance} to {@link InstanceArray}. - * - * @details - *

Contains the {@link instance repeated instance} to an {@link InstanceArray} to make - * {@link instance} to participate in the packing process. The returned {@link InstanceArray} will be - * registered on {@link Packer.instanceArray}. - * - * @return An array of instance containing repeated {@link instance}. - */ - toInstanceArray(): InstanceArray; - } -} -declare namespace bws.packer { - class WrapperArray extends protocol.EntityArrayCollection { - /** - * Default Constructor. - */ - constructor(); - /** - * @inheritdoc - */ - createChild(xml: library.XML): Wrapper; - /** - * Get (calculate) price. - */ - getPrice(): number; - /** - * Get (calculate) utilization rate. - */ - getUtilization(): number; - /** - * @inheritdoc - */ - TAG(): string; - /** - * @inheritdoc - */ - CHILD_TAG(): string; - } -} -declare namespace bws.packer { - class GAWrapperArray extends WrapperArray { - protected instanceArray: InstanceArray; - protected result: std.HashMap; - private price; - /** - * @brief Validity of this sequence list. - */ - private valid; - /** - * Construct from instances. - * - * @param instanceArray Instances to be wrapped. - */ - constructor(instanceArray: InstanceArray); - /** - * @brief Copy Constructor. - */ - constructor(genes: GAWrapperArray); - private constructResult(); - /** - * @brief Get optimization result. - * - * @return result map. - */ - getResult(): std.HashMap; - less(obj: GAWrapperArray): boolean; - } -} -declare namespace bws.packer { - /** - * An interface of physical 3D-instances. - * - * @author Jeongho Nam - */ - interface Instance extends protocol.IEntity { - /** - * Get name. - */ - getName(): string; - /** - * Get width, length on the X-axis in 3D. - */ - getWidth(): number; - /** - * Get height, length on the Y-axis in 3D. - */ - getHeight(): number; - /** - * Get length, length on the Z-axis in 3D. - */ - getLength(): number; - /** - * Get (calculate) volume. - * - * @return width x height x length - */ - getVolume(): number; - /** - * Set name. - */ - setName(val: string): void; - /** - * Set width, length on the X-axis in 3D. - */ - setWidth(val: number): void; - /** - * Set height, length on the Y-axis in 3D. - */ - setHeight(val: number): void; - /** - * Set length, length on the Z-axis in 3D. - */ - setLength(val: number): void; - /** - *

A type, identifier of derived class.

- * - *

Derived types

- *
    - *
  • {@link Product product}
  • - *
  • {@link Wrapper wrapper}
  • - *
      - */ - TYPE(): string; - } -} -declare namespace bws.packer { - /** - * An array of Instance objects. - * - * @author Jeongho Nam - */ - class InstanceArray extends protocol.EntityArray { - /** - * Default Constructor. - */ - constructor(); - /** - * @inheritdoc - */ - createChild(xml: library.XML): Instance; - /** - * @inheritdoc - */ - TAG(): string; - /** - * @inheritdoc - */ - CHILD_TAG(): string; - } -} -declare namespace bws.packer { - /** - * @brief Packer, a solver of 3d bin packing with multiple wrappers. - * - * @details - *

      Packer is a facade class supporting packing operations in user side. You can solve a packing problem - * by constructing Packer class with {@link WrapperArray wrappers} and {@link InstanceArray instances} to - * pack and executing {@link optimize Packer.optimize()} method.

      - * - *

      In background side, deducting packing solution, those algorithms are used.

      - * - * - * @author Jeongho Nam - */ - class Packer extends protocol.Entity { - /** - * Candidate wrappers who can contain instances. - */ - protected wrapperArray: WrapperArray; - /** - * Instances trying to pack into the wrapper. - */ - protected instanceArray: InstanceArray; - /** - * Default Constructor. - */ - constructor(); - /** - * Construct from members. - * - * @param wrapperArray Candidate wrappers who can contain instances. - * @param instanceArray Instances to be packed into some wrappers. - */ - constructor(wrapperArray: WrapperArray, instanceArray: InstanceArray); - /** - * @inheritdoc - */ - construct(xml: library.XML): void; - /** - * Get wrapperArray. - */ - getWrapperArray(): WrapperArray; - /** - * Get instanceArray. - */ - getInstanceArray(): InstanceArray; - /** - *

      Deduct - * - */ - optimize(): WrapperArray; - /** - * @brief Initialize sequence list (gene_array). - * - * @details - *

      Deducts initial sequence list by such assumption:

      - * - *
        - *
      • Cost of larger wrapper is less than smaller one, within framework of price per volume unit.
      • - *
          - *
        • Wrapper Larger: (price: $1,000, volume: 100cm^3 -> price per volume unit: $10 / cm^3)
        • - *
        • Wrapper Smaller: (price: $700, volume: 50cm^3 -> price per volume unit: $14 / cm^3)
        • - *
        • Larger's cost is less than Smaller, within framework of price per volume unit
        • - *
        - *
      - * - *

      Method {@link initGenes initGenes()} constructs {@link WrapperGroup WrapperGroups} corresponding - * with the {@link wrapperArray} and allocates {@link instanceArray instances} to a {@link WrapperGroup}, - * has the smallest cost between containbles.

      - * - *

      After executing packing solution by {@link WrapperGroup.optimize WrapperGroup.optimize()}, trying to - * {@link repack re-pack} each {@link WrapperGroup} to another type of {@link Wrapper}, deducts the best - * solution between them. It's the initial sequence list of genetic algorithm.

      - * - * @return Initial sequence list. - */ - protected initGenes(): GAWrapperArray; - /** - * Try to repack each wrappers to another type. - * - * @param $wrappers Wrappers to repack. - * @return Re-packed wrappers. - */ - protected repack($wrappers: WrapperArray): WrapperArray; - /** - * @inheritdoc - */ - TAG(): string; - /** - * @inheritdoc - */ - toXML(): library.XML; - } -} -declare namespace bws.packer { - /** - * A product. - * - * @author Jeongho Nam - */ - class Product extends protocol.Entity implements Instance { - /** - *

      Name, key of the Product.

      - * - *

      The name must be unique because a name identifies a {@link Product}.

      - */ - protected name: string; - /** - * Width of the Product, length on the X-axis in 3D. - */ - protected width: number; - /** - * Height of the Product, length on the Y-axis in 3D. - */ - protected height: number; - /** - * Length of the Product, length on the Z-axis in 3D. - */ - protected length: number; - /** - * Default Constructor. - */ - constructor(); - /** - * Construct from members. - * - * @param name Name, identifier of the Product. - * @param width Width, length on the X-axis in 3D. - * @param height Height, length on the Y-axis in 3D. - * @param length Length, length on the Z-axis in 3D. - */ - constructor(name: string, width: number, height: number, length: number); - /** - * Key of a Product is its name. - */ - key(): any; - /** - * @inheritdoc - */ - getName(): string; - /** - * @inheritdoc - */ - getWidth(): number; - /** - * @inheritdoc - */ - getHeight(): number; - /** - * @inheritdoc - */ - getLength(): number; - /** - * @inheritdoc - */ - getVolume(): number; - /** - * @inheritdoc - */ - setName(val: string): void; - /** - * @inheritdoc - */ - setWidth(val: number): void; - /** - * @inheritdoc - */ - setHeight(val: number): void; - /** - * @inheritdoc - */ - setLength(val: number): void; - /** - * @inheritdoc - */ - TYPE(): string; - /** - * @inheritdoc - */ - TAG(): string; - /** - * @inheritdoc - */ - toXML(): library.XML; - } -} -declare namespace bws.packer { - /** - *

      Wrap represents an act wrap(ping).

      - * - *

      {@link Wrap} is a class represents an act wrapping an {@link Instance} to an {@link Wrapper}. - * To represent the relationship, Wrap uses Bridge and Capsular patterns to links and intermediates - * relationship between Wrapper and Instance.

      - * - *

      Wrap also helps packing optimization and 3d-visualization with its own members - * {@link orientation} and position variables {@link x}, {@link y} and {@link z}.

      - * - * @author Jeongho Nam - */ - class Wrap extends protocol.Entity { - /** - * A wrapper wrapping the {@link instance}. - */ - protected wrapper: Wrapper; - /** - * An instance wrapped into the {@link wrapper}. - */ - protected instance: Instance; - /** - * Coordinate-X of the instance placement in the wrapper. - */ - protected x: number; - /** - * Coordinate-Y of the instance placement in the wrapper. - */ - protected y: number; - /** - * Coordinate-Z of the instance placement in the wrapper. - */ - protected z: number; - /** - * Placement orientation of wrapped {@link instance}. - */ - protected orientation: number; - /** - * Construct from a Wrapper. - * - * @param wrapper A wrapper who will contain an instance. - */ - constructor(wrapper: Wrapper); - /** - * Construct from a Wrapper and Instance with its position and default orientation 1. - * - * @param wrapper A wrapper who contains the instance. - * @param instance An instance contained into the wrapper. - * @param x Coordinate-X of the {@link instance} placement in the {@link wrapper}. - * @param y Coordinate-Y of the {@link instance} placement in the {@link wrapper}. - * @param z Coordinate-Z of the {@link instance} placement in the {@link wrapper}. - */ - constructor(wrapper: Wrapper, instance: Instance, x: number, y: number, z: number); - /** - * Construct from a Wrapper and Instance with its position and orientation. - * - * @param wrapper A wrapper who contains the instance. - * @param instance An instance contained into the wrapper. - * @param x Coordinate-X of the {@link instance} placement in the {@link wrapper}. - * @param y Coordinate-Y of the {@link instance} placement in the {@link wrapper}. - * @param z Coordinate-Z of the {@link instance} placement in the {@link wrapper}. - * @param orientation Placement orientation of wrapped {@link instance}. - */ - constructor(wrapper: Wrapper, instance: Instance, x: number, y: number, z: number, orientation: number); - /** - * @inheritdoc - */ - construct(xml: library.XML): void; - /** - * Factory method of wrapped Instance. - * - * @param type Type of contained Instance's type. - */ - protected createInstance(type: string): Instance; - /** - * Set orientation. - * - * @param orientation Orientation code (1 to 6). - */ - setOrientation(orientation: number): void; - /** - * Set position. - * - * @param x Coordinate-X of the instance placement in the wrapper. - * @param y Coordinate-Y of the instance placement in the wrapper. - * @param z Coordinate-Z of the instance placement in the wrapper. - */ - setPosition(x: number, y: number, z: number): void; - /** - * @brief Estimate orientation by given size. - * - * @param width Width by placement. - * @param height Height by placement. - * @param length Length by placement. - */ - estimateOrientation(width: number, height: number, length: number): void; - /** - * @brief Orientation change is occured in level of the packer. - * - * @details orientation Packer's new orientation. - */ - changeWrapperOrientation(orientation: number): void; - /** - * Get wrapper. - */ - getWrapper(): Wrapper; - /** - * Get instance. - */ - getInstance(): Instance; - /** - * Get x. - */ - getX(): number; - /** - * Get y. - */ - getY(): number; - /** - * Get z. - */ - getZ(): number; - /** - * Get orientation. - */ - getOrientation(): number; - /** - * Get width. - */ - getLayoutWidth(): number; - /** - * Get height. - */ - getLayoutHeight(): number; - /** - * Get length. - */ - getLength(): number; - /** - * Get volume. - */ - getVolume(): number; - readonly $instanceName: string; - readonly $layoutScale: string; - readonly $position: string; - /** - * @inheritdoc - */ - TAG(): string; - /** - * @inheritdoc - */ - toXML(): library.XML; - } -} -declare namespace bws.packer { - /** - * A wrapper wrapping instances. - * - * @author Jeongho Nam - */ - class Wrapper extends protocol.EntityDeque implements Instance { - /** - *

      Name, key of the Wrapper.

      - * - *

      The name represents a type of Wrapper and identifies the Wrapper.

      - */ - protected name: string; - /** - * Price, cost of using an Wrapper. - */ - protected price: number; - /** - * Width of the Wrapper, length on the X-axis in 3D. - */ - protected width: number; - /** - * Height of the Wrapper, length on the Y-axis in 3D. - */ - protected height: number; - /** - * Length of the Wrapper, length on the Z-axis in 3D. - */ - protected length: number; - /** - *

      Thickness, margin of a Wrapper causes shrinkness of containable volume.

      - * - *

      The thickness reduces each dimension's containable size (dimension - 2*thickness), - * so finally, it reduces total containable volume (-8 * thickness^3).

      - */ - protected thickness: number; - /** - * Default Constructor. - */ - constructor(); - /** - * Copy Constructor. - */ - constructor(wrapper: Wrapper); - /** - * Construct from members. - * - * @param name Name, identifier of a Wrapper. - * @param price Price, issued cost for a type of the Wrapper. - * @param width Width, dimensional length on the X-axis in 3D. - * @param height Height, dimensional length on the Y-axis in 3D. - * @param length Length, dimensional length on the Z-axis in 3D. - * @param thickness A thickness causes shrinkness on containable volume. - */ - constructor(name: string, price: number, width: number, height: number, length: number, thickness: number); - /** - * @inheritdoc - */ - createChild(xml: library.XML): Wrap; - /** - * Key of a Wrapper is its name. - */ - key(): any; - /** - * Get name. - */ - getName(): string; - /** - * Get price. - */ - getPrice(): number; - /** - * Get width, length on X-axis in 3D. - */ - getWidth(): number; - /** - * Get height, length on Y-axis in 3D. - */ - getHeight(): number; - /** - * Get length, length on Z-axis in 3D. - */ - getLength(): number; - /** - * Get thickness. - */ - getThickness(): number; - /** - *

      Get (calculate) containable width, length on the X-axis in 3D.

      - * - *

      Calculates containable width considering the {@link thickness}.

      - * - * @return width - (2 x thickness) - */ - getContainableWidth(): number; - /** - *

      Get (calculate) containable height, length on the Y-axis in 3D.

      - * - *

      Calculates containable height considering the {@link thickness}.

      - * - * @return height - (2 x thickness) - */ - getContainableHeight(): number; - /** - *

      Get (calculate) containable length, length on the Z-axis in 3D.

      - * - *

      Calculates containable length considering the {@link thickness}.

      - * - * @return length - (2 x thickness) - */ - getContainableLength(): number; - /** - *

      Get (calculate) volume.

      - * - *

      Notice

      - *

      If {@link thickness} of the Wrapper is not 0, the volume does not mean containable volume. - * In that case, use {@link containableVolume} instead.

      - * - * @return width x height x length - */ - getVolume(): number; - /** - *

      Get (calculate) containable volume.

      - * - *

      Calculates containable volume considering the {@link thickness}.

      - * - * @return volume - {(2 x thickness) ^ 3} - */ - getContainableVolume(): number; - /** - * Get utilization ratio of containable volume. - * - * @return utilization ratio. - */ - getUtilization(): number; - equals(obj: Wrapper): boolean; - /** - *

      Wrapper is enough greater?

      - * - *

      Test whether the Wrapper is enough greater than an Instance to contain.

      - * - * @param instance An Instance to test. - * @return Enough greater or not. - */ - containable(instance: Instance): boolean; - /** - * @inheritdoc - */ - setName(val: string): void; - /** - * Set price. - */ - setPrice(val: number): void; - /** - * @inheritdoc - */ - setWidth(val: number): void; - /** - * @inheritdoc - */ - setHeight(val: number): void; - /** - * @inheritdoc - */ - setLength(val: number): void; - /** - * Set thickness. - */ - setThickness(val: number): void; - $name: string; - $price: string; - $width: string; - $height: string; - $length: string; - $thickness: string; - readonly $scale: string; - readonly $spaceUtilization: string; - /** - * @inheritdoc - */ - TYPE(): string; - /** - * @inheritdoc - */ - TAG(): string; - /** - * @inheritdoc - */ - CHILD_TAG(): string; - /** - * @inheritdoc - */ - toXML(): library.XML; - } -} -declare namespace bws.packer { - /** - * A group of {@link Wrapper Wrappers} with same type. - * - * @author Jeongho Nam - */ - class WrapperGroup extends WrapperArray { - /** - *

      A sample, standard of the WrapperGroup.

      - * - *

      The sample represents what type of Wrappers are grouped into the WrapperGroup.

      - */ - protected sample: Wrapper; - /** - * Allocated instances. - */ - protected allocatedInstanceArray: InstanceArray; - /** - * Default Constructor. - */ - constructor(); - /** - * Copy Constructor. - */ - constructor(wrapperGroup: WrapperGroup); - /** - * Construct from a sample. - * - * @param sample A sample, standard of the WrapperGroup. - */ - constructor(sample: Wrapper); - /** - * Construct from members of the {@link sample}. - * - * @param name Name, identifier of the sample. - * @param price Price, issued cost for a type of the sample. - * @param width Width, dimensional length on the X-axis in 3D, of the sample. - * @param height Height, dimensional length on the Y-axis in 3D, of the sample. - * @param length Length, dimensional length on the Z-axis in 3D, of the sample. - * @param thickness A thickness, causes shrinkness on containable volume, of the sample. - */ - constructor(name: string, price: number, width: number, height: number, length: number, thickness: number); - /** - * Key of a WrapperGroup is dependent on its sample. - */ - key(): any; - /** - * Get sample. - */ - getSample(): Wrapper; - /** - * Get allocated instances. - */ - getAllocatedInstanceArray(): InstanceArray; - /** - * Get (calculate) price. - * - * @return (Price of the sample) x (numbers of children Wrappers) - */ - getPrice(): number; - /** - * @inheritdoc - */ - getUtilization(): number; - /** - *

      Allocate instance(s) to the WrapperGroup.

      - * - *

      Inspect the instance is enough small to be wrapped into an empty wrapper. If the instance - * is enough small, registers the instance (or repeated instances) to the {@link reserveds} and - * returns true. If the instance is too large to be capsuled, returns false.

      - * - *

      Note

      - *

      The word the instance is enough small to be wrapped into the empty wrapper means - * the instance can be contained into an empty, a new wrapper contaning nothing literally.

      - * - *

      In the method allocate(), it doesn't consider how many instances are wrapped into ordinary - * wrapper and how much volumes are consumed.

      - * - * @param instance An Instance to allocate. - * @param n Repeating number of the instance. - * - * @return Whether the instance is enough small to be wrapped into a (new) wrapper - * of same type with the sample. - */ - allocate(instance: Instance, n?: number): boolean; - /** - *

      Run optimization in level of the group.

      - * - *

      The optimization routine begins by creating a {@link Wrapper} like the {@link sample}. Then - * try to pack {@link allocatedInstanceArray allocated instances} to the {@link Wrapper} as a lot as - * possible. If there're some {@link Wrappers} can't be packed by overloading, then create a new - * {@link Wrapper} again and try to pack {@link allocatedInstanceArray instances} again, too.

      - * - *

      Repeats those steps until all {@link alloctedInstanceArray instances} are {@link Wrap packed} - * so that there's not any {@link Instance instance} left.

      - * - *

      Warning

      - *

      When call this {@link optimize optimize()} method, ordinary children {@link Wrapper} objects - * in the {@link WrapperGroup} will be substituted with the newly optimized {@link Wrapper} objects.

      - */ - optimize(): void; - /** - *

      Wrap allocated instances into a new {@link Wrapper}.

      - * - *

      {@link Wrap Wraps} instances to a new Wrapper which is copied from the sample.

      - *

      After the wrapping is done, the new {@link Wrapper} is registered to the {@link WrapperGroup} - * as a child and instances failed to wrap by overloading is returned.

      - * - * @param instanceArray instances to {@link Wrap wrap} into a new {@link Wrapper}. - * - * @return Instances failed to {@link Wrap wrap} by overloading. - * @see boxologic - */ - private pack(instanceArray); - /** - * @inheritdoc - */ - TAG(): string; - } -} diff --git a/types/3d-bin-packing/tsconfig.json b/types/3d-bin-packing/tsconfig.json deleted file mode 100644 index 18e4645ac9..0000000000 --- a/types/3d-bin-packing/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "3d-bin-packing-tests.ts" - ] -} \ No newline at end of file diff --git a/types/abbrev/abbrev-tests.ts b/types/abbrev/abbrev-tests.ts new file mode 100644 index 0000000000..b4f892e9e3 --- /dev/null +++ b/types/abbrev/abbrev-tests.ts @@ -0,0 +1,13 @@ +import abbrev = require('abbrev'); + +let abbrs: { [abbreviation: string]: string; }; +abbrs = abbrev(); +abbrs = abbrev('foo', 'fool', 'folding', 'flop'); +abbrs = abbrev(['foo', 'fool', 'folding', 'flop']); + +abbrev.monkeyPatch(); + +abbrs = [].abbrev(); +const roArr: ReadonlyArray = []; +abbrs = roArr.abbrev(); +abbrs = ({}).abbrev(); diff --git a/types/abbrev/index.d.ts b/types/abbrev/index.d.ts new file mode 100644 index 0000000000..0d55334d3f --- /dev/null +++ b/types/abbrev/index.d.ts @@ -0,0 +1,27 @@ +// Type definitions for abbrev 1.1 +// Project: https://github.com/isaacs/abbrev-js#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = abbrev; + +declare function abbrev(words: string[]): {[abbreviation: string]: string}; +declare function abbrev(...words: string[]): {[abbreviation: string]: string}; + +declare namespace abbrev { + function monkeyPatch(): void; +} + +declare global { + interface Array { + abbrev(): {[abbreviation: string]: string}; + } + + interface ReadonlyArray { + abbrev(): {[abbreviation: string]: string}; + } + + interface Object { + abbrev(): {[abbreviation: string]: string}; + } +} diff --git a/types/abbrev/tsconfig.json b/types/abbrev/tsconfig.json new file mode 100644 index 0000000000..95c20ed32a --- /dev/null +++ b/types/abbrev/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "abbrev-tests.ts" + ] +} diff --git a/types/raw-body/tslint.json b/types/abbrev/tslint.json similarity index 100% rename from types/raw-body/tslint.json rename to types/abbrev/tslint.json diff --git a/types/ably/index.d.ts b/types/ably/index.d.ts index 7bfc2338b6..3a150257ba 100644 --- a/types/ably/index.d.ts +++ b/types/ably/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Ably Realtime and Rest client library 0.9 // Project: https://www.ably.io/ -// Definitions by: Ably +// Definitions by: Ably // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export namespace ablyLib { @@ -287,7 +287,7 @@ export namespace ablyLib { } // Common Listeners - type paginatedResultCallback = (error: ErrorInfo, results: PaginatedResult ) => void; + type paginatedResultCallback = (error: ErrorInfo, results: PaginatedResult) => void; type standardCallback = (error: ErrorInfo, results: any) => void; type messageCallback = (message: T) => void; type errorCallback = (error: ErrorInfo) => void; @@ -410,7 +410,7 @@ export namespace ablyLib { state: ConnectionState; close: () => void; connect: () => void; - ping: (callback?: (error: ErrorInfo, responseTime: number ) => void ) => void; + ping: (callback?: (error: ErrorInfo, responseTime: number) => void) => void; } class Stats { diff --git a/types/ably/tslint.json b/types/ably/tslint.json index 3db14f85ea..d9d49e375e 100644 --- a/types/ably/tslint.json +++ b/types/ably/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-any-union": false + } +} diff --git a/types/accounting/index.d.ts b/types/accounting/index.d.ts index 9a990a6519..8a9feca611 100644 --- a/types/accounting/index.d.ts +++ b/types/accounting/index.d.ts @@ -1,7 +1,7 @@ // Type definitions for accounting.js 0.4 // Project: http://openexchangerates.github.io/accounting.js/ -// Definitions by: Sergey Gerasimov -// Christopher Eck +// Definitions by: Sergey Gerasimov +// Christopher Eck // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace accounting { diff --git a/types/acl/index.d.ts b/types/acl/index.d.ts index 3aa81de8e3..43de3f5369 100644 --- a/types/acl/index.d.ts +++ b/types/acl/index.d.ts @@ -50,7 +50,10 @@ interface Acl { allowedPermissions: (userId: Value, resources: strings, cb?: AnyCallback) => Promise; isAllowed: (userId: Value, resources: strings, permissions: strings, cb?: AllowedCallback) => Promise; areAnyRolesAllowed: (roles: strings, resource: strings, permissions: strings, cb?: AllowedCallback) => Promise; - whatResources: (roles: strings, permissions: strings, cb?: AnyCallback) => Promise; + whatResources: { + (roles: strings, cb?: AnyCallback): Promise; + (roles: strings, permissions: strings, cb?: AnyCallback): Promise; + } permittedResources: (roles: strings, permissions: strings, cb?: Function) => Promise; middleware: (numPathComponents?: number, userId?: Value | GetUserId, actions?: strings) => express.RequestHandler; } diff --git a/types/acl/test/index.ts b/types/acl/test/index.ts index c29574326d..bb3e6fa54e 100644 --- a/types/acl/test/index.ts +++ b/types/acl/test/index.ts @@ -66,6 +66,18 @@ acl.isAllowed('joed', 'blogs', 'view', (err, res) => { } }); +acl.whatResources('foo', (err, res) => { + if (res) { + console.log(res); + } +}); + +acl.whatResources('foo', 'view', (err, res) => { + if (res) { + console.log(res); + } +}); + acl.isAllowed('jsmith', 'blogs', ['edit','view','delete']) .then((result) => { console.dir('jsmith is allowed blogs ' + result); diff --git a/types/activex-adodb/activex-adodb-tests.ts b/types/activex-adodb/activex-adodb-tests.ts index cadb01c15e..22680d963c 100644 --- a/types/activex-adodb/activex-adodb-tests.ts +++ b/types/activex-adodb/activex-adodb-tests.ts @@ -14,9 +14,7 @@ let obj5 = new ActiveXObject('ADODB.Stream'); let pathToExcelFile = 'C:\\path\\to\\excel\\file.xlsx'; let conn = new ActiveXObject('ADODB.Connection'); conn.Provider = 'Microsoft.ACE.OLEDB.12.0'; -conn.ConnectionString = - 'Data Source="' + pathToExcelFile + '";' + - 'Extended Properties="Excel 12.0;HDR=Yes"'; +conn.ConnectionString = `Data Source="${pathToExcelFile}";Extended Properties="Excel 12.0;HDR=Yes"`; conn.Open(); // create a Command to access the data diff --git a/types/activex-adodb/package.json b/types/activex-adodb/package.json index d798f99261..d9b1031263 100644 --- a/types/activex-adodb/package.json +++ b/types/activex-adodb/package.json @@ -1 +1,6 @@ -{ "dependencies": { "activex-helpers": "*"}} \ No newline at end of file +{ + "private": true, + "dependencies": { + "activex-helpers": "*" + } +} \ No newline at end of file diff --git a/types/activex-adodb/tsconfig.json b/types/activex-adodb/tsconfig.json index 484faf1ed0..81c6088e56 100644 --- a/types/activex-adodb/tsconfig.json +++ b/types/activex-adodb/tsconfig.json @@ -6,7 +6,6 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, - "strict": true, "baseUrl": "../", "typeRoots": [ "../" diff --git a/types/activex-scripting/activex-scripting-tests.ts b/types/activex-scripting/activex-scripting-tests.ts index cc14a421ff..2297548b81 100644 --- a/types/activex-scripting/activex-scripting-tests.ts +++ b/types/activex-scripting/activex-scripting-tests.ts @@ -1,7 +1,7 @@ // source -- https://msdn.microsoft.com/en-us/library/ebkhfaaz.aspx // Generates a string describing the drive type of a given Drive object. -let showDriveType = (drive: Scripting.Drive) => { +function showDriveType(drive: Scripting.Drive) { switch (drive.DriveType) { case Scripting.DriveTypeConst.Removable: return 'Removeable'; @@ -16,15 +16,15 @@ let showDriveType = (drive: Scripting.Drive) => { default: return 'Unknown'; } -}; +} // Generates a string describing the attributes of a file or folder. -let showFileAttributes = (file: Scripting.File) => { - let attr = file.Attributes; +function showFileAttributes(file: Scripting.File) { + const attr = file.Attributes; if (attr === 0) { return 'Normal'; } - let attributeStrings: string[] = []; + const attributeStrings: string[] = []; if (attr & Scripting.FileAttribute.Directory) { attributeStrings.push('Directory'); } if (attr & Scripting.FileAttribute.ReadOnly) { attributeStrings.push('Read-only'); } if (attr & Scripting.FileAttribute.Hidden) { attributeStrings.push('Hidden'); } @@ -34,22 +34,22 @@ let showFileAttributes = (file: Scripting.File) => { if (attr & Scripting.FileAttribute.Alias) { attributeStrings.push('Alias'); } if (attr & Scripting.FileAttribute.Compressed) { attributeStrings.push('Compressed'); } return attributeStrings.join(','); -}; +} // source --https://msdn.microsoft.com/en-us/library/ts2t8ybh(v=vs.84).aspx -let showFreeSpace = (drvPath: string) => { - let fso = new ActiveXObject('Scripting.FileSystemObject'); - let d = fso.GetDrive(fso.GetDriveName(drvPath)); - let s = 'Drive ' + drvPath + ' - '; +function showFreeSpace(drvPath: string) { + const fso = new ActiveXObject('Scripting.FileSystemObject'); + const d = fso.GetDrive(fso.GetDriveName(drvPath)); + let s = `Drive ${drvPath} - `; s += d.VolumeName + '
      '; - s += 'Free Space: ' + d.FreeSpace / 1024 + ' Kbytes'; + s += `Free Space: ${d.FreeSpace / 1024} Kbytes`; return (s); -}; +} // source -- https://msdn.microsoft.com/en-us/library/kaf6yaft(v=vs.84).aspx -let getALine = (filespec: string) => { - let fso = new ActiveXObject('Scripting.FileSystemObject'); - let file = fso.OpenTextFile(filespec, Scripting.IOMode.ForReading, false); +function getALine(filespec: string) { + const fso = new ActiveXObject('Scripting.FileSystemObject'); + const file = fso.OpenTextFile(filespec, Scripting.IOMode.ForReading, false); let s = ''; while (!file.AtEndOfLine) { @@ -57,4 +57,4 @@ let getALine = (filespec: string) => { } file.Close(); return (s); -}; +} diff --git a/types/activex-scripting/package.json b/types/activex-scripting/package.json index d798f99261..d9b1031263 100644 --- a/types/activex-scripting/package.json +++ b/types/activex-scripting/package.json @@ -1 +1,6 @@ -{ "dependencies": { "activex-helpers": "*"}} \ No newline at end of file +{ + "private": true, + "dependencies": { + "activex-helpers": "*" + } +} \ No newline at end of file diff --git a/types/activex-scripting/tsconfig.json b/types/activex-scripting/tsconfig.json index 190e7bdcd6..e237423341 100644 --- a/types/activex-scripting/tsconfig.json +++ b/types/activex-scripting/tsconfig.json @@ -6,7 +6,6 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, - "strict": true, "baseUrl": "../", "typeRoots": [ "../" diff --git a/types/activex-wia/activex-wia-tests.ts b/types/activex-wia/activex-wia-tests.ts index 8384291f5d..d8046ef319 100644 --- a/types/activex-wia/activex-wia-tests.ts +++ b/types/activex-wia/activex-wia-tests.ts @@ -7,7 +7,7 @@ let img = commonDialog.ShowAcquireImage(); // when DefinitelyTyped supports Typescript 2.4 -- end of July 2017, replace these: let jpegFormatID = '{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}'; if (img.FormatID !== jpegFormatID) { - let ip = new ActiveXObject('WIA.ImageProcess'); + const ip = new ActiveXObject('WIA.ImageProcess'); ip.Filters.Add(ip.FilterInfos.Item('Convert').FilterID); ip.Filters.Item(1).Properties.Item('FormatID').Value = jpegFormatID; img = ip.Apply(img); @@ -24,8 +24,8 @@ if (img.FormatID !== jpegFormatID) { let dev = commonDialog.ShowSelectDevice(); if (dev.Type === WIA.WiaDeviceType.CameraDeviceType) { // when DefinitelyTyped supports Typescript 2.4 -- end of July 2017, replace these: - let commandID = '{AF933CAC-ACAD-11D2-A093-00C04F72DC3C}'; - let itm = dev.ExecuteCommand(commandID); + const commandID = '{AF933CAC-ACAD-11D2-A093-00C04F72DC3C}'; + const itm = dev.ExecuteCommand(commandID); // with this: // let itm = dev.ExecuteCommand(WIA.CommandID.wiaCommandTakePicture); @@ -36,15 +36,15 @@ dev = commonDialog.ShowSelectDevice(); let e = new Enumerator(dev.Properties); // no foreach over ActiveX collections e.moveFirst(); while (!e.atEnd()) { - let p = e.item(); - let s = p.Name + ' (' + p.PropertyID + ') = '; + const p = e.item(); + let s = `${p.Name} (${p.PropertyID}) = `; if (p.IsVector) { s += '[vector of data]'; } else { s += p.Value; if (p.SubType !== WIA.WiaSubType.UnspecifiedSubType) { if (p.Value !== p.SubTypeDefault) { - s += ' (Default = ' + p.SubTypeDefault + ')'; + s += ` (Default = ${p.SubTypeDefault})`; } } } @@ -60,7 +60,7 @@ while (!e.atEnd()) { } else { s += ' [valid values include: '; } - let count = p.SubTypeValues.Count; + const count = p.SubTypeValues.Count; for (let i = 1; i <= count; i++) { s += p.SubTypeValues.Item(i); if (i < count) { @@ -70,7 +70,7 @@ while (!e.atEnd()) { s += ']'; break; case WIA.WiaSubType.RangeSubType: - s += ' [valid values in the range from ' + p.SubTypeMin + ' to ' + p.SubTypeMax + ' in increments of ' + p.SubTypeStep + ']'; + s += ` [valid values in the range from ${p.SubTypeMin} to ${p.SubTypeMax} in increments of ${p.SubTypeStep}]`; break; } } diff --git a/types/activex-wia/package.json b/types/activex-wia/package.json index d798f99261..d9b1031263 100644 --- a/types/activex-wia/package.json +++ b/types/activex-wia/package.json @@ -1 +1,6 @@ -{ "dependencies": { "activex-helpers": "*"}} \ No newline at end of file +{ + "private": true, + "dependencies": { + "activex-helpers": "*" + } +} \ No newline at end of file diff --git a/types/activex-wia/tsconfig.json b/types/activex-wia/tsconfig.json index b06917d12c..b98459223d 100644 --- a/types/activex-wia/tsconfig.json +++ b/types/activex-wia/tsconfig.json @@ -6,7 +6,6 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, - "strict": true, "baseUrl": "../", "typeRoots": [ "../" diff --git a/types/adal/index.d.ts b/types/adal/index.d.ts index 2150716b17..43655efbbb 100644 --- a/types/adal/index.d.ts +++ b/types/adal/index.d.ts @@ -31,6 +31,8 @@ declare namespace adal { resource?: string; extraQueryParameter?: string; navigateToLoginRequestUrl?: boolean; + logOutUri?: string; + isAngular?: boolean; } interface User { diff --git a/types/adone/adone-tests.ts b/types/adone/adone-tests.ts new file mode 100644 index 0000000000..861660ee89 --- /dev/null +++ b/types/adone/adone-tests.ts @@ -0,0 +1,3 @@ +// Actual tests inside ./test/ + +const a: string = adone.ok; diff --git a/types/adone/adone.d.ts b/types/adone/adone.d.ts new file mode 100644 index 0000000000..a4f102752c --- /dev/null +++ b/types/adone/adone.d.ts @@ -0,0 +1,85 @@ +/// + +declare const _null: symbol; +export { _null as null }; +export function noop(): void; +export function identity(x: T): T; +export function truly(): true; +export function falsely(): false; +export const ok: "OK"; +export const bad: "BAD"; +export const exts: [".js", ".tjs", ".ajs"]; +export function log(...args: any[]): void; +export function fatal(...args: any[]): void; +export function error(...args: any[]): void; +export function warn(...args: any[]): void; +export function info(...args: any[]): void; +export function debug(...args: any[]): void; +export function trace(...args: any[]): void; +export function o(...props: any[]): object; +export const Date: typeof global.Date; +export const hrtime: typeof global.process.hrtime; +export const setTimeout: typeof global.setTimeout; +export const setInterval: typeof global.setInterval; +export const setImmediate: typeof global.setImmediate; +export const clearTimeout: typeof global.clearTimeout; +export const clearInterval: typeof global.clearInterval; +export const clearImmediate: typeof global.clearImmediate; +interface LazifyOptions { + configurable: boolean; +} +export function lazify(modules: object, obj?: object, require?: (path: string) => any, options?: LazifyOptions): object; +interface Tag { + set(Class: object, tag: string): void; + has(obj: object, tag: string): boolean; + define(tag: string, predicate?: string): void; + SUBSYSTEM: symbol; + APPLICATION: symbol; + TRANSFORM: symbol; + CORE_STREAM: symbol; + LOGGER: symbol; + LONG: symbol; + BIGNUMBER: symbol; + EXBUFFER: symbol; + EXDATE: symbol; + CONFIGURATION: symbol; + GENESIS_NETRON: symbol; + GENESIS_PEER: symbol; + NETRON: symbol; + NETRON_PEER: symbol; + NETRON_ADAPTER: symbol; + NETRON_DEFINITION: symbol; + NETRON_DEFINITIONS: symbol; + NETRON_REFERENCE: symbol; + NETRON_INTERFACE: symbol; + NETRON_STUB: symbol; + NETRON_REMOTESTUB: symbol; + NETRON_STREAM: symbol; + FAST_STREAM: symbol; + FAST_FS_STREAM: symbol; + FAST_FS_MAP_STREAM: symbol; +} +export const tag: Tag; +export function run(App: object, ignoreArgs?: boolean): Promise; +export function bind(libName: string): object; +export function getAssetAbsolutePath(relPath: string): string; +export function loadAsset(relPath: string): string | Buffer; +export function require(path: string): object; +export const package: object; + +import * as std from "./glosses/std"; +export { std }; + +export * from "./glosses/common"; +export * from "./glosses/math"; +export * from "./glosses/utils"; +export * from "./glosses/assertion"; +export * from "./glosses/promise"; +export * from "./glosses/shani"; + +import "./glosses/shani-global"; + +export const assert: adone.assertion.I.AssertFunction; +export const expect: adone.assertion.I.ExpectFunction; + +export as namespace adone; diff --git a/types/adone/glosses/assertion.d.ts b/types/adone/glosses/assertion.d.ts new file mode 100644 index 0000000000..4e8bfc593a --- /dev/null +++ b/types/adone/glosses/assertion.d.ts @@ -0,0 +1,1074 @@ +import adone from "adone"; + +/** + * assertion functions + */ +export namespace assertion { + namespace I { + interface assertion { + AssertionError: AssertionError; + config: Config; + use: UseFunction; + loadMockInterface: LoadInterfaceFunction; + loadExpectInterface: LoadInterfaceFunction; + loadAssertInterface: LoadInterfaceFunction; + assert: AssertFunction; + expect: ExpectFunction; + } + + interface Config { + /** + * Include stack in Assertion error message + */ + includeStack: boolean; + /** + * Include `showDiff` flag in the thrown errors + */ + showDiff: boolean; + /** + * Length threshold for actual and expected values in assertion errors + */ + truncateThreshold: number; + /** + * use Proxy to throw an error when a non-existent property is read + */ + useProxy: boolean; + /** + * properties that should be ignored instead of throwing an error if they do not exist on the assertion + */ + proxyExcludedKeys: string[]; + } + + type PossibleTypes = adone.util.I.PossibleTypes | "array"; + + type UseFunction = (fn: () => void) => assertion; + + type LoadInterfaceFunction = () => assertion; + + interface AssertFunction { + /** + * Asserts that value is truthy + */ + (value: any, message?: string): void; + /** + * Throws an AssertionError, like node.js + */ + fail(actual?: any, expected?: any, message?: string, operator?: any): void; + /** + * Asserts that value is truthy + */ + isOk(value: any, message?: string): void; + /** + * Asserts that value is truthy + */ + ok(value: any, message?: string): void; + /** + * Asserts that value is falsy + */ + isNotOk(value: any, message?: string): void; + /** + * Asserts that value is falsy + */ + notOk(value: any, message?: string): void; + /** + * Asserts non-strict equality + */ + equal(actual: any, expected: any, message?: string): void; + /** + * Asserts non-strict inequality + */ + notEqual(actual: any, expected: any, message?: string): void; + /** + * Asserts strict equality + */ + strictEqual(actual: any, expected: any, message?: string): void; + /** + * Asserts strict inequality + */ + notStrictEqual(actual: any, expected: any, message?: string): void; + /** + * Asserts that actual is deeply equal to expected + */ + deepEqual(actual: any, expected: any, message?: string): void; + /** + * Asserts that actual is deeply equal to expected + */ + deepStrictEqual(actual: any, expected: any, message?: string): void; + /** + * Asserts that actual and expected have the same length and the same members (===) + */ + equalArrays(actual: any[], expected: any[], message?: string): void; + /** + * Asserts that actual is not deeply equal to expected + */ + notDeepEqual(actual: any, expected: any, message?: string): void; + /** + * Asserts that value > above + */ + isAbove(value: any, above: any, message?: string): void; + /** + * Asserts that value >= atLeast + */ + isAtLeast(value: any, atLeast: any, message?: string): void; + /** + * Asserts that value < below + */ + isBelow(value: any, below: any, message?: string): void; + /** + * Asserts that value <= atMost + */ + isAtMost(value: any, atMost: any, message?: string): void; + /** + * Asserts that value is true + */ + isTrue(value: any, message?: string): void; + /** + * Asserts that value is not true + */ + isNotTrue(value: any, message?: string): void; + /** + * Asserts that value is false + */ + isFalse(value: any, message?: string): void; + /** + * Asserts that value is not false + */ + isNotFalse(value: any, message?: string): void; + /** + * Asserts that value is null + */ + isNull(value: any, message?: string): void; + /** + * Asserts that valus is not null + */ + isNotNull(value: any, message?: string): void; + /** + * Asserts that value is NaN + */ + isNaN(value: any, message?: string): void; + /** + * Asserts that value is not NaN + */ + isNotNaN(value: any, message?: string): void; + /** + * Asserts that value is neither null nor undefined + */ + exists(value: any, message?: string): void; + /** + * Asserts that value is either null or undefined + */ + notExists(value: any, message?: string): void; + /** + * Asserts that value is undefined + */ + isUndefined(value: any, message?: string): void; + /** + * Asserts that value is not undefined + */ + isDefined(value: any, message?: string): void; + /** + * Asserts that value is a function + */ + isFunction(value: any, message?: string): void; + /** + * Asserts that value is not a function + */ + isNotFunction(value: any, message?: string): void; + /** + * Asserts that value is an object of type Object + */ + isObject(value: any, message?: string): void; + /** + * Asserts that value is not an object of type Object + */ + isNotObject(value: any, message?: string): void; + /** + * Asserts that value is an array + */ + isArray(value: any, message?: string): void; + /** + * Asserts that value is not an array + */ + isNotArray(value: any, message?: string): void; + /** + * Asserts that value is a string + */ + isString(value: any, message?: string): void; + /** + * Asserts that value is not a string + */ + isNotString(value: any, message?: string): void; + /** + * Asserts that value is a number + */ + isNumber(value: any, message?: string): void; + /** + * Asserts that value is not a number + */ + isNotNumber(value: any, message?: string): void; + /** + * Asserts that value is a finite number + */ + isFinite(value: any, message?: string): void; + /** + * Asserts that value is a boolean + */ + isBoolean(value: any, message?: string): void; + /** + * Asserts that value is not a boolean + */ + isNotBoolean(value: any, message?: string): void; + /** + * Asserts that value's type is `type` + */ + typeOf(value: any, type: I.PossibleTypes, message?: string): void; + typeOf(value: any, type: string, message?: string): void; + /** + * Assert that value's type is not `type` + */ + notTypeOf(value: any, type: I.PossibleTypes, message?: string): void; + notTypeOf(value: any, type: string, message?: string): void; + /** + * Asserts that value is an instance of constructor + */ + instanceOf(value: any, constructor: object, message?: string): void; + /** + * Asserts that value is not an instance of constructor + */ + notInstanceOf(value: any, constructor: object, message?: string): void; + /** + * Asserts that expected includes inc + */ + include(expected: T[], inc: T, message?: string): void; + include(expected: string, inc: string, message?: string): void; + /** + * Asserts that expected does not include inc + */ + notInclude(expected: T[], inc: T, message?: string): void; + notInclude(expected: string, inc: string, message?: string): void; + /** + * Asserts that expected includes inc + */ + deepInclude(expected: T[], inc: T, message?: string): void; + deepInclude(expected: string, inc: string, message?: string): void; + /** + * Asserts that expected does not include inc + */ + notDeepInclude(expected: T[], inc: T, message?: string): void; + notDeepInclude(expected: string, inc: string, message?: string): void; + /** + * Asserts that expected includes inc + */ + nestedInclude(expected: object, inc: object, message?: string): void; + /** + * Asserts that expected does not include inc + */ + notNestedInclude(expected: object, inc: object, message?: string): void; + /** + * Assert that expected includes inc + */ + deepNestedInclude(expected: object, inc: object, message?: string): void; + /** + * Assert that expected includes inc + */ + notDeepNestedInclude(expected: object, inc: object, message?: string): void; + /** + * Assert that expected includes inc + */ + ownInclude(expected: object, inc: object, message?: string): void; + /** + * Assert that expected does not include inc + */ + notOwnInclude(expected: object, inc: object, message?: string): void; + /** + * Assert that expected includes inc + */ + deepOwnInclude(expected: object, inc: object, message?: string): void; + /** + * Assert that expected does not include inc + */ + notDeepOwnInclude(expected: object, inc: object, message?: string): void; + /** + * Asserts that expected matches the regular expression regExp + */ + match(expected: any, regExp: RegExp, message?: string): void; + /** + * Asserts that expected does not match the regular expression regExp + */ + notMatch(expected: any, regExp: RegExp, message?: string): void; + /** + * Asserts that object has a property named `property` + */ + property(object: object, property: string, message?: string): void; + /** + * Asserts that object does not have a property named `property` + */ + notProperty(object: object, property: string, message?: string): void; + /** + * Asserts that object has a property named `property` with value `value` (===) + */ + propertyVal(object: object, property: string, value: any, message?: string): void; + /** + * Asserts that object does not have a property named `property` with value `value` (===) + */ + notPropertyVal(object: object, property: string, value: any, message?: string): void; + /** + * Asserts that object has a property named `property` with a value `value` + */ + deepPropertyVal(object: object, property: string, value: any, message?: string): void; + /** + * Asserts that object does not have a property named `property` with value `value` + */ + notDeepPropertyVal(object: object, property: string, value: any, message?: string): void; + /** + * Asserts that object has an owned property named `property` + */ + ownProperty(object: object, property: string, message?: string): void; + /** + * Asserts that object does not have an owned property named `property` + */ + notOwnProperty(object: object, property: string, message?: string): void; + /** + * Asserts that object has an owned property named `property` with value `value`(===) + */ + ownPropertyVal(object: object, property: string, value: any, message?: string): void; + /** + * Asserts that object does not have an owned property named `property` with value `value`(===) + */ + notOwnPropertyVal(object: object, property: string, value: any, message?: string): void; + /** + * Asserts that object has an owned property named `property` with value `value` + */ + deepOwnPropertyVal(object: object, property: string, value: any, message?: string): void; + /** + * Asserts that object does not have an owned property named `property` with value `value`(===) + */ + notDeepOwnPropertyVal(object: object, property: string, value: any, message?: string): void; + /** + * Asserts that object has a property named `property` + */ + nestedProperty(object: object, property: string, message?: string): void; + /** + * Asserts that object does not have a property named `property` + */ + notNestedProperty(object: object, property: string, message?: string): void; + /** + * Asserts that object has a property named `property` with value `value`(===) + */ + nestedPropertyVal(object: object, property: string, value: any, message?: string): void; + /** + * Asserts that object does not have a property named `property` with value `value`(===) + */ + notNestedPropertyVal(object: object, property: string, value: any, message?: string): void; + /** + * Asserts that object has a property named `property` with value `value` + */ + deepNestedPropertyVal(object: object, property: string, value: any, message?: string): void; + /** + * Asserts that object does not have a property named `property` with value `value` + */ + notDeepNestedPropertyVal(object: object, property: string, value: any, message?: string): void; + /** + * Asserts that expected has a length property with value `length` + */ + lengthOf(expected: any, length: number, message?: string): void; + /** + * Asserts that object has at least one key from `keys` + */ + hasAnyKeys(object: object, keys: string | string[] | object, message?: string): void; + /** + * Asserts that object has all and only all of the keys provided + */ + hasAllKeys(object: object, keys: string | string[] | object, message?: string): void; + /** + * Asserts that object has all the keys provided but maybe more + */ + containsAllKeys(object: object, keys: string | string[] | object, message?: string): void; + /** + * Asserts that object does not have any provided key + */ + doesNotHaveAnyKeys(object: object, keys: string | string[] | object, message?: string): void; + /** + * Asserts that object does not have all the keys provided + */ + doesNotHaveAllKeys(object: object, keys: string | string[] | object, message?: string): void; + /** + * Asserts that object has at least one of the keys provided + */ + hasAnyDeepKeys(object: object, keys: string | string[] | object, message?: string): void; + /** + * Asserts that object has all and only all of the keys provided + */ + hasAllDeepKeys(object: object, keys: string | string[] | object, message?: string): void; + /** + * Asserts that object has all the keys provided but maybe more + */ + containsAllDeepKeys(object: object, keys: string | string[] | object, message?: string): void; + /** + * Asserts that object does not have any provided key + */ + doesNotHaveAnyDeepKeys(object: object, keys: string | string[] | object, message?: string): void; + /** + * Asserts that object does not have all the keys provided + */ + doesNotHaveAllDeepKeys(object: object, keys: string | string[] | object, message?: string): void; + /** + * Asserts that a function or an async functions throws an error + */ + throws(fn: () => void, errorLike?: object, errMsgMatcher?: string | RegExp, message?: string): any; + throws(fn: () => Promise, errorLike?: object, errMsgMatcher?: string | RegExp, message?: string): Promise; + /** + * Asserts that a function or an async functions throws an error + */ + throw(fn: () => void, errorLike?: object, errMsgMatcher?: string | RegExp, message?: string): any; + throw(fn: () => Promise, errorLike?: object, errMsgMatcher?: string | RegExp, message?: string): Promise; + /** + * Asserts that a function or an async function does not throw an error + */ + doesNotThrow(fn: () => Promise, errorLike?: object, errMsgMatcher?: string | RegExp, message?: string): Promise; + doesNotThrow(fn: () => void, errorLike?: object, errMsgMatcher?: string | RegExp, message?: string): any; + /** + * Compares two values using operator + */ + operator(value: any, operator: string, val2: any, message?: string): void; + /** + * Asserts that actual is expected +/- delta + */ + closeTo(actual: number, expected: number, delta: number, message?: string): void; + /** + * Asserts that actual is expect +/- delta + */ + approximately(actual: number, expected: number, delta: number, message?: string): void; + /** + * Asserts that arrays have the same members in any order (===) + */ + sameMembers(set1: any[], set2: any[], message?: string): void; + /** + * Asserts that arrays do not have the same members in any order (===) + */ + notSameMembers(set1: any[], set2: any[], message?: string): void; + /** + * Asserts that arrays have the same members in any order + */ + sameDeepMembers(set1: any[], set2: any[], message?: string): void; + /** + * Asserts that arrays do not have the same members in any order + */ + notSameDeepMembers(set1: any[], set2: any[], message?: string): void; + /** + * Asserts that arrays have the same members in the same order (===) + */ + sameOrderedMembers(set1: any[], set2: any[], message?: string): void; + /** + * Asserts that arrays do not have the same members in the same order (===) + */ + notSameOrderedMembers(set1: any[], set2: any[], message?: string): void; + /** + * Asserts that arrays have the same members in the same order + */ + sameDeepOrderedMembers(set1: any[], set2: any[], message?: string): void; + /** + * Asserts that arrays do not have the same members in the same order + */ + notSameDeepOrderedMembers(set1: any[], set2: any[], message?: string): void; + /** + * Asserts that subset is included in superset in any order (===) + */ + includeMembers(superset: any[], subset: any[], message?: string): void; + /** + * Asserts that subset is not included in superset in any order (===) + */ + notIncludeMembers(superset: any[], subset: any[], message?: string): void; + /** + * Asserts that subset is included in superset in any order + */ + includeDeepMembers(superset: any[], subset: any[], message?: string): void; + /** + * Asserts that subset is not included in superset in any order + */ + notIncludeDeepMembers(superset: any[], subset: any[], message?: string): void; + /** + * Asserts that subset is included in superset in the same order (===) + */ + includeOrderedMembers(superset: any[], subset: any[], message?: string): void; + /** + * Asserts that subset is not included in superset in the same order (===) + */ + notIncludeOrderedMembers(superset: any[], subset: any[], message?: string): void; + /** + * Asserts that subset is included in superset in the same order + */ + includeDeepOrderedMembers(superset: any[], subset: any[], message?: string): void; + /** + * Asserts that subset is not included in superset in the same order + */ + notIncludeDeepOrderedMembers(superset: any[], subset: any[], message?: string): void; + /** + * Asserts that list includes inList + */ + oneOf(inList: any, list: any[], message?: string): void; + /** + * Asserts that a function changes the value of a property + */ + changes(fn: () => void, object: object, property: string, message?: string): void; + /** + * Asserts that a function changes the value of a property by delta + */ + changesBy(fn: () => void, object: object, property: string, delta: number, message?: string): void; + /** + * Asserts that a function does not changes the value of a property + */ + doesNotChange(fn: () => void, object: object, property: string, message?: string): void; + /** + * Asserts that a function does not change the value of a property or of a function’s return value by delta + */ + changesButNotBy(fn: () => void, object: object, property: string, delta: number, message?: string): void; + /** + * Asserts that a function increases a numeric object property + */ + increases(fn: () => void, object: object, property: string, message?: string): void; + /** + * Asserts that a function increases a numeric object property or a function’s return value by delta + */ + increasesBy(fn: () => void, object: object, property: string, delta: number, message?: string): void; + /** + * Asserts that a function does not increase a numeric object property + */ + doesNotIncrease(fn: () => void, object: object, property: string, message?: string): void; + /** + * Asserts that a function does not increase a numeric object property or function’s return value by delta + */ + increasesButNotBy(fn: () => void, object: object, property: string, delta: number, message?: string): void; + /** + * Asserts that a function decreases the value of a property + */ + decreases(fn: () => void, object: object, property: string, message?: string): void; + /** + * Asserts that a function decreases the value of a property by delta + */ + decreasesBy(fn: () => void, object: object, property: string, delta: number, message?: string): void; + /** + * Asserts that a function does not decrease the value of a property + */ + doesNotDecrease(fn: () => void, object: object, property: string, message?: string): void; + /** + * Asserts that a function does not decrease the value of a property or a function's return value by delta + */ + doesNotDecreaseBy(fn: () => void, object: object, property: string, delta: number, message?: string): void; + /** + * Asserts that a function does not decreases a numeric object property or a function’s return value by delta + */ + decreasesButNotBy(fn: () => void, object: object, property: string, delta: number, message?: string): void; + /** + * Throws an error if value is truthy + */ + ifError(value: any): void; + /** + * Asserts that object is extensible + */ + isExtensible(object: object, message?: string): void; + /** + * Asserts that object is extensible + */ + extensible(object: object, message?: string): void; + /** + * Asserts that object is not extensible + */ + isNotExtensible(object: object, message?: string): void; + /** + * Asserts that object is not extensible + */ + notExtensible(object: object, message?: string): void; + /** + * Asserts that object is sealed + */ + isSealed(object: object, message?: string): void; + /** + * Asserts that object is sealed + */ + sealed(object: object, message?: string): void; + /** + * Asserts that object is not sealed + */ + isNotSealed(object: object, message?: string): void; + /** + * Asserts that object is not sealed + */ + notSealed(object: object, message?: string): void; + /** + * Asserts that object is frozen + */ + isFrozen(object: object, message?: string): void; + /** + * Asserts that object is frozen + */ + frozen(object: object, message?: string): void; + /** + * Asserts that object is not frozen + */ + isNotFrozen(object: object, message?: string): void; + /** + * Asserts that object is not frozen + */ + notFrozen(object: object, message?: string): void; + /** + * Asserts that value is empty + */ + isEmpty(value: any, message?: string): void; + /** + * Asserts that value is empty + */ + empty(value: any, message?: string): void; + /** + * Asserts that value is not empty + */ + isNotEmpty(value: any, message?: string): void; + /** + * Asserts that value is not empty + */ + notEmpty(value: any, message?: string): void; + } + + interface ExpectFunction { + (value: adone.shani.util.I.Spy, message?: string): MockAssertions; + (value: any, message?: string): Assertion; + fail(actual: any, expected: any, message?: string, operator?: any): void; + } + + interface LanguageChains { + to: this; + be: this; + been: this; + is: this; + that: this; + which: this; + and: this; + has: this; + have: this; + with: this; + at: this; + of: this; + same: this; + but: this; + does: this; + } + + interface Assertion extends LanguageChains { + /** + * Negates all following assertion in the chain + */ + not: this; + /** + * Causes following assertions to use deep equality + */ + deep: this; + /** + * Enables dot- and bracket-notation in following property and include assertions + */ + nested: this; + /** + * Causes following property and incude assertions to ignore inherited properties + */ + own: this; + /** + * Causes following members assertions to require that members be in the same order + */ + ordered: this; + /** + * Causes following keys assertions to only require that the target have at least one of the given keys + */ + any: this; + /** + * Causes following keys assertions to require that the target have all of the given keys + */ + all: this; + /** + * Asserts that the target's type is `type` + */ + a(type: I.PossibleTypes, message?: string): this; + a(type: string, message?: string): this; + /** + * Asserts that the target's type is `type` + */ + an(type: I.PossibleTypes, message?: string): this; + an(type: string, message?: string): this; + /** + * Asserts that the target includes the given value + */ + include(value: any, message?: string): this; + /** + * Asserts that the target includes the given value + */ + includes(value: any, message?: string): this; + /** + * Asserts that the target contains the given value + */ + contain(value: any, message?: string): this; + /** + * Asserts that the target contains the given value + */ + contains(value: any, message?: string): this; + /** + * Asserts that the target is non-strictly equal to true + */ + ok: this; + /** + * Asserts that the target is true + */ + true: this; + /** + * Asserts that the target is false + */ + false: this; + /** + * Asserts that the target is null + */ + null: this; + /** + * Asserts that the target is undefined + */ + undefined: this; + /** + * Asserts that the target is NaN + */ + NaN: this; + /** + * Asserts that the target is neither null nor undefined + */ + exist: this; + /** + * Asserts that the target is empty + */ + empty: this; + /** + * Asserts that the target is an arguments object + */ + arguments: this; + /** + * Asserts that the target is an arguments object + */ + Arguments: this; + /** + * Asserts that the target is strictly equal to value(===) + */ + equal(value: any, message?: string): this; + /** + * Asserts that the target is strictly equal to value(===) + */ + equals(value: any, message?: string): this; + /** + * Asserts that the target is strictly equal to value(===) + */ + eq(value: any, message?: string): this; + /** + * Asserts that the target is deeply equal to object + */ + eql(object: any, message?: string): this; + /** + * Asserts that the target is deeply equal to object + */ + eqls(object: any, message?: string): this; + /** + * Asserts that the target has the same length length and elements as array in the same order + */ + eqlArray(array: any[], message?: string): this; + /** + * Asserts that target > n + */ + above(n: number, message?: string): this; + /** + * Asserts that target > n + */ + gt(n: number, message?: string): this; + /** + * Asserts that target > n + */ + greaterThan(n: number, message?: string): this; + /** + * Asserts that target >= n + */ + least(n: number, message?: string): this; + /** + * Asserts that target >= n + */ + gte(n: number, message?: string): this; + /** + * Asserts that target < n + */ + below(n: number, message?: string): this; + /** + * Asserts that target < n + */ + lt(n: number, message?: string): this; + /** + * Asserts that target < n + */ + lessThan(n: number, message?: string): this; + /** + * Asserts that target <= n + */ + most(n: number, message?: string): this; + /** + * Asserts that target <= n + */ + lte(n: number, message?: string): this; + /** + * Asserts that start <= target <= end + */ + within(start: number, end: number, message?: string): this; + /** + * Asserts that the target is an instance of constructor + */ + instanceof(constructor: object, message?: string): this; + /** + * Asserts that the target is an instance of constructor + */ + instanceOf(constructor: object, message?: string): this; + /** + * Asserts that the target has a property name `name` with value `value` + */ + property(name: string, value?: any, message?: string): this; + /** + * Asserts that the target has its own property name `name` with value `value` + */ + ownProperty(name: string, value?: any, message?: string): this; + /** + * Asserts that the target has its own property name `name` with value `value` + */ + haveOwnProperty(name: string, value?: any, message?: string): this; + /** + * Asserts that the target has its own property descriptor with name `name` and value `value` + */ + ownPropertyDescriptor(name: string, descriptor?: object, message?: string): this; + /** + * Asserts that the target has its own property descriptor with name `name` and value `value` + */ + haveOwnPropertyDescriptor(name: string, descriptor?: object, message?: string): this; + /** + * Asserts that the target's property length equal to n + */ + length(n: number, message?: string): this; + /** + * Asserts that the target's property length equal to n + */ + lengthOf(n: number, message?: string): this; + /** + * Asserts that the target matches the regular expression regExp + */ + match(regExp: RegExp, message?: string): this; + /** + * Asserts that the target matches the regular expression regExp + */ + matches(regExp: RegExp, message?: string): this; + /** + * Asserts that the target contains str as a substring + */ + string(str: string, message?: string): this; + /** + * Assert that the target has the given keys + */ + key(key: string | string[] | object): this; + key(...keys: string[]): this; + /** + * Assert that the target has the given keys + */ + keys(key: string | string[] | object): this; + keys(...keys: string[]): this; + /** + * Assert that the target throws an error + */ + throw(errorLike?: object, errMsgMatcher?: string | RegExp, message?: string): this; + /** + * Assert that the target throws an error + */ + throws(errorLike?: object, errMsgMatcher?: string | RegExp, message?: string): this; + /** + * Assert that the target throws an error + */ + Throw(errorLike?: Error, errMsgMatcher?: string | RegExp): this; + /** + * Assert that the target has a method with name `method`. For functions checks the prototype + */ + respondTo(method: string, message?: string): this; + /** + * Assert that the target has a method with name `method`. For functions checks the prototype + */ + respondsTo(method: string, message?: string): this; + /** + * Makes respondsTo behave like the target is not a function + */ + itself: this; + /** + * Asserts that matches returns a truthy value with the target as the first argument + */ + satisfy(matcher: () => boolean, message?: string): this; + /** + * Asserts that matches returns a truthy value with the target as the first argument + */ + satisfies(matcher: () => boolean, message?: string): this; + /** + * Asserts that the target is expected +/- delta + */ + closeTo(expected: number, delta: number, message?: string): this; + /** + * Asserts that the target is expected +/- delta + */ + approximately(expected: number, delta: number, message?: string): this; + /** + * Asserts that the target array has the same members as the given + */ + members(set: any[], message?: string): this; + /** + * Asserts that the target is the member of list + */ + oneOf(list: any[], message?: string): this; + /** + * Asserts that fn returns a different value after the target's invokation than before + */ + change(fn: () => any, message?: string): this; + /** + * Asserts that the target's invokation changes subject's property + */ + change(subject: object, property: string, message?: string): this; + /** + * Asserts that fn returns a different value after the target's invokation than before + */ + changes(fn: () => any, message?: string): this; + /** + * Asserts that the target's invokation changes subject's property + */ + changes(subject: object, property: string, message?: string): this; + /** + * Asserts that fn returns a greater number after the target's invokation than before + */ + increase(fn: () => number, message?: string): this; + /** + * Asserts that the target's invokation increases subject's property + */ + increase(subject: object, property?: string, message?: string): this; + /** + * Asserts that fn returns a greater number after the target's invokation than before + */ + increases(fn: () => number, message?: string): this; + /** + * Asserts that the target's invokation increases subject's property + */ + increases(subject: object, property?: string, message?: string): this; + /** + * Asserts that fn returns a lesser number after the target's invokation than before + */ + decrease(fn: () => number, message?: string): this; + /** + * Asserts that the target's invokation decreases subject's property + */ + decrease(subject: object, property?: string, message?: string): this; + /** + * Asserts that fn returns a lesser number after the target's invokation than before + */ + decreases(fn: () => number, message?: string): this; + /** + * Asserts that the target's invokation decreases subject's property + */ + decreases(subject: object, property?: string, message?: string): this; + /** + * Asserts that the value was decreased/increased by delta + */ + by(delta: number, message?: string): this; + /** + * Asserts that the target is extensible + */ + extensible: this; + /** + * Asserts that the target is sealed + */ + sealed: this; + /** + * Asserts that the target is frozen + */ + frozen: this; + /** + * Asserts that the target is a finite number + */ + finite: this; + } + + interface MockAssertions extends Assertion { + /** + * Asserts that the spy has been called + */ + called: this; + /** + * Asserts that the spy has been called n times + */ + callCount(n: number): this; + /** + * Asserts that the spy has been called once + */ + calledOnce: this; + /** + * Asserts that the spy has been called twice + */ + calledTwice: this; + /** + * Asserts that the spy has been been called with `new` + */ + calledThrice: this; + /** + * Asserts that the spy has been called before anotherSpy + */ + calledBefore(anotherSpy: adone.shani.util.I.Spy): this; + /** + * Asserts that the spy has been called after anotherSpy + */ + calledAfter(anotherSpy: adone.shani.util.I.Spy): this; + /** + * Asserts that the spy has been called immediately before anotherSpy + */ + calledImmediatelyBefore(anotherSpy: adone.shani.util.I.Spy): this; + /** + * Asserts that the spy has been called immediately after anotherSpy + */ + calledImmediatelyAfter(anotherSpy: adone.shani.util.I.Spy): this; + /** + * Asserts that the spy has been called with context as this value + */ + calledOn(context: object): this; + /** + * Asserts that the spy has been called with the given arguments + */ + calledWith(...args: any[]): this; + /** + * Asserts that the spy has been called exactly with the given arguments + */ + calledWithExactly(...args: any[]): this; + /** + * Asserts that the spy has been called with matching arguments + */ + calledWithMatch(...args: any[]): this; + /** + * Asserts that the spy returned value + */ + returned(value: any): this; + /** + * Asserts that the spy threw error + */ + thrown(error: any): this; + /** + * Asserts that the spy threw error + */ + threw(error: any): this; + } + } + + class AssertionError extends adone.x.Exception { + constructor(message?: string, props?: object, ssf?: object) + } + + const config: I.Config; + const use: I.UseFunction; + const loadMockInterface: I.LoadInterfaceFunction; + const loadExpectInterface: I.LoadInterfaceFunction; + const loadAssertInterface: I.LoadInterfaceFunction; + const assert: I.AssertFunction; + const expect: I.ExpectFunction; +} diff --git a/types/adone/glosses/common.d.ts b/types/adone/glosses/common.d.ts new file mode 100644 index 0000000000..57025ea054 --- /dev/null +++ b/types/adone/glosses/common.d.ts @@ -0,0 +1,465 @@ +/** + * predicates + */ +export namespace is { + function _null(obj: any): boolean; + export { _null as null }; + export function undefined(obj: any): boolean; + export function exist(obj: any): boolean; + export function nil(obj: any): boolean; + export function number(obj: any): boolean; + export function numeral(obj: any): boolean; + export function infinite(obj: any): boolean; + export function odd(obj: any): boolean; + export function even(obj: any): boolean; + export function float(obj: any): boolean; + export function negativeZero(obj: any): boolean; + export function string(obj: any): boolean; + export function emptyString(obj: any): boolean; + export function substring(substring: string, string: string, offset?: number): boolean; + export function prefix(prefix: string, string: string): boolean; + export function suffix(suffix: string, string: string): boolean; + export function boolean(obj: any): boolean; + export function json(obj: any): boolean; + export function object(obj: any): boolean; + export function plainObject(obj: any): boolean; + function _class(obj: any): boolean; + export { _class as class }; + export function emptyObject(obj: any): boolean; + export function propertyOwned(obj: any, field: string): boolean; + export function propertyDefined(obj: any, field: string): boolean; + export function conforms(obj: object, schema: object, strict?: boolean): boolean; + export function arrayLikeObject(obj: any): boolean; + export function inArray(value: T, array: any[], offset?: number, comparator?: (a: T, b: T) => boolean): boolean; + export function sameType(value: any, other: any): boolean; + export function primitive(obj: any): boolean; + export function equalArrays(left: any[], right: any[]): boolean; + export function deepEqual(left: any, right: any): boolean; + export function shallowEqual(left: any, right: any): boolean; + export function stream(obj: any): boolean; + export function writableStream(obj: any): boolean; + export function readableStream(obj: any): boolean; + export function duplexStream(obj: any): boolean; + export function transformStream(obj: any): boolean; + export function utf8(obj: Buffer): boolean; + export function win32PathAbsolute(path: string): boolean; + export function posixPathAbsolute(path: string): boolean; + export function pathAbsolute(path: string): boolean; + export function glob(str: string): boolean; + export function dotfile(str: string): boolean; + function _function(obj: any): boolean; + export { _function as function }; + export function asyncFunction(obj: any): boolean; + export function promise(obj: any): boolean; + export function validDate(str: string): boolean; + export function buffer(obj: any): boolean; + export function callback(obj: any): boolean; + export function generator(obj: any): boolean; + export function nan(obj: any): boolean; + export function finite(obj: any): boolean; + export function integer(obj: any): boolean; + export function safeInteger(obj: any): boolean; + export function array(obj: any): boolean; + export function uint8Array(obj: any): boolean; + export function configuration(obj: any): boolean; + export function long(obj: any): boolean; + export function bigNumber(obj: any): boolean; + export function exbuffer(obj: any): boolean; + export function exdate(obj: any): boolean; + export function transform(obj: any): boolean; + export function subsystem(obj: any): boolean; + export function application(obj: any): boolean; + export function logger(obj: any): boolean; + export function coreStream(obj: any): boolean; + export function fastStream(obj: any): boolean; + export function fastFSStream(obj: any): boolean; + export function fastFSMapStream(obj: any): boolean; + export function genesisNetron(obj: any): boolean; + export function genesisPeer(obj: any): boolean; + export function netronAdapter(obj: any): boolean; + export function netron(obj: any): boolean; + export function netronPeer(obj: any): boolean; + export function netronDefinition(obj: any): boolean; + export function netronDefinitions(obj: any): boolean; + export function netronReference(obj: any): boolean; + export function netronInterface(obj: any): boolean; + export function netronContext(obj: any): boolean; + export function netronIMethod(netronInterface: object, name: string): boolean; + export function netronIProperty(netronInterface: any, name: string): boolean; + export function netronStub(obj: any): boolean; + export function netronRemoteStub(obj: any): boolean; + export function netronStream(obj: any): boolean; + export function iterable(obj: any): boolean; + export const windows: boolean; + export const linux: boolean; + export const freebsd: boolean; + export const darwin: boolean; + export const sunos: boolean; + export function uppercase(str: string): boolean; + export function lowercase(str: string): boolean; + export function digits(str: string): boolean; + export function identifier(str: string): boolean; + export function binaryExtension(str: string): boolean; + export function binaryPath(str: string): boolean; + export function ip4(str: string): boolean; + export function ip6(str: string): boolean; + export function arrayBuffer(obj: any): boolean; + export function arrayBufferView(obj: any): boolean; + export function date(obj: any): boolean; + export function error(obj: any): boolean; + export function map(obj: any): boolean; + export function regexp(obj: any): boolean; + export function set(obj: any): boolean; + export function symbol(obj: any): boolean; + export function validUTF8(obj: any): boolean; +} + +export namespace x { + class Exception extends Error { + constructor(message?: string | Error, captureStackTrace?: boolean); + } + class Runtime extends Exception { } + class IncompleteBufferError extends Exception { } + class NotImplemented extends Exception { } + class IllegalState extends Exception { } + class NotValid extends Exception { } + class Unknown extends Exception { } + class NotExists extends Exception { } + class Exists extends Exception { } + class Empty extends Exception { } + class InvalidAccess extends Exception { } + class NotSupported extends Exception { } + class InvalidArgument extends Exception { } + class InvalidNumberOfArguments extends Exception { } + class NotFound extends Exception { } + class Timeout extends Exception { } + class Incorrect extends Exception { } + class NotAllowed extends Exception { } + class LimitExceeded extends Exception { } + class Encoding extends Exception { } + class Network extends Exception { } + class Bind extends Exception { } + class Connect extends Exception { } + class Database extends Exception { } + class DatabaseInitialization extends Exception { } + class DatabaseOpen extends Exception { } + class DatabaseRead extends Exception { } + class DatabaseWrite extends Exception { } + class NetronIllegalState extends Exception { } + class NetronPeerDisconnected extends Exception { } + class NetronTimeout extends Exception { } +} + +export class EventEmitter { + static listenerCount(emitter: EventEmitter, event: string | symbol): number; + static defaultMaxListeners: number; + + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + removeListener(event: string | symbol, listener: (...args: any[]) => void): this; + removeAllListeners(event?: string | symbol): this; + setMaxListeners(n: number): this; + getMaxListeners(): number; + listeners(event: string | symbol): Array<(...args: any[]) => any>; + emit(event: string | symbol, ...args: any[]): boolean; + eventNames(): Array; + listenerCount(type: string | symbol): number; +} + +export class AsyncEmitter extends EventEmitter { + constructor(concurrency?: number); + + setConcurrency(max?: number): this; + + emitParallel(event: string, ...args: any[]): Promise; + + emitSerial(event: string, ...args: any[]): Promise; + + emitReduce(event: string, ...args: any[]): Promise; + + emitReduceRight(event: string, ...args: any[]): Promise; + + subscribe(event: string, listener: (...args: any[]) => void, once?: boolean): () => void; +} + +declare namespace I { + type Long = adone.math.Long; + + type Longable = adone.math.I.Longable; + + namespace ExBuffer { + interface Varint32 { + value: number; + length: number; + } + + interface Varint64 { + value: Long; + length: number; + } + + interface String { + string: string; + length: number; + } + + type Wrappable = string | ExBuffer | Buffer | Uint8Array | ArrayBuffer; + + type METRICS = "b" | "c"; + } +} + +export class ExBuffer { + constructor(capacity?: number, noAssert?: boolean); + + readBitSet(offset?: number): number[]; + + read(length: number, offset?: number): ExBuffer; + + readInt8(offset?: number): number; + + readUInt8(offset?: number): number; + + readInt16LE(offset?: number): number; + + readUInt16LE(offset?: number): number; + + readInt16BE(offset?: number): number; + + readUInt16BE(offset?: number): number; + + readInt32LE(offset?: number): number; + + readUInt32LE(offset?: number): number; + + readInt32BE(offset?: number): number; + + readUInt32BE(offset?: number): number; + + readInt64LE(offset?: number): adone.math.Long; + + readUInt64LE(offset?: number): adone.math.Long; + + readInt64BE(offset?: number): adone.math.Long; + + readUInt64BE(offset?: number): adone.math.Long; + + readFloatLE(offset?: number): number; + + readFloatBE(offset?: number): number; + + readDoubleLE(offset?: number): number; + + readDoubleBE(offset?: number): number; + + write(source: I.ExBuffer.Wrappable, offset?: number, length?: number, encoding?: string): this; + + writeBitSet(value: number[]): this; + + writeBitSet(value: number[], offset: number): number; + + writeInt8(value: number, offset?: number): this; + + writeUInt8(value: number, offset?: number): this; + + writeInt16LE(value: number, offset?: number): this; + + writeInt16BE(value: number, offset?: number): this; + + writeUInt16LE(value: number, offset?: number): this; + + writeUInt16BE(value: number, offset?: number): this; + + writeInt32LE(value: number, offset?: number): this; + + writeInt32BE(value: number, offset?: number): this; + + writeUInt32LE(value: number, offset?: number): this; + + writeUInt32BE(value: number, offset?: number): this; + + writeInt64LE(value: I.Longable, offset?: number): this; + + writeInt64BE(value: I.Longable, offset?: number): this; + + writeUInt64LE(value: I.Longable, offset?: number): this; + + writeUInt64BE(value: I.Longable, offset?: number): this; + + writeFloatLE(value: number, offset?: number): this; + + writeFloatBE(value: number, offset?: number): this; + + writeDoubleLE(value: number, offset?: number): this; + + writeDoubleBE(value: number, offset?: number): this; + + writeVarint32(value: number): this; + + writeVarint32(value: number, offset: number): number; + + writeVarint32ZigZag(value: number): this; + + writeVarint32ZigZag(value: number, offset: number): number; + + readVarint32(): number; + + readVarint32(offset: number): I.ExBuffer.Varint32; + + readVarint32ZigZag(): number; + + readVarint32ZigZag(offset: number): I.ExBuffer.Varint32; + + writeVarint64(value: I.Longable): this; + + writeVarint64(value: I.Longable, offset: number): number; + + writeVarint64ZigZag(value: I.Longable): this; + + writeVarint64ZigZag(value: I.Longable, offset: number): number; + + readVarint64(): I.Long; + + readVarint64(offset: number): I.ExBuffer.Varint64; + + readVarint64ZigZag(): adone.math.Long; + + readVarint64ZigZag(offset: number): I.ExBuffer.Varint64; + + writeCString(str: string): this; + + writeCString(str: string, offset: number): number; + + readCString(): string; + + readCString(offset: number): I.ExBuffer.String; + + writeString(str: string): this; + + writeString(str: string, offset: number): number; + + readString(length: number, metrics?: I.ExBuffer.METRICS): string; + + readString(length: number, metrics: I.ExBuffer.METRICS, offset: number): I.ExBuffer.String; + + readString(length: number, offset: number): I.ExBuffer.String; + + writeVString(str: string): this; + + writeVString(str: string, offset: number): number; + + readVString(): string; + + readVString(offset: number): I.ExBuffer.String; + + appendTo(target: ExBuffer, offset?: number): this; + + assert(assert?: boolean): this; + + capacity(): number; + + clear(): this; + + compact(begin?: number, end?: number): this; + + copy(begin?: number, end?: number): ExBuffer; + + copyTo(target: ExBuffer, targetOffset?: number, souceOffset?: number, sourceLimit?: number): this | ExBuffer; + + ensureCapacity(capacity: number): this; + + fill(value: string | number, begin?: number, end?: number): this; + + flip(): this; + + mark(offset?: number): this; + + prepend(source: I.ExBuffer.Wrappable, encoding?: string, offset?: number): this; + + prepend(source: I.ExBuffer.Wrappable, offset: number): this; + + prependTo(target: ExBuffer, offset?: number): this; + + remaining(): number; + + reset(): this; + + resize(capacity: number): this; + + reverse(begin?: number, end?: number): this; + + skip(length: number): this; + + slice(begin?: number, end?: number): ExBuffer; + + toBuffer(forceCopy?: boolean, begin?: number, end?: number): Buffer; + + toArrayBuffer(): ArrayBuffer; + + toString(encoding?: string, begin?: number, end?: number): string; + + toBase64(begin?: number, end?: number): string; + + toBinary(begin?: number, end?: number): string; + + toDebug(columns?: boolean): string; + + toHex(begin?: number, end?: number): string; + + toUTF8(begin?: number, end?: number): string; + + static accessor(): typeof Buffer; + + static allocate(capacity?: number, noAssert?: boolean): ExBuffer; + + static concat(buffers: I.ExBuffer.Wrappable[], encoding?: string, noAssert?: boolean): ExBuffer; + + static type(): typeof Buffer; + + static wrap(buffer: I.ExBuffer.Wrappable, encoding?: string, noAssert?: boolean): ExBuffer; + + static calculateVarint32(value: number): number; + + static zigZagEncode32(n: number): number; + + static zigZagDecode32(n: number): number; + + static calculateVarint64(value: number | string): number; + + static zigZagEncode64(value: number | string | I.Long): I.Long; + + static zigZagDecode64(value: number | string | I.Long): I.Long; + + static calculateUTF8Chars(str: string): number; + + static calculateString(str: string): number; + + static fromBase64(str: string): ExBuffer; + + static btoa(str: string): string; + + static atob(b64: string): string; + + static fromBinary(str: string): ExBuffer; + + static fromDebug(str: string, noAssert?: boolean): ExBuffer; + + static fromHex(str: string, noAssert?: boolean): ExBuffer; + + static fromUTF8(str: string, noAssert?: boolean): ExBuffer; + + static DEFAULT_CAPACITY: number; + + static DEFAULT_NOASSERT: boolean; + + static MAX_VARINT32_BYTES: number; + + static MAX_VARINT64_BYTES: number; + + static METRICS_CHARS: string; + + static METRICS_BYTES: string; +} diff --git a/types/adone/glosses/math.d.ts b/types/adone/glosses/math.d.ts new file mode 100644 index 0000000000..076bdd105f --- /dev/null +++ b/types/adone/glosses/math.d.ts @@ -0,0 +1,118 @@ +/** + * math related things + */ +export namespace math { + namespace I { + interface LowHighBits { + low: number; + high: number; + } + type Longable = math.Long | number | string | LowHighBits; + } + + export class Long { + constructor(low?: number, high?: number, unsigned?: boolean); + + toInt(): number; + + toNumber(): number; + + toString(radix?: number): string; + + getHighBits(): number; + + getHighBitsUnsigned(): number; + + getLowBits(): number; + + getLowBitsUnsigned(): number; + + getNumBitsAbs(): number; + + isZero(): boolean; + + isNegative(): boolean; + + isPositive(): boolean; + + isOdd(): boolean; + + isEven(): boolean; + + equals(other: I.Longable): boolean; + + lessThan(other: I.Longable): boolean; + + lessThanOrEqual(other: I.Longable): boolean; + + greaterThan(other: I.Longable): boolean; + + greaterThanOrEqual(other: I.Longable): boolean; + + compare(other: I.Longable): number; + + negate(): Long; + + add(addend: I.Longable): Long; + + sub(subtrahend: I.Longable): Long; + + mul(multiplier: I.Longable): Long; + + div(divisor: I.Longable): Long; + + mod(divisor: I.Longable): Long; + + not(): Long; + + and(other: I.Longable): Long; + + or(other: I.Longable): Long; + + xor(other: I.Longable): Long; + + shl(numBits: number | Long): Long; + + shr(numBits: number | Long): Long; + + shru(numBits: number | Long): Long; + + toSigned(): Long; + + toUnsigned(): Long; + + toBytes(le?: boolean): number[]; + + toBytesLE(): number[]; + + toBytesBE(): number[]; + + static fromInt(value: number, unsigned?: boolean): Long; + + static fromNumber(value?: number, unsigned?: boolean): Long; + + static fromBits(lowBits: number, highBits: number, unsigned?: boolean): Long; + + static fromString(str: string, unsigned?: boolean, radix?: number): Long; + + static fromString(str: string, radix?: number): Long; + + static fromValue(val: I.Longable): Long; + + static MIN_VALUE: Long; + + static MAX_VALUE: Long; + + static MAX_UNSIGNED_VALUE: Long; + + static ZERO: Long; + + static UZERO: Long; + + static ONE: Long; + + static UONE: Long; + + static NEG_ONE: Long; + } +} diff --git a/types/adone/glosses/promise.d.ts b/types/adone/glosses/promise.d.ts new file mode 100644 index 0000000000..a5267c69a3 --- /dev/null +++ b/types/adone/glosses/promise.d.ts @@ -0,0 +1,114 @@ +/** + * promise helpers + */ +export namespace promise { + namespace I { + interface Deferred { + /** + * Resolves the promise + */ + resolve(value?: T): void; + + /** + * Rejects the promise + */ + reject(value?: any): void; + + promise: Promise; + } + } + + /** + * Creates a promise and returns an interface to control the state + */ + export function defer(): I.Deferred; + + /** + * Creates a promise that will be resolved after given milliseconds + * + * @param ms delay in milliseconds + * @param value resolving value + */ + export function delay(ms: number, value?: T): Promise; + + /** + * Creates a promise that will be rejected after given milliseconds if the given promise is not fulfilled + * + * @param ms timeout in milliseconds + */ + export function timeout(promise: Promise, ms: number): Promise; + + /** + * Converts a promise to node.js style callback + */ + export function nodeify(promise: Promise, callback: (err?: any, value?: T) => void): Promise; + + namespace I { + interface PromisifyOptions { + /** + * Context to bind to new function + */ + context?: object; + } + } + + /** + * Converts a callback function to a promise-based function + */ + export function promisify(fn: (callback: (err?: any, result?: R) => void) => void, options?: I.PromisifyOptions): () => Promise; + export function promisify(fn: (a: T, callback: (err?: any, result?: R) => void) => void, options?: I.PromisifyOptions): (a: T) => Promise; + export function promisify(fn: (a: T, callback: (err?: any) => void) => void, options?: I.PromisifyOptions): (a: T) => Promise; + export function promisify(fn: (a: T1, b: T2, callback: (err?: any, result?: R) => void) => void, options?: I.PromisifyOptions): (a: T1, b: T2) => Promise; + export function promisify(fn: (a: T1, b: T2, callback: (err?: any) => void) => void, options?: I.PromisifyOptions): (a: T1, b: T2) => Promise; + export function promisify(fn: (a: T1, b: T2, c: T3, callback: (err?: any, result?: R) => void) => void, options?: I.PromisifyOptions): (a: T1, b: T2, c: T3) => Promise; + export function promisify(fn: (a: T1, b: T2, c: T3, callback: (err?: any) => void) => void, options?: I.PromisifyOptions): (a: T1, b: T2, c: T3) => Promise; + export function promisify( + fn: (a: T1, b: T2, c: T3, d: T4, callback: (err?: any, result?: R) => void) => void, + options?: I.PromisifyOptions + ): (a: T1, b: T2, c: T3, d: T4) => Promise; + export function promisify( + fn: (a: T1, b: T2, c: T3, d: T4, callback: (err?: any) => void) => void, + options?: I.PromisifyOptions + ): (a: T1, b: T2, c: T3, d: T4) => Promise; + export function promisify( + fn: (a: T1, b: T2, c: T3, d: T4, e: T5, callback: (err?: any, result?: R) => void) => void, + options?: I.PromisifyOptions + ): (a: T1, b: T2, c: T3, d: T4, e: T5) => Promise; + export function promisify( + fn: (a: T1, b: T2, c: T3, d: T4, callback: (err?: any) => void) => void, + options?: I.PromisifyOptions + ): (a: T1, b: T2, c: T3, d: T4, e: T5) => Promise; + export function promisify(fn: (...args: any[]) => void, options?: I.PromisifyOptions): (...args: any[]) => Promise; + + namespace I { + interface PromisifyAllOptions { + /** + * Suffix to use for keys + */ + suffix?: string; + + /** + * Function to filter keys + */ + + filter?(key: string): boolean; + /** + * Context to bind to new functions + */ + context?: object; + } + } + + /** + * Promisifies entire object + */ + export function promisifyAll(source: object, options?: I.PromisifyAllOptions): object; + + /** + * Executes a function after promise fulfillment + * + * @returns the original promise + */ + function _finally(promise: Promise, onFinally?: (...args: any[]) => void): Promise; + export { _finally as finally }; +} diff --git a/types/adone/glosses/shani-global.d.ts b/types/adone/glosses/shani-global.d.ts new file mode 100644 index 0000000000..8cb7bf1827 --- /dev/null +++ b/types/adone/glosses/shani-global.d.ts @@ -0,0 +1,79 @@ +/** + * Defines a tests block + */ +declare const describe: adone.shani.I.DescribeFunction; + +/** + * Defines a tests block + */ +declare const context: adone.shani.I.DescribeFunction; + +/** + * Defines a test + */ +declare const it: adone.shani.I.TestFunction; + +/** + * Defines a test + */ +declare const specify: adone.shani.I.TestFunction; + +/** + * Defines a hook that will be called only once before the block's tests + */ +declare const before: adone.shani.I.HookFunction; + +/** + * Defines a hook that will be called only once after the block's tests + */ +declare const after: adone.shani.I.HookFunction; + +/** + * Defines a hook that will be called before each test + */ +declare const beforeEach: adone.shani.I.HookFunction; + +/** + * Defines a hook that will be called after each test + */ +declare const afterEach: adone.shani.I.HookFunction; + +/** + * assertion functions + */ +declare const assert: adone.assertion.I.AssertFunction; + +/** + * bdd-style assertion functons + */ +declare const expect: adone.assertion.I.ExpectFunction; + +/** + * tools for installing controllable timer functions + */ +declare const fakeClock: adone.util.I.fakeClock.FakeClock; + +/** + * defines a spy function + */ +declare const spy: typeof adone.shani.util.spy; + +/** + * defines a stub function + */ +declare const stub: typeof adone.shani.util.stub; + +/** + * defines a mock function + */ +declare const mock: typeof adone.shani.util.mock; + +/** + * defines a matcher for spies/stubs/mocks + */ +declare const match: typeof adone.shani.util.match; + +/** + * assertion tool for http server responses + */ +declare const request: typeof adone.shani.util.request; diff --git a/types/adone/glosses/shani.d.ts b/types/adone/glosses/shani.d.ts new file mode 100644 index 0000000000..788267c693 --- /dev/null +++ b/types/adone/glosses/shani.d.ts @@ -0,0 +1,1655 @@ +/** + * testing framework + */ +export namespace shani { + namespace I { + interface EngineOptions { + /** + * Default timeout for tests and block + */ + defaultTimeout?: number; + + /** + * Default timeout for hooks + */ + defaultHookTimeout?: number; + + /** + * Options that transplirer uses when loads tests from files + */ + transpilerOptions?: object; // TODO: possible options to adone.js.compiler + + /** + * Forca calling gc function after each processed file + */ + callGc?: boolean; + } + + interface DescribeOptions { + /** + * Specify that this block must be skipped + */ + skip?: boolean | (() => void); + + /** + * Specify the timeout for this block + */ + timeout?: number | (() => void); + } + + interface DescribeRuntimeContext { + /** + * Skip this block + */ + skip(): void; + + /** + * Specify timeout for this block + */ + timeout(ms: number): void; + + [key: string]: any; + } + + type DescribeCallback = (this: DescribeRuntimeContext) => void; + + interface DescribeFunction { + (description: string, callback: DescribeCallback): void; + (description: string, options: DescribeOptions, callback: DescribeCallback): void; + (a: string, description: string, callback: DescribeCallback): void; + (a: string, description: string, options: DescribeOptions, callback: DescribeCallback): void; + (a: string, b: string, description: string, callback: DescribeCallback): void; + (a: string, b: string, description: string, options: DescribeOptions, callback: DescribeCallback): void; + (a: string, b: string, c: string, description: string, callback: DescribeCallback): void; + (a: string, b: string, c: string, description: string, options: DescribeOptions, callback: DescribeCallback): void; + (a: string, b: string, c: string, d: string, description: string, callback: DescribeCallback): void; + (a: string, b: string, c: string, d: string, description: string, options: DescribeOptions, callback: DescribeCallback): void; + (a: string, b: string, c: string, d: string, e: string, description: string, callback: DescribeCallback): void; + (a: string, b: string, c: string, d: string, e: string, description: string, options: DescribeOptions, callback: DescribeCallback): void; + (a: string, b: string, c: string, d: string, e: string, f: string, description: string, callback: DescribeCallback): void; + (a: string, b: string, c: string, d: string, e: string, f: string, description: string, options: DescribeOptions, callback: DescribeCallback): void; + (a: string, b: string, c: string, d: string, e: string, f: string, g: string, description: string, callback: DescribeCallback): void; + (a: string, b: string, c: string, d: string, e: string, f: string, g: string, description: string, options: DescribeOptions, callback: DescribeCallback): void; + (a: string, b: string, c: string, d: string, e: string, f: string, g: string, h: string, description: string, callback: DescribeCallback): void; + (a: string, b: string, c: string, d: string, e: string, f: string, g: string, h: string, description: string, options: DescribeOptions, callback: DescribeCallback): void; + (a: string, b: string, c: string, d: string, e: string, f: string, g: string, h: string, i: string, description: string, callback: DescribeCallback): void; + (a: string, b: string, c: string, d: string, e: string, f: string, g: string, h: string, i: string, description: string, options: DescribeOptions, callback: DescribeCallback): void; + (a: string, b: string, c: string, d: string, e: string, f: string, g: string, h: string, i: string, j: string, description: string, callback: DescribeCallback): void; + ( + a: string, b: string, c: string, + d: string, e: string, f: string, + g: string, h: string, i: string, + j: string, description: string, options: DescribeOptions, + callback: DescribeCallback + ): void; + (a: string, ...args: Array): void; + + /** + * Mark this block as inclusive + */ + only: DescribeFunction; + + /** + * Mark this block as exclusive + */ + skip: DescribeFunction; + } + + interface TestOptions { + /** + * Specify that this test must be skipped + */ + skip?: boolean | (() => void); + + /** + * Specify timeout for this test + */ + timeout?: number | (() => void); + + /** + * Add before hook for this test + */ + before?: HookCallback | [string, HookCallback]; + + /** + * Add after hook for this test + */ + after?: HookCallback | [string, HookCallback]; + } + + interface TestRuntimeContext { + /** + * Skip this test + */ + skip(): void; + + /** + * Specify timeout for this test + */ + timeout(ms: number): void; + + [key: string]: any; + } + + type TestCallback = (this: TestRuntimeContext, done: (err?: any) => void) => void; + + interface TestFunction { + (description: string, callback: TestCallback): void; + (description: string, options: TestOptions, callback: TestCallback): void; + /** + * Mark this test as inclusive + */ + only: TestFunction; + + /** + * Mark this test as exclusive + */ + skip: TestFunction; + } + + interface HookRuntimeContext { + /** + * Specify timeout for this hook + */ + timeout(ms: number): void; + + [key: string]: any; + } + + type HookCallback = (this: HookRuntimeContext, done: (err?: any) => void) => void; + + interface HookFunction { + (callback: HookCallback): void; + (description: string, callback: HookCallback): void; + } + + type StartHookEvent = "start before hook" | "start after hook" + | "start before each hook" | "start after each hook" + | "start before test hook" | "start after test hook"; + + type EndHookEvent = "end before hook" | "end after hook" + | "end before each hook" | "end after each hook" + | "end before test hook" | "end after test hook"; + + interface Emitter extends adone.EventEmitter { + on(event: "enter block", listener: (event: { block: Block }) => void): this; + on(event: "exit block", listener: (event: { block: Block }) => void): this; + on(event: "start test", listener: (event: { block: Block, test: Test }) => void): this; + on(event: "end test", listener: (event: { block: Block, test: Test, meta: ExecutionResult }) => void): this; + on(event: "skip test", listener: (event: { block: Block, test: Test, runtime: boolean }) => void): this; + on(event: StartHookEvent, listener: (event: { block: Block, test: Test, hook: Hook }) => void): this; + on(event: EndHookEvent, listener: (event: { block: Block, test: Test, hook: Hook, meta: ExecutionResult }) => void): this; + on(event: "error", listener: (err: any) => void): this; + on(event: "done", listener: () => void): this; + + /** + * Stops testing + */ + stop(): void; + } + + interface ExecutionResult { + /** + * Resulting error + */ + err: any; + + /** + * Elapsed time in milliseconds + */ + elapsed: number; + } + + class Hook { + desctiption: string; + + constructor(description: string, callback: HookCallback, runtimeContext: object); + + /** + * Check if this hook has been run + */ + fired(): boolean; + + /** + * Check if this hook failed + */ + failed(): boolean; + + /** + * The cause of the fail + */ + cause(): any; + + /** + * Returns the timeout of the hook + */ + timeout(): number; + + /** + * Seta a timeout for this hook + */ + timeout(ms: number): this; + + /** + * Executes the hook + */ + run(): Promise; + } + + class Test { + description: string; + + constructor(description: string, callback: TestCallback, block: Block, runtimeContext: object, options: TestOptions); + + /** + * Handles params from options + */ + prepare(): Promise; + + /** + * Checks if this test is exclusive (has skip flag) + */ + isExclusive(): boolean; + + /** + * Checks if this test is exclusive (has only flag) + */ + isInclusive(): boolean; + + /** + * Skips this test + */ + skip(): this; + + /** + * Marks this test as inclusive + */ + only(): this; + + /** + * Returns the timeout of the test + */ + timeout(): number | null; + + /** + * Sets a timeout for this test + */ + timeout(ms: number): this; + + /** + * Returns a string of names from the root to this test + */ + chain(): string; + + /** + * Executes the test + */ + run(): Promise; + } + + class Block { + name: string; + hooks: { + before: Hook[]; + beforeEach: Hook[]; + afterEach: Hook[]; + after: Hook[]; + }; + children: Array; + + constructor(name: string, parent: Block, options: DescribeOptions); + + /** + * Handles params from options + */ + prepare(): Promise; + + /** + * Adds a new child into this block + */ + addChild(child: Block | Test): void; + + /** + * Before hooks iterator + */ + beforeHooks(): IterableIterator; + + /** + * After hooks iterator + */ + afterHooks(): IterableIterator; + + /** + * Before each hooks iterator + */ + beforeEachHooks(): IterableIterator; + + /** + * After each hooks iterator + */ + afterEachHooks(): IterableIterator; + + /** + * Checks if this block is exclusive (has skip flag) + */ + isExclusive(): boolean; + + /** + * Checks if this block is inclusive (has only flag) + */ + isInclusive(): boolean; + + /** + * Checks if this block has an inclusive node + */ + hasInclusive(): boolean; + + /** + * Skips this block + */ + skip(): this; + + /** + * Marks this block as inclusive + */ + only(): this; + + /** + * Returns the timeout of the block + */ + timeout(): number | null; + + /** + * Sets a timeout for this block + */ + timeout(ms: number): this; + + /** + * Returns the block's level, the length of parent blocks chain + */ + level(): number; + + /** + * Sets the block's level + */ + level(level: number): this; + + /** + * Returns a string of names from the root to this block + */ + chain(): string; + + /** + * Returns a chain of blocks from the root to this block + */ + blockChain(): Block[]; + } + + interface Context { + /** + * Defines a tests block + */ + describe: DescribeFunction; + + /** + * Defines a tests block + */ + context: DescribeFunction; + + /** + * Defines a test + */ + it: TestFunction; + + /** + * Defines a test + */ + specify: TestFunction; + + /** + * Defines a hook that will be called only once before the block's tests + */ + before: HookFunction; + + /** + * Defines a hook that will be called only once after the block's tests + */ + after: HookFunction; + + /** + * Defines a hook that will be called before each test + */ + beforeEach: HookFunction; + + /** + * Defines a hook that will be called after each test + */ + afterEach: HookFunction; + + /** + * Root node + */ + root: Block; + + /** + * Starts testing + */ + start(): Emitter; + } + } + + /** + * Represents a testing engine + */ + export class Engine { + constructor(options?: I.EngineOptions); + + /** + * Includes given files as test files + */ + include(...paths: string[]): void; + + /** + * Excludes given paths from testing + */ + exclude(...paths: string[]): void; + + /** + * Returns a testing context + */ + context(): I.Context; + + /** + * Starts testing + */ + start(): I.Emitter; + } + + namespace util { + namespace I { + // based on https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/sinon + + interface SpyCallApi { + /** + * The call's this value + */ + thisValue: any; + + /** + * The call's arguments + */ + args: any[]; + + /** + * Exception throws if any + */ + exception: any; + + /** + * Return value + */ + returnValue: any; + + /** + * Whether the spy was called on obj (this value) + */ + calledOn(obj: any): boolean; + + /** + * Whether the arguments were args (and possibly others) + */ + calledWith(...args: any[]): boolean; + + /** + * Whether the arguments were exactly args (no others) + */ + calledWithExactly(...args: any[]): boolean; + + /** + * Whether the call received matching args (and possibly others) + */ + calledWithMatch(...args: any[]): boolean; + + /** + * Whether the call did not receive args + */ + notCalledWith(...args: any[]): boolean; + + /** + * Whether the call did not receive matching args + */ + notCalledWithMatch(...args: any[]): boolean; + + /** + * Whether the call returned the given value + */ + returned(value: any): boolean; + + /** + * Whether the call threw an exception + */ + threw(): boolean; + + /** + * Whether the call threw an exception of provided type + */ + threw(type: string): boolean; + + /** + * Whether the call threw obj + */ + threw(obj: any): boolean; + + /** + * Calls the argument at the given index + */ + callArg(pos: number): void; + + /** + * Calls the argument at the given index on the given context + */ + callArgOn(pos: number, obj: any): void; + + /** + * Calls the argument at the given index with arguments + */ + callArgWith(pos: number, ...args: any[]): void; + + /** + * Calls the argument at the given index on the given context and with the given arguments + */ + callArgOnWith(pos: number, obj: any, ...args: any[]): void; + + /** + * Calls a callback from the arguments with the given arguments + */ + yield(...args: any[]): void; + + /** + * Calls a callback from the arguments with the given arguments on the given context + */ + yieldOn(obj: any, ...args: any[]): void; + + /** + * Calls with the given arguments a callback that is a property of the call's argument with the given name + */ + yieldTo(property: string, ...args: any[]): void; + + /** + * Calls on the given context with the given arguments a callback that + * is a property of the call's argument with the given name + */ + yieldToOn(property: string, obj: any, ...args: any[]): void; + } + + interface SpyCall extends SpyCallApi { + /** + * Whether the call was called before the given call + */ + calledBefore(call: SpyCall): boolean; + + /** + * Whether the call was called after the given call + */ + calledAfter(call: SpyCall): boolean; + + /** + * Whether the call was called using the new operator + */ + calledWithNew(call: SpyCall): boolean; + } + + interface Spy extends SpyCallApi { + /** + * The number of recorded calls + */ + callCount: number; + + /** + * Whether the spy was called + */ + called: boolean; + + /** + * Whether the spy was not called + */ + notCalled: boolean; + + /** + * Whether the spy was called once + */ + calledOnce: boolean; + + /** + * Whether the spy was called twice + */ + calledTwice: boolean; + + /** + * Whether the spy was called thrice + */ + calledThrice: boolean; + + /** + * The first call + */ + firstCall: SpyCall; + + /** + * The second call + */ + secondCall: SpyCall; + + /** + * The third call + */ + thirdCall: SpyCall; + + /** + * The last call + */ + lastCall: SpyCall; + + /** + * Array of the calls contexts + */ + thisValues: any[]; + + /** + * Array of the calls arguments + */ + args: any[][]; + + /** + * Array of the calls exceptions + */ + exceptions: any[]; + + /** + * Array of the calls return values + */ + returnValues: any[]; + + (...args: any[]): any; + /** + * Whether the spy was called before another spy + */ + calledBefore(anotherSpy: Spy): boolean; + + /** + * Whether the spy was called after another spy + */ + calledAfter(anotherSpy: Spy): boolean; + + /** + * Whether the spy was called before another spy and no spies occured between them + */ + calledImmediatelyBefore(anotherSpy: Spy): boolean; + + /** + * Whether the spy was called after another spy and no spies occured between them + */ + calledImmediatelyAfter(anotherSpy: Spy): boolean; + + /** + * Whether the spy was called using the new operator + */ + calledWithNew(): boolean; + + /** + * Creates a spy that record calls only with the given arguments + */ + withArgs(...args: any[]): Spy; + + /** + * Whether the spy was called on the given context (this value) + */ + alwaysCalledOn(obj: any): boolean; + + /** + * Whether the spy was called with the given arguments (and possibly others) + */ + alwaysCalledWith(...args: any[]): boolean; + + /** + * Whether the spy was called exactly with the given arguments (no others) + */ + alwaysCalledWithExactly(...args: any[]): boolean; + + /** + * Whether the spy was called with the matching arguments (and possibly others) + */ + alwaysCalledWithMatch(...args: any[]): boolean; + + /** + * Whether the spy was never called with the given arguments + */ + neverCalledWith(...args: any[]): boolean; + + /** + * Whether the spy was neven called with the matching arguments + */ + neverCalledWithMatch(...args: any[]): boolean; + + /** + * Whether the spy always threw exceptions + */ + alwaysThrew(): boolean; + + /** + * Whether the spy always threw exceptions of the given types + */ + alwaysThrew(type: string): boolean; + + /** + * Whether the spy always threw the given object + */ + alwaysThrew(obj: any): boolean; + + /** + * Whether the spy always returned the given object + */ + alwaysReturned(obj: any): boolean; + + /** + * Invokes the callbacks passed in the arguments with the given arguments + */ + invokeCallback(...args: any[]): void; + + /** + * Returns the call with the given index + */ + getCall(n: number): SpyCall; + + /** + * Returns all the calls + */ + getCalls(): SpyCall[]; + + /** + * Resets the state of the spy + */ + reset(): void; + + /** + * Returns the passed format string with the given replacements + */ + printf(format: string, ...args: any[]): string; + + /** + * Replaces the spy with the original method if the spy replaced an original method + */ + restore(): void; + } + + interface Stub extends Spy { + /** + * Resets the stub's behavior to the default behavior + */ + resetBehavior(): void; + + /** + * Resets the stub's history + */ + resetHistory(): void; + + /** + * Causes the stub to return promises using the given promise library + */ + usingPromise(promiseLibrary: any): Stub; + + /** + * Makes the stub return the given object + */ + returns(obj: any): Stub; + + /** + * Causes the stub to return the argument at the given index + */ + returnsArg(index: number): Stub; + + /** + * Causes the stub to return its this value + */ + returnsThis(): Stub; + + /** + * Causes the stub to return a promise that resolves to the given value + */ + resolves(value?: any): Stub; + + /* + * Causes the stub to throw an exception of the given type + */ + throws(type?: string): Stub; + + /** + * Causes the stub to throw the given object + */ + throws(obj: any): Stub; + + /** + * Causes the stub to throw the argument at the given index + */ + throwsArg(index: number): Stub; + + /* + * Causes the stub to throw an exception of the given type + */ + throwsException(type?: string): Stub; + + /** + * Causes the stub to throw the argument at the given index + */ + throwsException(obj: any): Stub; + + /** + * Causes the stub to reject + */ + rejects(): Stub; + + /** + * Causes the stub to reject with the given type + */ + rejects(errorType: string): Stub; + + /** + * Causes the stub to reject with the given value + */ + rejects(value: any): Stub; + + /** + * Causes the stub to call the argument at the provided index as a callback function + */ + callsArg(index: number): Stub; + + /** + * Causes the original method wrapped into the stub to be called when none of the conditional stubs are matched + */ + callThrough(): Stub; + + /** + * Causes the stub to call the argument at the provided index as a callback function on the given context + */ + callsArgOn(index: number, context: any): Stub; + + /** + * Causes the stub to call the argument at the provided index as a callback function with the given arguments + */ + callsArgWith(index: number, ...args: any[]): Stub; + + /** + * Causes the stub to call the argument at the provided index as a callback function on the given context with the given arguments + */ + callsArgOnWith(index: number, context: any, ...args: any[]): Stub; + + /** + * Causes the stub to asynchronously call the argument at the provided index as a callback function + */ + callsArgAsync(index: number): Stub; + + /** + * Causes the stub to asynchronously call the argument at the provided index as a callback function on the given context + */ + callsArgOnAsync(index: number, context: any): Stub; + + /** + * Causes the stub to asynchronously call the argument at the provided index as a callback function on the given context with the given arguments + */ + callsArgWithAsync(index: number, ...args: any[]): Stub; + + /** + * Causes the stub to asynchronously call the argument at the provided index as a callback function on the given context with the given arguments + */ + callsArgOnWithAsync(index: number, context: any, ...args: any[]): Stub; + + /** + * Makes the stub call the provided fake function + */ + callsFake(func: (...args: any[]) => void): Stub; + + /** + * Replaces a new getter with this stub + */ + get(func: () => any): Stub; + + /** + * Replaces a new getter with this stub + */ + set(func: (v: any) => void): Stub; + + /** + * Defines the behavior of the stub on the call with the given index + */ + onCall(n: number): Stub; + + /** + * Defines the behavior of the stub on the first call + */ + onFirstCall(): Stub; + + /** + * Defines the behavior of the stub on the second call + */ + onSecondCall(): Stub; + + /** + * Defines the behavior of the stub on the third call + */ + onThirdCall(): Stub; + + /** + * Defines a new value for this stub + */ + value(val: any): Stub; + + /** + * Causes the stub to call the first callback it receives with the provided arguments + */ + yields(...args: any[]): Stub; + + /** + * Causes the stub to call the first callback it receives with the provided arguments on the given context + */ + yieldsOn(context: any, ...args: any[]): Stub; + + /** + * Causes the stub to call the last callback it receives with the provided arguments + */ + yieldsRight(...args: any[]): Stub; + + /** + * Causes the stub to invoke a callback passed as a property of an object to the spy + */ + yieldsTo(property: string, ...args: any[]): Stub; + + /** + * Causes the stub to invoke a callback passed as a property of an object to the spy on the given context + */ + yieldsToOn(property: string, context: any, ...args: any[]): Stub; + + /** + * Causes the stub to asynchronously call the first callback it receives with the provided arguments + */ + yieldsAsync(...args: any[]): Stub; + + /** + * Causes the stub to asynchronously call the first callback it receives with the provided arguments on the given context + */ + yieldsOnAsync(context: any, ...args: any[]): Stub; + + /** + * Causes the stub to asynchronously invoke a callback passed as a property of an object to the spy + */ + yieldsToAsync(property: string, ...args: any[]): Stub; + + /** + * Causes the stub to asynchronously invoke a callback passed as a property of an object to the spy on the given context + */ + yieldsToOnAsync(property: string, context: any, ...args: any[]): Stub; + + /** + * Stubs the method only for the provided arguments + */ + withArgs(...args: any[]): Stub; + } + + interface Expectation extends Stub { + /** + * Specifies the minimum amount of calls expected + */ + atLeast(n: number): Expectation; + + /** + * Specifies the maximum amount of calls expected + */ + atMost(n: number): Expectation; + + /** + * Expects the method to never be called + */ + never(): Expectation; + + /** + * Expects the method to be called exactly once + */ + once(): Expectation; + + /** + * Expects the method to be called exactly twice + */ + twice(): Expectation; + + /** + * Expects the method to be called exactly thrice + */ + thrice(): Expectation; + + /** + * Expects the method to be called exactly n times + */ + exactly(n: number): Expectation; + + /** + * Expects the method to be called with the provided arguments and possibly others + */ + withArgs(...args: any[]): Expectation; + + /** + * Expects the method to be called with the provided arguments and no others + */ + withExactArgs(...args: any[]): Expectation; + + /** + * Expects the method to be called with obj as this + */ + on(obj: any): Expectation; + + /** + * Verifies the expectation and throws an exception if it’s not met + */ + verify(): Expectation; + + /** + * Restores all mocked methods + */ + restore(): void; + } + + interface ExpectationStatic { + /** + * Creates a new expectation + */ + create(methodName?: string): Expectation; + } + + interface Mock { + /** + * Overrides obj.method with a mock function and returns it + */ + expects(method: string): Expectation; + + /** + * Restores all mocked methods + */ + restore(): void; + + /** + * Verifies all expectations on the mock + */ + verify(): void; + } + + interface ExposeOptions { + /** + * prefix to give assertions + */ + prefix?: string; + + /** + * Whether to copy the fail and failException properties + */ + includeFail?: boolean; + } + + interface Assert { + /** + * Default error type thrown by .fail + */ + failException: string; + + /** + * Every assertion fails by calling this method + */ + fail(message?: string): void; + + /** + * Called every time assertion passes + */ + pass(assertion: any): void; + + /** + * Passes if spy was never called + */ + notCalled(spy: Spy): void; + + /** + * Passes if spy was called at least once + */ + called(spy: Spy): void; + + /** + * Passes if spy was called once and only once + */ + calledOnce(spy: Spy): void; + + /** + * Passes if spy was called exactly twice + */ + calledTwice(spy: Spy): void; + + /** + * Passes if spy was called exactly three times + */ + calledThrice(spy: Spy): void; + + /** + * Passes if spy was called exactly count times + */ + callCount(spy: Spy, count: number): void; + + /** + * Passes if provided spies were called in the specified order + */ + callOrder(...spies: Spy[]): void; + + /** + * Passes if spy was ever called with obj as its this value + */ + calledOn(spy: Spy, obj: any): void; + + /** + * Passes if spy was always called with obj as its this value + */ + alwaysCalledOn(spy: Spy, obj: any): void; + + /** + * Passes if spy was called with the provided arguments + */ + calledWith(spy: Spy, ...args: any[]): void; + + /** + * Passes if spy was always called with the provided arguments + */ + alwaysCalledWith(spy: Spy, ...args: any[]): void; + + /** + * Passes if spy was never called with the provided arguments + */ + neverCalledWith(spy: Spy, ...args: any[]): void; + + /** + * Passes if spy was called with the provided arguments and no others + */ + calledWithExactly(spy: Spy, ...args: any[]): void; + + /** + * Passes if spy was always called with the provided arguments and no others + */ + alwaysCalledWithExactly(spy: Spy, ...args: any[]): void; + + /** + * Passes if spy was called with matching arguments. + */ + calledWithMatch(spy: Spy, ...args: any[]): void; + + /** + * Passes if spy was always called with matching arguments + */ + alwaysCalledWithMatch(spy: Spy, ...args: any[]): void; + + /** + * Passes if spy was never called with matching arguments + */ + neverCalledWithMatch(spy: Spy, ...args: any[]): void; + + /** + * Passes if spy threw + */ + threw(spy: Spy): void; + + /** + * Passes if spy threw the given exception type + */ + threw(spy: Spy, exception: string): void; + + /** + * Passes if spy threw the given object + */ + threw(spy: Spy, exception: any): void; + + /** + * Passes if always spy threw + */ + alwaysThrew(spy: Spy): void; + + /** + * Passes if spy always threw the given exception type + */ + alwaysThrew(spy: Spy, exception: string): void; + + /** + * Passes if spy always threw the given object + */ + alwaysThrew(spy: Spy, exception: any): void; + + /** + * Exposes assertions into another object, to better integrate with the test framework + */ + expose(obj: any, options?: ExposeOptions): void; + } + + interface Matcher { + /** + * Logical and + */ + and(expr: Matcher): Matcher; + + /** + * Logical or + */ + or(expr: Matcher): Matcher; + } + + interface ArrayMatcher extends Matcher { + /** + * Requires an Array to be deep equal another one. + */ + deepEquals(expected: any[]): Matcher; + + /** + * Requires an Array to start with the same values as another one. + */ + startsWith(expected: any[]): Matcher; + + /** + * Requires an Array to end with the same values as another one. + */ + endsWith(expected: any[]): Matcher; + + /** + * Requires an Array to contain each one of the values the given array has. + */ + contains(expected: any[]): Matcher; + } + + interface MapMatcher extends Matcher { + /** + * Requires a Map to be deep equal another one. + */ + deepEquals(expected: Map): Matcher; + + /** + * Requires a Map to contain each one of the items the given map has. + */ + contains(expected: Map): Matcher; + } + + interface SetMatcher extends Matcher { + /** + * Requires a Set to be deep equal another one. + */ + deepEquals(expected: Set): Matcher; + + /** + * Requires a Set to contain each one of the items the given set has. + */ + contains(expected: Set): Matcher; + } + + interface Match { + /** + * Requires the value to be == to the given number + */ + (value: number): Matcher; + + /** + * Requires the value to be a string and have the expectation as a substring + */ + (value: string): Matcher; + + /** + * Requires the value to be a string and match the given regular expression + */ + (expr: RegExp): Matcher; + + /** + * Requires the value to be not null or undefined and have at least the same properties as expectation + */ + (obj: any): Matcher; + + /** + * Specify a custom matcher + */ + (callback: (value: any) => boolean, message?: string): Matcher; + + /** + * Matches anything + */ + any: Matcher; + + /** + * Requires the value to be defined + */ + defined: Matcher; + + /** + * Requires the value to be truthy + */ + truthy: Matcher; + + /** + * Requires the value to be falsy + */ + falsy: Matcher; + + /** + * Requires the value to be a boolean + */ + bool: Matcher; + + /** + * Requires the value to be a number + */ + number: Matcher; + + /** + * Requires the value to be a string + */ + string: Matcher; + + /** + * Requires the value to be an object + */ + object: Matcher; + + /** + * Requires the value to be a function + */ + func: Matcher; + + /** + * Requires the value to be a map. + */ + map: MapMatcher; + + /** + * Requires the value to be a set. + */ + set: SetMatcher; + + /** + * Requires the value to be an array. + */ + array: ArrayMatcher; + + /** + * Requires the value to be a regular expression + */ + regexp: Matcher; + + /** + * Requires the value to be a date object + */ + date: Matcher; + + /** + * Requires the value to be a symbol + */ + symbol: Matcher; + + /** + * Requires the value to strictly equal obj + */ + same(obj: any): Matcher; + + /** + * Requires the value to be of the given type + */ + typeOf(type: adone.util.I.PossibleTypes): Matcher; + typeOf(type: string): Matcher; + + /** + * Requires the value to be an instance of the given type + */ + instanceOf(type: any): Matcher; + + /** + * Requires the value to define the given property + */ + has(property: string, expect?: any): Matcher; + + /** + * Requires the value to define the given property by itself + */ + hasOwn(property: string, expect?: any): Matcher; + } + + interface SandboxConfig { + /** + * An object to add properties to + */ + injectInto?: any; + + /** + * What properties to inject + */ + properties?: string[]; + } + + interface Sandbox { + /** + * A convenience reference for assert + */ + assert: Assert; + + /** + * Works exactly like spy, only also adds the returned spy to the internal collection of fakes + */ + spy: typeof spy; + + /** + * Works exactly like stub, only also adds the returned spy to the internal collection of fakes + */ + stub: typeof stub; + + /** + * Works exactly like mock, only also adds the returned spy to the internal collection of fakes + */ + mock: typeof mock; + + /** + * Restores all fakes created through sandbox + */ + restore(): void; + + /** + * Resets the internal state of all fakes created through sandbox + */ + reset(): void; + + /** + * Resets the history of all stubs created through the sandbox + */ + resetHistory(): void; + + /** + * Resets the behaviour of all stubs created through the sandbox + */ + resetBehavior(): void; + + /** + * Causes all stubs created from the sandbox to return promises using a specific promise library + */ + usingPromise(promiseLibrary: any): Sandbox; + + /** + * Verifies all mocks created through the sandbox + */ + verify(): void; + + /** + * Verifies all mocks and restores all fakes created through the sandbox + */ + verifyAndRestore(): void; + } + + interface SandboxStatic { + /** + * Creates a sandbox object with spies, stubs, and mocks + */ + create(config?: SandboxConfig): Sandbox; + } + } + + /** + * Return a function that records arguments, return value, the value of this and exception thrown (if any) for all its calls + */ + function spy(func?: (...args: any[]) => void): I.Spy; + function spy(object: T, method: keyof T): I.Spy; + + /** + * Creates a function (spy) with pre-programmed behavior + */ + function stub(obj?: any): I.Stub; + function stub(obj: T, method: keyof T): I.Stub; + + const expectation: I.ExpectationStatic; + + /** + * Creates a fake method (like spy) with pre-programmed behavior (like stub) + */ + function mock(): I.Expectation; + function mock(obj: any): I.Mock; + + /** + * Assertions for spies/stubs + */ + export const assert: I.Assert; + + /** + * Creates a matcher function + */ + export const match: I.Match; + + /** + * Removes the need to keep track of every fake created + */ + export const sandbox: I.SandboxStatic; + + namespace I { + interface Response extends adone.std.http.IncomingMessage { + body: Buffer; + } + + interface ExpectBodyOptions { + decompress?: boolean; + } + + interface AttachOptions { + type?: string; + filename?: string; + } + + interface Request extends Promise { + /** + * Sets the request method to GET + */ + get(path: string): this; + + /** + * Sets the request method to HEAD + */ + head(path: string): this; + + /** + * Sets the request method to POST + */ + post(path: string): this; + + /** + * Attaches an attachment + */ + attach(name: string, contents: string | Buffer, options?: AttachOptions): this; + + /** + * Attaches an attachment like a field + */ + field(name: string, value: string): this; + + /** + * Sets the request body + */ + send(value: string): this; + + /** + * Sets the request method to OPTIONS + */ + options(path: string): this; + + /** + * Sets the request method to PUT + */ + put(path: string): this; + + /** + * Sets a header value + */ + setHeader(key: string, value: string): this; + + /** + * Sets the basic auth header + */ + auth(username: string, password: string): this; + + /** + * Executes a function with the response and asserts it returns true + */ + expect(fn: (response: Response) => boolean | Promise): this; + + /** + * Asserts the response status + */ + expectStatus(code: number, message?: string): this; + + /** + * Asserts the respose status message + */ + expectStatusMessage(value: string): this; + + /** + * Asserts the response body + */ + expectBody(body: RegExp | string | Buffer, options?: ExpectBodyOptions): this; + + /** + * Asserts the response json body + */ + expectBody(body: object, options?: ExpectBodyOptions): this; + + /** + * Asserts that the response body is empty + */ + expectEmptyBody(): this; + + /** + * Asserts that the response has a header with the given key and value + */ + expectHeader(key: string, value: string | RegExp): this; + + /** + * Asserts that the response has a header with the given name + */ + expectHeaderExists(key: string): this; + + /** + * Asserts that the response does not have a header with the given name + */ + expectNoHeader(key: string): this; + } + } + + /** + * Assertion tool for http server responses + */ + function request(server: any): I.Request; // TODO: sever must be adone.net.http.server.Server or standard node.js server + + namespace FS { + // TODO: after fs + } + + namespace nock { + // TODO: after revision + } + } +} diff --git a/types/adone/glosses/std.d.ts b/types/adone/glosses/std.d.ts new file mode 100644 index 0000000000..9c30b41f62 --- /dev/null +++ b/types/adone/glosses/std.d.ts @@ -0,0 +1,65 @@ +import * as assert from "assert"; +import * as fs from "fs"; +import * as path from "path"; +import * as util from "util"; +import * as events from "events"; +import * as stream from "stream"; +import * as url from "url"; +import * as net from "net"; +import * as http from "http"; +import * as https from "https"; +import * as child_process from "child_process"; +import * as os from "os"; +import * as cluster from "cluster"; +import * as repl from "repl"; +import * as punycode from "punycode"; +import * as readline from "readline"; +import * as string_decoder from "string_decoder"; +import * as querystring from "querystring"; +import * as crypto from "crypto"; +import * as vm from "vm"; +import * as v8 from "v8"; +import * as domain from "domain"; +import * as tty from "tty"; +import * as buffer from "buffer"; +import * as constants from "constants"; +import * as zlib from "zlib"; +import * as tls from "tls"; +import * as console from "console"; +import * as dns from "dns"; +import * as timers from "timers"; +import * as dgram from "dgram"; + +export { + assert, + fs, + path, + util, + events, + stream, + url, + net, + http, + https, + child_process, + os, + cluster, + repl, + punycode, + readline, + string_decoder, + querystring, + crypto, + vm, + v8, + domain, + tty, + buffer, + constants, + zlib, + tls, + console, + dns, + timers, + dgram, +}; diff --git a/types/adone/glosses/utils.d.ts b/types/adone/glosses/utils.d.ts new file mode 100644 index 0000000000..8f90ae180b --- /dev/null +++ b/types/adone/glosses/utils.d.ts @@ -0,0 +1,473 @@ +/** + * various utility functions + */ +export namespace util { + function arrify(val: T[]): T[]; + function arrify(val: T): [T]; + + function slice(args: T[], sliceStart?: number, sliceEnd?: number): T[]; + + function spliceOne(list: any[], index: number): void; + + function normalizePath(str: string, stripTrailing?: boolean): string; + + function unixifyPath(filePath: string, unescape?: boolean): string; + + function functionName(fn: (...args: any[]) => any): string; + + function mapArguments(argmap: (...args: any[]) => any | any[]): (...args: any[]) => any; + function mapArguments(argmap: number): (...args: T[]) => T[]; + function mapArguments(...args: any[]): (x: T) => T; + + namespace I { + interface ParseMsResult { + days: number; + hours: number; + minutes: number; + seconds: number; + milliseconds: number; + } + } + function parseMs(ms: number): I.ParseMsResult; + + function pluralizeWord(str: string, plural?: string, count?: number): string; + + function functionParams(func: (...args: any[]) => any): string[]; + + function randomChoice(arrayLike: ArrayLike, from?: number, to?: number): T; + + function shuffleArray(array: T[]): T[]; + + function enumerate(iterable: Iterable, start?: number): IterableIterator<[number, T]>; + + function zip(a: Iterable, b: Iterable): IterableIterator<[T1, T2]>; + function zip(a: Iterable, b: Iterable, c: Iterable): IterableIterator<[T1, T2, T3]>; + function zip(a: Iterable, b: Iterable, c: Iterable, d: Iterable): IterableIterator<[T1, T2, T3, T4]>; + function zip(...iterables: Array>): IterableIterator; + + namespace I { + interface KeysOptions { + onlyEnumerable?: boolean; + followProto?: boolean; + all?: boolean; + } + } + function keys(object: object, options?: I.KeysOptions): string[]; + + function values(object: object, options?: I.KeysOptions): any[]; + + function entries(object: object, options?: I.KeysOptions): Array; + + function toDotNotation(object: object): object; + + namespace I { + interface FlattenOptions { + depth?: number; + } + } + function flatten(array: any[], options?: I.FlattenOptions): any[]; + + function globParent(str: string): string; + + namespace I { + interface ByResult { + (a: S, b: S): R; + compare(a: T, b: T): R; + by(a: S): T; + } + } + function by(by: (a: S) => T, compare?: (a: T, b: T) => R): I.ByResult; + + function toFastProperties(object: object): object; + + function stripBom(x: string): string; + + namespace I { + interface SortKeysOptions { + deep?: boolean; + compare?(a: any, b: any): number; + } + } + function sortKeys(object: object, options?: I.SortKeysOptions): object; + + namespace I { + interface GlobizeOptions { + exts?: string; + recursively?: boolean; + } + } + function globize(path: string, options?: I.GlobizeOptions): string; + + function unique(array: T[], projection?: (a: T) => any): T[]; + + function invertObject(source: object, options?: I.KeysOptions): object; + + namespace I { + interface HumanizeTimeOptions { + msDecimalDigits?: number; + secDecimalDigits?: number; + verbose?: boolean; + compact?: boolean; + } + } + function humanizeTime(ms: number, options?: I.HumanizeTimeOptions): string; + function humanizeSize(num: number, space?: string): string; + + function parseSize(str: string | number): number | null; + + namespace I { + interface CloneOptions { + deep?: boolean; + } + } + function clone(object: object, options?: I.CloneOptions): object; + + function toUTF8Array(str: string): number[]; + + function asyncIter(array: T[], iter: (elem: T, index: number, cb: () => void) => any, cb: () => void): void; + + function asyncFor(obj: { [key: string]: T }, iter: (key: string, value: T, index: number, length: number, next: () => void) => void, cb: () => void): void; + + namespace I { + interface OnceOptions { + silent: boolean; + } + } + function once(fn: (...args: any[]) => T, options?: I.OnceOptions): (...args: any[]) => T; + + namespace I { + type WaterFallTask = (...args: any[]) => void; + } + function asyncWaterfall(tasks: I.WaterFallTask[], callback?: (err?: Error | null, ...args: any[]) => void): void; + + function xrange(start?: number, stop?: number, step?: number): IterableIterator; + + function range(start?: number, stop?: number, step?: number): number[]; + + function reFindAll(regexp: RegExp, str: string): RegExpExecArray[]; + + function assignDeep(target: T, ...sources: object[]): T; + + namespace I { + interface MatchOptions { + index?: boolean; + start?: number; + end?: number; + dot?: boolean; + } + } + function match(criteria: any | any[], options?: I.MatchOptions): (value: any | any[], options?: I.MatchOptions) => number | boolean; + function match(criteria: any | any[], value: any | any[], options?: I.MatchOptions): number | boolean; + + namespace I { + interface ToposortFunction { + (edges: Array<[T, T]>): T[]; + array(nodes: T[], edges: Array<[T, T]>): T[]; + } + } + const toposort: I.ToposortFunction; + + namespace I { + interface JSEscOptions { + escapeEverything?: boolean; + minimal?: boolean; + isScriptContext?: boolean; + quotes?: string; + wrap?: boolean; + es6?: boolean; + json?: boolean; + compact?: boolean; + lowercaseHex?: boolean; + numbers?: string; + indent?: string; + indentLevel?: number; + __inline1__?: boolean; + __inline2__?: boolean; + } + } + function jsesc(argument: any, options?: I.JSEscOptions): string; + + namespace I { + type PossibleTypes = "object" | "class" | "null" | "global" | "Array" | "RegExp" | "Date" + | "Promise" | "Set" | "Map" | "WeakSet" | "DataView" | "Map Iterator" | "Set Iterator" + | "Array Iterator" | "String Iterator" | "Object" | "function" | "boolean" | "number" + | "undefined" | "string" | "symbol"; + } + + function typeOf(obj: any): I.PossibleTypes; + function typeOf(obj: any): string; + + namespace memcpy { + function utou(target: Buffer, targetOffset: number, source: Buffer, sourceStart: number, sourceEnd: number): number; + function atoa(target: ArrayBuffer, targetOffset: number, source: ArrayBuffer, sourceStart: number, sourceEnd: number): number; + function atou(target: Buffer, targetOffset: number, source: ArrayBuffer, sourceStart: number, sourceEnd: number): number; + function utoa(target: ArrayBuffer, targetOffset: number, source: Buffer, sourceStart: number, sourceEnd: number): number; + function copy(target: Buffer | ArrayBuffer, targetOffset: number, source: Buffer | ArrayBuffer, sourceStart: number, sourceEnd: number): number; + } + + namespace uuid { + namespace I { + interface V1Options { + clockseq?: number; + msecs?: number; + nsecs?: number; + } + } + function v1(options?: I.V1Options): string; + function v1(options: I.V1Options, buf: any[], offset?: number): number[]; + + function v4(options?: any): string; + function v4(options: any, buf: any[], offset?: number): number[]; + + function v5(name: string | number[], namespace: string | number[]): string; + function v5(name: string | number[], namespace: string | number[], buf: any[], offset?: number): number[]; + } + + namespace I { + interface Delegator { + method(name: string): Delegator; + access(name: string): Delegator; + getter(name: string): Delegator; + setter(name: string): Delegator; + } + } + function delegate(object: object, property: string): I.Delegator; + + namespace I { + interface GlobExpOptions { + nocomment?: boolean; + nonegate?: boolean; + nobrace?: boolean; + noglobstar?: boolean; + nocase?: boolean; + dot?: boolean; + noext?: boolean; + matchBase?: boolean; + flipNegate?: boolean; + } + } + + class GlobExp { + constructor(pattern: string, options?: I.GlobExpOptions); + + hasMagic(): boolean; + + static hasMagic(pattern: string, options?: I.GlobExpOptions): boolean; + + expandBraces(): string[]; + + static expandBraces(pattern: string, options?: I.GlobExpOptions): string[]; + + makeRe(): RegExp; + + static makeRe(pattern: string, options?: I.GlobExpOptions): RegExp; + + static test(p: string, pattern: string, options?: I.GlobExpOptions): boolean; + + test(p: string): boolean; + } + + namespace iconv { + // TODO: need to normalize source code + } + + namespace sqlstring { + function escapeId(val: string | string[], forbidQualified?: boolean): string; + function dateToString(date: any, timeZone?: string): string; + function arrayToList(array: any[]): string; + function bufferToString(buffer: Buffer): string; + function objectToValues(object: object, timeZone?: string): string; + function escape(value: any, stringifyObjects?: boolean, timeZone?: string): string; + function format(sql: string, values?: any | any[], stringifyObjects?: boolean, timeZone?: string): string; + } + + namespace I { + interface EditorOptions { + text?: string; + editor?: string; + path?: string; + ext?: string; + } + } + class Editor { + static DEFAULT: string; + + constructor(options?: I.EditorOptions); + + spawn(): Promise; + + run(): Promise; + + cleanup(): Promise; + + static edit(options?: I.EditorOptions): Promise; + } + + namespace I { + interface BinarySearchFunction { + (aHaystack: T[], aNeedle: number, aLow?: number, aHigh?: number, aCompare?: (a: T, b: T) => number, aBias?: number): T; + GREATEST_LOWER_BOUND: number; + LEAST_UPPER_BOUND: number; + } + } + const binarySearch: I.BinarySearchFunction; + + namespace buffer { + function concat(list: Buffer[], totalLength: number): Buffer; + function mask(buffer: Buffer, mask: Buffer, output: Buffer, offset: number, length: number): void; + function unmask(buffer: Buffer, mask: Buffer): void; + } + + function shebang(str: string): string | null; + + class ReInterval { + constructor(callback: (...args: any[]) => void, interval: number, args?: any[]); + + reschedule(interval: number): void; + + clear(): void; + + destroy(): void; + } + + class RateLimiter { + constructor(tokensPerInterval?: number, interval?: number, fireImmediately?: boolean); + + removeTokens(count: number): Promise; + + tryRemoveTokens(count: number): boolean; + + getTokensRemaining(): number; + } + + namespace I { + interface ThrottleOptions { + max?: number; + interval?: number; + ordered?: boolean; + waitForReturn?: boolean; + } + } + function throttle(fn: () => R, options?: I.ThrottleOptions): () => Promise; + function throttle(fn: (a: T1) => R, options?: I.ThrottleOptions): (a: T1) => Promise; + function throttle(fn: (a: T1, b: T2) => R, options?: I.ThrottleOptions): (a: T1, b: T2) => Promise; + function throttle(fn: (a: T1, b: T2, c: T3) => R, options?: I.ThrottleOptions): (a: T1, b: T2, c: T3) => Promise; + function throttle(fn: (a: T1, b: T2, c: T3, d: T4) => R, options?: I.ThrottleOptions): (a: T1, b: T2, c: T3, d: T4) => Promise; + function throttle(fn: (a: T1, b: T2, c: T3, d: T4, e: T5) => R, options?: I.ThrottleOptions): (a: T1, b: T2, c: T3, d: T4, e: T5) => Promise; + function throttle(fn: (...args: any[]) => R, options?: I.ThrottleOptions): (...args: any[]) => Promise; + + namespace I.fakeClock { + interface Timer { + id: number; + ref(): void; + unref(): void; + } + interface Clock { + setTimeout(func: (...args: any[]) => void, timeout: number, ...args: any[]): Timer; + clearTimeout(timer: Timer): void; + nextTick(func: (...args: any[]) => void, ...args: any[]): void; + setInterval(func: (...args: any[]) => void, ...args: any[]): Timer; + clearInterval(timer: Timer): void; + setImmediate(func: (...args: any[]) => void, ...args: any[]): Timer; + clearImmediate(timer: Timer): void; + updateHrTime(newNow: number): void; + tick(ms: number): number; + next(): number; + runAll(): number; + runToLast(): number; + setSystemTime(systemTime: number): void; + hrtime(prev?: [number, number]): [number, number]; + } + interface InstalledClock extends Clock { + uninstall(): void; + } + interface InstallOptions { + target?: object; + now?: number; + toFake?: string[]; + loopLimit?: number; + shouldAdvanceTime?: boolean; + advanceTimeDelta?: number; + } + + interface Timers { + setTimeout: typeof global.setTimeout; + clearTimeout: typeof global.clearTimeout; + setInterval: typeof global.setInterval; + clearInterval: typeof global.clearInterval; + setImmediate: typeof global.setImmediate; + clearImmediate: typeof global.clearImmediate; + Date: typeof global.Date; + hrtime: typeof global.process.hrtime; + nextTick: typeof global.process.nextTick; + } + + interface FakeClock { + timers: Timers; + createClock(now?: number, loopLimit?: number): Clock; + install(now?: number | Date | InstallOptions): InstalledClock; + } + } + + const fakeClock: I.fakeClock.FakeClock; + + namespace ltgt { + namespace I { + interface Range { + lt?: T; + lte?: T; + gt?: T; + gte?: T; + min?: T; + max?: T; + start?: T; + end?: T; + reverse?: boolean; + } + type Comparator = (a: T, b: T) => number; + } + function contains(range: I.Range, key: T, compare?: I.Comparator): boolean; + + function filter(range: I.Range, compare?: I.Comparator): (key: T) => boolean; + + function toLtgt( + range: I.Range, + _range: object, + map?: (value: T, isUpperBound: boolean) => R, + lowerBound?: T, + upperBound?: T + ): I.Range; + + function endInclusive(range: I.Range): boolean; + + function startInclusive(range: I.Range): boolean; + + function end(range: I.Range): T | undefined; + + function end(range: I.Range, defaultValue: R): T | R; + + function start(range: I.Range): T | undefined; + + function start(range: I.Range, defaultValue?: R): T | R; + + function upperBound(range: I.Range): T | undefined; + + function upperBound(range: I.Range, defaultValue: R): T | R; + + function upperBoundKey(range: I.Range): T | undefined; + + function upperBoundExclusive(range: I.Range): boolean; + + function lowerBoundExclusive(range: I.Range): boolean; + + function upperBoundInclusive(range: I.Range): boolean; + + function lowerBoundInclusive(range: I.Range): boolean; + + function lowerBound(range: I.Range): T | undefined; + + function lowerBound(range: I.Range, defaultValue: R): T | R; + + function lowerBoundKey(range: I.Range): T | undefined; + } +} diff --git a/types/adone/index.d.ts b/types/adone/index.d.ts new file mode 100644 index 0000000000..663e8c8407 --- /dev/null +++ b/types/adone/index.d.ts @@ -0,0 +1,9 @@ +// Type definitions for adone 0.6 +// Project: https://github.com/ciferox/adone +// Definitions by: am , Maximus +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +import * as adone from "./adone"; + +export default adone; diff --git a/types/adone/test/glosses/assertion.ts b/types/adone/test/glosses/assertion.ts new file mode 100644 index 0000000000..4d07c78182 --- /dev/null +++ b/types/adone/test/glosses/assertion.ts @@ -0,0 +1,653 @@ +namespace assertionTests { + const { assertion } = adone; + + namespace assertionInterface { + namespace exception { + const a: adone.x.Exception = new assertion.AssertionError(); + const b: adone.x.Exception = new assertion.AssertionError("hello"); + const c: adone.x.Exception = new assertion.AssertionError("hello", { actual: 2, expected: 3 }, () => {}); + } + + namespace config { + assertion.config.includeStack = true; + assertion.config.proxyExcludedKeys = ["a"]; + assertion.config.showDiff = false; + assertion.config.truncateThreshold = 20; + assertion.config.useProxy = false; + } + + namespace loadInterfaces { + assertion.loadAssertInterface().config.includeStack = true; + assertion.loadExpectInterface().config.includeStack = true; + assertion.loadMockInterface().config.includeStack = true; + } + + namespace use { + assertion.use(() => {}).use(() => {}).config.includeStack = true; + } + } + + const { assert } = assertion; + + namespace assertTests { + assert(1); + assert(1, "hello"); + assert.fail(); + assert.fail(1); + assert.fail(1, 2); + assert.fail(1, 2, "hello"); + assert.fail(1, 2, "hello", "<"); + + assert.isOk(1); + assert.isOk(1, "hello"); + + assert.isNotOk(1); + assert.isNotOk(1, "hello"); + + assert.equal(1, 2); + assert.equal(1, 2, "hello"); + + assert.notEqual(1, 2); + assert.notEqual(1, 2, "hello"); + + assert.strictEqual(1, 2); + assert.strictEqual(1, 2, "hello"); + + assert.notStrictEqual(1, 2); + assert.notStrictEqual(1, 2, "hello"); + + assert.deepEqual(1, 2); + assert.deepEqual(1, 2, "hello"); + + assert.deepStrictEqual(1, 2); + assert.deepStrictEqual(1, 2, "hello"); + + assert.equalArrays([1, 2, 3], [4, 5, 6]); + assert.equalArrays([1, 2, 3], [4, 5, 6], "hello"); + + assert.notDeepEqual(1, 2); + assert.notDeepEqual(1, 2, "hello"); + + assert.isAbove(1, 2); + assert.isAbove(1, 2, "hello"); + + assert.isAtLeast(1, 2); + assert.isAtLeast(1, 2, "hello"); + + assert.isBelow(1, 2); + assert.isBelow(1, 2, "hello"); + + assert.isAtMost(1, 2); + assert.isAtMost(1, 2, "hello"); + + assert.isTrue(1); + assert.isTrue(1, "hello"); + + assert.isNotTrue(1); + assert.isNotTrue(1, "hello"); + + assert.isFalse(1); + assert.isFalse(1, "hello"); + + assert.isNotFalse(1); + assert.isNotFalse(1, "hello"); + + assert.isNull(1); + assert.isNull(1, "hello"); + + assert.isNaN(1); + assert.isNaN(1, "hello"); + + assert.isNotNaN(1); + assert.isNotNaN(1, "hello"); + + assert.exists(1); + assert.exists(1, "hello"); + + assert.notExists(1); + assert.notExists(1, "hello"); + + assert.isUndefined(1); + assert.isUndefined(1, "hello"); + + assert.isDefined(1); + assert.isDefined(1, "hello"); + + assert.isFunction(1); + assert.isFunction(1, "hello"); + + assert.isNotFunction(1); + assert.isNotFunction(1, "hello"); + + assert.isObject(1); + assert.isObject(1, "hello"); + + assert.isNotObject(1); + assert.isNotObject(1, "hello"); + + assert.isArray(1); + assert.isArray(1, "hello"); + + assert.isNotArray(1); + assert.isNotArray(1, "hello"); + + assert.isString(1, "hello"); + + assert.isNotString(1); + assert.isNotString(1, "hello"); + + assert.isNumber(1); + assert.isNumber(1, "hello"); + + assert.isNotNumber(1); + assert.isNotNumber(1, "hello"); + + assert.isFinite(1); + assert.isFinite(1, "hello"); + + assert.isBoolean(1); + assert.isBoolean(1, "hello"); + + assert.isNotBoolean(1); + assert.isNotBoolean(1, "hello"); + + assert.typeOf(1, "string"); + assert.typeOf(1, "number", "hello"); + + assert.notTypeOf(1, "string"); + assert.notTypeOf(1, "number", "hello"); + + assert.instanceOf(1, Date); + class A {} + assert.instanceOf("4", A, "hello"); + + assert.notInstanceOf(1, Date); + assert.notInstanceOf(Date, A, "hello"); + + assert.include([1, 2, 3], 4); + assert.include([1, 2, 3], 4, "hello"); + assert.include("string", "string"); + assert.include("string", "string", "string"); + + assert.notInclude([1, 2, 3], 4); + assert.notInclude([1, 2, 3], 4, "hello"); + assert.notInclude("string", "string"); + assert.notInclude("string", "string", "string"); + + assert.deepInclude([1, 2, 3], 4); + assert.deepInclude([1, 2, 3], 4, "hello"); + assert.deepInclude("string", "string"); + assert.deepInclude("string", "string", "string"); + + assert.notDeepInclude([1, 2, 3], 4); + assert.notDeepInclude([1, 2, 3], 4, "hello"); + assert.notDeepInclude("string", "string"); + assert.notDeepInclude("string", "string", "string"); + + assert.nestedInclude({ a: 1 }, {}); + assert.nestedInclude({ a: 1 }, {}, "hello"); + + assert.notNestedInclude({ a: 1 }, {}); + assert.notNestedInclude({ a: 1 }, {}, "hello"); + + assert.deepNestedInclude({ a: 1 }, {}); + assert.deepNestedInclude({ a: 1 }, {}, "hello"); + + assert.notDeepNestedInclude({ a: 1 }, {}); + assert.notDeepNestedInclude({ a: 1 }, {}, "hello"); + + assert.ownInclude({ a: 1 }, {}); + assert.ownInclude({ a: 1 }, {}, "hello"); + + assert.notOwnInclude({ a: 1 }, {}); + assert.notOwnInclude({ a: 1 }, {}, "hello"); + + assert.deepOwnInclude({ a: 1 }, {}); + assert.deepOwnInclude({ a: 1 }, {}, "hello"); + + assert.notDeepOwnInclude({ a: 1 }, {}); + assert.notDeepOwnInclude({ a: 1 }, {}, "hello"); + + assert.match("1", /\d+/); + assert.match("1", /\d+/, "hello"); + + assert.notMatch("1", /\d+/); + assert.notMatch("1", /\d+/, "hello"); + + assert.property({ a: 1 }, "a"); + assert.property({ a: 1 }, "a", "hello"); + + assert.notProperty({ a: 1 }, "a"); + assert.notProperty({ a: 1 }, "a", "hello"); + + assert.propertyVal({ a: 1 }, "a", 1); + assert.propertyVal({ a: 1 }, "a", 1, "hello"); + + assert.notPropertyVal({ a: 1 }, "a", 1); + assert.notPropertyVal({ a: 1 }, "a", 1, "hello"); + + assert.deepPropertyVal({ a: 1 }, "a", 1); + assert.deepPropertyVal({ a: 1 }, "a", 1, "hello"); + + assert.notDeepPropertyVal({ a: 1 }, "a", 1); + assert.notDeepPropertyVal({ a: 1 }, "a", 1, "hello"); + + assert.ownProperty({ a: 1 }, "a"); + assert.ownProperty({ a: 1 }, "a", "hello"); + + assert.notOwnProperty({ a: 1 }, "a"); + assert.notOwnProperty({ a: 1 }, "a", "hello"); + + assert.ownPropertyVal({ a: 1 }, "a", 1); + assert.ownPropertyVal({ a: 1 }, "a", 1, "hello"); + + assert.deepOwnPropertyVal({ a: 1 }, "a", 1); + assert.deepOwnPropertyVal({ a: 1 }, "a", 1, "hello"); + + assert.notDeepOwnPropertyVal({ a: 1 }, "a", 1); + assert.notDeepOwnPropertyVal({ a: 1 }, "a", 1, "hello"); + + assert.nestedProperty({ a: 1 }, "a"); + assert.nestedProperty({ a: 1 }, "a", "hello"); + + assert.notNestedProperty({ a: 1 }, "a"); + assert.notNestedProperty({ a: 1 }, "a", "hello"); + + assert.nestedPropertyVal({ a: 1 }, "a", 1); + assert.nestedPropertyVal({ a: 1 }, "a", 1, "hello"); + + assert.notNestedPropertyVal({ a: 1 }, "a", 1); + assert.notNestedPropertyVal({ a: 1 }, "a", 1, "hello"); + + assert.deepNestedPropertyVal({ a: 1 }, "a", 1); + assert.deepNestedPropertyVal({ a: 1 }, "a", 1, "hello"); + + assert.notDeepNestedPropertyVal({ a: 1 }, "a", 1); + assert.notDeepNestedPropertyVal({ a: 1 }, "a", 1, "hello"); + + assert.lengthOf([1, 2, 3], 3); + assert.lengthOf([1, 2, 3], 3, "hello"); + + assert.hasAnyKeys({ a: 1 }, "a"); + assert.hasAnyKeys({ a: 1 }, ["a"]); + assert.hasAnyKeys({ a: 1 }, ["a"], "hello"); + + assert.hasAnyKeys({ a: 1 }, { a: 1 }); + assert.hasAnyKeys({ a: 1 }, { a: 1 }, "hello"); + + assert.hasAllKeys({ a: 1 }, "a"); + assert.hasAllKeys({ a: 1 }, ["a"]); + assert.hasAllKeys({ a: 1 }, ["a"], "hello"); + + assert.hasAllKeys({ a: 1 }, { a: 1 }); + assert.hasAllKeys({ a: 1 }, { a: 1 }, "hello"); + + assert.containsAllKeys({ a: 1 }, "a"); + assert.containsAllKeys({ a: 1 }, ["a"]); + assert.containsAllKeys({ a: 1 }, ["a"], "hello"); + + assert.containsAllKeys({ a: 1 }, { a: 1 }); + assert.containsAllKeys({ a: 1 }, { a: 1 }, "hello"); + + assert.doesNotHaveAnyKeys({ a: 1 }, "a"); + assert.doesNotHaveAnyKeys({ a: 1 }, ["a"]); + assert.doesNotHaveAnyKeys({ a: 1 }, ["a"], "hello"); + + assert.doesNotHaveAnyKeys({ a: 1 }, { a: 1 }); + assert.doesNotHaveAnyKeys({ a: 1 }, { a: 1 }, "hello"); + + assert.doesNotHaveAllDeepKeys({ a: 1 }, "a"); + assert.doesNotHaveAllDeepKeys({ a: 1 }, ["a"]); + assert.doesNotHaveAllDeepKeys({ a: 1 }, ["a"], "hello"); + + assert.doesNotHaveAllDeepKeys({ a: 1 }, { a: 1 }); + assert.doesNotHaveAllDeepKeys({ a: 1 }, { a: 1 }, "hello"); + + assert.hasAnyDeepKeys({ a: 1 }, "a"); + assert.hasAnyDeepKeys({ a: 1 }, ["a"]); + assert.hasAnyDeepKeys({ a: 1 }, ["a"], "hello"); + + assert.hasAnyDeepKeys({ a: 1 }, { a: 1 }); + assert.hasAnyDeepKeys({ a: 1 }, { a: 1 }, "hello"); + + assert.hasAllDeepKeys({ a: 1 }, "a"); + assert.hasAllDeepKeys({ a: 1 }, ["a"]); + assert.hasAllDeepKeys({ a: 1 }, ["a"], "hello"); + + assert.hasAllDeepKeys({ a: 1 }, { a: 1 }); + assert.hasAllDeepKeys({ a: 1 }, { a: 1 }, "hello"); + + assert.containsAllDeepKeys({ a: 1 }, "a"); + assert.containsAllDeepKeys({ a: 1 }, ["a"]); + assert.containsAllDeepKeys({ a: 1 }, ["a"], "hello"); + + assert.containsAllDeepKeys({ a: 1 }, { a: 1 }); + assert.containsAllDeepKeys({ a: 1 }, { a: 1 }, "hello"); + + assert.doesNotHaveAnyDeepKeys({ a: 1 }, "a"); + assert.doesNotHaveAnyDeepKeys({ a: 1 }, ["a"]); + assert.doesNotHaveAnyDeepKeys({ a: 1 }, ["a"], "hello"); + + assert.doesNotHaveAnyDeepKeys({ a: 1 }, { a: 1 }); + assert.doesNotHaveAnyDeepKeys({ a: 1 }, { a: 1 }, "hello"); + + assert.doesNotHaveAllDeepKeys({ a: 1 }, "a"); + assert.doesNotHaveAllDeepKeys({ a: 1 }, ["a"]); + assert.doesNotHaveAllDeepKeys({ a: 1 }, ["a"], "hello"); + + assert.doesNotHaveAllDeepKeys({ a: 1 }, { a: 1 }); + assert.doesNotHaveAllDeepKeys({ a: 1 }, { a: 1 }, "hello"); + + assert.throws(() => {}); + assert.throws(() => {}, Error); + assert.throws(() => {}, Error, /\d+/); + assert.throws(() => {}, Error, "string"); + assert.throws(() => {}, Error, "string", "hello"); + + assert.throws(async () => {}).then(() => 42); + assert.throws(async () => {}, Error).then(() => 42); + assert.throws(async () => {}, Error, /\d+/).then(() => 42); + assert.throws(async () => {}, Error, "string").then(() => 42); + assert.throws(async () => {}, Error, "string", "hello").then(() => 42); + + assert.doesNotThrow(() => {}); + assert.doesNotThrow(() => {}, Error); + assert.doesNotThrow(() => {}, Error, /\d+/); + assert.doesNotThrow(() => {}, Error, "string"); + assert.doesNotThrow(() => {}, Error, "string", "hello"); + + assert.doesNotThrow(async () => {}).then(() => 42); + assert.doesNotThrow(async () => {}, Error).then(() => 42); + assert.doesNotThrow(async () => {}, Error, /\d+/).then(() => 42); + assert.doesNotThrow(async () => {}, Error, "string").then(() => 42); + assert.doesNotThrow(async () => {}, Error, "string", "hello").then(() => 42); + + assert.operator(1, "<", 2); + assert.operator(1, "<", 2, "hello"); + + assert.closeTo(1, 2, 1); + assert.closeTo(1, 2, 1, "hello"); + + assert.approximately(1, 2, 2); + assert.approximately(1, 2, 2, "hello"); + + assert.sameMembers([1, 2, 3], [4, 5, 6]); + assert.sameMembers([1, 2, 3], [4, 5, 6], "hello"); + + assert.notSameMembers([1, 2, 3], [4, 5, 6]); + assert.notSameMembers([1, 2, 3], [4, 5, 6], "hello"); + + assert.sameDeepMembers([1, 2, 3], [4, 5, 6]); + assert.sameDeepMembers([1, 2, 3], [4, 5, 6], "hello"); + + assert.notSameDeepMembers([1, 2, 3], [4, 5, 6]); + assert.notSameDeepMembers([1, 2, 3], [4, 5, 6], "hello"); + + assert.sameOrderedMembers([1, 2, 3], [4, 5, 6]); + assert.sameOrderedMembers([1, 2, 3], [4, 5, 6], "hello"); + + assert.notSameOrderedMembers([1, 2, 3], [4, 5, 6]); + assert.notSameOrderedMembers([1, 2, 3], [4, 5, 6], "hello"); + + assert.includeMembers([1, 2, 3], [3]); + assert.includeMembers([1, 2, 3], [3], "hello"); + + assert.notIncludeMembers([1, 2, 3], [3]); + assert.notIncludeMembers([1, 2, 3], [3], "hello"); + + assert.includeDeepMembers([1, 2, 3], [3]); + assert.includeDeepMembers([1, 2, 3], [3], "hello"); + + assert.notIncludeDeepMembers([1, 2, 3], [3]); + assert.notIncludeDeepMembers([1, 2, 3], [3], "hello"); + + assert.includeOrderedMembers([1, 2, 3], [3]); + assert.includeOrderedMembers([1, 2, 3], [3], "hello"); + + assert.notIncludeOrderedMembers([1, 2, 3], [3]); + assert.notIncludeOrderedMembers([1, 2, 3], [3], "hello"); + + assert.includeDeepOrderedMembers([1, 2, 3], [3]); + assert.includeDeepOrderedMembers([1, 2, 3], [3], "hello"); + + assert.notIncludeDeepOrderedMembers([1, 2, 3], [3]); + assert.notIncludeDeepOrderedMembers([1, 2, 3], [3], "hello"); + + assert.oneOf(1, [1, 2, 3]); + assert.oneOf(1, [1, 2, 3], "hello"); + + assert.changes(() => {}, {}, "a"); + assert.changes(() => {}, {}, "a", "hello"); + + assert.changesBy(() => {}, {}, "a", 2); + assert.changesBy(() => {}, {}, "a", 2, "hello"); + + assert.doesNotChange(() => {}, {}, "a"); + assert.doesNotChange(() => {}, {}, "a", "hello"); + + assert.changesButNotBy(() => {}, {}, "a", 20); + assert.changesButNotBy(() => {}, {}, "a", 20, "hello"); + + assert.increases(() => {}, {}, "a"); + assert.increases(() => {}, {}, "a", "hello"); + + assert.increasesBy(() => {}, {}, "a", 20); + assert.increasesBy(() => {}, {}, "a", 20, "hello"); + + assert.doesNotIncrease(() => {}, {}, "a"); + assert.doesNotIncrease(() => {}, {}, "a", "hello"); + + assert.increasesButNotBy(() => {}, {}, "a", 20); + assert.increasesButNotBy(() => {}, {}, "a", 20, "hello"); + + assert.decreases(() => {}, {}, "a"); + assert.decreases(() => {}, {}, "a", "hello"); + + assert.decreasesBy(() => {}, {}, "a", 20); + assert.decreasesBy(() => {}, {}, "a", 20, "hello"); + + assert.doesNotDecrease(() => {}, {}, "a"); + assert.doesNotDecrease(() => {}, {}, "a", "hello"); + + assert.doesNotDecreaseBy(() => {}, {}, "a", 20); + assert.doesNotDecreaseBy(() => {}, {}, "a", 20, "hello"); + + assert.decreasesButNotBy(() => {}, {}, "a", 20); + assert.decreasesButNotBy(() => {}, {}, "a", 20, "hello"); + + assert.ifError(1); + + assert.isExtensible({}); + assert.isExtensible({}, "hello"); + + assert.isNotExtensible({}); + assert.isNotExtensible({}, "hello"); + + assert.isSealed({}); + assert.isSealed({}, "hello"); + + assert.isNotSealed({}); + assert.isNotSealed({}, "hello"); + + assert.isFrozen({}); + assert.isFrozen({}, "hello"); + + assert.isNotFrozen({}); + assert.isNotFrozen({}, "hello"); + + assert.isEmpty({}); + assert.isEmpty({}, "hello"); + } + + const { expect } = assertion; + + namespace expectTests { + expect(1); + expect(1, "hello"); + expect.fail(1, 2); + expect.fail(1, 2, "hello"); + expect.fail(1, 2, "hello", "+"); + expect(1).to.be.been.is.and.has.have.with.that.which.at.of.same.but.does.not.deep.nested.own.ordered.any.all.a("number"); + expect(1).to.be.a("number", "hello").and; + expect(1).to.be.an("array").and; + expect(1).to.be.an("array", "hello").and; + expect(1).to.include(1).and; + expect(1).to.include(1, "hello").and; + expect(1).but.includes(2).and; + expect(1).but.includes(2, "hello").and; + expect(1).to.contain(2).and; + expect(1).to.contain(2, "hello").and; + expect(1).but.contains(2).and; + expect(1).but.contains(2, "hello").and; + expect(1).to.ok.not.ok; + expect(1).to.be.true.but.false; + expect(1).to.be.false.but.true; + expect(1).to.be.null.and.null; + expect(1).to.be.undefined.and.true; + expect(1).to.be.NaN.and.null; + expect(1).to.exist.and.be.null; + expect(1).to.be.empty.and.true; + expect(1).to.be.arguments.and.a("number"); + expect(1).to.be.Arguments.and.false; + expect(1).to.be.equal(2).and; + expect(1).to.be.equal(2, "hello").and; + expect(1).but.equals(2).and; + expect(1).but.equals(2, "hello").and; + expect(1).to.eq(2).and; + expect(1).to.eq(2, "hello").and; + expect(1).but.eqls(2).and; + expect(1).but.eqls(2, "hello").and; + expect(1).to.eqlArray([1, 2, 3]).and; + expect(1).to.eqlArray([1, 2, 3], "hello").and; + expect(1).to.be.above(2).and; + expect(1).to.be.above(2, "hello").and; + expect(1).to.be.gt(2).and; + expect(1).to.be.gt(2, "hello").and; + expect(1).to.be.greaterThan(2).and; + expect(1).to.be.greaterThan(2, "hello").and; + expect(1).to.be.at.least(10).and; + expect(1).to.be.at.least(10, "hello").and; + expect(1).to.be.gte(10).and; + expect(1).to.be.gte(10, "hello").and; + expect(1).to.be.below(100).and; + expect(1).to.be.below(100, "hello").and; + expect(1).to.be.lt(10).and; + expect(1).to.be.lt(10, "hello").and; + expect(1).to.be.lessThan(10, "hello").and; + expect(1).to.be.at.most(10).and; + expect(1).to.be.at.most(10, "hello").and; + expect(1).to.be.lte(10).and; + expect(1).to.be.lte(10, "hello").and; + expect(1).to.be.within(1, 10).and; + expect(1).to.be.within(1, 10, "hello").and; + expect(1).to.be.instanceof(Number).and; + expect(1).to.be.instanceof(Number, "hello").and; + expect(1).to.be.instanceOf(Number).and; + expect(1).to.be.instanceOf(Number, "hello").and; + expect(1).to.have.property("a").and; + expect(1).to.have.property("a", 1).and; + expect(1).to.have.property("a", 1, "hello").and; + expect(1).to.have.ownProperty("a").and; + expect(1).to.have.ownProperty("a", 1).and; + expect(1).to.have.ownProperty("a", 1, "hello").and; + expect(1).to.haveOwnProperty("a").and; + expect(1).to.haveOwnProperty("a", 1).and; + expect(1).to.haveOwnProperty("a", 1, "hello").and; + expect(1).to.have.ownPropertyDescriptor("a").and; + expect(1).to.have.ownPropertyDescriptor("a", {}).and; + expect(1).to.have.ownPropertyDescriptor("a", {}, "hello").and; + expect(1).to.haveOwnPropertyDescriptor("a").and; + expect(1).to.haveOwnPropertyDescriptor("a", {}).and; + expect(1).to.haveOwnPropertyDescriptor("a", {}, "hello").and; + expect("a").to.have.length(1).and; + expect("a").to.have.length(1, "hello").and; + expect("a").to.have.lengthOf(1).and; + expect("a").to.have.lengthOf(1, "hello").and; + expect(1).to.match(/\d+/).and; + expect(1).to.match(/\d+/, "hello").and; + expect(1).to.have.string("1230").and; + expect(1).to.have.string("1230", "hello").and; + expect(1).to.have.key("a").and; + expect(1).to.have.key("a", "b").and; + expect(1).to.have.key(["a", "b"]).and; + expect(1).to.have.key({ a: 1, b: 2 }).and; + expect(1).to.have.keys("a").and; + expect(1).to.have.keys("a", "b").and; + expect(1).to.have.keys(["a", "b"]).and; + expect(1).to.have.keys({ a: 1, b: 2 }).and; + expect(() => {}).to.throw().and; + expect(() => {}).to.throw(Error).and; + expect(() => {}).to.throw(Error, "string").and; + expect(() => {}).to.throw(Error, "string", "hello").and; + expect(() => {}).to.throw(Error, /\d+/).and; + expect(() => {}).to.throw(Error, /\d+/, "hello").and; + expect(() => {}).but.throws().and; + expect(() => {}).but.throws(Error).and; + expect(() => {}).but.throws(Error, "string").and; + expect(() => {}).but.throws(Error, "string", "hello").and; + expect(() => {}).but.throws(Error, /\d+/).and; + expect(() => {}).but.throws(Error, /\d+/, "hello").and; + expect(1).to.respondTo("a").and; + expect(1).to.respondTo("a", "hello").and; + expect(1).to.respondsTo("a").and; + expect(1).to.respondsTo("a", "hello").and; + expect(1).itself.to.respondsTo("a").and; + expect(1).to.satisfy(() => true).and; + expect(1).to.satisfy(() => true, "hello").and; + expect(1).but.satisfies(() => true).and; + expect(1).but.satisfies(() => true, "hello").and; + expect(1).to.be.closeTo(2, 1).and; + expect(1).to.be.closeTo(2, 1, "hello").and; + expect(1).to.be.approximately(1, 2).and; + expect(1).to.be.approximately(1, 2, "hello").and; + expect(1).to.have.members([1, 2, 3]).and; + expect(1).to.have.members([1, 2, 3], "hello").and; + expect(1).to.be.oneOf([1, 2, 3]).and; + expect(1).to.be.oneOf([1, 2, 3], "hello").and; + expect(() => {}).to.change(() => {}).and; + expect(() => {}).to.change({}, "a").and; + expect(() => {}).to.change({}, "a", "hello").and; + expect(() => {}).but.changes(() => {}).and; + expect(() => {}).but.changes({}, "a").and; + expect(() => {}).but.changes({}, "a", "hello").and; + expect(() => {}).to.increase({}).and; + expect(() => {}).to.increase({}, "a").and; + expect(() => {}).to.increase({}, "a", "hello").and; + expect(() => {}).but.increases({}).and; + expect(() => {}).but.increases({}, "a").and; + expect(() => {}).but.increases({}, "a", "hello").and; + expect(() => {}).to.decrease({}).and; + expect(() => {}).to.decrease({}, "a").and; + expect(() => {}).to.decrease({}, "a", "hello").and; + expect(() => {}).but.decreases({}).and; + expect(() => {}).but.decreases({}, "a").and; + expect(() => {}).but.decreases({}, "a", "hello").and; + expect(() => {}).to.decreases({}).by(2).and; + expect(() => {}).to.decreases({}).by(2, "hello").and; + expect({}).to.be.extensible.and; + expect({}).to.be.sealed.and; + expect({}).to.be.frozen.and; + expect({}).to.be.finite.and; + + namespace mockTests { + const s1 = adone.shani.util.spy(); + const s2 = adone.shani.util.spy(); + + expect(s1).to.have.been.called; + expect(s1).to.have.been.calledOnce; + expect(s1).to.have.been.calledTwice; + expect(s1).to.have.been.calledThrice; + expect(s1).to.have.callCount(100); + expect(s1).to.have.been.calledBefore(s2); + expect(s1).to.have.been.calledAfter(s2); + expect(s1).to.have.been.calledImmediatelyAfter(s2); + expect(s1).to.have.been.calledImmediatelyBefore(s2); + expect(s1).to.have.been.calledOn({}); + expect(s1).to.have.been.calledOn({}); + expect(s1).to.have.been.calledWith(1, 2, 3); + expect(s1).to.have.been.calledWithExactly(1, 2, 3); + expect(s1).to.have.returned(1); + expect(s1).to.have.thrown({}); + } + } +} diff --git a/types/adone/test/glosses/common.ts b/types/adone/test/glosses/common.ts new file mode 100644 index 0000000000..c66f6a5410 --- /dev/null +++ b/types/adone/test/glosses/common.ts @@ -0,0 +1,808 @@ +namespace commonTests { + namespace is { + { const a: boolean = adone.is.null({}); } + { const a: boolean = adone.is.undefined({}); } + { const a: boolean = adone.is.exist({}); } + { const a: boolean = adone.is.nil({}); } + { const a: boolean = adone.is.number({}); } + { const a: boolean = adone.is.numeral({}); } + { const a: boolean = adone.is.infinite({}); } + { const a: boolean = adone.is.odd({}); } + { const a: boolean = adone.is.even({}); } + { const a: boolean = adone.is.float({}); } + { const a: boolean = adone.is.negativeZero({}); } + { const a: boolean = adone.is.string({}); } + { const a: boolean = adone.is.emptyString({}); } + { const a: boolean = adone.is.substring("abc", "abcdef"); } + { const a: boolean = adone.is.substring("abc", "abcdef", 0); } + { const a: boolean = adone.is.prefix("abc", "abcdef"); } + { const a: boolean = adone.is.suffix("def", "abbdef"); } + { const a: boolean = adone.is.boolean({}); } + { const a: boolean = adone.is.json({}); } + { const a: boolean = adone.is.object({}); } + { const a: boolean = adone.is.plainObject({}); } + { const a: boolean = adone.is.class({}); } + { const a: boolean = adone.is.emptyObject({}); } + { const a: boolean = adone.is.propertyOwned({}, "a"); } + { const a: boolean = adone.is.propertyDefined({}, "a"); } + { const a: boolean = adone.is.conforms({}, {}); } + { const a: boolean = adone.is.conforms({}, {}, true); } + { const a: boolean = adone.is.arrayLikeObject({}); } + { const a: boolean = adone.is.inArray(1, [1, 2, 3]); } + { const a: boolean = adone.is.inArray(1, [1, 2, 3], 0); } + { const a: boolean = adone.is.inArray(1, [1, 2, 3], 0, (a, b) => a === b); } + { const a: boolean = adone.is.sameType({}, {}); } + { const a: boolean = adone.is.primitive({}); } + { const a: boolean = adone.is.equalArrays([], []); } + { const a: boolean = adone.is.deepEqual({}, {}); } + { const a: boolean = adone.is.shallowEqual({}, {}); } + { const a: boolean = adone.is.stream({}); } + { const a: boolean = adone.is.writableStream({}); } + { const a: boolean = adone.is.readableStream({}); } + { const a: boolean = adone.is.duplexStream({}); } + { const a: boolean = adone.is.transformStream({}); } + { const a: boolean = adone.is.utf8(Buffer.alloc(10)); } + { const a: boolean = adone.is.win32PathAbsolute("abc"); } + { const a: boolean = adone.is.posixPathAbsolute("abc"); } + { const a: boolean = adone.is.pathAbsolute("abc"); } + { const a: boolean = adone.is.glob("abc"); } + { const a: boolean = adone.is.dotfile("abc"); } + { const a: boolean = adone.is.function(() => { }); } + { const a: boolean = adone.is.asyncFunction(async () => { }); } + { const a: boolean = adone.is.promise({}); } + { const a: boolean = adone.is.validDate("07.08.2017"); } + { const a: boolean = adone.is.buffer({}); } + { const a: boolean = adone.is.callback({}); } + { const a: boolean = adone.is.generator({}); } + { const a: boolean = adone.is.nan({}); } + { const a: boolean = adone.is.finite({}); } + { const a: boolean = adone.is.integer({}); } + { const a: boolean = adone.is.safeInteger({}); } + { const a: boolean = adone.is.array({}); } + { const a: boolean = adone.is.uint8Array({}); } + { const a: boolean = adone.is.configuration({}); } + { const a: boolean = adone.is.long({}); } + { const a: boolean = adone.is.bigNumber({}); } + { const a: boolean = adone.is.exbuffer({}); } + { const a: boolean = adone.is.exdate({}); } + { const a: boolean = adone.is.transform({}); } + { const a: boolean = adone.is.subsystem({}); } + { const a: boolean = adone.is.application({}); } + { const a: boolean = adone.is.logger({}); } + { const a: boolean = adone.is.coreStream({}); } + { const a: boolean = adone.is.fastStream({}); } + { const a: boolean = adone.is.fastFSStream({}); } + { const a: boolean = adone.is.fastFSMapStream({}); } + { const a: boolean = adone.is.genesisNetron({}); } + { const a: boolean = adone.is.genesisPeer({}); } + { const a: boolean = adone.is.netronAdapter({}); } + { const a: boolean = adone.is.netron({}); } + { const a: boolean = adone.is.netronPeer({}); } + { const a: boolean = adone.is.netronDefinition({}); } + { const a: boolean = adone.is.netronDefinitions({}); } + { const a: boolean = adone.is.netronReference({}); } + { const a: boolean = adone.is.netronInterface({}); } + { const a: boolean = adone.is.netronContext({}); } + { const a: boolean = adone.is.netronIMethod({}, "hello"); } + { const a: boolean = adone.is.netronIProperty({}, "hello"); } + { const a: boolean = adone.is.netronStub({}); } + { const a: boolean = adone.is.netronRemoteStub({}); } + { const a: boolean = adone.is.netronStream({}); } + { const a: boolean = adone.is.iterable({}); } + { const a: boolean = adone.is.windows; } + { const a: boolean = adone.is.linux; } + { const a: boolean = adone.is.freebsd; } + { const a: boolean = adone.is.darwin; } + { const a: boolean = adone.is.sunos; } + { const a: boolean = adone.is.uppercase("abc"); } + { const a: boolean = adone.is.lowercase("abc"); } + { const a: boolean = adone.is.digits("012"); } + { const a: boolean = adone.is.identifier("someMethod"); } + { const a: boolean = adone.is.binaryExtension("mp3"); } + { const a: boolean = adone.is.binaryPath("a.mp3"); } + { const a: boolean = adone.is.ip4("192.168.1.1"); } + { const a: boolean = adone.is.ip6("::192.168.1.1"); } + { const a: boolean = adone.is.arrayBuffer({}); } + { const a: boolean = adone.is.arrayBufferView({}); } + { const a: boolean = adone.is.date({}); } + { const a: boolean = adone.is.error({}); } + { const a: boolean = adone.is.map({}); } + { const a: boolean = adone.is.regexp({}); } + { const a: boolean = adone.is.set({}); } + { const a: boolean = adone.is.symbol({}); } + { const a: boolean = adone.is.validUTF8({}); } + } + + namespace x { + { const a: Error = new adone.x.Exception(); } + { const a: Error = new adone.x.Exception("message"); } + { const a: Error = new adone.x.Exception(new Error()); } + { const a: Error = new adone.x.Exception(new Error(), true); } + { const a: adone.x.Exception = new adone.x.Runtime(); } + { const a: adone.x.Exception = new adone.x.IncompleteBufferError(); } + { const a: adone.x.Exception = new adone.x.NotImplemented(); } + { const a: adone.x.Exception = new adone.x.IllegalState(); } + { const a: adone.x.Exception = new adone.x.NotValid(); } + { const a: adone.x.Exception = new adone.x.Unknown(); } + { const a: adone.x.Exception = new adone.x.NotExists(); } + { const a: adone.x.Exception = new adone.x.Exists(); } + { const a: adone.x.Exception = new adone.x.Empty(); } + { const a: adone.x.Exception = new adone.x.InvalidAccess(); } + { const a: adone.x.Exception = new adone.x.NotSupported(); } + { const a: adone.x.Exception = new adone.x.InvalidArgument(); } + { const a: adone.x.Exception = new adone.x.InvalidNumberOfArguments(); } + { const a: adone.x.Exception = new adone.x.NotFound(); } + { const a: adone.x.Exception = new adone.x.Timeout(); } + { const a: adone.x.Exception = new adone.x.Incorrect(); } + { const a: adone.x.Exception = new adone.x.NotAllowed(); } + { const a: adone.x.Exception = new adone.x.LimitExceeded(); } + { const a: adone.x.Exception = new adone.x.Encoding(); } + { const a: adone.x.Exception = new adone.x.Network(); } + { const a: adone.x.Exception = new adone.x.Bind(); } + { const a: adone.x.Exception = new adone.x.Connect(); } + { const a: adone.x.Exception = new adone.x.Database(); } + { const a: adone.x.Exception = new adone.x.DatabaseInitialization(); } + { const a: adone.x.Exception = new adone.x.DatabaseOpen(); } + { const a: adone.x.Exception = new adone.x.DatabaseRead(); } + { const a: adone.x.Exception = new adone.x.DatabaseWrite(); } + { const a: adone.x.Exception = new adone.x.NetronIllegalState(); } + { const a: adone.x.Exception = new adone.x.NetronPeerDisconnected(); } + { const a: adone.x.Exception = new adone.x.NetronTimeout(); } + } + + namespace EventEmitter { + namespace static { + const a: number = adone.EventEmitter.listenerCount(new adone.EventEmitter(), "event"); + const b: number = adone.EventEmitter.defaultMaxListeners; + } + + namespace addListener { + const a: adone.EventEmitter = new adone.EventEmitter().addListener("event", () => { }); + const b: adone.EventEmitter = new adone.EventEmitter().addListener(Symbol("event"), () => { }); + } + + namespace on { + const a: adone.EventEmitter = new adone.EventEmitter().on("event", () => { }); + const b: adone.EventEmitter = new adone.EventEmitter().on(Symbol("event"), () => { }); + } + + namespace once { + const a: adone.EventEmitter = new adone.EventEmitter().once("event", () => { }); + const b: adone.EventEmitter = new adone.EventEmitter().once(Symbol("event"), () => { }); + } + + namespace prependListener { + const a: adone.EventEmitter = new adone.EventEmitter().prependListener("event", () => { }); + const b: adone.EventEmitter = new adone.EventEmitter().prependListener(Symbol("event"), () => { }); + } + + namespace prependOnceListener { + const a: adone.EventEmitter = new adone.EventEmitter().prependOnceListener("event", () => { }); + const b: adone.EventEmitter = new adone.EventEmitter().prependOnceListener(Symbol("event"), () => { }); + } + + namespace prependOnceListener { + const a: adone.EventEmitter = new adone.EventEmitter().prependOnceListener("event", () => { }); + const b: adone.EventEmitter = new adone.EventEmitter().prependOnceListener(Symbol("event"), () => { }); + } + + namespace removeListener { + const a: adone.EventEmitter = new adone.EventEmitter().removeListener("event", () => { }); + const b: adone.EventEmitter = new adone.EventEmitter().removeListener(Symbol("event"), () => { }); + } + + namespace removeAllListeners { + const a: adone.EventEmitter = new adone.EventEmitter().removeAllListeners("event"); + const b: adone.EventEmitter = new adone.EventEmitter().removeAllListeners(Symbol("event")); + } + + namespace setMaxListeners { + const a: adone.EventEmitter = new adone.EventEmitter().setMaxListeners(10); + } + + namespace getMaxListeners { + const a: number = new adone.EventEmitter().getMaxListeners(); + } + + namespace listeners { + const a: Array<(...args: any[]) => any> = new adone.EventEmitter().listeners("event"); + const b: Array<(...args: any[]) => any> = new adone.EventEmitter().listeners(Symbol("event")); + } + + namespace emit { + const a: boolean = new adone.EventEmitter().emit("event", 1, 2, 3); + const b: boolean = new adone.EventEmitter().emit(Symbol("event"), 1, 2, 3); + } + + namespace eventNames { + const a: Array = new adone.EventEmitter().eventNames(); + const b: Array = new adone.EventEmitter().eventNames(); + } + + namespace listenerCount { + const a: number = new adone.EventEmitter().listenerCount("event"); + const b: number = new adone.EventEmitter().listenerCount(Symbol("event")); + } + } + + namespace AsyncEmitter { + const a: adone.EventEmitter = new adone.AsyncEmitter(); + new adone.AsyncEmitter(10); + + namespace setConcurrency { + const a: adone.AsyncEmitter = new adone.AsyncEmitter().setConcurrency(); + const b: adone.AsyncEmitter = new adone.AsyncEmitter().setConcurrency(10); + } + + namespace emitParallel { + const a: Promise = new adone.AsyncEmitter().emitParallel("even"); + const b: Promise = new adone.AsyncEmitter().emitParallel("even", 1, 2, 3); + } + + namespace emitSerial { + const a: Promise = new adone.AsyncEmitter().emitSerial("even"); + const b: Promise = new adone.AsyncEmitter().emitSerial("even", 1, 2, 3); + } + + namespace emitReduce { + const a: Promise = new adone.AsyncEmitter().emitReduce("even"); + const b: Promise = new adone.AsyncEmitter().emitReduce("even", 1, 2, 3); + } + + namespace emitReduceRight { + const a: Promise = new adone.AsyncEmitter().emitReduceRight("even"); + const b: Promise = new adone.AsyncEmitter().emitReduceRight("even", 1, 2, 3); + } + + namespace subscribe { + const a: () => void = new adone.AsyncEmitter().subscribe("event", () => { }); + const b: () => void = new adone.AsyncEmitter().subscribe("event", () => { }, true); + } + } + + namespace ExBuffer { + new adone.ExBuffer(); + new adone.ExBuffer(10); + new adone.ExBuffer(10, true); + + const buffer = new adone.ExBuffer(); + + namespace readBitSet { + const a: number[] = buffer.readBitSet(); + const b: number[] = buffer.readBitSet(10); + } + + namespace read { + const a: adone.ExBuffer = buffer.read(1); + const b: adone.ExBuffer = buffer.read(1, 10); + } + + namespace readInt8 { + const a: number = buffer.readInt8(); + const b: number = buffer.readInt8(10); + } + + namespace readUInt8 { + const a: number = buffer.readUInt8(); + const b: number = buffer.readUInt8(10); + } + + namespace readInt16LE { + const a: number = buffer.readInt16LE(); + const b: number = buffer.readInt16LE(10); + } + + namespace readUInt16LE { + const a: number = buffer.readUInt16LE(); + const b: number = buffer.readUInt16LE(10); + } + + namespace readInt16BE { + const a: number = buffer.readInt16BE(); + const b: number = buffer.readInt16BE(10); + } + + namespace readUInt16BE { + const a: number = buffer.readUInt16BE(); + const b: number = buffer.readUInt16BE(10); + } + + namespace readInt32LE { + const a: number = buffer.readInt32LE(); + const b: number = buffer.readInt32LE(10); + } + + namespace readUInt32LE { + const a: number = buffer.readUInt32LE(); + const b: number = buffer.readUInt32LE(10); + } + + namespace readInt32BE { + const a: number = buffer.readInt32BE(); + const b: number = buffer.readInt32BE(10); + } + + namespace readUInt32BE { + const a: number = buffer.readUInt32BE(); + const b: number = buffer.readUInt32BE(10); + } + + namespace readInt64LE { + const a: adone.math.Long = buffer.readInt64LE(); + const b: adone.math.Long = buffer.readInt64LE(10); + } + + namespace readUInt64LE { + const a: adone.math.Long = buffer.readUInt64LE(); + const b: adone.math.Long = buffer.readUInt64LE(10); + } + + namespace readInt64BE { + const a: adone.math.Long = buffer.readInt64BE(); + const b: adone.math.Long = buffer.readInt64BE(10); + } + + namespace readUInt64BE { + const a: adone.math.Long = buffer.readUInt64BE(); + const b: adone.math.Long = buffer.readUInt64BE(10); + } + + namespace readFloatLE { + const a: number = buffer.readFloatLE(); + const b: number = buffer.readFloatLE(10); + } + + namespace readFloatBE { + const a: number = buffer.readFloatBE(); + const b: number = buffer.readFloatBE(10); + } + + namespace readDoubleLE { + const a: number = buffer.readDoubleLE(); + const b: number = buffer.readDoubleLE(10); + } + + namespace readDoubleBE { + const a: number = buffer.readDoubleBE(); + const b: number = buffer.readDoubleBE(10); + } + + namespace write { + const a: adone.ExBuffer = buffer.write("1"); + const b: adone.ExBuffer = buffer.write(new adone.ExBuffer()); + const c: adone.ExBuffer = buffer.write(Buffer.alloc(10)); + const d: adone.ExBuffer = buffer.write(new Uint8Array([1, 2, 3])); + const e: adone.ExBuffer = buffer.write(new ArrayBuffer(10)); + const f: adone.ExBuffer = buffer.write("1", 10); + const g: adone.ExBuffer = buffer.write("1", 10, 10); + const h: adone.ExBuffer = buffer.write("1", 10, 10, "utf8"); + } + + namespace writeBitSet { + const a: adone.ExBuffer = buffer.writeBitSet([1, 2, 3]); + const b: number = buffer.writeBitSet([1, 2, 3], 10); + } + + namespace writeInt8 { + const a: adone.ExBuffer = buffer.writeInt8(10); + const b: adone.ExBuffer = buffer.writeInt8(10, 10); + } + + namespace writeUInt8 { + const a: adone.ExBuffer = buffer.writeUInt8(10); + const b: adone.ExBuffer = buffer.writeUInt8(10, 10); + } + + namespace writeInt16LE { + const a: adone.ExBuffer = buffer.writeInt16LE(10); + const b: adone.ExBuffer = buffer.writeInt16LE(10, 10); + } + + namespace writeInt16BE { + const a: adone.ExBuffer = buffer.writeInt16BE(10); + const b: adone.ExBuffer = buffer.writeInt16BE(10, 10); + } + + namespace writeUInt16LE { + const a: adone.ExBuffer = buffer.writeUInt16LE(10); + const b: adone.ExBuffer = buffer.writeUInt16LE(10, 10); + } + + namespace writeUInt16BE { + const a: adone.ExBuffer = buffer.writeUInt16BE(10); + const b: adone.ExBuffer = buffer.writeUInt16BE(10, 10); + } + + namespace writeInt32LE { + const a: adone.ExBuffer = buffer.writeInt32LE(10); + const b: adone.ExBuffer = buffer.writeInt32LE(10, 10); + } + + namespace writeInt32BE { + const a: adone.ExBuffer = buffer.writeInt32BE(10); + const b: adone.ExBuffer = buffer.writeInt32BE(10, 10); + } + + namespace writeUInt32LE { + const a: adone.ExBuffer = buffer.writeUInt32LE(10); + const b: adone.ExBuffer = buffer.writeUInt32LE(10, 10); + } + + namespace writeUInt32BE { + const a: adone.ExBuffer = buffer.writeUInt32BE(10); + const b: adone.ExBuffer = buffer.writeUInt32BE(10, 10); + } + + namespace writeInt64LE { + const a: adone.ExBuffer = buffer.writeInt64LE(10); + const b: adone.ExBuffer = buffer.writeInt64LE(10, 10); + } + + namespace writeInt64BE { + const a: adone.ExBuffer = buffer.writeInt64BE(10); + const b: adone.ExBuffer = buffer.writeInt64BE(10, 10); + } + + namespace writeUInt64LE { + const a: adone.ExBuffer = buffer.writeUInt64LE(10); + const b: adone.ExBuffer = buffer.writeUInt64LE(10, 10); + } + + namespace writeUInt64BE { + const a: adone.ExBuffer = buffer.writeUInt64BE(10); + const b: adone.ExBuffer = buffer.writeUInt64BE(10, 10); + } + + namespace writeFloatLE { + const a: adone.ExBuffer = buffer.writeFloatLE(10); + const b: adone.ExBuffer = buffer.writeFloatLE(10, 10); + } + + namespace writeFloatBE { + const a: adone.ExBuffer = buffer.writeFloatBE(10); + const b: adone.ExBuffer = buffer.writeFloatBE(10, 10); + } + + namespace writeDoubleLE { + const a: adone.ExBuffer = buffer.writeDoubleLE(10); + const b: adone.ExBuffer = buffer.writeDoubleLE(10, 10); + } + + namespace writeDoubleBE { + const a: adone.ExBuffer = buffer.writeDoubleBE(10); + const b: adone.ExBuffer = buffer.writeDoubleBE(10, 10); + } + + namespace writeVarInt32 { + const a: adone.ExBuffer = buffer.writeVarint32(10); + const b: number = buffer.writeVarint32(10, 10); + } + + namespace writeVarInt32ZigZag { + const a: adone.ExBuffer = buffer.writeVarint32ZigZag(10); + const b: number = buffer.writeVarint32ZigZag(10, 10); + } + + namespace readVarint32 { + const a: number = buffer.readVarint32(); + const b: { value: number, length: number } = buffer.readVarint32(10); + } + + namespace readVarint32ZigZag { + const a: number = buffer.readVarint32ZigZag(); + const b: { value: number, length: number } = buffer.readVarint32ZigZag(10); + } + + namespace writeVarint64 { + const a: adone.ExBuffer = buffer.writeVarint64(10); + const b: number = buffer.writeVarint64(10, 10); + } + + namespace writeVarint64ZigZag { + const a: adone.ExBuffer = buffer.writeVarint64ZigZag(10); + const b: number = buffer.writeVarint64ZigZag(10, 10); + } + + namespace readVarint64 { + const a: adone.math.Long = buffer.readVarint64(); + const b: { value: adone.math.Long, length: number } = buffer.readVarint64(10); + } + + namespace readVarint64ZigZag { + const a: adone.math.Long = buffer.readVarint64ZigZag(); + const b: { value: adone.math.Long, length: number } = buffer.readVarint64ZigZag(10); + } + + namespace writeCString { + const a: adone.ExBuffer = buffer.writeCString("asd"); + const b: number = buffer.writeCString("123", 10); + } + + namespace readCString { + const a: string = buffer.readCString(); + const b: { string: string, length: number } = buffer.readCString(10); + } + + namespace writeString { + const a: adone.ExBuffer = buffer.writeString("abc"); + const b: number = buffer.writeString("abc", 10); + } + + namespace readString { + const a: string = buffer.readString(10); + const b: string = buffer.readString(10, "b"); + const c: string = buffer.readString(10, "c"); + const d: { string: string, length: number } = buffer.readString(10, "c", 10); + } + + namespace writeVString { + const a: adone.ExBuffer = buffer.writeVString("abc"); + const b: number = buffer.writeVString("abc", 10); + } + + namespace readVString { + const a: string = buffer.readVString(); + const b: { string: string, length: number } = buffer.readVString(10); + } + + namespace appendTo { + const a: adone.ExBuffer = buffer.appendTo(new adone.ExBuffer()); + const b: adone.ExBuffer = buffer.appendTo(new adone.ExBuffer(), 10); + } + + namespace assert { + const a: adone.ExBuffer = buffer.assert(); + const b: adone.ExBuffer = buffer.assert(true); + } + + namespace capacity { + const a: number = buffer.capacity(); + } + + namespace clear { + const a: adone.ExBuffer = buffer.clear(); + } + + namespace compact { + const a: adone.ExBuffer = buffer.compact(); + const b: adone.ExBuffer = buffer.compact(1); + const c: adone.ExBuffer = buffer.compact(1, 10); + } + + namespace copyTo { + const a: adone.ExBuffer = buffer.copyTo(new adone.ExBuffer()); + const b: adone.ExBuffer = buffer.copyTo(new adone.ExBuffer(), 0); + const c: adone.ExBuffer = buffer.copyTo(new adone.ExBuffer(), 0, 0); + const d: adone.ExBuffer = buffer.copyTo(new adone.ExBuffer(), 0, 0, 10); + } + + namespace ensureCapacity { + const a: adone.ExBuffer = buffer.ensureCapacity(10); + } + + namespace fill { + const a: adone.ExBuffer = buffer.fill("0"); + const b: adone.ExBuffer = buffer.fill(0); + const c: adone.ExBuffer = buffer.fill(0, 0); + const d: adone.ExBuffer = buffer.fill(0, 0, 10); + } + + namespace flip { + const a: adone.ExBuffer = buffer.flip(); + } + + namespace mark { + const a: adone.ExBuffer = buffer.mark(); + const b: adone.ExBuffer = buffer.mark(10); + } + + namespace prepend { + const a: adone.ExBuffer = buffer.prepend(""); + const b: adone.ExBuffer = buffer.prepend(new adone.ExBuffer()); + const c: adone.ExBuffer = buffer.prepend(Buffer.alloc(10)); + const d: adone.ExBuffer = buffer.prepend(new Uint8Array([1, 2, 3])); + const e: adone.ExBuffer = buffer.prepend(new ArrayBuffer(10)); + const f: adone.ExBuffer = buffer.prepend("", "utf8"); + const g: adone.ExBuffer = buffer.prepend("", "utf8", 10); + const h: adone.ExBuffer = buffer.prepend("", 10); + } + + namespace prependTo { + const a: adone.ExBuffer = buffer.prependTo(new adone.ExBuffer()); + const b: adone.ExBuffer = buffer.prependTo(new adone.ExBuffer(), 10); + } + + namespace remaining { + const a: number = buffer.remaining(); + } + + namespace reset { + const a: adone.ExBuffer = buffer.reset(); + } + + namespace resize { + const a: adone.ExBuffer = buffer.resize(10); + } + + namespace reverse { + const a: adone.ExBuffer = buffer.reverse(); + const b: adone.ExBuffer = buffer.reverse(1); + const c: adone.ExBuffer = buffer.reverse(1, 10); + } + + namespace skip { + const a: adone.ExBuffer = buffer.skip(10); + } + + namespace slice { + const a: adone.ExBuffer = buffer.slice(); + const b: adone.ExBuffer = buffer.slice(1); + const c: adone.ExBuffer = buffer.slice(1, 10); + } + + namespace toBuffer { + const a: Buffer = buffer.toBuffer(); + const b: Buffer = buffer.toBuffer(true); + const c: Buffer = buffer.toBuffer(true, 0); + const d: Buffer = buffer.toBuffer(true, 0, 10); + } + + namespace toArrayBuffer { + const a: ArrayBuffer = buffer.toArrayBuffer(); + } + + namespace toString { + const a: string = buffer.toString(); + const b: string = buffer.toString("utf8"); + const c: string = buffer.toString("utf8", 0); + const d: string = buffer.toString("utf8", 0, 10); + } + + namespace toBase64 { + const a: string = buffer.toBase64(); + const b: string = buffer.toBase64(0); + const c: string = buffer.toBase64(0, 10); + } + + namespace toBinary { + const a: string = buffer.toBinary(); + const b: string = buffer.toBinary(0); + const c: string = buffer.toBinary(0, 10); + } + + namespace toDebug { + const a: string = buffer.toDebug(); + const b: string = buffer.toDebug(true); + } + + namespace toUTF8 { + const a: string = buffer.toUTF8(); + const b: string = buffer.toUTF8(0); + const c: string = buffer.toUTF8(0, 10); + } + + namespace static { + namespace accessor { + const a: typeof Buffer = adone.ExBuffer.accessor(); + } + + namespace allocate { + const a: adone.ExBuffer = adone.ExBuffer.allocate(); + const b: adone.ExBuffer = adone.ExBuffer.allocate(10); + const c: adone.ExBuffer = adone.ExBuffer.allocate(10, true); + } + + namespace concat { + const a: adone.ExBuffer = adone.ExBuffer.concat([ + new adone.ExBuffer(), + Buffer.alloc(10), + new Uint8Array([1, 2, 3]), + new ArrayBuffer(10) + ]); + const b: adone.ExBuffer = adone.ExBuffer.concat([ + new adone.ExBuffer(), + Buffer.alloc(10), + new Uint8Array([1, 2, 3]), + new ArrayBuffer(10) + ], "utf8"); + const c: adone.ExBuffer = adone.ExBuffer.concat([ + new adone.ExBuffer(), + Buffer.alloc(10), + new Uint8Array([1, 2, 3]), + new ArrayBuffer(10) + ], "utf8", true); + } + + namespace type { + const a: typeof Buffer = adone.ExBuffer.type(); + } + + namespace wrap { + const a: adone.ExBuffer = adone.ExBuffer.wrap(""); + const b: adone.ExBuffer = adone.ExBuffer.wrap(new adone.ExBuffer()); + const c: adone.ExBuffer = adone.ExBuffer.wrap(Buffer.alloc(10)); + const d: adone.ExBuffer = adone.ExBuffer.wrap(new Uint8Array([1, 2, 3])); + const e: adone.ExBuffer = adone.ExBuffer.wrap(new ArrayBuffer(10)); + const f: adone.ExBuffer = adone.ExBuffer.wrap("", "utf8"); + const g: adone.ExBuffer = adone.ExBuffer.wrap("", "utf8", true); + } + + namespace calculateVarint32 { + const a: number = adone.ExBuffer.calculateVarint32(10); + } + + namespace zigZagEncode32 { + const a: number = adone.ExBuffer.zigZagEncode32(10); + } + + namespace zigZagDecode32 { + const a: number = adone.ExBuffer.zigZagDecode32(10); + } + + namespace calculateVarint64 { + const a: number = adone.ExBuffer.calculateVarint64(10); + const b: number = adone.ExBuffer.calculateVarint64("10"); + } + + namespace zigZagEncode64 { + const a: adone.math.Long = adone.ExBuffer.zigZagEncode64(10); + const b: adone.math.Long = adone.ExBuffer.zigZagEncode64("10"); + const c: adone.math.Long = adone.ExBuffer.zigZagEncode64(adone.math.Long.fromValue(10)); + } + + namespace zigZagDecode64 { + const a: adone.math.Long = adone.ExBuffer.zigZagDecode64(10); + const b: adone.math.Long = adone.ExBuffer.zigZagDecode64("10"); + const c: adone.math.Long = adone.ExBuffer.zigZagDecode64(adone.math.Long.fromValue(10)); + } + + namespace calculateUTF8Chars { + const a: number = adone.ExBuffer.calculateUTF8Chars("123"); + } + + namespace calculateString { + const a: number = adone.ExBuffer.calculateString("123"); + } + + namespace fromBase64 { + const a: adone.ExBuffer = adone.ExBuffer.fromBase64("123"); + } + + namespace btoa { + const a: string = adone.ExBuffer.btoa("123"); + } + + namespace atob { + const a: string = adone.ExBuffer.atob("123"); + } + + namespace fromBinary { + const a: adone.ExBuffer = adone.ExBuffer.fromBinary("123"); + } + + namespace fromDebug { + const a: adone.ExBuffer = adone.ExBuffer.fromDebug("12"); + const b: adone.ExBuffer = adone.ExBuffer.fromDebug("12", true); + } + + namespace fromHex { + const a: adone.ExBuffer = adone.ExBuffer.fromHex("192"); + const b: adone.ExBuffer = adone.ExBuffer.fromHex("192", true); + } + + namespace fromUTF8 { + const a: adone.ExBuffer = adone.ExBuffer.fromUTF8("123"); + const b: adone.ExBuffer = adone.ExBuffer.fromUTF8("123", true); + } + + namespace constants { + const a: number = adone.ExBuffer.DEFAULT_CAPACITY; + const b: boolean = adone.ExBuffer.DEFAULT_NOASSERT; + const c: number = adone.ExBuffer.MAX_VARINT32_BYTES; + const d: number = adone.ExBuffer.MAX_VARINT64_BYTES; + const e: string = adone.ExBuffer.METRICS_CHARS; + const f: string = adone.ExBuffer.METRICS_BYTES; + } + } + } +} diff --git a/types/adone/test/glosses/math.ts b/types/adone/test/glosses/math.ts new file mode 100644 index 0000000000..8a9e9bc1cf --- /dev/null +++ b/types/adone/test/glosses/math.ts @@ -0,0 +1,259 @@ +const { math } = adone; + +namespace mathTests { + namespace Long { + new math.Long(); + new math.Long(0); + new math.Long(0, 0); + new math.Long(0, 0, true); + + namespace toInt { + const a: number = new math.Long().toInt(); + } + + namespace toNumber { + const a: number = new math.Long().toNumber(); + } + + namespace toString { + const a: string = new math.Long().toString(); + const b: string = new math.Long().toString(16); + } + + namespace getHighBits { + const a: number = new math.Long().getHighBits(); + } + + namespace getLowBits { + const a: number = new math.Long().getLowBits(); + } + + namespace getLowBitsUnsigned { + const a: number = new math.Long().getLowBitsUnsigned(); + } + + namespace getHighBitsUnsigned { + const a: number = new math.Long().getHighBitsUnsigned(); + } + + namespace getNumBitsAbs { + const a: number = new math.Long().getNumBitsAbs(); + } + + namespace isZero { + const a: boolean = new math.Long().isZero(); + } + + namespace isNegative { + const a: boolean = new math.Long().isNegative(); + } + + namespace isPositive { + const a: boolean = new math.Long().isPositive(); + } + + namespace isOdd { + const a: boolean = new math.Long().isOdd(); + } + + namespace isEven { + const a: boolean = new math.Long().isEven(); + } + + namespace equals { + const a = new math.Long(); + const b: boolean = a.equals(new math.Long()); + const c: boolean = a.equals(1); + const d: boolean = a.equals("1"); + const e: boolean = a.equals({ low: 0, high: 0 }); + } + + namespace lessThan { + const a = new math.Long(); + const b: boolean = a.lessThan(new math.Long()); + const c: boolean = a.lessThan(1); + const d: boolean = a.lessThan("1"); + const e: boolean = a.lessThan({ low: 0, high: 0 }); + } + + namespace lessThanOrEqual { + const a = new math.Long(); + const b: boolean = a.lessThanOrEqual(new math.Long()); + const c: boolean = a.lessThanOrEqual(1); + const d: boolean = a.lessThanOrEqual("1"); + const e: boolean = a.lessThanOrEqual({ low: 0, high: 0 }); + } + + namespace greaterThan { + const a = new math.Long(); + const b: boolean = a.greaterThan(new math.Long()); + const c: boolean = a.greaterThan(1); + const d: boolean = a.greaterThan("1"); + const e: boolean = a.greaterThan({ low: 0, high: 0 }); + } + + namespace greaterThanOrEqual { + const a = new math.Long(); + const b: boolean = a.greaterThanOrEqual(new math.Long()); + const c: boolean = a.greaterThanOrEqual(1); + const d: boolean = a.greaterThanOrEqual("1"); + const e: boolean = a.greaterThanOrEqual({ low: 0, high: 0 }); + } + + namespace greaterThanOrEqual { + const a = new math.Long(); + const b: number = a.compare(new math.Long()); + const c: number = a.compare(1); + const d: number = a.compare("1"); + const e: number = a.compare({ low: 0, high: 0 }); + } + + namespace negate { + const a: adone.math.Long = new math.Long().negate(); + } + + namespace add { + const a = new math.Long(); + const b: adone.math.Long = a.add(new math.Long()); + const c: adone.math.Long = a.add(1); + const d: adone.math.Long = a.add("1"); + const e: adone.math.Long = a.add({ low: 0, high: 0 }); + } + + namespace sub { + const a = new math.Long(); + const b: adone.math.Long = a.sub(new math.Long()); + const c: adone.math.Long = a.sub(1); + const d: adone.math.Long = a.sub("1"); + const e: adone.math.Long = a.sub({ low: 0, high: 0 }); + } + + namespace mul { + const a = new math.Long(); + const b: adone.math.Long = a.mul(new math.Long()); + const c: adone.math.Long = a.mul(1); + const d: adone.math.Long = a.mul("1"); + const e: adone.math.Long = a.mul({ low: 0, high: 0 }); + } + + namespace div { + const a = new math.Long(); + const b: adone.math.Long = a.div(new math.Long()); + const c: adone.math.Long = a.div(1); + const d: adone.math.Long = a.div("1"); + const e: adone.math.Long = a.div({ low: 0, high: 0 }); + } + + namespace mod { + const a = new math.Long(); + const b: adone.math.Long = a.mod(new math.Long()); + const c: adone.math.Long = a.mod(1); + const d: adone.math.Long = a.mod("1"); + const e: adone.math.Long = a.mod({ low: 0, high: 0 }); + } + + namespace not { + const a: adone.math.Long = new math.Long().not(); + } + + namespace and { + const a = new math.Long(); + const b: adone.math.Long = a.and(new math.Long()); + const c: adone.math.Long = a.and(1); + const d: adone.math.Long = a.and("1"); + const e: adone.math.Long = a.and({ low: 0, high: 0 }); + } + + namespace or { + const a = new math.Long(); + const b: adone.math.Long = a.or(new math.Long()); + const c: adone.math.Long = a.or(1); + const d: adone.math.Long = a.or("1"); + const e: adone.math.Long = a.or({ low: 0, high: 0 }); + } + + namespace xor { + const a = new math.Long(); + const b: adone.math.Long = a.xor(new math.Long()); + const c: adone.math.Long = a.xor(1); + const d: adone.math.Long = a.xor("1"); + const e: adone.math.Long = a.xor({ low: 0, high: 0 }); + } + + namespace shl { + const a = new math.Long(); + const b: adone.math.Long = a.shl(new math.Long()); + const c: adone.math.Long = a.shl(1); + } + + namespace shr { + const a = new math.Long(); + const b: adone.math.Long = a.shr(new math.Long()); + const c: adone.math.Long = a.shr(1); + } + + namespace shru { + const a = new math.Long(); + const b: adone.math.Long = a.shr(new math.Long()); + const c: adone.math.Long = a.shr(1); + } + + namespace toSigned { + const a: adone.math.Long = new math.Long().toSigned(); + } + + namespace toUnsigned { + const a: adone.math.Long = new math.Long().toUnsigned(); + } + + namespace toBytes { + const a: number[] = new math.Long().toBytes(); + } + + namespace toBytesLE { + const a: number[] = new math.Long().toBytesLE(); + } + + namespace static { + namespace fromInt { + const a: adone.math.Long = math.Long.fromInt(123); + const b: adone.math.Long = math.Long.fromInt(123, true); + } + + namespace fromNumber { + const a: adone.math.Long = math.Long.fromNumber(123); + const b: adone.math.Long = math.Long.fromNumber(123, true); + } + + namespace fromBits { + const a: adone.math.Long = math.Long.fromBits(0, 0); + const b: adone.math.Long = math.Long.fromBits(123, 0, true); + } + + namespace fromString { + const a: adone.math.Long = math.Long.fromString("123"); + const b: adone.math.Long = math.Long.fromString("123", true); + const c: adone.math.Long = math.Long.fromString("123", 16); + const d: adone.math.Long = math.Long.fromString("123", true, 16); + } + + namespace fromValue { + const a: adone.math.Long = math.Long.fromValue(new math.Long()); + const b: adone.math.Long = math.Long.fromValue(1); + const c: adone.math.Long = math.Long.fromValue("1"); + const e: adone.math.Long = math.Long.fromValue({ low: 0, high: 0 }); + } + + namespace constants { + const a: adone.math.Long = math.Long.MIN_VALUE; + const b: adone.math.Long = math.Long.MAX_VALUE; + const c: adone.math.Long = math.Long.MAX_UNSIGNED_VALUE; + const d: adone.math.Long = math.Long.ZERO; + const e: adone.math.Long = math.Long.UZERO; + const f: adone.math.Long = math.Long.ONE; + const g: adone.math.Long = math.Long.UONE; + const h: adone.math.Long = math.Long.NEG_ONE; + } + } + } +} diff --git a/types/adone/test/glosses/promise.ts b/types/adone/test/glosses/promise.ts new file mode 100644 index 0000000000..c16d1a4852 --- /dev/null +++ b/types/adone/test/glosses/promise.ts @@ -0,0 +1,97 @@ +namespace promiseTests { + const { promise } = adone; + + namespace defer { + const a = promise.defer(); + a.promise.then((x) => 2); + a.resolve(2); + a.reject(3); + const b = promise.defer(); + b.resolve("3"); + b.reject(2); + b.promise.then((x: string) => x); + } + + namespace delay { + const a: Promise = promise.delay(10); + const b: Promise = promise.delay(10, 2); + promise.delay(20, "3").then((x: string) => x); + } + + namespace timeout { + promise.timeout(Promise.resolve(2), 100).then((x: number) => x); + } + + namespace nodeify { + promise.nodeify(Promise.resolve(2), (err: any, value: number) => value).then((x: number) => x); + promise.nodeify(Promise.resolve(2), () => 42).then((x: number) => x); + } + + namespace promisify { + type Callback = (err?: any, result?: T) => void; + namespace noargs { + const f = (cb: Callback) => { + cb(null, 32); + }; + promise.promisify(f)().then((x: number) => { }); + } + namespace nargs1 { + const f = (a: number, cb: Callback) => { + cb(null, 32); + }; + promise.promisify(f)(1).then((x: number) => { }); + } + + namespace nargs2 { + const f = (a: number, b: string, cb: Callback) => { + cb(null, 32); + }; + promise.promisify(f)(1, "1").then((x: number) => { }); + } + + namespace nargs3 { + const f = (a: number, b: string, c: number, cb: Callback) => { + cb(null, 32); + }; + promise.promisify(f)(1, "1", 1).then((x: number) => { }); + } + + namespace nargs4 { + const f = (a: number, b: string, c: number, d: string, cb: Callback) => { + cb(null, 32); + }; + promise.promisify(f)(1, "1", 1, "1").then((x: number) => { }); + } + + namespace nargs5 { + const f = (a: number, b: string, c: number, d: string, e: number, cb: Callback) => { + cb(null, 32); + }; + promise.promisify(f)(1, "1", 1, "1", 1).then((x: number) => { }); + } + + namespace moreargs { + const f = (a: number, b: string, c: number, d: string, e: number, f: string, cb: Callback) => { + cb(null, 32); + }; + promise.promisify(f)(1, 2, 3).then((x) => x); + } + + namespace options { + promise.promisify((cb: Callback) => cb(null, 42), {}); + promise.promisify((cb: Callback) => cb(null, 42), { context: {} }); + } + } + + namespace promisifyAll { + const a: object = promise.promisifyAll({}); + promise.promisifyAll({}, {}); + promise.promisifyAll({}, { context: {} }); + promise.promisifyAll({}, { filter: () => true }); + promise.promisifyAll({}, { suffix: "Async" }); + } + + namespace _finally { + promise.finally(Promise.resolve(2), () => 2).then((x: number) => {}); + } +} diff --git a/types/adone/test/glosses/shani-global.ts b/types/adone/test/glosses/shani-global.ts new file mode 100644 index 0000000000..b59dce4b6a --- /dev/null +++ b/types/adone/test/glosses/shani-global.ts @@ -0,0 +1,163 @@ +namespace shaniGlobalTests { + namespace describeTests { + describe("hello", () => {}); + + describe("hello", function () { + this.skip(); + this.timeout(10); + this.a; + }); + + describe("1", "2", "3", "4", "45", function () { + this.skip(); + this.timeout(10); + this.a; + }); + + describe("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", function () { + this.skip(); + this.timeout(10); + this.a; + }); + + context("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", function () { + this.skip(); + this.timeout(10); + this.a; + }); + } + + namespace itTests { + it("should be here", () => {}); + + it("should be here", function () { + this.timeout(100); + this.skip(); + this.a; + }); + + it("should be here", function (done: () => void) { + this.timeout(1000); + done(); + this.a; + }); + + it("hello", {}, () => {}); + + it("hello", { + skip: true + }, () => {}); + + it("hello", { + skip: () => true + }, () => {}); + + it("hello", { + timeout: () => 1202 + }, () => {}); + + it("hello", { + timeout: 1010 + }, () => {}); + + it("hello", { + before() {} + }, () => {}); + + it("hello", { + before: ["hello", () => {}] + }, () => {}); + + it("hello", { + after() {} + }, () => {}); + + it("hello", { + after: ["hello", () => {}] + }, () => {}); + + specify("hello", { + after: ["hello", () => {}] + }, () => {}); + } + + namespace beforeTests { + before(function() { + this.timeout(100); + this.a; + }); + + before("description", function () { + this.timeout(100); + this.a; + }); + + before("description", function (done) { + this.timeout(100); + done(); + this.a; + }); + } + + namespace afterTests { + after(function () { + this.timeout(10); + this.a; + }); + + after("description", function () { + this.timeout(10); + this.a; + }); + + after("description", function (done) { + this.timeout(10); + this.a; + }); + } + + namespace beforeEachTests { + beforeEach(function () { + this.timeout(100); + this.a; + }); + + beforeEach("hello", function () { + this.timeout(100); + this.a; + }); + + beforeEach("hello", function (done) { + this.timeout(100); + done(); + this.a; + }); + } + + namespace afterEachTests { + afterEach(function () { + this.timeout(100); + this.a; + }); + + afterEach("asd", function () { + this.timeout(100); + this.a; + }); + + afterEach("asd", function (done) { + this.timeout(100); + done(); + this.a; + }); + } + + expect(1).to.be.a("number"); + assert.equal(1, 1); + fakeClock.install().tick(100); + stub()(1, 2, 3); + expect(spy()).to.have.been.calledOnce; + match(2).and(match(2)); + mock().alwaysCalledOn({}); + request({}).expectBody(""); +} diff --git a/types/adone/test/glosses/shani.ts b/types/adone/test/glosses/shani.ts new file mode 100644 index 0000000000..1c09ef3837 --- /dev/null +++ b/types/adone/test/glosses/shani.ts @@ -0,0 +1,544 @@ +namespace shaniTests { + const { shani } = adone; + + namespace engineOptionsTests { + new shani.Engine(); + new shani.Engine({}); + new shani.Engine({ callGc: true }); + new shani.Engine({ defaultTimeout: 1000 }); + new shani.Engine({ defaultHookTimeout: 1000 }); + new shani.Engine({ transpilerOptions: {} }); + } + + namespace contextTests { + const e = new adone.shani.Engine(); + const c = e.context(); + + namespace describeTests { + c.describe("hello", () => {}); + + c.describe("hello", function () { + this.skip(); + this.timeout(10); + this.a; + }); + + c.describe("1", "2", "3", "4", "45", function () { + this.skip(); + this.timeout(10); + this.a; + }); + + c.describe("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", function () { + this.skip(); + this.timeout(10); + this.a; + }); + + c.context("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", function () { + this.skip(); + this.timeout(10); + this.a; + }); + } + + namespace itTests { + c.it("should be here", () => {}); + + c.it("should be here", function () { + this.timeout(100); + this.skip(); + this.a; + }); + + c.it("should be here", function (done) { + this.timeout(100); + this.skip(); + done(); + this.a; + }); + + c.it("hello", {}, () => { }); + + c.it("hello", { + skip: true + }, () => { }); + + c.it("hello", { + skip: () => true + }, () => { }); + + c.it("hello", { + timeout: () => 1202 + }, () => { }); + + c.it("hello", { + timeout: 1010 + }, () => { }); + + c.it("hello", { + before() { } + }, () => { }); + + c.it("hello", { + before: ["hello", () => { }] + }, () => { }); + + c.it("hello", { + after() { } + }, () => { }); + + c.it("hello", { + after: ["hello", () => { }] + }, () => { }); + + c.specify("hello", { + after: ["hello", () => { }] + }, () => { }); + } + + namespace beforeTests { + c.before(function () { + this.timeout(100); + this.a; + }); + + c.before("description", function () { + this.timeout(100); + this.a; + }); + + c.before("description", function (done) { + this.timeout(100); + done(); + this.a; + }); + } + + namespace afterTests { + c.after(function () { + this.timeout(10); + this.a; + }); + + c.after("description", function () { + this.timeout(10); + this.a; + }); + + c.after("description", function (done) { + this.timeout(10); + done(); + this.a; + }); + } + + namespace beforeEachTests { + c.beforeEach(function () { + this.timeout(100); + this.a; + }); + + c.beforeEach("hello", function () { + this.timeout(100); + this.a; + }); + + c.beforeEach("hello", function (done) { + this.timeout(100); + done(); + this.a; + }); + } + + namespace afterEachTests { + c.afterEach(function () { + this.timeout(100); + this.a; + }); + + c.afterEach("asd", function () { + this.timeout(100); + this.a; + }); + + c.afterEach("asd", function (done) { + this.timeout(100); + done(); + this.a; + }); + } + + namespace rootTests { + const { root } = c; + root.children[0]; + root.prepare().then((x) => { }); + root.addChild(root); + const check = (hook: adone.shani.I.Hook) => { + hook.run().then((x) => x); + hook.cause(); + hook.failed() === true; + hook.timeout() + 2; + hook.timeout(10).timeout(10).timeout() + 2; + }; + for (const hook of root.beforeHooks()) { + check(hook); + } + for (const hook of root.afterHooks()) { + check(hook); + } + for (const hook of root.beforeEachHooks()) { + check(hook); + } + for (const hook of root.afterEachHooks()) { + check(hook); + } + root.isInclusive() === true; + root.isExclusive() === false; + root.hasInclusive() === true; + root.skip().only().skip(); + const a: number | null = root.timeout(); + root.timeout(100).timeout(100); + root.level() + 2; + root.level(2).level() + 2; + root.chain().toLowerCase(); + root.blockChain()[0].blockChain()[0].addChild(root); + } + + namespace eventEmitterTests { + const a = c.start(); + a.on("enter block", ({ block }) => { + block.addChild(block); + }).on("exit block", ({ block }) => { + block.addChild(block); + }).on("start test", ({ block, test }) => { + block.addChild(test); + test.chain(); + }).on("end test", ({ block, test, meta }) => { + block.addChild(test); + test.chain(); + meta.err; + meta.elapsed + 2; + }).on("start before hook", ({ block, hook }) => { + block.addChild(block); + hook.desctiption; + }).on("end before hook", ({ block, hook, meta }) => { + block.addChild(block); + hook.desctiption; + meta.err; + meta.elapsed; + }).on("start after hook", ({ block, hook }) => { + block.addChild(block); + hook.desctiption; + }).on("end after hook", ({ block, hook, meta }) => { + block.addChild(block); + hook.desctiption; + meta.err; + meta.elapsed; + }).on("start before each hook", ({ block, hook }) => { + block.addChild(block); + hook.desctiption; + }).on("end before each hook", ({ block, hook, meta }) => { + block.addChild(block); + hook.desctiption; + meta.err; + meta.elapsed; + }).on("start after each hook", ({ block, hook }) => { + block.addChild(block); + hook.desctiption; + }).on("end after each hook", ({ block, hook, meta }) => { + block.addChild(block); + hook.desctiption; + meta.err; + meta.elapsed; + }).on("start before test hook", ({ block, hook }) => { + block.addChild(block); + hook.desctiption; + }).on("end before test hook", ({ block, hook, meta }) => { + block.addChild(block); + hook.desctiption; + meta.err; + meta.elapsed; + }).on("start after test hook", ({ block, hook }) => { + block.addChild(block); + hook.desctiption; + }).on("end after test hook", ({ block, hook, meta }) => { + block.addChild(block); + hook.desctiption; + meta.err; + meta.elapsed; + }).on("error", (err) => {}).on("done", () => {}).stop(); + } + } + + namespace utilTests { + const { util } = shani; + + namespace spyCallTests { + const call = util.spy().firstCall; + call.calledBefore(call) === true; + call.calledAfter(call) === true; + call.calledWithNew(call) === true; + call.thisValue; + call.args[0]; + call.exception; + call.returnValue; + call.calledOn({}) === true; + call.calledWith(1, 2, 3) === true; + call.calledWithExactly(1, 2, 3) === true; + call.calledWithMatch(1, 2, 3) === true; + call.notCalledWith(1, 2, 3) === true; + call.notCalledWithMatch(1, 2, 3) === true; + call.returned(1) === true; + call.threw() === true; + call.threw("12") === true; + call.threw({}) === true; + call.callArg(1); + call.callArgOn(1, {}); + call.callArgWith(1, 1, 2, 3); + call.callArgOnWith(1, {}, 1, 2, 3); + call.yield(1, 2, 3); + call.yieldOn({}, 1, 2, 3); + call.yieldToOn("a", {}, 1, 2, 3); + } + + namespace spyTests { + util.spy().alwaysCalledOn({}); + util.spy(() => { }).alwaysCalledOn({}); + const a: number = util.spy().callCount; + const s = util.spy(); + s.called === true; + s.notCalled === true; + s.calledOnce === true; + s.calledTwice === true; + s.calledThrice === true; + s.firstCall.args; + s.secondCall.args; + s.thirdCall.args; + s.lastCall.args; + s.thisValues[0]; + s.args[0][0]; + s.exceptions[0]; + s.returnValues[0]; + s(1, 2, 3); + s.calledBefore(s); + s.calledAfter(s); + s.calledImmediatelyAfter(s); + s.calledImmediatelyBefore(s); + s.calledWithNew() === true; + s.withArgs(1, 2, 3).firstCall.args; + s.alwaysCalledOn({}) === true; + s.alwaysCalledWith(1, 2, 3) === true; + s.alwaysCalledWithExactly(1, 2, 3) === true; + s.alwaysCalledWithMatch(1, 2, 3) === true; + s.neverCalledWith(1, 2, 3) === true; + s.neverCalledWithMatch(1, 2, 3) === true; + s.alwaysThrew() === true; + s.alwaysThrew("a") === true; + s.alwaysThrew({}) === true; + s.alwaysReturned({}) === true; + s.invokeCallback(1, 2, 3); + s.getCall(0).args; + s.getCalls()[0].args; + s.reset(); + s.printf("%s", "1").toLowerCase(); + s.restore(); + } + + namespace stubTests { + util.stub({}); + class A { + a() {} + } + util.stub(new A(), "a").resetHistory(); + const s = util.stub(); + s.resetBehavior(); + s.resetHistory(); + s.usingPromise({}).alwaysCalledOn(2); + s.returns({}).resetBehavior(); + s.returnsArg(1).resetBehavior(); + s.returnsThis().resetBehavior(); + s.resolves().resetBehavior(); + s.resolves(1).resetBehavior(); + s.throws().resetBehavior(); + s.throws("1").resetBehavior(); + s.throwsArg(1).resetBehavior(); + s.throwsException().resetBehavior(); + s.throwsException("1").resetBehavior(); + s.throwsException({}).resetBehavior(); + s.rejects().resetBehavior(); + s.rejects("string").resetBehavior(); + s.rejects(1).resetBehavior(); + s.callsArg(1).resetBehavior(); + s.callThrough().resetBehavior(); + s.callsArgOn(1, {}).resetBehavior(); + s.callsArgOnWith(1, {}, 123).resetBehavior(); + s.callsArgAsync(1).resetBehavior(); + s.callsArgOnAsync(1, {}).resetBehavior(); + s.callsArgOnWithAsync(1, {}, 1, 2, 3).resetBehavior(); + s.callsFake(() => { }).resetBehavior(); + s.get(() => { }).resetBehavior(); + s.set((v) => 1).resetBehavior(); + s.onCall(1).resetBehavior(); + s.onFirstCall().resetBehavior(); + s.onSecondCall().resetBehavior(); + s.onThirdCall().resetBehavior(); + s.value(1).resetBehavior(); + s.yields(1, 2, 3).resetBehavior(); + s.yieldsOn({}, 1, 2).resetBehavior(); + s.yieldsRight(1, 2, 3).resetBehavior(); + s.yieldsTo("a", 1, 2, 3).resetBehavior(); + s.yieldsToOn("a", {}, 1, 2, 3).resetBehavior(); + s.yieldsAsync(1, 2, 3).resetBehavior(); + s.yieldsOnAsync({}, 1, 2, 3).resetBehavior(); + s.yieldsToAsync("a", 1, 2, 3).resetBehavior(); + s.yieldsToOnAsync("1", {}, 1, 2, 3).resetBehavior(); + s.withArgs(1, 2, 3).resetBehavior(); + } + + namespace expectationTests { + util.expectation.create(""); + const e = util.expectation.create(); + e.atLeast(1).never(); + e.atMost(2).never(); + e.never().never(); + e.once().never(); + e.twice().never(); + e.thrice().never(); + e.exactly(1).never(); + e.withArgs(1, 2, 3).never(); + e.withExactArgs(1, 2, 3).never(); + e.on({}).never(); + e.verify().never(); + e.restore(); + } + + namespace mockTests { + util.mock().never(); + util.mock({}).expects("").restore(); + util.mock({}).verify(); + } + + namespace assertTests { + util.assert.failException; + util.assert.fail(); + util.assert.fail("1"); + util.assert.pass(1); + const s = util.spy(); + util.assert.notCalled(s); + util.assert.called(s); + util.assert.calledOnce(s); + util.assert.calledTwice(s); + util.assert.calledThrice(s); + util.assert.callCount(s, 10); + util.assert.callOrder(s, s, s, s); + util.assert.calledOn(s, {}); + util.assert.calledOn(s, {}); + util.assert.alwaysCalledOn(s, {}); + util.assert.calledWith(s, {}); + util.assert.neverCalledWith(s, {}); + util.assert.calledWithExactly(s, {}); + util.assert.alwaysCalledWithExactly(s, {}); + util.assert.calledWithMatch(s, {}); + util.assert.alwaysCalledWithMatch(s, {}); + util.assert.neverCalledWithMatch(s, {}); + util.assert.threw(s); + util.assert.threw(s, "a"); + util.assert.threw(s, {}); + util.assert.alwaysThrew(s); + util.assert.alwaysThrew(s, ""); + util.assert.alwaysThrew(s, {}); + util.assert.expose({}); + util.assert.expose({}, { includeFail: true }); + util.assert.expose({}, { prefix: "a" }); + } + + namespace matchTests { + util.match(1).and(util.match(1)); + util.match("1").and(util.match(1)); + util.match(/1/).and(util.match(1)); + util.match({}).and(util.match(1)); + util.match((v: any) => true).and(util.match(1)); + util.match((v: any) => true, "a").and(util.match(1)); + util.match.any.and; + util.match.defined.and; + util.match.truthy.and; + util.match.falsy.and; + util.match.bool.and; + util.match.number.and; + util.match.string.and; + util.match.object.and; + util.match.func.and; + util.match.map.contains(new Map()); + util.match.map.deepEquals(new Map()); + util.match.set.contains(new Set()); + util.match.array.contains([]); + util.match.array.deepEquals([]); + util.match.array.endsWith([]); + util.match.array.startsWith([]); + util.match.regexp.and; + util.match.date.and; + util.match.symbol.and; + util.match.same({}).and; + util.match.typeOf("string").and; + util.match.instanceOf({}).and; + util.match.has("a").and; + util.match.has("a", {}).and; + util.match.hasOwn("a").and; + util.match.hasOwn("a", {}).and; + } + + namespace sandboxTests { + util.sandbox.create(); + util.sandbox.create({}); + util.sandbox.create({ injectInto: {} }); + util.sandbox.create({ properties: ["a"] }); + const s = util.sandbox.create(); + s.assert.alwaysCalledOn(s.spy(), {}); + s.spy().args; + s.stub().args; + s.mock().args; + s.restore(); + s.reset(); + s.resetHistory(); + s.resetBehavior(); + s.usingPromise({}).reset(); + s.verify(); + s.verifyAndRestore(); + } + } + + namespace requestTests { + const r = request({}); + r.get("/").head("/").post("/").put("/").options("/"); + r.attach("fname", "hello"); + r.attach("fname", "hello", {}); + r.attach("fname", "hello", { type: "application/javascript" }); + r.attach("fname", "hello", { filename: "a.js" }); + r.field("a", "basd"); + r.send("asd"); + r.setHeader("Cookie", "key=value"); + r.auth("user", "pass"); + r.expect(() => true); + r.expect(async () => true); + r.expect((response) => { + assert.equal(response.statusCode, 200); + return response.body.length === 0; + }); + r.expectStatus(200); + r.expectStatusMessage("OK"); + r.expectBody("body"); + r.expectBody(Buffer.from("body")); + r.expectBody(/body/); + r.expectBody({ a: 1 }); + r.expectBody("body", {}); + r.expectBody("body", { decompress: true }); + r.expectEmptyBody(); + r.expectHeader("Cookie", "key=value"); + r.expectHeaderExists("Cookie"); + r.then((x: adone.shani.util.I.Response) => { + x.statusCode === 200; + x.body.fill(0); + }); + } +} diff --git a/types/adone/test/glosses/std.ts b/types/adone/test/glosses/std.ts new file mode 100644 index 0000000000..611f9401e9 --- /dev/null +++ b/types/adone/test/glosses/std.ts @@ -0,0 +1,161 @@ +import adone from "adone"; + +import * as assert from "assert"; +import * as fs from "fs"; +import * as path from "path"; +import * as util from "util"; +import * as events from "events"; +import * as stream from "stream"; +import * as url from "url"; +import * as net from "net"; +import * as http from "http"; +import * as https from "https"; +import * as child_process from "child_process"; +import * as os from "os"; +import * as cluster from "cluster"; +import * as repl from "repl"; +import * as punycode from "punycode"; +import * as readline from "readline"; +import * as string_decoder from "string_decoder"; +import * as querystring from "querystring"; +import * as crypto from "crypto"; +import * as vm from "vm"; +import * as v8 from "v8"; +import * as domain from "domain"; +import * as tty from "tty"; +import * as buffer from "buffer"; +import * as constants from "constants"; +import * as zlib from "zlib"; +import * as tls from "tls"; +import * as console from "console"; +import * as dns from "dns"; +import * as timers from "timers"; +import * as dgram from "dgram"; + +const { std } = adone; + +namespace stdTests { + namespace assert { + std.assert(true); + } + + namespace fs { + std.fs.readFileSync("test").length; + } + + namespace path { + std.path.join("a", "b").charAt(0); + } + + namespace util { + std.util.format("hello").charAt(0); + } + + namespace events { + new std.events.EventEmitter().on("event", () => {}); + } + + namespace steam { + new std.stream.PassThrough().resume(); + } + + namespace url { + std.url.parse("https://adone.io").hostname; + } + + namespace net { + std.net.connect(31337).write("hello"); + } + + namespace http { + std.http.get("http://localhost").end(); + } + + namespace https { + std.https.get("https://adone.io").end(); + } + + namespace child_process { + std.child_process.fork(__filename, [], { stdio: ["ipc"] }).send("hello"); + } + + namespace os { + std.os.tmpdir().charAt(0); + } + + namespace cluster { + std.cluster.fork().kill(); + } + + namespace repl { + std.repl.start().close(); + } + + namespace punycode { + std.punycode.decode("ads").charAt(0); + } + + namespace readline { + std.readline.clearLine(process.stdout, 1); + } + + namespace string_decoder { + new std.string_decoder.StringDecoder().end().charAt(0); + } + + namespace querystring { + std.querystring.escape("hello").charAt(0); + } + + namespace crypto { + std.crypto.createHash("sha1").update("hello").digest("hex"); + } + + namespace vm { + std.vm.runInContext("a + 2", std.vm.createContext({ a: 1 })); + } + + namespace v8 { + std.v8.getHeapStatistics().heap_size_limit + 2; + } + + namespace domain { + std.domain.create().members; + } + + namespace tty { + std.tty.isatty(1) === true; + } + + namespace buffer { + std.buffer.Buffer.alloc(10); + } + + namespace constants { + std.constants.EACCES + 2; + } + + namespace zlib { + std.zlib.createDeflate().write("ttt"); + } + + namespace tls { + std.tls.connect({}).end(); + } + + namespace console { + std.console.trace("message"); + } + + namespace dns { + std.dns.resolve4("adone.io", (err, data) => {}); + } + + namespace timers { + std.timers.setTimeout(() => {}, 2000).unref(); + } + + namespace dgram { + std.dgram.createSocket("udp4").bind(31337); + } +} diff --git a/types/adone/test/glosses/utils.ts b/types/adone/test/glosses/utils.ts new file mode 100644 index 0000000000..9372fb4b30 --- /dev/null +++ b/types/adone/test/glosses/utils.ts @@ -0,0 +1,737 @@ +const { util } = adone; + +namespace utilTests { + namespace arrify { + const a: number[] = util.arrify([1, 2, 3]); + const b: number[] = util.arrify(1); + const c: string[] = util.arrify("2"); + const d: string[] = util.arrify(["1"]); + } + + namespace slice { + const a: number[] = util.slice([1, 2, 3]); + const b: number[] = util.slice([1, 2, 3], 1); + const c: number[] = util.slice([1, 2, 3], 1, 4); + const d: string[] = util.slice(["1"]); + } + + namespace spliceOne { + util.spliceOne([1, 2, 3], 0); + } + + namespace normalizePath { + const a: string = util.normalizePath("path"); + const b: string = util.normalizePath("path", true); + } + + namespace unixifyPath { + const a: string = util.unixifyPath("path"); + const b: string = util.unixifyPath("path", true); + } + + namespace functionName { + const a: string = util.functionName(function f() { }); + const b: string = util.functionName((a, b, c) => { }); + } + + namespace mapArguments { + const a: (...args: any[]) => any = util.mapArguments(() => { }); + const b: (...args: T[]) => T[] = util.mapArguments(1); + const c: (...args: any[]) => any = util.mapArguments([1]); + const d: (x: T) => T = util.mapArguments(); + } + + namespace parseMs { + const result: { + days: number; + hours: number; + milliseconds: number; + minutes: number; + } = util.parseMs(123); + } + + namespace pluralizeWord { + const a: string = util.pluralizeWord("day"); + const b: string = util.pluralizeWord("day", "days"); + const c: string = util.pluralizeWord("day", "days", 1); + } + + namespace functionParams { + const a: string[] = util.functionParams((a: any, b: any, c: any) => { }); + } + + namespace randomChoice { + const a: number = util.randomChoice([1, 2, 3]); + const b: string = util.randomChoice(["1", "2", "3"]); + } + + namespace shuffleArray { + const a: number[] = util.shuffleArray([1, 2, 3]); + const b: string[] = util.shuffleArray(["1", "2", "3"]); + } + + namespace enumerate { + { + const a = util.enumerate([1, 2, 3]); + const it = a[Symbol.iterator](); + const value: [number, number] = it.next().value; + for (const i of a) { + const [idx, value]: [number, number] = i; + } + } + { + const a = util.enumerate(["1", "2"]); + const it = a[Symbol.iterator](); + const value: [number, string] = it.next().value; + for (const i of a) { + const [idx, value]: [number, string] = i; + } + } + } + + namespace zip { + { + const a = util.zip([1, 2, 3], ["4", "5", "6"]); + const it = a[Symbol.iterator](); + const value: [number, string] = it.next().value; + for (const i of a) { + const [i1, i2]: [number, string] = i; + } + } + { + const a = util.zip( + [1, 2, 3], + ["4", "5", "6"], + [7, 8, 9] + ); + const it = a[Symbol.iterator](); + const value: [number, string, number] = it.next().value; + for (const i of a) { + const [i1, i2, i3]: [number, string, number] = i; + } + } + { + const a = util.zip( + [1, 2, 3], + ["4", "5", "6"], + [7, 8, 9], + ["10", "11", "12"] + ); + const it = a[Symbol.iterator](); + const value: [number, string, number, string] = it.next().value; + for (const i of a) { + const [i1, i2, i3, i4]: [number, string, number, string] = i; + } + } + { + const a = util.zip( + [1, 2, 3], + ["4", "5", "6"], + [7, 8, 9], + ["10", "11", "12"], + [13, 14, 15, 16] + ); + const it = a[Symbol.iterator](); + const value: any[] = it.next().value; + for (const i of a) { + const [i1, i2, i3, i4]: any[] = i; + } + } + } + + namespace keys { + const a: string[] = util.keys({}); + const b: string[] = util.keys({}, { all: true }); + const c: string[] = util.keys({}, { followProto: true }); + const d: string[] = util.keys({}, { onlyEnumerable: true }); + } + + namespace values { + const a: any[] = util.values({}); + const b: any[] = util.values({}, { all: true }); + const c: any[] = util.values({}, { followProto: true }); + const d: any[] = util.values({}, { onlyEnumerable: true }); + } + + namespace entries { + const a: Array<[string, any]> = util.entries({}); + const b: Array<[string, any]> = util.entries({}, { all: true }); + const c: Array<[string, any]> = util.entries({}, { followProto: true }); + const d: Array<[string, any]> = util.entries({}, { onlyEnumerable: true }); + } + + namespace toDotNotation { + const a: object = util.toDotNotation({ a: 1 }); + } + + namespace flatten { + const a: number[] = util.flatten([1, [2, 3]]); + const b: number[] = util.flatten([1, [2, 3]], {}); + const c: number[] = util.flatten([1, [2, 3]], { depth: 1 }); + } + + namespace globParent { + const a: string = util.globParent("a/b/c/**"); + } + + namespace by { + const a: (a: number, b: number) => any = util.by((x: number): number => x); + const b: (a: number, b: number) => number = util.by((x: number): string => `${x}`, (a: string, b: string) => a.length - b.length); + } + + namespace toFastProperties { + const a: object = util.toFastProperties({}); + } + + namespace stripBom { + const a: string = util.stripBom("123"); + } + + namespace sortKeys { + const a: object = util.sortKeys({}); + const b: object = util.sortKeys({}, {}); + const c: object = util.sortKeys({}, { deep: true }); + const d: object = util.sortKeys({}, { compare: (a, b) => 2 }); + } + + namespace globize { + const a: string = util.globize("test"); + const b: string = util.globize("test", {}); + const c: string = util.globize("test", { exts: "" }); + const d: string = util.globize("test", { recursively: true }); + } + + namespace unique { + const a: number[] = util.unique([1, 2, 3]); + const b: string[] = util.unique(["1", "2", "3"]); + const c: object[] = util.unique([{ a: 1 }, { a: 2 }], (obj: any) => obj.a); + } + + namespace invertObject { + const a: object = util.invertObject({}); + const b: object = util.invertObject({}, {}); + const c: object = util.invertObject({}, { all: true }); + const d: object = util.invertObject({}, { followProto: true }); + const e: object = util.invertObject({}, { onlyEnumerable: true }); + } + + namespace humanizeTime { + const a: string = util.humanizeTime(12345); + const b: string = util.humanizeTime(12345, {}); + const c: string = util.humanizeTime(12345, { compact: true }); + const d: string = util.humanizeTime(12345, { msDecimalDigits: 2 }); + const e: string = util.humanizeTime(12345, { secDecimalDigits: 2 }); + const f: string = util.humanizeTime(12345, { verbose: true }); + } + + namespace humanizeSize { + const a: string = util.humanizeSize(12345); + const b: string = util.humanizeSize(12345, ""); + } + + namespace parseSize { + const a: number | null = util.parseSize(123); + const b: number | null = util.parseSize("123Kb"); + } + + namespace clone { + const a: object = util.clone({}); + const b: object = util.clone({}, {}); + const c: object = util.clone({}, { deep: true }); + } + + namespace toUTF8Array { + const a: number[] = util.toUTF8Array("hello"); + } + + namespace asyncIter { + util.asyncIter([1, 2, 3], () => { }, () => { }); + } + + namespace asyncFor { + util.asyncFor({}, () => { }, () => { }); + } + + namespace once { + { + const f = () => 2; + const a: () => number = util.once(f); + } + { + const f = (a: number) => `${a}`; + const a: (a: number) => string = util.once(f); + } + } + + namespace asyncWaterfall { + util.asyncWaterfall([ + (callback: (a: any, b: any, c: any) => void) => { + callback(null, 'one', 'two'); + } + ], (err: any, result: any) => { + // + }); + } + + namespace xrange { + for (const i of util.xrange(10)) { + const a: number = i; + } + for (const i of util.xrange(1, 10)) { + const a: number = i; + } + for (const i of util.xrange(1, 10, 2)) { + const a: number = i; + } + } + namespace range { + const a: number[] = util.range(10); + const b: number[] = util.range(1, 10); + const c: number[] = util.range(1, 10, 2); + } + + namespace reFindAll { + const a: RegExpExecArray[] = util.reFindAll(/\d+/, "1 2 3 4 5"); + } + + namespace assignDeep { + const a: object = util.assignDeep({ a: 1 }, { a: 2 }); + } + + namespace match { + const a: number | boolean = util.match(["a", "b", "c"], "a"); + const b: (a: any, b: any) => number | boolean = util.match("a", { index: true }); + const c: number | boolean = util.match(["a", "b", "c"], "a", { dot: true }); + const d: (a: any, b: any) => number | boolean = util.match("a", { end: 2 }); + const e: (a: any, b: any) => number | boolean = util.match("a", { start: 2 }); + const f: (a: any, b: any) => number | boolean = util.match("a"); + } + + namespace toposort { + const a: number[] = util.toposort([ + [0, 1], + [2, 3], + [4, 5], + [6, 7] + ]); + const b: number[] = util.toposort.array([0, 1, 2], [ + [0, 1], + [2, 3], + [4, 5], + [6, 7] + ]); + } + + namespace jsesc { + const a: string = util.jsesc({ a: 1 }); + const b: string = util.jsesc({ a: 1 }, { escapeEverything: true }); + const c: string = util.jsesc({ a: 1 }, { minimal: true }); + const d: string = util.jsesc({ a: 1 }, { isScriptContext: true }); + const e: string = util.jsesc({ a: 1 }, { quotes: "'" }); + const f: string = util.jsesc({ a: 1 }, { wrap: true }); + const g: string = util.jsesc({ a: 1 }, { es6: true }); + const h: string = util.jsesc({ a: 1 }, { json: true }); + const i: string = util.jsesc({ a: 1 }, { compact: true }); + const j: string = util.jsesc({ a: 1 }, { lowercaseHex: true }); + const k: string = util.jsesc({ a: 1 }, { numbers: "decimal" }); + const l: string = util.jsesc({ a: 1 }, { indent: " " }); + const m: string = util.jsesc({ a: 1 }, { indentLevel: 4 }); + const n: string = util.jsesc({ a: 1 }, { __inline1__: true }); + const o: string = util.jsesc({ a: 1 }, { __inline2__: true }); + } + + namespace typeOf { + const a: string = util.typeOf(1); + } + + namespace memcpy { + const a: number = util.memcpy.utou(Buffer.alloc(10), 0, Buffer.alloc(10), 0, 10); + const b: number = util.memcpy.atoa(new ArrayBuffer(10), 0, new ArrayBuffer(10), 0, 10); + const c: number = util.memcpy.atou(Buffer.alloc(10), 0, new ArrayBuffer(10), 0, 10); + const d: number = util.memcpy.utoa(new ArrayBuffer(10), 0, Buffer.alloc(10), 0, 10); + const e: number = util.memcpy.copy(Buffer.alloc(10), 0, Buffer.alloc(10), 0, 10); + const f: number = util.memcpy.copy(new ArrayBuffer(10), 0, new ArrayBuffer(10), 0, 10); + const g: number = util.memcpy.copy(Buffer.alloc(10), 0, new ArrayBuffer(10), 0, 10); + const h: number = util.memcpy.copy(new ArrayBuffer(10), 0, Buffer.alloc(10), 0, 10); + } + + namespace uuid { + namespace v1 { + const a: string = util.uuid.v1(); + const b: number[] = util.uuid.v1({}, []); + const c: number[] = util.uuid.v1({}, [], 1); + const d: string = util.uuid.v1({}); + const e: string = util.uuid.v1({ clockseq: 1 }); + const f: string = util.uuid.v1({ msecs: 1 }); + const g: string = util.uuid.v1({ nsecs: 1 }); + } + + namespace v4 { + const a: string = util.uuid.v4(); + const b: number[] = util.uuid.v4({}, []); + const c: number[] = util.uuid.v4({}, [], 1); + const d: string = util.uuid.v4({}); + const e: string = util.uuid.v4({ clockseq: 1 }); + const f: string = util.uuid.v4({ msecs: 1 }); + const g: string = util.uuid.v4({ nsecs: 1 }); + } + + namespace v5 { + const a: string = util.uuid.v5([], []); + const b: number[] = util.uuid.v5([], [], []); + const c: number[] = util.uuid.v5([], [], [], 1); + } + } + + namespace delegate { + const a = util.delegate({}, "a"); + a.getter("a").access("b").method("c").setter("d"); + } + + namespace GlobExp { + { + const glob = new util.GlobExp("*.js"); + const a: boolean = glob.hasMagic(); + const b: string[] = glob.expandBraces(); + const c: RegExp = glob.makeRe(); + const d: boolean = glob.test("a.js"); + } + { + const a: boolean = util.GlobExp.hasMagic("*.js"); + const b: string[] = util.GlobExp.expandBraces("*.js"); + const c: RegExp = util.GlobExp.makeRe("*.js"); + const d: boolean = util.GlobExp.test("*.js", "a.js"); + } + new util.GlobExp(""); + new util.GlobExp("", {}); + new util.GlobExp("", { dot: true }); + new util.GlobExp("", { flipNegate: true }); + new util.GlobExp("", { matchBase: true }); + new util.GlobExp("", { nobrace: true }); + new util.GlobExp("", { nocase: true }); + new util.GlobExp("", { nocomment: true }); + new util.GlobExp("", { noext: true }); + new util.GlobExp("", { noglobstar: true }); + new util.GlobExp("", { nonegate: true }); + util.GlobExp.hasMagic("", {}); + util.GlobExp.hasMagic("", { dot: true }); + util.GlobExp.hasMagic("", { flipNegate: true }); + util.GlobExp.hasMagic("", { matchBase: true }); + util.GlobExp.hasMagic("", { nobrace: true }); + util.GlobExp.hasMagic("", { nocase: true }); + util.GlobExp.hasMagic("", { nocomment: true }); + util.GlobExp.hasMagic("", { noext: true }); + util.GlobExp.hasMagic("", { noglobstar: true }); + util.GlobExp.hasMagic("", { nonegate: true }); + util.GlobExp.expandBraces("", {}); + util.GlobExp.expandBraces("", { dot: true }); + util.GlobExp.expandBraces("", { flipNegate: true }); + util.GlobExp.expandBraces("", { matchBase: true }); + util.GlobExp.expandBraces("", { nobrace: true }); + util.GlobExp.expandBraces("", { nocase: true }); + util.GlobExp.expandBraces("", { nocomment: true }); + util.GlobExp.expandBraces("", { noext: true }); + util.GlobExp.expandBraces("", { noglobstar: true }); + util.GlobExp.expandBraces("", { nonegate: true }); + util.GlobExp.makeRe("", {}); + util.GlobExp.makeRe("", { dot: true }); + util.GlobExp.makeRe("", { flipNegate: true }); + util.GlobExp.makeRe("", { matchBase: true }); + util.GlobExp.makeRe("", { nobrace: true }); + util.GlobExp.makeRe("", { nocase: true }); + util.GlobExp.makeRe("", { nocomment: true }); + util.GlobExp.makeRe("", { noext: true }); + util.GlobExp.makeRe("", { noglobstar: true }); + util.GlobExp.makeRe("", { nonegate: true }); + util.GlobExp.test("a", "b", {}); + util.GlobExp.test("a", "b", { dot: true }); + util.GlobExp.test("a", "b", { flipNegate: true }); + util.GlobExp.test("a", "b", { matchBase: true }); + util.GlobExp.test("a", "b", { nobrace: true }); + util.GlobExp.test("a", "b", { nocase: true }); + util.GlobExp.test("a", "b", { nocomment: true }); + util.GlobExp.test("a", "b", { noext: true }); + util.GlobExp.test("a", "b", { noglobstar: true }); + util.GlobExp.test("a", "b", { nonegate: true }); + } + + namespace iconv { + // TODO + } + + namespace sqlstring { + namespace escapeId { + const a: string = util.sqlstring.escapeId("asd"); + const b: string = util.sqlstring.escapeId(["asd"]); + const c: string = util.sqlstring.escapeId(["asd"], true); + } + + namespace dateToString { + const a: string = util.sqlstring.dateToString(Date.now()); + const b: string = util.sqlstring.dateToString(123, "local"); + } + + namespace arrayToList { + const a: string = util.sqlstring.arrayToList(["1", "a"]); + } + + namespace bufferToString { + const a: string = util.sqlstring.bufferToString(Buffer.alloc(10)); + } + + namespace objectToValues { + const a: string = util.sqlstring.objectToValues({ a: 1 }); + const b: string = util.sqlstring.objectToValues({ a: 1 }, "local"); + } + + namespace escape { + const a: string = util.sqlstring.escape(1); + const b: string = util.sqlstring.escape(1, true); + const c: string = util.sqlstring.escape(1, true, "local"); + } + + namespace format { + const a: string = util.sqlstring.format("??"); + const b: string = util.sqlstring.format("??", "a"); + const c: string = util.sqlstring.format("??", ["a"]); + const d: string = util.sqlstring.format("??", ["a"], true); + } + } + + namespace Editor { + namespace options { + new util.Editor(); + new util.Editor({}); + new util.Editor({ text: "" }); + new util.Editor({ editor: "" }); + new util.Editor({ path: "" }); + new util.Editor({ ext: "" }); + } + + const a: string = util.Editor.DEFAULT; + new util.Editor().spawn().then((x: adone.std.child_process.ChildProcess) => { }); + new util.Editor().run().then((x: string) => { }); + new util.Editor().cleanup().then((x: undefined) => { }); + util.Editor.edit().then((x: string) => { }); + } + + namespace binarySearch { + const a: number = util.binarySearch.GREATEST_LOWER_BOUND; + const b: number = util.binarySearch.GREATEST_LOWER_BOUND; + const c: number = util.binarySearch([1, 2, 3], 2); + const d: number = util.binarySearch([1, 2, 3], 2, 0); + const e: number = util.binarySearch([1, 2, 3], 2, 0, 10); + const f: number = util.binarySearch([1, 2, 3], 2, 0, 10, (a, b) => a - b); + const g: number = util.binarySearch([1, 2, 3], 2, 0, 10, (a, b) => a - b, util.binarySearch.GREATEST_LOWER_BOUND); + } + + namespace buffer { + const a: Buffer = util.buffer.concat([Buffer.alloc(10), Buffer.alloc(20)], 30); + util.buffer.mask(Buffer.alloc(10), Buffer.alloc(10), Buffer.alloc(10), 0, 10); + util.buffer.unmask(Buffer.alloc(10), Buffer.alloc(10)); + } + + namespace shebang { + const a: string | null = util.shebang("#!/bin/sh"); + } + + namespace ReInterval { + new util.ReInterval(() => { }, 1000); + new util.ReInterval(() => { }, 1000, [1]); + const a = new util.ReInterval(() => { }, 1000); + a.reschedule(400); + a.clear(); + a.destroy(); + } + + namespace RateLimiter { + new util.RateLimiter(); + new util.RateLimiter(1); + new util.RateLimiter(1, 1000); + new util.RateLimiter(1, 1000, true); + const a = new util.RateLimiter(); + a.removeTokens(1).then((x: number) => { }); + const b: boolean = a.tryRemoveTokens(10); + const c: number = a.getTokensRemaining(); + } + + namespace throttle { + const a: () => Promise = util.throttle(() => 42); + const b: (a: number) => Promise = util.throttle((a: number) => `${a}`); + const c: (a: number, b: string) => Promise = util.throttle((a: number, b: string) => String(a) + b); + const d = util.throttle(() => { }, {}); + const e = util.throttle(() => { }, { interval: 1000 }); + const f = util.throttle(() => { }, { max: 10 }); + const g = util.throttle(() => { }, { ordered: true }); + const h = util.throttle(() => { }, { waitForReturn: true }); + } + + namespace fakeClock { + namespace timers { + const a: typeof global.setTimeout = util.fakeClock.timers.setTimeout; + const b: typeof global.clearTimeout = util.fakeClock.timers.clearTimeout; + const c: typeof global.setInterval = util.fakeClock.timers.setInterval; + const d: typeof global.clearInterval = util.fakeClock.timers.clearInterval; + const e: typeof global.setImmediate = util.fakeClock.timers.setImmediate; + const f: typeof global.clearImmediate = util.fakeClock.timers.clearImmediate; + const g: typeof global.Date = util.fakeClock.timers.Date; + const h: typeof global.process.hrtime = util.fakeClock.timers.hrtime; + const i: typeof global.process.nextTick = util.fakeClock.timers.nextTick; + } + + namespace install { + util.fakeClock.install(); + util.fakeClock.install(100); + util.fakeClock.install(new Date()); + util.fakeClock.install({}); + util.fakeClock.install({ advanceTimeDelta: 20 }); + util.fakeClock.install({ loopLimit: 20 }); + util.fakeClock.install({ now: 20 }); + util.fakeClock.install({ shouldAdvanceTime: false }); + util.fakeClock.install({ target: {} }); + const clock = util.fakeClock.install({ toFake: ["setTimeout", "clearTimeout"] }); + { + const timer = clock.setTimeout(() => {}, 100, 1, 2, 3); + const id: number = timer.id; + timer.ref(); + timer.unref(); + clock.clearTimeout(timer); + } + { + const timer = clock.setInterval(() => {}, 1, 2, 3); + const id: number = timer.id; + timer.ref(); + timer.unref(); + clock.clearInterval(timer); + } + { + const timer = clock.setImmediate(() => {}, 1, 2, 3); + const id: number = timer.id; + timer.ref(); + timer.unref(); + clock.clearImmediate(timer); + } + clock.nextTick(() => {}, 1, 2, 3); + clock.updateHrTime(10); + const a: number = clock.tick(100); + const b: number = clock.next(); + const c: number = clock.runAll(); + const d: number = clock.runToLast(); + clock.setSystemTime(100); + const e: [number, number] = clock.hrtime(); + const f: [number, number] = clock.hrtime(e); + clock.uninstall(); + } + + namespace createClock { + util.fakeClock.createClock(); + util.fakeClock.createClock(0); + const clock = util.fakeClock.createClock(0, 100); + { + const timer = clock.setTimeout(() => {}, 100, 1, 2, 3); + const id: number = timer.id; + timer.ref(); + timer.unref(); + clock.clearTimeout(timer); + } + { + const timer = clock.setInterval(() => {}, 1, 2, 3); + const id: number = timer.id; + timer.ref(); + timer.unref(); + clock.clearInterval(timer); + } + { + const timer = clock.setImmediate(() => {}, 1, 2, 3); + const id: number = timer.id; + timer.ref(); + timer.unref(); + clock.clearImmediate(timer); + } + clock.nextTick(() => {}, 1, 2, 3); + clock.updateHrTime(10); + const a: number = clock.tick(100); + const b: number = clock.next(); + const c: number = clock.runAll(); + const d: number = clock.runToLast(); + clock.setSystemTime(100); + const e: [number, number] = clock.hrtime(); + const f: [number, number] = clock.hrtime(e); + } + + namespace ltgt { + namespace contains { + const a: boolean = util.ltgt.contains({ lt: 2 }, 2); + const b: boolean = util.ltgt.contains({ lt: 2 }, 2, (a, b) => b - a); + const c: boolean = util.ltgt.contains({ lt: "2" }, "2"); + const d: boolean = util.ltgt.contains({ lt: "2" }, "2", (a, b) => b.charCodeAt(0) - a.charCodeAt(0)); + } + + namespace filter { + const a: (a: number) => boolean = util.ltgt.filter({ lt: 2 }); + const b: (a: number) => boolean = util.ltgt.filter({ lt: 2 }, (a, b) => b - a); + const c: (a: string) => boolean = util.ltgt.filter({ lt: "2" }); + const d: (a: string) => boolean = util.ltgt.filter({ lt: "2" }, (a, b) => b.charCodeAt(0) - a.charCodeAt(0)); + } + + namespace toLtgt { + const a: adone.util.ltgt.I.Range = util.ltgt.toLtgt({ lt: 2 }, {}); + const b: adone.util.ltgt.I.Range = util.ltgt.toLtgt({ lt: 2 }, {}, (a) => `${a}`); + const c: adone.util.ltgt.I.Range = util.ltgt.toLtgt({ lt: 2 }, {}, (a) => a, 2); + const d: adone.util.ltgt.I.Range = util.ltgt.toLtgt({ lt: 2 }, {}, (a) => a, 2, 5); + } + + namespace endEnclusive { + const a: boolean = util.ltgt.endInclusive({ lt: 2 }); + } + + namespace startInclusive { + const a: boolean = util.ltgt.startInclusive({ lt: 2 }); + } + + namespace end { + const a: number | undefined = util.ltgt.end({ lt: 2 }); + const b: number | string = util.ltgt.end({ lt: 2 }, "2"); + const c: number = util.ltgt.end({ lt: 2 }, 2); + } + + namespace start { + const a: number | undefined = util.ltgt.start({ lt: 2 }); + const b: number | string = util.ltgt.start({ lt: 2 }, "2"); + const c: number = util.ltgt.start({ lt: 2 }, 2); + } + + namespace upperBound { + const a: number | undefined = util.ltgt.upperBound({ lt: 2 }); + const b: number | string = util.ltgt.upperBound({ lt: 2 }, "2"); + const c: number = util.ltgt.upperBound({ lt: 2 }, 2); + } + + namespace upperBoundKey { + const a: number | undefined = util.ltgt.upperBoundKey({ lt: 2 }); + } + + namespace upperBoundExclusive { + const a: boolean = util.ltgt.upperBoundInclusive({ lt: 2 }); + } + + namespace lowerBoundExclusive { + const a: boolean = util.ltgt.lowerBoundInclusive({ lt: 2 }); + } + + namespace upperBoundInclusive { + const a: boolean = util.ltgt.upperBoundInclusive({ lt: 2 }); + } + + namespace lowerBoundInclusive { + const a: boolean = util.ltgt.lowerBoundInclusive({ lt: 2 }); + } + + namespace lowerBound { + const a: number | undefined = util.ltgt.lowerBound({ lt: 2 }); + const b: number | string = util.ltgt.lowerBound({ lt: 2 }, "2"); + const c: number = util.ltgt.lowerBound({ lt: 2 }, 2); + } + } + } +} diff --git a/types/adone/test/index-import.ts b/types/adone/test/index-import.ts new file mode 100644 index 0000000000..906e57938c --- /dev/null +++ b/types/adone/test/index-import.ts @@ -0,0 +1,6 @@ +import adone from "adone"; + +namespace AdoneRootImportTests { + adone.falsely() === false; + adone.std.fs.createReadStream(__filename).close(); +} diff --git a/types/adone/test/index.ts b/types/adone/test/index.ts new file mode 100644 index 0000000000..a6cd5093f3 --- /dev/null +++ b/types/adone/test/index.ts @@ -0,0 +1,71 @@ +namespace AdoneRootTests { + { const a: symbol = adone.null; } + adone.noop(); + { const a: number = adone.identity(2); } + { const a: string = adone.identity("2"); } + { const a: number[] = adone.identity([1, 2]); } + { adone.truly() === true; } + { adone.falsely() === false; } + { const a: string = adone.ok; } + { const a: string = adone.bad; } + { const a: string[] = adone.exts; } + adone.log(); + adone.fatal(); + adone.error(); + adone.warn(); + adone.info(); + adone.debug(); + adone.trace(); + { const a: object = adone.o(); } + { const a: object = adone.o({}); } + { const a: typeof Date = adone.Date; } + { const a: typeof process.hrtime = adone.hrtime; } + { const a: typeof setTimeout = adone.setTimeout; } + { const a: typeof clearTimeout = adone.clearTimeout; } + { const a: typeof setInterval = adone.setInterval; } + { const a: typeof clearInterval = adone.clearInterval; } + { const a: typeof setImmediate = adone.setImmediate; } + { const a: typeof clearImmediate = adone.clearImmediate; } + adone.lazify({}); + adone.lazify({}, {}); + adone.lazify({}, {}, () => { }); + adone.lazify({}, {}, () => { }, { configurable: true }); + adone.tag.set({}, "123"); + adone.tag.has({}, "123") === true; + adone.tag.define("12"); + adone.tag.define("123", "456"); + { const a: symbol = adone.tag.SUBSYSTEM; } + { const a: symbol = adone.tag.APPLICATION; } + { const a: symbol = adone.tag.TRANSFORM; } + { const a: symbol = adone.tag.CORE_STREAM; } + { const a: symbol = adone.tag.LOGGER; } + { const a: symbol = adone.tag.LONG; } + { const a: symbol = adone.tag.BIGNUMBER; } + { const a: symbol = adone.tag.EXBUFFER; } + { const a: symbol = adone.tag.EXDATE; } + { const a: symbol = adone.tag.CONFIGURATION; } + { const a: symbol = adone.tag.GENESIS_NETRON; } + { const a: symbol = adone.tag.GENESIS_PEER; } + { const a: symbol = adone.tag.NETRON; } + { const a: symbol = adone.tag.NETRON_PEER; } + { const a: symbol = adone.tag.NETRON_ADAPTER; } + { const a: symbol = adone.tag.NETRON_DEFINITION; } + { const a: symbol = adone.tag.NETRON_DEFINITIONS; } + { const a: symbol = adone.tag.NETRON_REFERENCE; } + { const a: symbol = adone.tag.NETRON_INTERFACE; } + { const a: symbol = adone.tag.NETRON_STUB; } + { const a: symbol = adone.tag.NETRON_REMOTESTUB; } + { const a: symbol = adone.tag.NETRON_STREAM; } + { const a: symbol = adone.tag.FAST_STREAM; } + { const a: symbol = adone.tag.FAST_FS_STREAM; } + { const a: symbol = adone.tag.FAST_FS_MAP_STREAM; } + { const a: Promise = adone.run({}); } + { const a: Promise = adone.run({}, false); } + { const a: object = adone.bind("library"); } // hmm + { const a: string = adone.getAssetAbsolutePath("asset"); } + { const a: Buffer | string = adone.loadAsset("asset"); } + { const a: object = adone.require("path"); } + { const a: object = adone.package; } + { const a: typeof adone.assertion.assert = adone.assert; } + { const a: typeof adone.assertion.expect = adone.expect; } +} diff --git a/types/adone/tsconfig.json b/types/adone/tsconfig.json new file mode 100644 index 0000000000..ad90d2b5d7 --- /dev/null +++ b/types/adone/tsconfig.json @@ -0,0 +1,42 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es2017", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "adone.d.ts", + "glosses/common.d.ts", + "glosses/math.d.ts", + "glosses/std.d.ts", + "glosses/utils.d.ts", + "glosses/assertion.d.ts", + "glosses/promise.d.ts", + "glosses/shani.d.ts", + "glosses/shani-global.d.ts", + "adone-tests.ts", + "test/index.ts", + "test/index-import.ts", + "test/glosses/common.ts", + "test/glosses/math.ts", + "test/glosses/std.ts", + "test/glosses/utils.ts", + "test/glosses/assertion.ts", + "test/glosses/promise.ts", + "test/glosses/shani.ts", + "test/glosses/shani-global.ts" + ] +} diff --git a/types/adone/tslint.json b/types/adone/tslint.json new file mode 100644 index 0000000000..ef323bd7a5 --- /dev/null +++ b/types/adone/tslint.json @@ -0,0 +1,17 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + // TODOs + "align": false, + "no-namespace": false, + "strict-export-declare-modifiers": false, + "no-any-union": false, + "no-boolean-literal-compare": false, + "no-mergeable-namespace": false, + "no-single-declare-module": false, + "no-unnecessary-generics": false, + "no-unnecessary-qualifier": false, + "unified-signatures": false, + "space-before-function-paren": false + } +} \ No newline at end of file diff --git a/types/aframe/tsconfig.json b/types/aframe/tsconfig.json index 9488fe8297..f11ddb6188 100755 --- a/types/aframe/tsconfig.json +++ b/types/aframe/tsconfig.json @@ -1,25 +1,25 @@ { "compilerOptions": { - "baseUrl": "..", - "lib": [ - "es5", - "dom", - "es2015.iterable", - "es2015.promise" - ], - "module": "commonjs", - "noImplicitAny": true, - "noImplicitThis": true, - "removeComments": false, - "sourceMap": true, - "strictNullChecks": true, - "noEmit": true, - "forceConsistentCasingInFileNames": true, - "typeRoots": [ "../" ], - "types": [ ] + "module": "commonjs", + "lib": [ + "es5", + "dom", + "es2015.iterable", + "es2015.promise" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true }, "files": [ - "index.d.ts", - "aframe-tests.ts" + "index.d.ts", + "aframe-tests.ts" ] -} +} \ No newline at end of file diff --git a/types/aframe/tslint.json b/types/aframe/tslint.json index d88586e5bd..71ee04c4e1 100644 --- a/types/aframe/tslint.json +++ b/types/aframe/tslint.json @@ -1,3 +1,6 @@ { - "extends": "dtslint/dt.json" + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } } diff --git a/types/ag-grid/ag-grid-tests.ts b/types/ag-grid/ag-grid-tests.ts deleted file mode 100644 index 7c4ebb0c8c..0000000000 --- a/types/ag-grid/ag-grid-tests.ts +++ /dev/null @@ -1,136 +0,0 @@ - -checkGridOptions({}); -checkColDef({}); - -function checkGridOptions(gridOptions: ag.grid.GridOptions): void { - - gridOptions.virtualPaging = true; - gridOptions.toolPanelSuppressPivot = true; - gridOptions.toolPanelSuppressValues = true; - gridOptions.rowsAlreadyGrouped = true; - gridOptions.suppressRowClickSelection = true; - gridOptions.suppressCellSelection = true; - gridOptions.sortingOrder = ['asc','desc']; - gridOptions.suppressMultiSort = true; - gridOptions.suppressHorizontalScroll = true; - gridOptions.unSortIcon = true; - gridOptions.rowHeight = 0; - gridOptions.rowBuffer = 0; - gridOptions.enableColResize = true; - gridOptions.enableCellExpressions = true; - gridOptions.enableSorting = true; - gridOptions.enableServerSideSorting = true; - gridOptions.enableFilter = true; - gridOptions.enableServerSideFilter = true; - gridOptions.colWidth = 0; - gridOptions.suppressMenuHide = true; - gridOptions.singleClickEdit = true; - gridOptions.debug = true; - gridOptions.icons = {}; - gridOptions.angularCompileRows = true; - gridOptions.angularCompileFilters = true; - gridOptions.angularCompileHeaders = true; - gridOptions.localeText = {}; - gridOptions.localeTextFunc = function() {} - gridOptions.suppressScrollLag = true; - gridOptions.groupSuppressAutoColumn = true; - gridOptions.groupSelectsChildren = true; - gridOptions.groupHidePivotColumns = true; - gridOptions.groupIncludeFooter = true; - gridOptions.groupUseEntireRow = true; - gridOptions.groupSuppressRow = true; - gridOptions.groupSuppressBlankHeader = true; - gridOptions.forPrint = true; - gridOptions.groupColumnDef = {}; - gridOptions.context = {}; - gridOptions.rowStyle = {color: 'red'}; - gridOptions.rowClass = 'green'; - gridOptions.groupDefaultExpanded = false; - gridOptions.slaveGrids = []; - gridOptions.rowSelection = 'single'; - gridOptions.rowDeselection = true; - gridOptions.rowData = []; - gridOptions.floatingTopRowData = []; - gridOptions.floatingBottomRowData = []; - gridOptions.showToolPanel = true; - gridOptions.groupKeys = ['a','b'] - gridOptions.groupAggFields = ['a','b'] - gridOptions.columnDefs = []; - gridOptions.datasource = {}; - gridOptions.pinnedColumnCount = 0; - gridOptions.groupHeaders = true; - gridOptions.headerHeight = 0; - gridOptions.groupRowInnerRenderer = function(params) {}; - gridOptions.groupRowRenderer = {}; - gridOptions.isScrollLag = function() {return true;} - gridOptions.isExternalFilterPresent = function() { return true; }; - gridOptions.doesExternalFilterPass = function(node: ag.grid.RowNode) { return false; }; - gridOptions.getRowStyle = function() {}; - gridOptions.getRowClass = function() {}; - gridOptions.headerCellRenderer = function() {}; - gridOptions.groupAggFunction = function(nodes: any[]) {}; - gridOptions.onReady = function(api: any) {}; - gridOptions.onModelUpdated = function() {}; - gridOptions.onCellClicked = function(params) {}; - gridOptions.onCellDoubleClicked = function(params) {}; - gridOptions.onCellContextMenu = function(params) {}; - gridOptions.onCellValueChanged = function(params) {}; - gridOptions.onCellFocused = function(params) {}; - gridOptions.onRowSelected = function(params) {}; - gridOptions.onSelectionChanged = function() {}; - gridOptions.onBeforeFilterChanged = function() {}; - gridOptions.onAfterFilterChanged = function() {}; - gridOptions.onFilterModified = function() {}; - gridOptions.onBeforeSortChanged = function() {}; - gridOptions.onAfterSortChanged = function() {}; - gridOptions.onVirtualRowRemoved = function(params) {}; - gridOptions.onRowClicked = function(params) {}; - gridOptions.api = null; - gridOptions.columnApi = null; - -} - -function checkColDef(colDef: ag.grid.ColDef): void { - - colDef.sort = 'test'; - colDef.sortedAt = 0; - colDef.sortingOrder = ['asc','desc']; - colDef.headerName = 'test'; - colDef.field = 'test'; - colDef.headerValueGetter = 'test'; - colDef.colId = 'test'; - colDef.hide = true; - colDef.headerTooltip = 'test'; - colDef.valueGetter = 'test'; - colDef.headerCellRenderer = {}; - colDef.headerClass = 'test'; - colDef.width = 0; - colDef.minWidth = 0; - colDef.maxWidth = 0; - colDef.cellClass = 'test'; - colDef.cellStyle = {color: 'test'}; - colDef.cellRenderer = function() {}; - colDef.floatingCellRenderer = function() {}; - colDef.aggFunc = 'test'; - colDef.comparator = function() {}; - colDef.checkboxSelection = true; - colDef.suppressMenu = true; - colDef.suppressSorting = true; - colDef.unSortIcon = true; - colDef.suppressSizeToFit = true; - colDef.suppressResize = true; - colDef.headerGroup = 'test'; - colDef.headerGroupShow = 'test'; - colDef.editable = true; - colDef.newValueHandler = function() {}; - colDef.volatile = true; - colDef.template = 'test'; - colDef.templateUrl = 'test'; - colDef.filter = 'test'; - colDef.filterParams = {}; - colDef.onCellValueChanged = function() {}; - colDef.onCellClicked = function() {}; - colDef.onCellDoubleClicked = function() {}; - colDef.onCellContextMenu = function() {}; - colDef.cellClassRules = {}; -} diff --git a/types/ag-grid/index.d.ts b/types/ag-grid/index.d.ts deleted file mode 100644 index 3fe37571b1..0000000000 --- a/types/ag-grid/index.d.ts +++ /dev/null @@ -1,1991 +0,0 @@ -// Type definitions for ag-grid v2.1.2 -// Project: http://www.ag-grid.com/ -// Definitions by: Niall Crosby -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -declare namespace ag.grid { - class ColumnChangeEvent { - private type; - private column; - private columnGroup; - private fromIndex; - private toIndex; - private pinnedColumnCount; - constructor(type: string); - toString(): string; - withColumn(column: Column): ColumnChangeEvent; - withColumnGroup(columnGroup: ColumnGroup): ColumnChangeEvent; - withFromIndex(fromIndex: number): ColumnChangeEvent; - withPinnedColumnCount(pinnedColumnCount: number): ColumnChangeEvent; - withToIndex(toIndex: number): ColumnChangeEvent; - getFromIndex(): number; - getToIndex(): number; - getPinnedColumnCount(): number; - getType(): string; - getColumn(): Column; - getColumnGroup(): ColumnGroup; - isPivotChanged(): boolean; - isValueChanged(): boolean; - isIndividualColumnResized(): boolean; - } -} -declare namespace ag.grid { - class Utils { - private static isSafari; - private static isIE; - static iterateObject(object: any, callback: (key: string, value: any) => void): void; - static cloneObject(object: any): any; - static map(array: TItem[], callback: (item: TItem) => TResult): TResult[]; - static forEach(array: T[], callback: (item: T, index: number) => void): void; - static filter(array: T[], callback: (item: T) => boolean): T[]; - static assign(object: any, source: any): void; - static getFunctionParameters(func: any): any; - static find(collection: any, predicate: any, value: any): any; - static toStrings(array: T[]): string[]; - static iterateArray(array: T[], callback: (item: T, index: number) => void): void; - static isNode(o: any): boolean; - static isElement(o: any): boolean; - static isNodeOrElement(o: any): boolean; - static addChangeListener(element: HTMLElement, listener: EventListener): void; - static makeNull(value: any): any; - static removeAllChildren(node: HTMLElement): void; - static removeElement(parent: HTMLElement, cssSelector: string): void; - static removeFromParent(node: Element): void; - static isVisible(element: HTMLElement): boolean; - /** - * loads the template and returns it as an element. makes up for no simple way in - * the dom api to load html directly, eg we cannot do this: document.createElement(template) - */ - static loadTemplate(template: string): Node; - static querySelectorAll_addCssClass(eParent: any, selector: string, cssClass: string): void; - static querySelectorAll_removeCssClass(eParent: any, selector: string, cssClass: string): void; - static querySelectorAll_replaceCssClass(eParent: any, selector: string, cssClassToRemove: string, cssClassToAdd: string): void; - static addOrRemoveCssClass(element: HTMLElement, className: string, addOrRemove: boolean): void; - static addCssClass(element: HTMLElement, className: string): void; - static offsetHeight(element: HTMLElement): number; - static offsetWidth(element: HTMLElement): number; - static removeCssClass(element: HTMLElement, className: string): void; - static removeFromArray(array: T[], object: T): void; - static defaultComparator(valueA: any, valueB: any): number; - static formatWidth(width: number | string): string; - /** - * Tries to use the provided renderer. - */ - static useRenderer(eParent: Element, eRenderer: (params: TParams) => Node | string, params: TParams): void; - /** - * If icon provided, use this (either a string, or a function callback). - * if not, then use the second parameter, which is the svgFactory function - */ - static createIcon(iconName: any, gridOptionsWrapper: any, colDefWrapper: any, svgFactoryFunc: () => Node): HTMLSpanElement; - static addStylesToElement(eElement: any, styles: any): void; - static getScrollbarWidth(): number; - static isKeyPressed(event: KeyboardEvent, keyToCheck: number): boolean; - static setVisible(element: HTMLElement, visible: boolean): void; - static isBrowserIE(): boolean; - static isBrowserSafari(): boolean; - } -} -declare namespace ag.grid { - class Constants { - static STEP_EVERYTHING: number; - static STEP_FILTER: number; - static STEP_SORT: number; - static STEP_MAP: number; - static ASC: string; - static DESC: string; - static ROW_BUFFER_SIZE: number; - static MIN_COL_WIDTH: number; - static SUM: string; - static MIN: string; - static MAX: string; - static KEY_TAB: number; - static KEY_ENTER: number; - static KEY_BACKSPACE: number; - static KEY_DELETE: number; - static KEY_ESCAPE: number; - static KEY_SPACE: number; - static KEY_DOWN: number; - static KEY_UP: number; - static KEY_LEFT: number; - static KEY_RIGHT: number; - } -} -declare namespace ag.grid { - class Column { - static colIdSequence: number; - colDef: ColDef; - actualWidth: any; - visible: any; - colId: any; - pinned: boolean; - index: number; - aggFunc: string; - pivotIndex: number; - sort: string; - sortedAt: number; - constructor(colDef: ColDef, actualWidth: any); - isGreaterThanMax(width: number): boolean; - getMinimumWidth(): number; - setMinimum(): void; - } -} -declare namespace ag.grid { - class ColumnGroup { - pinned: any; - name: any; - allColumns: Column[]; - displayedColumns: Column[]; - expandable: boolean; - expanded: boolean; - actualWidth: number; - constructor(pinned: any, name: any); - getMinimumWidth(): number; - addColumn(column: any): void; - calculateExpandable(): void; - calculateActualWidth(): void; - calculateDisplayedColumns(): void; - addToVisibleColumns(colsToAdd: any): void; - } -} -declare namespace ag.grid { - class GridOptionsWrapper { - private gridOptions; - private groupHeaders; - private headerHeight; - private rowHeight; - private floatingTopRowData; - private floatingBottomRowData; - init(gridOptions: GridOptions, eventService: EventService): void; - isRowSelection(): boolean; - isRowDeselection(): boolean; - isRowSelectionMulti(): boolean; - getContext(): any; - isVirtualPaging(): boolean; - isShowToolPanel(): boolean; - isToolPanelSuppressPivot(): boolean; - isToolPanelSuppressValues(): boolean; - isRowsAlreadyGrouped(): boolean; - isGroupSelectsChildren(): boolean; - isGroupHidePivotColumns(): boolean; - isGroupIncludeFooter(): boolean; - isGroupSuppressBlankHeader(): boolean; - isSuppressRowClickSelection(): boolean; - isSuppressCellSelection(): boolean; - isSuppressMultiSort(): boolean; - isGroupSuppressAutoColumn(): boolean; - isForPrint(): boolean; - isSuppressHorizontalScroll(): boolean; - isUnSortIcon(): boolean; - isSuppressMenuHide(): boolean; - getRowStyle(): any; - getRowClass(): any; - getRowStyleFunc(): any; - getRowClassFunc(): any; - getHeaderCellRenderer(): any; - getApi(): GridApi; - isEnableColResize(): boolean; - isSingleClickEdit(): boolean; - getGroupDefaultExpanded(): any; - getGroupKeys(): string[]; - getGroupAggFunction(): (nodes: any[]) => any; - getGroupAggFields(): string[]; - getRowData(): any[]; - isGroupUseEntireRow(): boolean; - getGroupColumnDef(): any; - isGroupSuppressRow(): boolean; - isAngularCompileRows(): boolean; - isAngularCompileFilters(): boolean; - isAngularCompileHeaders(): boolean; - isDebug(): boolean; - getColumnDefs(): any[]; - getDatasource(): any; - getRowBuffer(): number; - isEnableSorting(): boolean; - isEnableCellExpressions(): boolean; - isEnableServerSideSorting(): boolean; - isEnableFilter(): boolean; - isEnableServerSideFilter(): boolean; - isSuppressScrollLag(): boolean; - getIcons(): any; - getIsScrollLag(): () => boolean; - getSortingOrder(): string[]; - getSlaveGrids(): GridOptions[]; - getGroupRowRenderer(): Object | Function; - getRowHeight(): number; - getHeaderHeight(): number; - setHeaderHeight(headerHeight: number): void; - isGroupHeaders(): boolean; - setGroupHeaders(groupHeaders: boolean): void; - getFloatingTopRowData(): any[]; - setFloatingTopRowData(rows: any[]): void; - getFloatingBottomRowData(): any[]; - setFloatingBottomRowData(rows: any[]): void; - isExternalFilterPresent(): boolean; - doesExternalFilterPass(node: RowNode): boolean; - getGroupRowInnerRenderer(): (params: any) => void; - getColWidth(): number; - private checkForDeprecated(); - getPinnedColCount(): number; - getLocaleTextFunc(): Function; - globalEventHandler(eventName: string, event?: any): void; - private getCallbackForEvent(eventName); - } -} -declare namespace ag.grid { - class LoggerFactory { - private logging; - init(gridOptionsWrapper: GridOptionsWrapper): void; - create(name: string): Logger; - } - class Logger { - private logging; - private name; - constructor(name: string, logging: boolean); - log(message: string): void; - } -} -declare namespace ag.grid { - class Events { - /** A new set of columns has been entered, everything has potentially changed. */ - static EVENT_COLUMN_EVERYTHING_CHANGED: string; - /** A pivot column was added, removed or order changed. */ - static EVENT_COLUMN_PIVOT_CHANGE: string; - /** A value column was added, removed or agg function was changed. */ - static EVENT_COLUMN_VALUE_CHANGE: string; - /** A column was moved */ - static EVENT_COLUMN_MOVED: string; - /** One or more columns was shown / hidden */ - static EVENT_COLUMN_VISIBLE: string; - /** A column group was opened / closed */ - static EVENT_COLUMN_GROUP_OPENED: string; - /** One or more columns was resized. If just one, the column in the event is set. */ - static EVENT_COLUMN_RESIZED: string; - /** One or more columns was resized. If just one, the column in the event is set. */ - static EVENT_COLUMN_PINNED_COUNT_CHANGED: string; - static EVENT_MODEL_UPDATED: string; - static EVENT_CELL_CLICKED: string; - static EVENT_CELL_DOUBLE_CLICKED: string; - static EVENT_CELL_CONTEXT_MENU: string; - static EVENT_CELL_VALUE_CHANGED: string; - static EVENT_CELL_FOCUSED: string; - static EVENT_ROW_SELECTED: string; - static EVENT_SELECTION_CHANGED: string; - static EVENT_BEFORE_FILTER_CHANGED: string; - static EVENT_AFTER_FILTER_CHANGED: string; - static EVENT_FILTER_MODIFIED: string; - static EVENT_BEFORE_SORT_CHANGED: string; - static EVENT_AFTER_SORT_CHANGED: string; - static EVENT_VIRTUAL_ROW_REMOVED: string; - static EVENT_ROW_CLICKED: string; - static EVENT_READY: string; - } -} -declare namespace ag.grid { - class EventService { - private allListeners; - private globalListeners; - private getListenerList(eventType); - addEventListener(eventType: string, listener: Function): void; - addGlobalListener(listener: Function): void; - removeEventListener(eventType: string, listener: Function): void; - removeGlobalListener(listener: Function): void; - dispatchEvent(eventType: string, event?: any): void; - } -} -declare namespace ag.grid { - class MasterSlaveService { - private gridOptionsWrapper; - private columnController; - private gridPanel; - private logger; - private eventService; - private consuming; - init(gridOptionsWrapper: GridOptionsWrapper, columnController: ColumnController, gridPanel: GridPanel, loggerFactory: LoggerFactory, eventService: EventService): void; - private fireEvent(callback); - private onEvent(callback); - private fireColumnEvent(event); - fireHorizontalScrollEvent(horizontalScroll: number): void; - onScrollEvent(horizontalScroll: number): void; - onColumnEvent(event: ColumnChangeEvent): void; - } -} -declare namespace ag.grid { - class ColumnApi { - private _columnController; - constructor(_columnController: ColumnController); - sizeColumnsToFit(gridWidth: any): void; - hideColumns(colIds: any, hide: any): void; - columnGroupOpened(group: ColumnGroup, newValue: boolean): void; - getColumnGroup(name: string): ColumnGroup; - getDisplayNameForCol(column: any): string; - getColumn(key: any): Column; - setState(columnState: any): void; - getState(): [any]; - isPinning(): boolean; - getVisibleColAfter(col: Column): Column; - getVisibleColBefore(col: Column): Column; - setColumnVisible(column: Column, visible: boolean): void; - getAllColumns(): Column[]; - getDisplayedColumns(): Column[]; - getPivotedColumns(): Column[]; - getValueColumns(): Column[]; - moveColumn(fromIndex: number, toIndex: number): void; - movePivotColumn(fromIndex: number, toIndex: number): void; - setColumnAggFunction(column: Column, aggFunc: string): void; - setColumnWidth(column: Column, newWidth: number): void; - removeValueColumn(column: Column): void; - addValueColumn(column: Column): void; - removePivotColumn(column: Column): void; - setPinnedColumnCount(count: number): void; - addPivotColumn(column: Column): void; - getHeaderGroups(): ColumnGroup[]; - hideColumn(colId: any, hide: any): void; - } - class ColumnController { - private gridOptionsWrapper; - private angularGrid; - private selectionRendererFactory; - private expressionService; - private masterSlaveController; - private allColumns; - private visibleColumns; - private displayedColumns; - private pivotColumns; - private valueColumns; - private columnGroups; - private setupComplete; - private valueService; - private pinnedColumnCount; - private eventService; - constructor(); - init(angularGrid: Grid, selectionRendererFactory: SelectionRendererFactory, gridOptionsWrapper: GridOptionsWrapper, expressionService: ExpressionService, valueService: ValueService, masterSlaveController: MasterSlaveService, eventService: EventService): void; - getColumnApi(): ColumnApi; - isSetupComplete(): boolean; - getHeaderGroups(): ColumnGroup[]; - getPinnedContainerWidth(): number; - addPivotColumn(column: Column): void; - setPinnedColumnCount(count: number): void; - removePivotColumn(column: Column): void; - addValueColumn(column: Column): void; - removeValueColumn(column: Column): void; - private doesColumnExistInGrid(column); - setColumnWidth(column: Column, newWidth: number): void; - private updateGroupWidthsAfterColumnResize(column); - setColumnAggFunction(column: Column, aggFunc: string): void; - movePivotColumn(fromIndex: number, toIndex: number): void; - moveColumn(fromIndex: number, toIndex: number): void; - getBodyContainerWidth(): number; - getValueColumns(): Column[]; - getPivotedColumns(): Column[]; - getDisplayedColumns(): Column[]; - getAllColumns(): Column[]; - setColumnVisible(column: Column, visible: boolean): void; - getVisibleColBefore(col: any): Column; - getVisibleColAfter(col: Column): Column; - isPinning(): boolean; - getState(): [any]; - setState(columnState: any): void; - getColumns(keys: any[]): Column[]; - getColumn(key: any): Column; - getDisplayNameForCol(column: any): string; - getColumnGroup(name: string): ColumnGroup; - onColumnsChanged(): void; - private checkForDeprecatedItems(columnDefs); - columnGroupOpened(group: ColumnGroup, newValue: boolean): void; - hideColumns(colIds: any, hide: any): void; - private updateModel(); - private updateDisplayedColumns(); - sizeColumnsToFit(gridWidth: any): void; - private buildGroups(); - private updateGroups(); - private updateVisibleColumns(); - private updatePinnedColumns(); - private createColumns(colDefs); - private createPivotColumns(); - private createValueColumns(); - private createDummyColumn(field); - private calculateColInitialWidth(colDef); - private getTotalColWidth(includePinned); - } -} -declare namespace ag.grid { - interface CsvExportParams { - skipHeader?: boolean; - skipFooters?: boolean; - skipGroups?: boolean; - fileName?: string; - } - class CsvCreator { - private rowController; - private columnController; - private grid; - private valueService; - constructor(rowController: InMemoryRowController, columnController: ColumnController, grid: Grid, valueService: ValueService); - exportDataAsCsv(params?: CsvExportParams): void; - getDataAsCsv(params?: CsvExportParams): string; - private createValueForGroupNode(node); - private escape(value); - } -} -declare namespace ag.grid { - class ExpressionService { - private expressionToFunctionCache; - private logger; - init(loggerFactory: LoggerFactory): void; - evaluate(expression: string, params: any): any; - private createExpressionFunction(expression); - private createFunctionBody(expression); - } -} -declare namespace ag.grid { - interface TextAndNumberFilterParameters { - /** What to do when new rows are loaded. The default is to reset the filter, to keep it in line with 'set' filters. If you want to keep the selection, then set this value to 'keep'. */ - newRowsAction?: string; - } -} -declare namespace ag.grid { - class TextFilter implements Filter { - private filterParams; - private filterChangedCallback; - private filterModifiedCallback; - private localeTextFunc; - private valueGetter; - private filterText; - private filterType; - private api; - private eGui; - private eFilterTextField; - private eTypeSelect; - private applyActive; - private eApplyButton; - init(params: any): void; - onNewRowsLoaded(): void; - afterGuiAttached(): void; - doesFilterPass(node: any): boolean; - getGui(): any; - isFilterActive(): boolean; - private createTemplate(); - private createGui(); - private setupApply(); - private onTypeChanged(); - private onFilterChanged(); - private filterChanged(); - private createApi(); - private getApi(); - } -} -declare namespace ag.grid { - class NumberFilter implements Filter { - private filterParams; - private filterChangedCallback; - private filterModifiedCallback; - private localeTextFunc; - private valueGetter; - private filterNumber; - private filterType; - private api; - private eGui; - private eFilterTextField; - private eTypeSelect; - private applyActive; - private eApplyButton; - init(params: any): void; - onNewRowsLoaded(): void; - afterGuiAttached(): void; - doesFilterPass(node: any): boolean; - getGui(): any; - isFilterActive(): boolean; - private createTemplate(); - private createGui(); - private setupApply(); - private onTypeChanged(); - private filterChanged(); - private onFilterChanged(); - private createApi(); - private getApi(); - } -} -declare namespace ag.grid { - interface ColDef { - /** If sorting by default, set it here. Set to 'asc' or 'desc' */ - sort?: string; - /** If sorting more than one column by default, the milliseconds when this column was sorted, so we know what order to sort the columns in. */ - sortedAt?: number; - /** The sort order, provide an array with any of the following in any order ['asc','desc',null] */ - sortingOrder?: string[]; - /** The name to render in the column header */ - headerName: string; - /** The field of the row to get the cells data from */ - field: string; - /** Expression or function to get the cells value. */ - headerValueGetter?: string | Function; - /** The unique ID to give the column. This is optional. If missing, the ID will default to the field. If both field and colId are missing, a unique ID will be generated. - * This ID is used to identify the column in the API for sorting, filtering etc. */ - colId?: string; - /** Set to true for this column to be hidden. Naturally you might think, it would make more sense to call this field 'visible' and mark it false to hide, - * however we want all default values to be false and we want columns to be visible by default. */ - hide?: boolean; - /** Tooltip for the column header */ - headerTooltip?: string; - /** Expression or function to get the cells value. */ - valueGetter?: string | Function; - /** To provide custom rendering to the header. */ - headerCellRenderer?: Function | Object; - /** CSS class for the header */ - headerClass?: string | string[] | ((params: any) => string | string[]); - /** Initial width, in pixels, of the cell */ - width?: number; - /** Min width, in pixels, of the cell */ - minWidth?: number; - /** Max width, in pixels, of the cell */ - maxWidth?: number; - /** Class to use for the cell. Can be string, array of strings, or function. */ - cellClass?: string | string[] | ((cellClassParams: any) => string | string[]); - /** An object of css values. Or a function returning an object of css values. */ - cellStyle?: {} | ((params: any) => {}); - /** A function for rendering a cell. */ - cellRenderer?: Function | {}; - /** A function for rendering a floating cell. */ - floatingCellRenderer?: Function | {}; - /** Name of function to use for aggregation. One of [sum,min,max]. */ - aggFunc?: string; - /** Comparator function for custom sorting. */ - comparator?: Function; - /** Set to true to render a selection checkbox in the column. */ - checkboxSelection?: boolean; - /** Set to true if no menu should be shown for this column header. */ - suppressMenu?: boolean; - /** Set to true if no sorting should be done for this column. */ - suppressSorting?: boolean; - /** Set to true if you want the unsorted icon to be shown when no sort is applied to this column. */ - unSortIcon?: boolean; - /** Set to true if you want this columns width to be fixed during 'size to fit' operation. */ - suppressSizeToFit?: boolean; - /** Set to true if you do not want this column to be resizable by dragging it's edge. */ - suppressResize?: boolean; - /** If grouping columns, the group this column belongs to. */ - headerGroup?: string; - /** Whether to show the column when the group is open / closed. */ - headerGroupShow?: string; - /** Set to true if this col is editable, otherwise false. Can also be a function to have different rows editable. */ - editable?: boolean | (Function); - /** Callbacks for editing.See editing section for further details. */ - newValueHandler?: Function; - /** If true, this cell gets refreshed when api.softRefreshView() gets called. */ - volatile?: boolean; - /** Cell template to use for cell. Useful for AngularJS cells. */ - template?: string; - /** Cell template URL to load template from to use for cell. Useful for AngularJS cells. */ - templateUrl?: string; - /** one of the built in filter names: [set, number, text], or a filter function*/ - filter?: string | Function; - /** The filter params are specific to each filter! */ - filterParams?: SetFilterParameters | TextAndNumberFilterParameters; - /** Rules for applying css classes */ - cellClassRules?: { - [cssClassName: string]: (Function | string); - }; - /** Callbacks for editing.See editing section for further details. */ - onCellValueChanged?: Function; - /** Function callback, gets called when a cell is clicked. */ - onCellClicked?: Function; - /** Function callback, gets called when a cell is double clicked. */ - onCellDoubleClicked?: Function; - /** Function callback, gets called when a cell is right clicked. */ - onCellContextMenu?: Function; - } -} -declare namespace ag.grid { - class SetFilterModel { - private colDef; - private filterParams; - private rowModel; - private valueGetter; - private allUniqueValues; - private availableUniqueValues; - private displayedValues; - private miniFilter; - private selectedValuesCount; - private selectedValuesMap; - private showingAvailableOnly; - private usingProvidedSet; - private doesRowPassOtherFilters; - constructor(colDef: ColDef, rowModel: any, valueGetter: any, doesRowPassOtherFilters: any); - refreshAfterNewRowsLoaded(keepSelection: any, isSelectAll: boolean): void; - refreshAfterAnyFilterChanged(): void; - private createAllUniqueValues(); - private createAvailableUniqueValues(); - private getUniqueValues(filterOutNotAvailable); - setMiniFilter(newMiniFilter: any): boolean; - getMiniFilter(): any; - private processMiniFilter(); - getDisplayedValueCount(): any; - getDisplayedValue(index: any): any; - selectEverything(): void; - isFilterActive(): boolean; - selectNothing(): void; - getUniqueValueCount(): any; - getUniqueValue(index: any): any; - unselectValue(value: any): void; - selectValue(value: any): void; - isValueSelected(value: any): boolean; - isEverythingSelected(): boolean; - isNothingSelected(): boolean; - getModel(): any; - setModel(model: any, isSelectAll: boolean): void; - } -} -/** The filter parameters for set filter */ -declare namespace ag.grid { - interface SetFilterParameters { - /** Same as cell renderer for grid (you can use the same one in both locations). Setting it separatly here allows for the value to be rendered differently in the filter. */ - cellRenderer?: Function; - /** The height of the cell. */ - cellHeight?: number; - /** The values to display in the filter. */ - values?: any; - /** What to do when new rows are loaded. The default is to reset the filter, as the set of values to select from can have changed. If you want to keep the selection, then set this value to 'keep'. */ - newRowsAction?: string; - /** If true, the filter will not remove items that are no longer availabe due to other filters. */ - suppressRemoveEntries?: boolean; - } -} -declare namespace ag.grid { - class SetFilter implements Filter { - private eGui; - private filterParams; - private rowHeight; - private model; - private filterChangedCallback; - private filterModifiedCallback; - private valueGetter; - private rowsInBodyContainer; - private colDef; - private localeTextFunc; - private cellRenderer; - private eListContainer; - private eFilterValueTemplate; - private eSelectAll; - private eListViewport; - private eMiniFilter; - private api; - private applyActive; - private eApplyButton; - init(params: any): void; - afterGuiAttached(): void; - isFilterActive(): boolean; - doesFilterPass(node: any): boolean; - getGui(): any; - onNewRowsLoaded(): void; - onAnyFilterChanged(): void; - private createTemplate(); - private createGui(); - private setupApply(); - private setContainerHeight(); - private drawVirtualRows(); - private ensureRowsRendered(start, finish); - private removeVirtualRows(rowsToRemove); - private insertRow(value, rowIndex); - private onCheckboxClicked(eCheckbox, value); - private filterChanged(); - private onMiniFilterChanged(); - private refreshVirtualRows(); - private clearVirtualRows(); - private onSelectAll(); - private updateAllCheckboxes(checked); - private addScrollListener(); - getApi(): any; - private createApi(); - } -} -declare namespace ag.grid { - class PopupService { - private ePopupParent; - init(ePopupParent: any): void; - positionPopup(eventSource: any, ePopup: any, minWidth: any): void; - addAsModalPopup(eChild: any, closeOnEsc: boolean): (event: any) => void; - } -} -declare namespace ag.grid { - interface RowNode { - /** Unique ID for the node. Can be though of as the index of the row in the original list, - * however exceptions apply so don't depend on uniqueness. */ - id?: number; - /** The user provided data */ - data?: any; - /** The parent node to this node, or empty if top level */ - parent?: RowNode; - /** How many levels this node is from the top */ - level?: number; - /** True if this node is a group node (ie has children) */ - group?: boolean; - /** True if this is the first child in this group */ - firstChild?: boolean; - /** True if this is the last child in this group */ - lastChild?: boolean; - /** The index of this node in the group */ - childIndex?: number; - /** True if this row is a floating row */ - floating?: boolean; - /** True if this row is a floating top row */ - floatingTop?: boolean; - /** True if this row is a floating bottom row */ - floatingBottom?: boolean; - /** If using quick filter, stores a string representation of the row for searching against */ - quickFilterAggregateText?: string; - /** Groups only - True if row is a footer. Footers have group = true and footer = true */ - footer?: boolean; - /** Groups only - Children of this group */ - children?: RowNode[]; - /** Groups only - The field we are pivoting on eg Country*/ - field?: string; - /** Groups only - The key for the pivot eg Ireland, UK, USA */ - key?: any; - /** Groups only - Filtered children of this group */ - childrenAfterFilter?: RowNode[]; - /** Groups only - Sorted children of this group */ - childrenAfterSort?: RowNode[]; - /** Groups only - Number of children and grand children */ - allChildrenCount?: number; - /** Groups only - True if group is expanded, otherwise false */ - expanded?: boolean; - /** Groups only - If doing footers, reference to the footer node for this group */ - sibling?: RowNode; - /** Not to be used, internal temporary map used by the grid when creating groups */ - _childrenMap?: {}; - } -} -declare namespace ag.grid { - class FilterManager { - private $compile; - private $scope; - private gridOptionsWrapper; - private grid; - private allFilters; - private rowModel; - private popupService; - private valueService; - private columnController; - private quickFilter; - private advancedFilterPresent; - private externalFilterPresent; - init(grid: Grid, gridOptionsWrapper: GridOptionsWrapper, $compile: any, $scope: any, columnController: ColumnController, popupService: PopupService, valueService: ValueService): void; - setFilterModel(model: any): void; - private setModelOnFilterWrapper(filter, newModel); - getFilterModel(): any; - setRowModel(rowModel: any): void; - isAdvancedFilterPresent(): boolean; - isAnyFilterPresent(): boolean; - isFilterPresentForCol(colId: any): any; - private doesFilterPass(node, filterToSkip?); - setQuickFilter(newFilter: any): boolean; - onFilterChanged(): void; - isQuickFilterPresent(): boolean; - doesRowPassOtherFilters(filterToSkip: any, node: any): boolean; - doesRowPassFilter(node: any, filterToSkip?: any): boolean; - private aggregateRowForQuickFilter(node); - refreshDisplayedValues(): void; - onNewRowsLoaded(): void; - private createValueGetter(column); - getFilterApi(column: Column): any; - private getOrCreateFilterWrapper(column); - private createFilterWrapper(column); - private assertMethodHasNoParameters(theMethod); - showFilter(column: Column, eventSource: any): void; - } -} -declare namespace ag.grid { - class TemplateService { - templateCache: any; - waitingCallbacks: any; - $scope: any; - init($scope: any): void; - getTemplate(url: any, callback: any): any; - handleHttpResult(httpResult: any, url: any): void; - } -} -declare namespace ag.grid { - class SelectionRendererFactory { - private angularGrid; - private selectionController; - init(angularGrid: any, selectionController: any): void; - createSelectionCheckbox(node: any, rowIndex: any): HTMLInputElement; - } -} -declare namespace ag.vdom { - class VElement { - static idSequence: number; - private id; - private elementAttachedListeners; - constructor(); - getId(): number; - addElementAttachedListener(listener: (element: Element) => void): void; - protected fireElementAttached(element: Element): void; - elementAttached(element: Element): void; - toHtmlString(): string; - } -} -declare namespace ag.vdom { - class VHtmlElement extends VElement { - private type; - private classes; - private eventListeners; - private attributes; - private children; - private innerHtml; - private style; - private bound; - private element; - constructor(type: string); - getElement(): HTMLElement; - setInnerHtml(innerHtml: string): void; - addStyles(styles: any): void; - private attachEventListeners(node); - addClass(newClass: string): void; - removeClass(oldClass: string): void; - addClasses(classes: string[]): void; - toHtmlString(): string; - private toHtmlStringChildren(); - private toHtmlStringAttributes(); - private toHtmlStringClasses(); - private toHtmlStringStyles(); - appendChild(child: any): void; - setAttribute(key: string, value: string): void; - addEventListener(event: string, listener: EventListener): void; - elementAttached(element: Element): void; - fireElementAttachedToChildren(element: Element): void; - } -} -declare namespace ag.vdom { - class VWrapperElement extends VElement { - private wrappedElement; - constructor(wrappedElement: Element); - toHtmlString(): string; - elementAttached(element: Element): void; - } -} -declare namespace ag.grid { - class RenderedCell { - private vGridCell; - private vSpanWithValue; - private vCellWrapper; - private vParentOfValue; - private checkboxOnChangeListener; - private column; - private data; - private node; - private rowIndex; - private editingCell; - private scope; - private isFirstColumn; - private gridOptionsWrapper; - private expressionService; - private selectionRendererFactory; - private rowRenderer; - private selectionController; - private $compile; - private templateService; - private cellRendererMap; - private eCheckbox; - private columnController; - private valueService; - private eventService; - private value; - private checkboxSelection; - constructor(isFirstColumn: any, column: any, $compile: any, rowRenderer: RowRenderer, gridOptionsWrapper: GridOptionsWrapper, expressionService: ExpressionService, selectionRendererFactory: SelectionRendererFactory, selectionController: SelectionController, templateService: TemplateService, cellRendererMap: { - [key: string]: any; - }, node: any, rowIndex: number, scope: any, columnController: ColumnController, valueService: ValueService, eventService: EventService); - getColumn(): Column; - private getValue(); - getVGridCell(): ag.vdom.VHtmlElement; - private getDataForRow(); - private setupComponents(); - startEditing(key?: number): void; - focusCell(forceBrowserFocus: boolean): void; - private stopEditing(eInput, blurListener, reset?); - createParams(): any; - createEvent(event: any, eventSource: any): any; - private addCellDoubleClickedHandler(); - private addCellContextMenuHandler(); - isCellEditable(): any; - private addCellClickedHandler(); - private populateCell(); - private addStylesFromCollDef(); - private addClassesFromCollDef(); - private addClassesFromRules(); - private addCellNavigationHandler(); - private isKeycodeForStartEditing(key); - createSelectionCheckbox(): void; - setSelected(state: boolean): void; - private createParentOfValue(); - isVolatile(): boolean; - refreshCell(): void; - private putDataIntoCell(); - private useCellRenderer(cellRenderer); - private addClasses(); - } -} -declare namespace ag.grid { - class RenderedRow { - vPinnedRow: any; - vBodyRow: any; - private renderedCells; - private scope; - private node; - private rowIndex; - private cellRendererMap; - private gridOptionsWrapper; - private parentScope; - private angularGrid; - private columnController; - private expressionService; - private rowRenderer; - private selectionRendererFactory; - private $compile; - private templateService; - private selectionController; - private pinning; - private eBodyContainer; - private ePinnedContainer; - private valueService; - private eventService; - constructor(gridOptionsWrapper: GridOptionsWrapper, valueService: ValueService, parentScope: any, angularGrid: Grid, columnController: ColumnController, expressionService: ExpressionService, cellRendererMap: { - [key: string]: any; - }, selectionRendererFactory: SelectionRendererFactory, $compile: any, templateService: TemplateService, selectionController: SelectionController, rowRenderer: RowRenderer, eBodyContainer: HTMLElement, ePinnedContainer: HTMLElement, node: any, rowIndex: number, eventService: EventService); - onRowSelected(selected: boolean): void; - softRefresh(): void; - getRenderedCellForColumn(column: Column): RenderedCell; - getCellForCol(column: Column): any; - destroy(): void; - private destroyScope(); - isDataInList(rows: any[]): boolean; - isNodeInList(nodes: RowNode[]): boolean; - isGroup(): boolean; - private drawNormalRow(); - private bindVirtualElement(vElement); - private createGroupRow(); - private createGroupSpanningEntireRowCell(padding); - setMainRowWidth(width: number): void; - private createChildScopeOrNull(data); - private addDynamicStyles(); - private createRowContainer(); - getRowNode(): any; - getRowIndex(): any; - refreshCells(colIds: string[]): void; - private addDynamicClasses(); - } -} -declare namespace ag.grid { - class SvgFactory { - static theInstance: SvgFactory; - static getInstance(): SvgFactory; - createFilterSvg(): Element; - createColumnShowingSvg(): Element; - createColumnHiddenSvg(): Element; - createMenuSvg(): Element; - createArrowUpSvg(): Element; - createArrowLeftSvg(): Element; - createArrowDownSvg(): Element; - createArrowRightSvg(): Element; - createSmallArrowDownSvg(): Element; - createArrowUpDownSvg(): Element; - } -} -declare namespace ag.grid { - function groupCellRendererFactory(gridOptionsWrapper: GridOptionsWrapper, selectionRendererFactory: SelectionRendererFactory, expressionService: ExpressionService): (params: any) => HTMLSpanElement; -} -declare namespace ag.grid { - class RowRenderer { - private columnModel; - private gridOptionsWrapper; - private angularGrid; - private selectionRendererFactory; - private gridPanel; - private $compile; - private $scope; - private selectionController; - private expressionService; - private templateService; - private cellRendererMap; - private rowModel; - private firstVirtualRenderedRow; - private lastVirtualRenderedRow; - private focusedCell; - private valueService; - private eventService; - private renderedRows; - private renderedTopFloatingRows; - private renderedBottomFloatingRows; - private eAllBodyContainers; - private eAllPinnedContainers; - private eBodyContainer; - private eBodyViewport; - private ePinnedColsContainer; - private eFloatingTopContainer; - private eFloatingTopPinnedContainer; - private eFloatingBottomContainer; - private eFloatingBottomPinnedContainer; - private eParentsOfRows; - init(columnModel: any, gridOptionsWrapper: GridOptionsWrapper, gridPanel: GridPanel, angularGrid: Grid, selectionRendererFactory: SelectionRendererFactory, $compile: any, $scope: any, selectionController: SelectionController, expressionService: ExpressionService, templateService: TemplateService, valueService: ValueService, eventService: EventService): void; - setRowModel(rowModel: any): void; - onIndividualColumnResized(column: Column): void; - setMainRowWidths(): void; - private findAllElements(gridPanel); - refreshAllFloatingRows(): void; - private refreshFloatingRows(renderedRows, rowData, pinnedContainer, bodyContainer, isTop); - refreshView(refreshFromIndex?: any): void; - softRefreshView(): void; - refreshRows(rowNodes: RowNode[]): void; - refreshCells(rowNodes: RowNode[], colIds: string[]): void; - rowDataChanged(rows: any): void; - private refreshAllVirtualRows(fromIndex); - refreshGroupRows(): void; - private removeVirtualRow(rowsToRemove, fromIndex?); - private unbindVirtualRow(indexToRemove); - drawVirtualRows(): void; - getFirstVirtualRenderedRow(): number; - getLastVirtualRenderedRow(): number; - private ensureRowsRendered(); - private insertRow(node, rowIndex, mainRowWidth); - getRenderedNodes(): any[]; - getIndexOfRenderedNode(node: any): number; - navigateToNextCell(key: any, rowIndex: number, column: Column): void; - private getNextCellToFocus(key, lastCellToFocus); - onRowSelected(rowIndex: number, selected: boolean): void; - focusCell(eCell: any, rowIndex: number, colIndex: number, colDef: ColDef, forceBrowserFocus: any): void; - getFocusedCell(): any; - setFocusedCell(rowIndex: any, colIndex: any): void; - startEditingNextCell(rowIndex: any, column: any, shiftKey: any): void; - } -} -declare namespace ag.grid { - class SelectionController { - private eParentsOfRows; - private angularGrid; - private gridOptionsWrapper; - private $scope; - private rowRenderer; - private selectedRows; - private selectedNodesById; - private rowModel; - private eventService; - init(angularGrid: Grid, gridPanel: GridPanel, gridOptionsWrapper: GridOptionsWrapper, $scope: any, rowRenderer: RowRenderer, eventService: EventService): void; - private initSelectedNodesById(); - getSelectedNodesById(): any; - getSelectedRows(): any; - getSelectedNodes(): any; - getBestCostNodeSelection(): any; - setRowModel(rowModel: any): void; - deselectAll(): void; - selectAll(): void; - selectNode(node: any, tryMulti: any, suppressEvents?: any): void; - private recursivelySelectAllChildren(node, suppressEvents?); - private recursivelyDeselectAllChildren(node); - private doWorkOfSelectNode(node, suppressEvents); - private addCssClassForNode_andInformVirtualRowListener(node); - private doWorkOfDeselectAllNodes(nodeToKeepSelected?); - private deselectRealNode(node); - private removeCssClassForNode(node); - deselectIndex(rowIndex: any): void; - deselectNode(node: any): void; - selectIndex(index: any, tryMulti: any, suppressEvents?: any): void; - private syncSelectedRowsAndCallListener(suppressEvents?); - private recursivelyCheckIfSelected(node); - isNodeSelected(node: any): boolean; - private updateGroupParentsIfNeeded(); - } -} -declare namespace ag.grid { - class RenderedHeaderElement { - private eRoot; - private dragStartX; - constructor(eRoot: HTMLElement); - getERoot(): HTMLElement; - destroy(): void; - refreshFilterIcon(): void; - refreshSortIcon(): void; - onDragStart(): void; - onDragging(dragChange: number): void; - onIndividualColumnResized(column: Column): void; - addDragHandler(eDraggableElement: any): void; - stopDragging(listenersToRemove: any): void; - } -} -declare namespace ag.grid { - class RenderedHeaderCell extends RenderedHeaderElement { - private static DEFAULT_SORTING_ORDER; - private eHeaderCell; - private eSortAsc; - private eSortDesc; - private eSortNone; - private eFilterIcon; - private column; - private gridOptionsWrapper; - private parentScope; - private childScope; - private filterManager; - private columnController; - private $compile; - private angularGrid; - private parentGroup; - private startWidth; - constructor(column: Column, parentGroup: RenderedHeaderGroupCell, gridOptionsWrapper: GridOptionsWrapper, parentScope: any, filterManager: FilterManager, columnController: ColumnController, $compile: any, angularGrid: Grid, eRoot: HTMLElement); - getGui(): HTMLElement; - destroy(): void; - private createScope(); - private addAttributes(); - private addClasses(); - private addMenu(); - private addSortIcons(headerCellLabel); - private setupComponents(); - private useRenderer(headerNameValue, headerCellRenderer, headerCellLabel); - refreshFilterIcon(): void; - refreshSortIcon(): void; - private getNextSortDirection(); - private addSortHandling(headerCellLabel); - onDragStart(): void; - onDragging(dragChange: number): void; - onIndividualColumnResized(column: Column): void; - private addHeaderClassesFromCollDef(); - } -} -declare namespace ag.grid { - class RenderedHeaderGroupCell extends RenderedHeaderElement { - private eHeaderGroup; - private eHeaderGroupCell; - private eHeaderCellResize; - private columnGroup; - private gridOptionsWrapper; - private columnController; - private children; - private groupWidthStart; - private childrenWidthStarts; - private minWidth; - private parentScope; - private filterManager; - private $compile; - private angularGrid; - constructor(columnGroup: ColumnGroup, gridOptionsWrapper: GridOptionsWrapper, columnController: ColumnController, eRoot: HTMLElement, angularGrid: Grid, parentScope: any, filterManager: FilterManager, $compile: any); - getGui(): HTMLElement; - destroy(): void; - refreshFilterIcon(): void; - refreshSortIcon(): void; - onIndividualColumnResized(column: Column): void; - private setupComponents(); - private isColumnInOurDisplayedGroup(column); - private setWidthOfGroupHeaderCell(); - private addGroupExpandIcon(eGroupCellLabel); - onDragStart(): void; - onDragging(dragChange: any): void; - } -} -declare namespace ag.grid { - class HeaderRenderer { - private gridOptionsWrapper; - private columnController; - private angularGrid; - private filterManager; - private $scope; - private $compile; - private ePinnedHeader; - private eHeaderContainer; - private eRoot; - private headerElements; - init(gridOptionsWrapper: GridOptionsWrapper, columnController: ColumnController, gridPanel: GridPanel, angularGrid: Grid, filterManager: FilterManager, $scope: any, $compile: any): void; - private findAllElements(gridPanel); - refreshHeader(): void; - private insertHeadersWithGrouping(); - private insertHeadersWithoutGrouping(); - updateSortIcons(): void; - updateFilterIcons(): void; - onIndividualColumnResized(column: Column): void; - } -} -declare namespace ag.grid { - class GroupCreator { - private valueService; - init(valueService: ValueService): void; - group(rowNodes: RowNode[], groupedCols: Column[], expandByDefault: any): RowNode[]; - isExpanded(expandByDefault: any, level: any): boolean; - } -} -declare namespace ag.grid { - class InMemoryRowController { - private gridOptionsWrapper; - private columnController; - private angularGrid; - private filterManager; - private $scope; - private allRows; - private rowsAfterGroup; - private rowsAfterFilter; - private rowsAfterSort; - private rowsAfterMap; - private model; - private groupCreator; - private valueService; - private eventService; - constructor(); - init(gridOptionsWrapper: GridOptionsWrapper, columnController: ColumnController, angularGrid: any, filterManager: FilterManager, $scope: any, groupCreator: GroupCreator, valueService: ValueService, eventService: EventService): void; - private createModel(); - getModel(): any; - forEachInMemory(callback: Function): void; - forEachNode(callback: Function): void; - forEachNodeAfterFilter(callback: Function): void; - forEachNodeAfterFilterAndSort(callback: Function): void; - private recursivelyWalkNodesAndCallback(list, callback); - updateModel(step: any): void; - private defaultGroupAggFunctionFactory(valueColumns, valueKeys); - doAggregate(): void; - expandOrCollapseAll(expand: boolean, rowNodes: RowNode[]): void; - private recursivelyClearAggData(nodes); - private recursivelyCreateAggData(nodes, groupAggFunction, level); - private doSort(); - private recursivelyResetSort(rowNodes); - private sortList(nodes, sortOptions); - private updateChildIndexes(nodes); - onPivotChanged(): void; - private doPivoting(); - private doFilter(); - private filterItems(rowNodes); - private recursivelyResetFilter(nodes); - setAllRows(rows: RowNode[], firstId?: number): void; - private recursivelyAddIdToNodes(nodes, index); - private recursivelyCheckUserProvidedNodes(nodes, parent, level); - private getTotalChildCount(rowNodes); - private doGroupMapping(); - private addToMap(mappedData, originalNodes); - private createFooterNode(groupNode); - } -} -declare namespace ag.grid { - class VirtualPageRowController { - rowRenderer: any; - datasourceVersion: any; - gridOptionsWrapper: any; - angularGrid: any; - datasource: any; - virtualRowCount: any; - foundMaxRow: any; - pageCache: any; - pageCacheSize: any; - pageLoadsInProgress: any; - pageLoadsQueued: any; - pageAccessTimes: any; - accessTime: any; - maxConcurrentDatasourceRequests: any; - maxPagesInCache: any; - pageSize: any; - overflowSize: any; - init(rowRenderer: any, gridOptionsWrapper: any, angularGrid: any): void; - setDatasource(datasource: any): void; - reset(): void; - createNodesFromRows(pageNumber: any, rows: any): any; - removeFromLoading(pageNumber: any): void; - pageLoadFailed(pageNumber: any): void; - pageLoaded(pageNumber: any, rows: any, lastRow: any): void; - putPageIntoCacheAndPurge(pageNumber: any, rows: any): void; - checkMaxRowAndInformRowRenderer(pageNumber: any, lastRow: any): void; - isPageAlreadyLoading(pageNumber: any): boolean; - doLoadOrQueue(pageNumber: any): void; - addToQueueAndPurgeQueue(pageNumber: any): void; - findLeastRecentlyAccessedPage(pageIndexes: any): number; - checkQueueForNextLoad(): void; - loadPage(pageNumber: any): void; - requestIsDaemon(datasourceVersionCopy: any): boolean; - getVirtualRow(rowIndex: any): any; - forEachNode(callback: any): void; - getModel(): { - getVirtualRow: (index: any) => any; - getVirtualRowCount: () => any; - forEachInMemory: (callback: any) => void; - forEachNode: (callback: any) => void; - forEachNodeAfterFilter: (callback: any) => void; - forEachNodeAfterFilterAndSort: (callback: any) => void; - }; - } -} -declare namespace ag.grid { - class PaginationController { - eGui: any; - btNext: any; - btPrevious: any; - btFirst: any; - btLast: any; - lbCurrent: any; - lbTotal: any; - lbRecordCount: any; - lbFirstRowOnPage: any; - lbLastRowOnPage: any; - ePageRowSummaryPanel: any; - angularGrid: any; - callVersion: any; - gridOptionsWrapper: any; - datasource: any; - pageSize: any; - rowCount: any; - foundMaxRow: any; - totalPages: any; - currentPage: any; - init(angularGrid: any, gridOptionsWrapper: any): void; - setDatasource(datasource: any): void; - reset(): void; - setTotalLabels(): void; - calculateTotalPages(): void; - pageLoaded(rows: any, lastRowIndex: any): void; - updateRowLabels(): void; - loadPage(): void; - isCallDaemon(versionCopy: any): boolean; - onBtNext(): void; - onBtPrevious(): void; - onBtFirst(): void; - onBtLast(): void; - isZeroPagesToDisplay(): boolean; - enableOrDisableButtons(): void; - createTemplate(): string; - getGui(): any; - setupComponents(): void; - } -} -declare namespace ag.grid { - class BorderLayout { - private eNorthWrapper; - private eSouthWrapper; - private eEastWrapper; - private eWestWrapper; - private eCenterWrapper; - private eOverlayWrapper; - private eCenterRow; - private eNorthChildLayout; - private eSouthChildLayout; - private eEastChildLayout; - private eWestChildLayout; - private eCenterChildLayout; - private isLayoutPanel; - private fullHeight; - private layoutActive; - private eGui; - private id; - private childPanels; - private centerHeightLastTime; - private sizeChangeListners; - constructor(params: any); - addSizeChangeListener(listener: Function): void; - fireSizeChanged(): void; - private setupPanels(params); - private setupPanel(content, ePanel); - getGui(): any; - doLayout(): boolean; - private layoutChild(childPanel); - private layoutHeight(); - private layoutHeightFullHeight(); - private layoutHeightNormal(); - getCentreHeight(): number; - private layoutWidth(); - setEastVisible(visible: any): void; - setOverlayVisible(visible: any): void; - setSouthVisible(visible: any): void; - } -} -declare namespace ag.grid { - class GridPanel { - private masterSlaveService; - private gridOptionsWrapper; - private columnModel; - private rowRenderer; - private rowModel; - private layout; - private forPrint; - private scrollWidth; - private scrollLagCounter; - private eBodyViewport; - private eRoot; - private eBody; - private eBodyContainer; - private ePinnedColsContainer; - private eHeaderContainer; - private ePinnedHeader; - private eHeader; - private eParentsOfRows; - private eBodyViewportWrapper; - private ePinnedColsViewport; - private eFloatingTop; - private ePinnedFloatingTop; - private eFloatingTopContainer; - private eFloatingBottom; - private ePinnedFloatingBottom; - private eFloatingBottomContainer; - init(gridOptionsWrapper: GridOptionsWrapper, columnModel: ColumnController, rowRenderer: RowRenderer, masterSlaveService: MasterSlaveService): void; - getLayout(): BorderLayout; - private setupComponents(); - getPinnedFloatingTop(): HTMLElement; - getFloatingTopContainer(): HTMLElement; - getPinnedFloatingBottom(): HTMLElement; - getFloatingBottomContainer(): HTMLElement; - private createTemplate(); - ensureIndexVisible(index: any): void; - ensureColIndexVisible(index: any): void; - showLoading(loading: any): void; - getWidthForSizeColsToFit(): number; - setRowModel(rowModel: any): void; - getBodyContainer(): HTMLElement; - getBodyViewport(): HTMLElement; - getPinnedColsContainer(): HTMLElement; - getHeaderContainer(): HTMLElement; - getRoot(): HTMLElement; - getPinnedHeader(): HTMLElement; - getRowsParent(): HTMLElement[]; - private queryHtmlElement(selector); - private findElements(); - private mouseWheelListener(event); - setBodyContainerWidth(): void; - setPinnedColContainerWidth(): void; - showPinnedColContainersIfNeeded(): void; - onBodyHeightChange(): void; - private sizeHeaderAndBody(); - private sizeHeaderAndBodyNormal(); - private sizeHeaderAndBodyForPrint(); - setHorizontalScrollPosition(hScrollPosition: number): void; - private addScrollListener(); - private requestDrawVirtualRows(); - private scrollHeader(bodyLeftPosition); - private scrollPinned(bodyTopPosition); - } -} -declare namespace ag.grid { - class DragAndDropService { - static theInstance: DragAndDropService; - static getInstance(): DragAndDropService; - dragItem: any; - constructor(); - stopDragging(): void; - setDragCssClasses(eListItem: any, dragging: any): void; - addDragSource(eDragSource: any, dragSourceCallback: any): void; - onMouseDownDragSource(eDragSource: any, dragSourceCallback: any): void; - addDropTarget(eDropTarget: any, dropTargetCallback: any): void; - } -} -declare namespace ag.grid { - class AgList { - private eGui; - private uniqueId; - private modelChangedListeners; - private itemSelectedListeners; - private beforeDropListeners; - private itemMovedListeners; - private dragSources; - private emptyMessage; - private eFilterValueTemplate; - private eListParent; - private model; - private cellRenderer; - private readOnly; - constructor(); - setReadOnly(readOnly: boolean): void; - setEmptyMessage(emptyMessage: any): void; - getUniqueId(): any; - addStyles(styles: any): void; - addCssClass(cssClass: any): void; - addDragSource(dragSource: any): void; - addModelChangedListener(listener: Function): void; - addItemSelectedListener(listener: any): void; - addItemMovedListener(listener: any): void; - addBeforeDropListener(listener: any): void; - private fireItemMoved(fromIndex, toIndex); - private fireModelChanged(); - private fireItemSelected(item); - private fireBeforeDrop(item); - private setupComponents(); - setModel(model: any): void; - getModel(): any; - setCellRenderer(cellRenderer: any): void; - refreshView(): void; - private insertRows(); - private insertBlankMessage(); - private setupAsDropTarget(); - private externalAcceptDrag(dragEvent); - private externalDrop(dragEvent); - private externalNoDrop(); - private addItemToList(newItem); - private addDragAndDropToListItem(eListItem, item); - private internalAcceptDrag(targetColumn, dragItem, eListItem); - private internalDrop(targetColumn, draggedColumn); - private internalNoDrop(eListItem); - private dragAfterThisItem(targetColumn, draggedColumn); - private setDropCssClasses(eListItem, state); - getGui(): any; - } -} -declare namespace ag.grid { - class ColumnSelectionPanel { - private gridOptionsWrapper; - private columnController; - private cColumnList; - layout: any; - private eRootPanel; - constructor(columnController: ColumnController, gridOptionsWrapper: GridOptionsWrapper, eventService: EventService); - private columnsChanged(); - getDragSource(): any; - private columnCellRenderer(params); - private setupComponents(); - private onItemMoved(fromIndex, toIndex); - getGui(): any; - } -} -declare namespace ag.grid { - class GroupSelectionPanel { - gridOptionsWrapper: any; - columnController: ColumnController; - inMemoryRowController: any; - cColumnList: any; - layout: any; - constructor(columnController: ColumnController, inMemoryRowController: any, gridOptionsWrapper: GridOptionsWrapper, eventService: EventService); - private columnsChanged(); - addDragSource(dragSource: any): void; - private columnCellRenderer(params); - private setupComponents(); - private onBeforeDrop(newItem); - private onItemMoved(fromIndex, toIndex); - } -} -declare namespace ag.grid { - class AgDropdownList { - private itemSelectedListeners; - private eValue; - private agList; - private eGui; - private hidePopupCallback; - private selectedItem; - private cellRenderer; - private popupService; - constructor(popupService: PopupService); - setWidth(width: any): void; - addItemSelectedListener(listener: any): void; - fireItemSelected(item: any): void; - setupComponents(): void; - itemSelected(item: any): void; - onClick(): void; - getGui(): any; - setSelected(item: any): void; - setCellRenderer(cellRenderer: any): void; - refreshView(): void; - setModel(model: any): void; - } -} -declare namespace ag.grid { - class ValuesSelectionPanel { - private gridOptionsWrapper; - private columnController; - private cColumnList; - private layout; - private popupService; - constructor(columnController: ColumnController, gridOptionsWrapper: GridOptionsWrapper, popupService: PopupService, eventService: EventService); - getLayout(): any; - private columnsChanged(); - addDragSource(dragSource: any): void; - private cellRenderer(params); - private setupComponents(); - private beforeDropListener(newItem); - } -} -declare namespace ag.grid { - class VerticalStack { - isLayoutPanel: any; - childPanels: any; - eGui: any; - constructor(); - addPanel(panel: any, height: any): void; - getGui(): any; - doLayout(): void; - } -} -declare namespace ag.grid { - class ToolPanel { - layout: any; - constructor(); - init(columnController: any, inMemoryRowController: any, gridOptionsWrapper: GridOptionsWrapper, popupService: PopupService, eventService: EventService): void; - } -} -declare namespace ag.grid { - interface GridOptions { - virtualPaging?: boolean; - toolPanelSuppressPivot?: boolean; - toolPanelSuppressValues?: boolean; - rowsAlreadyGrouped?: boolean; - suppressRowClickSelection?: boolean; - suppressCellSelection?: boolean; - sortingOrder?: string[]; - suppressMultiSort?: boolean; - suppressHorizontalScroll?: boolean; - unSortIcon?: boolean; - rowHeight?: number; - rowBuffer?: number; - enableColResize?: boolean; - enableCellExpressions?: boolean; - enableSorting?: boolean; - enableServerSideSorting?: boolean; - enableFilter?: boolean; - enableServerSideFilter?: boolean; - colWidth?: number; - suppressMenuHide?: boolean; - singleClickEdit?: boolean; - debug?: boolean; - icons?: any; - angularCompileRows?: boolean; - angularCompileFilters?: boolean; - angularCompileHeaders?: boolean; - localeText?: any; - localeTextFunc?: Function; - suppressScrollLag?: boolean; - groupSuppressAutoColumn?: boolean; - groupSelectsChildren?: boolean; - groupHidePivotColumns?: boolean; - groupIncludeFooter?: boolean; - groupUseEntireRow?: boolean; - groupSuppressRow?: boolean; - groupSuppressBlankHeader?: boolean; - forPrint?: boolean; - groupColumnDef?: any; - context?: any; - rowStyle?: any; - rowClass?: any; - groupDefaultExpanded?: any; - slaveGrids?: GridOptions[]; - rowSelection?: string; - rowDeselection?: boolean; - rowData?: any[]; - floatingTopRowData?: any[]; - floatingBottomRowData?: any[]; - showToolPanel?: boolean; - groupKeys?: string[]; - groupAggFields?: string[]; - columnDefs?: any[]; - datasource?: any; - pinnedColumnCount?: number; - groupHeaders?: boolean; - headerHeight?: number; - groupRowInnerRenderer?(params: any): void; - groupRowRenderer?: Function | Object; - isScrollLag?(): boolean; - isExternalFilterPresent?(): boolean; - doesExternalFilterPass?(node: RowNode): boolean; - getRowStyle?: any; - getRowClass?: any; - headerCellRenderer?: any; - groupAggFunction?(nodes: any[]): any; - onReady?(api: any): void; - onModelUpdated?(): void; - onCellClicked?(params: any): void; - onCellDoubleClicked?(params: any): void; - onCellContextMenu?(params: any): void; - onCellValueChanged?(params: any): void; - onCellFocused?(params: any): void; - onRowSelected?(params: any): void; - onSelectionChanged?(): void; - onBeforeFilterChanged?(): void; - onAfterFilterChanged?(): void; - onFilterModified?(): void; - onBeforeSortChanged?(): void; - onAfterSortChanged?(): void; - onVirtualRowRemoved?(params: any): void; - onRowClicked?(params: any): void; - api?: GridApi; - columnApi?: ColumnApi; - } -} -declare namespace ag.grid { - class GridApi { - private grid; - private rowRenderer; - private headerRenderer; - private filterManager; - private columnController; - private inMemoryRowController; - private selectionController; - private gridOptionsWrapper; - private gridPanel; - private valueService; - private masterSlaveService; - private eventService; - private csvCreator; - constructor(grid: Grid, rowRenderer: RowRenderer, headerRenderer: HeaderRenderer, filterManager: FilterManager, columnController: ColumnController, inMemoryRowController: InMemoryRowController, selectionController: SelectionController, gridOptionsWrapper: GridOptionsWrapper, gridPanel: GridPanel, valueService: ValueService, masterSlaveService: MasterSlaveService, eventService: EventService); - /** Used internally by grid. Not intended to be used by the client. Interface may change between releases. */ - __getMasterSlaveService(): MasterSlaveService; - getDataAsCsv(params?: CsvExportParams): string; - exportDataAsCsv(params?: CsvExportParams): void; - setDatasource(datasource: any): void; - onNewDatasource(): void; - setRowData(rowData: any): void; - setRows(rows: any): void; - onNewRows(): void; - setFloatingTopRowData(rows: any[]): void; - setFloatingBottomRowData(rows: any[]): void; - onNewCols(): void; - setColumnDefs(colDefs: ColDef[]): void; - unselectAll(): void; - refreshRows(rowNodes: RowNode[]): void; - refreshCells(rowNodes: RowNode[], colIds: string[]): void; - rowDataChanged(rows: any): void; - refreshView(): void; - softRefreshView(): void; - refreshGroupRows(): void; - refreshHeader(): void; - isAnyFilterPresent(): boolean; - isAdvancedFilterPresent(): boolean; - isQuickFilterPresent(): boolean; - getModel(): any; - onGroupExpandedOrCollapsed(refreshFromIndex: any): void; - expandAll(): void; - collapseAll(): void; - addVirtualRowListener(rowIndex: any, callback: any): void; - setQuickFilter(newFilter: any): void; - selectIndex(index: any, tryMulti: any, suppressEvents: any): void; - deselectIndex(index: any): void; - selectNode(node: any, tryMulti: any, suppressEvents: any): void; - deselectNode(node: any): void; - selectAll(): void; - deselectAll(): void; - recomputeAggregates(): void; - sizeColumnsToFit(): void; - showLoading(show: any): void; - isNodeSelected(node: any): boolean; - getSelectedNodesById(): { - [nodeId: number]: RowNode; - }; - getSelectedNodes(): RowNode[]; - getSelectedRows(): any[]; - getBestCostNodeSelection(): any; - getRenderedNodes(): any[]; - ensureColIndexVisible(index: any): void; - ensureIndexVisible(index: any): void; - ensureNodeVisible(comparator: any): void; - forEachInMemory(callback: Function): void; - forEachNode(callback: Function): void; - forEachNodeAfterFilter(callback: Function): void; - forEachNodeAfterFilterAndSort(callback: Function): void; - getFilterApiForColDef(colDef: any): any; - getFilterApi(key: any): any; - getColumnDef(key: any): ColDef; - onFilterChanged(): void; - setSortModel(sortModel: any): void; - getSortModel(): any; - setFilterModel(model: any): void; - getFilterModel(): any; - getFocusedCell(): any; - setFocusedCell(rowIndex: any, colIndex: any): void; - setHeaderHeight(headerHeight: number): void; - setGroupHeaders(groupHeaders: boolean): void; - showToolPanel(show: any): void; - isToolPanelShowing(): boolean; - hideColumn(colId: any, hide: any): void; - hideColumns(colIds: any, hide: any): void; - getColumnState(): [any]; - setColumnState(state: any): void; - doLayout(): void; - getValue(colDef: ColDef, data: any, node: any): any; - addEventListener(eventType: string, listener: Function): void; - addGlobalListener(listener: Function): void; - removeEventListener(eventType: string, listener: Function): void; - removeGlobalListener(listener: Function): void; - refreshPivot(): void; - } -} -declare namespace ag.grid { - class ValueService { - private gridOptionsWrapper; - private expressionService; - private columnController; - init(gridOptionsWrapper: GridOptionsWrapper, expressionService: ExpressionService, columnController: ColumnController): void; - getValue(colDef: ColDef, data: any, node: any): any; - private executeValueGetter(valueGetter, data, colDef, node); - private getValueCallback(data, node, field); - } -} -declare namespace ag.grid { - class Grid { - private virtualRowCallbacks; - private gridOptions; - private gridOptionsWrapper; - private inMemoryRowController; - private doingVirtualPaging; - private paginationController; - private virtualPageRowController; - private finished; - private selectionController; - private columnController; - private rowRenderer; - private headerRenderer; - private filterManager; - private valueService; - private masterSlaveService; - private eventService; - private toolPanel; - private gridPanel; - private eRootPanel; - private toolPanelShowing; - private doingPagination; - private usingInMemoryModel; - private rowModel; - constructor(eGridDiv: any, gridOptions: any, globalEventListener?: Function, $scope?: any, $compile?: any, quickFilterOnScope?: any); - getRowModel(): any; - private periodicallyDoLayout(); - private setupComponents($scope, $compile, eUserProvidedDiv, globalEventListener); - private onColumnChanged(event); - refreshPivot(): void; - getEventService(): EventService; - private onIndividualColumnResized(column); - showToolPanel(show: any): void; - isToolPanelShowing(): boolean; - isUsingInMemoryModel(): boolean; - setDatasource(datasource?: any): void; - private refreshHeaderAndBody(); - setFinished(): void; - onQuickFilterChanged(newFilter: any): void; - onFilterModified(): void; - onFilterChanged(): void; - onRowClicked(event: any, rowIndex: any, node: any): void; - showLoadingPanel(show: any): void; - private setupColumns(); - updateModelAndRefresh(step: any, refreshFromIndex?: any): void; - setRows(rows?: any, firstId?: any): void; - ensureNodeVisible(comparator: any): void; - getFilterModel(): any; - setFocusedCell(rowIndex: any, colIndex: any): void; - getSortModel(): any; - setSortModel(sortModel: any): void; - onSortingChanged(): void; - addVirtualRowListener(rowIndex: any, callback: any): void; - onVirtualRowSelected(rowIndex: any, selected: any): void; - onVirtualRowRemoved(rowIndex: any): void; - setColumnDefs(colDefs?: ColDef[]): void; - updateBodyContainerWidthAfterColResize(): void; - updatePinnedColContainerWidthAfterColResize(): void; - doLayout(): void; - } -} -declare namespace ag.grid { - class ComponentUtil { - static SIMPLE_PROPERTIES: string[]; - static SIMPLE_NUMBER_PROPERTIES: string[]; - static SIMPLE_BOOLEAN_PROPERTIES: string[]; - static WITH_IMPACT_NUMBER_PROPERTIES: string[]; - static WITH_IMPACT_BOOLEAN_PROPERTIES: string[]; - static WITH_IMPACT_OTHER_PROPERTIES: string[]; - static CALLBACKS: string[]; - static ALL_PROPERTIES: string[]; - static copyAttributesToGridOptions(gridOptions: GridOptions, component: any): GridOptions; - static processOnChange(changes: any, gridOptions: GridOptions, component: any): void; - static toBoolean(value: any): boolean; - static toNumber(value: any): number; - } -} -declare namespace ag.grid { - class AgGridNg2 { - private elementDef; - private _agGrid; - private _initialised; - private gridOptions; - private api; - private columnApi; - modelUpdated: any; - cellClicked: any; - cellDoubleClicked: any; - cellContextMenu: any; - cellValueChanged: any; - cellFocused: any; - rowSelected: any; - selectionChanged: any; - beforeFilterChanged: any; - afterFilterChanged: any; - filterModified: any; - beforeSortChanged: any; - afterSortChanged: any; - virtualRowRemoved: any; - rowClicked: any; - ready: any; - columnEverythingChanged: any; - columnPivotChanged: any; - columnValueChanged: any; - columnMoved: any; - columnVisible: any; - columnGroupOpened: any; - columnResized: any; - columnPinnedCountChanged: any; - virtualPaging: boolean; - toolPanelSuppressPivot: boolean; - toolPanelSuppressValues: boolean; - rowsAlreadyGrouped: boolean; - suppressRowClickSelection: boolean; - suppressCellSelection: boolean; - sortingOrder: string[]; - suppressMultiSort: boolean; - suppressHorizontalScroll: boolean; - unSortIcon: boolean; - rowHeight: number; - rowBuffer: number; - enableColResize: boolean; - enableCellExpressions: boolean; - enableSorting: boolean; - enableServerSideSorting: boolean; - enableFilter: boolean; - enableServerSideFilter: boolean; - colWidth: number; - suppressMenuHide: boolean; - debug: boolean; - icons: any; - angularCompileRows: boolean; - angularCompileFilters: boolean; - angularCompileHeaders: boolean; - localeText: any; - localeTextFunc: Function; - groupSuppressAutoColumn: boolean; - groupSelectsChildren: boolean; - groupHidePivotColumns: boolean; - groupIncludeFooter: boolean; - groupUseEntireRow: boolean; - groupSuppressRow: boolean; - groupSuppressBlankHeader: boolean; - groupColumnDef: any; - forPrint: boolean; - context: any; - rowStyle: any; - rowClass: any; - headerCellRenderer: any; - groupDefaultExpanded: any; - slaveGrids: GridOptions[]; - rowSelection: string; - rowDeselection: boolean; - rowData: any[]; - floatingTopRowData: any[]; - floatingBottomRowData: any[]; - showToolPanel: boolean; - groupKeys: string[]; - groupAggFunction: (nodes: any[]) => void; - groupAggFields: string[]; - columnDefs: any[]; - datasource: any; - pinnedColumnCount: number; - quickFilterText: string; - groupHeaders: boolean; - headerHeight: number; - constructor(elementDef: any); - onInit(): void; - onChange(changes: any): void; - private globalEventListener(eventType, event); - } -} -declare namespace ag.grid { -} -declare var exports: any; -declare var module: any; -declare namespace ag.grid { - interface Filter { - getGui(): any; - isFilterActive(): boolean; - doesFilterPass(params: any): boolean; - afterGuiAttached?(params?: { - hidePopup?: Function; - }): void; - onNewRowsLoaded?(): void; - } -} diff --git a/types/ag-grid/tsconfig.json b/types/ag-grid/tsconfig.json deleted file mode 100644 index fd05cca8e1..0000000000 --- a/types/ag-grid/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "files": [ - "index.d.ts", - "ag-grid-tests.ts" - ], - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - } -} \ No newline at end of file diff --git a/types/agenda/agenda-tests.ts b/types/agenda/agenda-tests.ts index 8c5e3e19bb..964eb1b836 100644 --- a/types/agenda/agenda-tests.ts +++ b/types/agenda/agenda-tests.ts @@ -3,16 +3,16 @@ import * as Agenda from "agenda"; var mongoConnectionString = "mongodb://127.0.0.1/agenda"; var agenda = new Agenda({ db: { address: mongoConnectionString } }); - - + + agenda.define('delete old users', (job, done) => { }); agenda.on('ready', () => { agenda.every('3 minutes', 'delete old users'); - - // Alternatively, you could also do: + + // Alternatively, you could also do: agenda.every('*/3 * * * *', 'delete old users'); agenda.start(); @@ -81,6 +81,8 @@ agenda.stop(function() { process.exit(0); }); +job.agenda.now('do the hokey pokey'); + job.repeatEvery('10 minutes'); job.repeatAt('3:30pm'); diff --git a/types/agenda/index.d.ts b/types/agenda/index.d.ts index fe8ecc45a6..d170a6f6f1 100644 --- a/types/agenda/index.d.ts +++ b/types/agenda/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Agenda v0.8.9 +// Type definitions for Agenda v1.0.0 // Project: https://github.com/rschmukler/agenda // Definitions by: Meir Gottlieb // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -337,6 +337,11 @@ declare namespace Agenda { */ attrs: JobAttributes; + /** + * The agenda that created the job. + */ + agenda: Agenda; + /** * Specifies an interval on which the job should repeat. * @param interval A human-readable format String, a cron format String, or a Number. diff --git a/types/aggregate-error/aggregate-error-tests.ts b/types/aggregate-error/aggregate-error-tests.ts new file mode 100644 index 0000000000..69e544f9ee --- /dev/null +++ b/types/aggregate-error/aggregate-error-tests.ts @@ -0,0 +1,9 @@ +import AggregateError = require('aggregate-error'); + +const err = new AggregateError([new Error('foo'), 'bar']); + +for (const el of Array.from(err)) { + const err: Error = el; +} + +throw err; diff --git a/types/aggregate-error/index.d.ts b/types/aggregate-error/index.d.ts new file mode 100644 index 0000000000..8c8c4cd3b2 --- /dev/null +++ b/types/aggregate-error/index.d.ts @@ -0,0 +1,12 @@ +// Type definitions for aggregate-error 1.0 +// Project: https://github.com/sindresorhus/aggregate-error#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = AggregateError; + +declare class AggregateError extends Error implements Iterable { + constructor(errors: Iterable); + + [Symbol.iterator](): Iterator; +} diff --git a/types/aggregate-error/tsconfig.json b/types/aggregate-error/tsconfig.json new file mode 100644 index 0000000000..253c743b98 --- /dev/null +++ b/types/aggregate-error/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "aggregate-error-tests.ts" + ] +} diff --git a/types/aggregate-error/tslint.json b/types/aggregate-error/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/aggregate-error/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/alertify/index.d.ts b/types/alertify/index.d.ts index fa71118381..1eb2699f6f 100644 --- a/types/alertify/index.d.ts +++ b/types/alertify/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for alertify 0.3.11 // Project: http://fabien-d.github.io/alertify.js/ -// Definitions by: John Jeffery +// Definitions by: John Jeffery // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare var alertify: alertify.IAlertifyStatic; diff --git a/types/alexa-sdk/alexa-sdk-tests.ts b/types/alexa-sdk/alexa-sdk-tests.ts index c384bf194d..c77bc93091 100644 --- a/types/alexa-sdk/alexa-sdk-tests.ts +++ b/types/alexa-sdk/alexa-sdk-tests.ts @@ -1,13 +1,13 @@ import * as Alexa from "alexa-sdk"; const handler = (event: Alexa.RequestBody, context: Alexa.Context, callback: () => void) => { - let alexa = Alexa.handler(event, context); + const alexa = Alexa.handler(event, context); alexa.resources = {}; alexa.registerHandlers(handlers); alexa.execute(); }; -let handlers: Alexa.Handlers = { +const handlers: Alexa.Handlers = { 'LaunchRequest': function() { this.emit('SayHello'); }, diff --git a/types/alexa-sdk/index.d.ts b/types/alexa-sdk/index.d.ts index d5892f6ec7..1c39755b2d 100644 --- a/types/alexa-sdk/index.d.ts +++ b/types/alexa-sdk/index.d.ts @@ -7,7 +7,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 -export function handler(event: RequestBody, context: Context, callback?: (err: any, response: any) => void ): AlexaObject; +export function handler(event: RequestBody, context: Context, callback?: (err: any, response: any) => void): AlexaObject; export function CreateStateHandler(state: string, obj: any): any; export let StateString: string; @@ -98,10 +98,34 @@ export interface Request { locale?: string; } +export interface ResolutionStatus { + code: string; +} + +export interface ResolutionValue { + name: string; + id: string; +} + +export interface ResolutionValueContainer { + value: ResolutionValue; +} + +export interface Resolution { + authority: string; + status: ResolutionStatus; + values: ResolutionValueContainer[]; +} + +export interface Resolutions { + resolutionsPerAuthority: Resolution[]; +} + export interface SlotValue { confirmationStatus?: ConfirmationStatuses; name: string; value?: any; + resolutions?: Resolutions; } export interface Intent { diff --git a/types/algebra.js/algebra.js-tests.ts b/types/algebra.js/algebra.js-tests.ts index 0dc7f260e7..0ecaccd2ef 100644 --- a/types/algebra.js/algebra.js-tests.ts +++ b/types/algebra.js/algebra.js-tests.ts @@ -5,9 +5,9 @@ import { Equation, Expression, Fraction, parse, toTex } from 'algebra.js'; expr = expr.subtract(3); expr = expr.add("x"); expr.toString(); - let eq = new Equation(expr, 4); + const eq = new Equation(expr, 4); eq.toString(); - let x = eq.solveFor("x"); + const x = eq.solveFor("x"); x.toString(); } { @@ -29,14 +29,14 @@ import { Equation, Expression, Fraction, parse, toTex } from 'algebra.js'; x.toString(); x = x.add("y"); x.toString(); - let otherExp = new Expression("x").add(6); + const otherExp = new Expression("x").add(6); x = x.add(otherExp); x.toString(); let expr1 = new Expression("a").add("b").add("c"); let expr2 = new Expression("c").subtract("b"); let expr3 = expr1.subtract(expr2); - expr1.toString() + " - (" + expr2.toString() + ") = " + expr3.toString(); + `${expr1.toString()} - (${expr2.toString()}) = ${expr3.toString()}`; expr1 = new Expression("x"); expr1 = expr1.add(2); @@ -46,7 +46,7 @@ import { Equation, Expression, Fraction, parse, toTex } from 'algebra.js'; expr2 = expr2.multiply(new Fraction(1, 3)); expr2 = expr2.add(4); expr3 = expr1.multiply(expr2); - "(" + expr1.toString() + ")(" + expr2.toString() + ") = " + expr3.toString(); + `(${expr1.toString()})(${expr2.toString()}) = ${expr3.toString()}`; x = new Expression("x").divide(2).divide(new Fraction(1, 5)); x.toString(); @@ -54,11 +54,11 @@ import { Equation, Expression, Fraction, parse, toTex } from 'algebra.js'; exp = exp.add("y"); exp = exp.add(3); exp.toString(); - let sum = exp.summation("x", 3, 6); + const sum = exp.summation("x", 3, 6); sum.toString(); exp = new Expression("x").add(2); - let exp3 = exp.pow(3); - "(" + exp.toString() + ")^3 = " + exp3.toString(); + const exp3 = exp.pow(3); + `(${exp.toString()})^3 = ${exp3.toString()}`; let expr = new Expression("x"); expr = expr.multiply(2); @@ -66,14 +66,14 @@ import { Equation, Expression, Fraction, parse, toTex } from 'algebra.js'; expr = expr.add("y"); expr = expr.add(new Fraction(1, 3)); expr.toString(); - let answer1 = expr.eval({ x: 2 }); - let answer2 = expr.eval({ x: 2, y: new Fraction(3, 4) }); + const answer1 = expr.eval({ x: 2 }); + const answer2 = expr.eval({ x: 2, y: new Fraction(3, 4) }); answer1.toString(); answer2.toString(); expr = new Expression("x").add(2); expr.toString(); - let sub = new Expression("y").add(4); - let answer = expr.eval({ x: sub }); + const sub = new Expression("y").add(4); + const answer = expr.eval({ x: sub }); answer.toString(); exp = new Expression("x").add(2); exp.toString(); @@ -91,23 +91,23 @@ import { Equation, Expression, Fraction, parse, toTex } from 'algebra.js'; exp.toString(); exp = exp.simplify(); exp.toString(); - let z = new Expression("z"); - let eq1 = new Equation(z.subtract(4).divide(9), z.add(6)); + const z = new Expression("z"); + const eq1 = new Equation(z.subtract(4).divide(9), z.add(6)); eq1.toString(); - let eq2 = new Equation(z.add(4).multiply(9), 6); + const eq2 = new Equation(z.add(4).multiply(9), 6); eq2.toString(); - let eq3 = new Equation(z.divide(2).multiply(7), new Fraction(1, 4)); + const eq3 = new Equation(z.divide(2).multiply(7), new Fraction(1, 4)); eq3.toString(); } { - let x1 = parse("1/5 * x + 2/15"); - let x2 = parse("1/7 * x + 4"); + const x1 = parse("1/5 * x + 2/15"); + const x2 = parse("1/7 * x + 4"); let eq = new Equation(x1 as Expression, x2 as Expression); eq.toString(); - let answer = eq.solveFor("x"); + const answer = eq.solveFor("x"); "x = " + answer.toString(); - let expr1 = parse("1/4 * x + 5/4"); - let expr2 = parse("3 * y - 12/5"); + const expr1 = parse("1/4 * x + 5/4"); + const expr2 = parse("3 * y - 12/5"); eq = new Equation(expr1 as Expression, expr2 as Expression); eq.toString(); let xAnswer = eq.solveFor("x"); @@ -116,14 +116,14 @@ import { Equation, Expression, Fraction, parse, toTex } from 'algebra.js'; "y = " + yAnswer.toString(); let n1 = parse("x + 5") as Expression; let n2 = parse("x - 3/4") as Expression; - let quad = new Equation(n1.multiply(n2), 0); + const quad = new Equation(n1.multiply(n2), 0); quad.toString(); let answers = quad.solveFor("x"); "x = " + answers.toString(); n1 = parse("x + 2") as Expression; n2 = parse("x + 3") as Expression; - let n3 = parse("x + 4") as Expression; - let cubic = new Equation(n1.multiply(n2).multiply(n3), 0); + const n3 = parse("x + 4") as Expression; + const cubic = new Equation(n1.multiply(n2).multiply(n3), 0); cubic.toString(); answers = cubic.solveFor("x"); "x = " + answers.toString(); @@ -143,20 +143,20 @@ import { Equation, Expression, Fraction, parse, toTex } from 'algebra.js'; exp.toString(); } { - let eq = parse("x^2 + 4 * x + 4 = 0") as Equation; + const eq = parse("x^2 + 4 * x + 4 = 0") as Equation; eq.toString(); - let ans = eq.solveFor("x"); + const ans = eq.solveFor("x"); "x = " + ans.toString(); - let a = new Expression("x").pow(2); - let b = new Expression("x").multiply(new Fraction(5, 4)); - let c = new Fraction(-21, 4); - let expr = a.add(b).add(c); - let quad = new Equation(expr, 0); + const a = new Expression("x").pow(2); + const b = new Expression("x").multiply(new Fraction(5, 4)); + const c = new Fraction(-21, 4); + const expr = a.add(b).add(c); + const quad = new Equation(expr, 0); toTex(quad); - let answers = quad.solveFor("x"); + const answers = quad.solveFor("x"); toTex(answers); - let lambda = new Expression("lambda").add(3).divide(4); - let Phi = new Expression("Phi").subtract(new Fraction(1, 5)).add(lambda); + const lambda = new Expression("lambda").add(3).divide(4); + const Phi = new Expression("Phi").subtract(new Fraction(1, 5)).add(lambda); toTex(lambda); toTex(Phi); } diff --git a/types/algoliasearch/algoliasearch-tests.ts b/types/algoliasearch/algoliasearch-tests.ts index 43a4d677cf..dfcf27c94f 100644 --- a/types/algoliasearch/algoliasearch-tests.ts +++ b/types/algoliasearch/algoliasearch-tests.ts @@ -48,7 +48,7 @@ let _algoliaSecuredApiOptions: AlgoliaSecuredApiOptions = { let _algoliaIndexSettings: AlgoliaIndexSettings = { attributesToIndex: [""], - attributesforFaceting: [""], + attributesForFaceting: [""], unretrievableAttributes: [""], attributesToRetrieve: [""], ranking: [""], diff --git a/types/algoliasearch/index.d.ts b/types/algoliasearch/index.d.ts index 2fdd00f983..1bb77a50e9 100644 --- a/types/algoliasearch/index.d.ts +++ b/types/algoliasearch/index.d.ts @@ -976,7 +976,7 @@ declare namespace algoliasearch { * default: null * https://github.com/algolia/algoliasearch-client-js#attributesforfaceting */ - attributesforFaceting?: string[]; + attributesForFaceting?: string[]; /** * The list of attributes that cannot be retrieved at query time * default: null diff --git a/types/amazon-product-api/index.d.ts b/types/amazon-product-api/index.d.ts index 6cb7389c73..797adf45f4 100644 --- a/types/amazon-product-api/index.d.ts +++ b/types/amazon-product-api/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for amazon-product-api // Project: https://github.com/t3chnoboy/amazon-product-api -// Definitions by: Matti Lehtinen +// Definitions by: Matti Lehtinen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/amplify-deferred/index.d.ts b/types/amplify-deferred/index.d.ts index fd738e9cbe..508cb5bb11 100644 --- a/types/amplify-deferred/index.d.ts +++ b/types/amplify-deferred/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for AmplifyJs (using JQuery Deferred) 1.1 // Project: http://amplifyjs.com/ -// Definitions by: Jonas Eriksson , Laurentiu Stamate +// Definitions by: Jonas Eriksson , Laurentiu Stamate // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/amplify/amplify-tests.ts b/types/amplify/amplify-tests.ts index 62b00052dd..d26ff023bd 100644 --- a/types/amplify/amplify-tests.ts +++ b/types/amplify/amplify-tests.ts @@ -151,7 +151,7 @@ amplify.request.define("twitter-search", "ajax", { } }); -amplify.request("twitter-search", { term: "amplifyjs" } ); +amplify.request("twitter-search", { term: "amplifyjs" }); // Similarly, we can create a request that searches for mentions, by accepting a username: @@ -168,19 +168,24 @@ amplify.request("twitter-mentions", { user: "amplifyjs" }); // Example: const appEnvelopeDecoder: amplify.Decoder = (data, status, xhr, success, error) => { - if (data.status === "success") { - success(data.data); - } else if (data.status === "fail" || data.status === "error") { - error(data.message, data.status); - } else { - error(data.message, "fatal"); + switch (data.status) { + case "success": + success(data.data); + break; + case "fail": + case "error": + error(data.message, data.status); + break; + default: + error(data.message, "fatal"); + break; } }; // a new decoder can be added to the amplifyDecoders interface declare module "amplify" { interface Decoders { - appEnvelope: amplify.Decoder; + appEnvelope: Decoder; } } @@ -213,12 +218,17 @@ amplify.request.define("decoderSingleExample", "ajax", { url: "/myAjaxUrl", type: "POST", decoder(data, status, xhr, success, error) { - if (data.status === "success") { - success(data.data); - } else if (data.status === "fail" || data.status === "error") { - error(data.message, data.status); - } else { - error(data.message, "fatal"); + switch (data.status) { + case "success": + success(data.data); + break; + case "fail": + case "error": + error(data.message, data.status); + break; + default: + error(data.message, "fatal"); + break; } } }); diff --git a/types/amplify/index.d.ts b/types/amplify/index.d.ts index 2c3e2e1e5a..b88a2d5e80 100644 --- a/types/amplify/index.d.ts +++ b/types/amplify/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for AmplifyJs 1.1 // Project: http://amplifyjs.com/ -// Definitions by: Jonas Eriksson +// Definitions by: Jonas Eriksson // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/amqp-rpc/index.d.ts b/types/amqp-rpc/index.d.ts index 337f8d8a16..de2e3c25e6 100644 --- a/types/amqp-rpc/index.d.ts +++ b/types/amqp-rpc/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for amqp-rpc v0.0.8 // Project: https://github.com/demchenkoe/node-amqp-rpc/ -// Definitions by: Wonshik Kim +// Definitions by: Wonshik Kim // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// diff --git a/types/amqp/index.d.ts b/types/amqp/index.d.ts index a7dae4eb56..ea7d6bcc65 100644 --- a/types/amqp/index.d.ts +++ b/types/amqp/index.d.ts @@ -49,6 +49,7 @@ export interface AMQPQueue extends events.EventEmitter { export interface AMQPExchange extends events.EventEmitter { on(event: 'open' | 'ack' | 'error' | 'exchangeBindOk' | 'exchangeUnbindOk', callback: Callback): this; + publish(routingKey: string, message: Buffer | {}, callback: (err?: boolean, msg?: string) => void): void; publish(routingKey: string, message: Buffer | {}, options: ExchangePublishOptions, callback?: (err?: boolean, msg?: string) => void): void; /** diff --git a/types/amqplib/amqplib-tests.ts b/types/amqplib/amqplib-tests.ts index 8bfcf3c9b4..ef448d5b36 100644 --- a/types/amqplib/amqplib-tests.ts +++ b/types/amqplib/amqplib-tests.ts @@ -16,13 +16,19 @@ amqp.connect('amqp://localhost') .then(connection => { return connection.createChannel() .tap(channel => channel.checkQueue('myQueue')) - .then(channel => channel.consume('myQueue', newMsg => console.log('New Message: ' + newMsg.content.toString()))) + .then(channel => { + return channel.consume('myQueue', newMsg => { + if (newMsg != null) { + // test promise api properties + if (newMsg.properties.contentType === 'application/json') { + console.log('New Message: ' + newMsg.content.toString()); + } + } + }); + }) .finally(() => connection.close()); }); -// test promise api properties -let amqpMessage: amqp.Message; -amqpMessage.properties.contentType = 'application/json'; let amqpAssertExchangeOptions: amqp.Options.AssertExchange; let anqpAssertExchangeReplies: amqp.Replies.AssertExchange; @@ -49,7 +55,14 @@ amqpcb.connect('amqp://localhost', (err, connection) => { if (!err) { channel.assertQueue('myQueue', {}, (err, ok) => { if (!err) { - channel.consume('myQueue', newMsg => console.log('New Message: ' + newMsg.content.toString())); + channel.consume('myQueue', newMsg => { + if (newMsg != null) { + // test callback api properties + if (newMsg.properties.contentType === 'application/json') { + console.log('New Message: ' + newMsg.content.toString()); + } + } + }); } }); } @@ -57,8 +70,5 @@ amqpcb.connect('amqp://localhost', (err, connection) => { } }); -// test callback api properties -let amqpcbMessage: amqpcb.Message; -amqpcbMessage.properties.contentType = 'application/json'; let amqpcbAssertExchangeOptions: amqpcb.Options.AssertExchange; let anqpcbAssertExchangeReplies: amqpcb.Replies.AssertExchange; diff --git a/types/amqplib/callback_api.d.ts b/types/amqplib/callback_api.d.ts index d36a849873..60ff8cf622 100644 --- a/types/amqplib/callback_api.d.ts +++ b/types/amqplib/callback_api.d.ts @@ -31,7 +31,7 @@ export interface Channel extends events.EventEmitter { publish(exchange: string, routingKey: string, content: Buffer, options?: Options.Publish): boolean; sendToQueue(queue: string, content: Buffer, options?: Options.Publish): boolean; - consume(queue: string, onMessage: (msg: Message) => any, options?: Options.Consume, callback?: (err: any, ok: Replies.Consume) => void): void; + consume(queue: string, onMessage: (msg: Message | null) => any, options?: Options.Consume, callback?: (err: any, ok: Replies.Consume) => void): void; cancel(consumerTag: string, callback?: (err: any, ok: Replies.Empty) => void): void; get(queue: string, options?: Options.Get, callback?: (err: any, ok: Message | false) => void): void; diff --git a/types/amqplib/index.d.ts b/types/amqplib/index.d.ts index 45b5e6e3ca..91060d23b0 100644 --- a/types/amqplib/index.d.ts +++ b/types/amqplib/index.d.ts @@ -40,7 +40,7 @@ export interface Channel extends events.EventEmitter { publish(exchange: string, routingKey: string, content: Buffer, options?: Options.Publish): boolean; sendToQueue(queue: string, content: Buffer, options?: Options.Publish): boolean; - consume(queue: string, onMessage: (msg: Message) => any, options?: Options.Consume): Promise; + consume(queue: string, onMessage: (msg: Message | null) => any, options?: Options.Consume): Promise; cancel(consumerTag: string): Promise; get(queue: string, options?: Options.Get): Promise; diff --git a/types/amqplib/tsconfig.json b/types/amqplib/tsconfig.json index 1f880d1396..16ed704846 100644 --- a/types/amqplib/tsconfig.json +++ b/types/amqplib/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -20,4 +20,4 @@ "callback_api.d.ts", "amqplib-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/amqplib/tslint.json b/types/amqplib/tslint.json index 4f44991c3c..bfc9508c49 100644 --- a/types/amqplib/tslint.json +++ b/types/amqplib/tslint.json @@ -1,6 +1,8 @@ { "extends": "dtslint/dt.json", "rules": { - "no-empty-interface": false + // All are TODOs + "no-empty-interface": false, + "prefer-const": false } } diff --git a/types/angular-block-ui/angular-block-ui-tests.ts b/types/angular-block-ui/angular-block-ui-tests.ts index 4b3903f9cc..58547fff4d 100644 --- a/types/angular-block-ui/angular-block-ui-tests.ts +++ b/types/angular-block-ui/angular-block-ui-tests.ts @@ -37,5 +37,5 @@ app.controller('Ctrl', ($scope: ng.IScope, blockUI: angular.blockUI.BlockUIServi blockUI.reset(); blockUI.message("Hello Types"); blockUI.done(); - let b: boolean = blockUI.isBlocking(); + const b: boolean = blockUI.isBlocking(); }); diff --git a/types/angular-block-ui/index.d.ts b/types/angular-block-ui/index.d.ts index 7733bc72f7..47ba9902b9 100644 --- a/types/angular-block-ui/index.d.ts +++ b/types/angular-block-ui/index.d.ts @@ -70,7 +70,7 @@ declare module 'angular' { * @param {angular.IRequestConfig} config - the Angular request config object. * */ - requestFilter?(config: angular.IRequestConfig): (string | boolean); + requestFilter?(config: IRequestConfig): (string | boolean); /** * When the module is started it will inject the main block element diff --git a/types/angular-bootstrap-calendar/package.json b/types/angular-bootstrap-calendar/package.json index 4c6d24a445..fce08a048d 100644 --- a/types/angular-bootstrap-calendar/package.json +++ b/types/angular-bootstrap-calendar/package.json @@ -1,4 +1,5 @@ { + "private": true, "dependencies": { "moment": ">=2.14.0" } diff --git a/types/angular-clipboard/index.d.ts b/types/angular-clipboard/index.d.ts index 0f59feaf56..a9a15821b6 100644 --- a/types/angular-clipboard/index.d.ts +++ b/types/angular-clipboard/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for angular-clipboard v1.5 // Project: https://github.com/omichelsen/angular-clipboard -// Definitions by: Bradford Wagner +// Definitions by: Bradford Wagner // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/angular-cookies/index.d.ts b/types/angular-cookies/index.d.ts index 502e83a2e9..dc6fd913e9 100644 --- a/types/angular-cookies/index.d.ts +++ b/types/angular-cookies/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Angular JS (ngCookies module) 1.4 // Project: http://angularjs.org -// Definitions by: Diego Vilar , Anthony Ciccarello +// Definitions by: Diego Vilar , Anthony Ciccarello // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/angular-deferred-bootstrap/index.d.ts b/types/angular-deferred-bootstrap/index.d.ts index df489e48ee..2c1a2d141c 100644 --- a/types/angular-deferred-bootstrap/index.d.ts +++ b/types/angular-deferred-bootstrap/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for angular-deferred-bootstrap v0.1.9 // Project: https://github.com/philippd/angular-deferred-bootstrap -// Definitions by: Markus Wagner +// Definitions by: Markus Wagner // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/angular-es/index.d.ts b/types/angular-es/index.d.ts index 0972b42da0..a3a57edcfc 100644 --- a/types/angular-es/index.d.ts +++ b/types/angular-es/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for angular-es v0.0.3 // Project: https://github.com/mbutsykin/angular-es -// Definitions by: mbutsykin +// Definitions by: mbutsykin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module 'angular-es' { diff --git a/types/angular-feature-flags/angular-feature-flags-tests.ts b/types/angular-feature-flags/angular-feature-flags-tests.ts index ac956dd657..bd44d7b5cf 100644 --- a/types/angular-feature-flags/angular-feature-flags-tests.ts +++ b/types/angular-feature-flags/angular-feature-flags-tests.ts @@ -1,8 +1,8 @@ -import * as angular from "angular"; +import * as ng from 'angular'; -let myApp = angular.module('myApp', ['feature-flags']); +const myApp = ng.module('myApp', ['feature-flags']); -const flagsData: Array = [ +const flagsData: Array = [ { key: '1', active: true, @@ -17,15 +17,16 @@ const flagsData: Array = [ } ]; -myApp.config(function (featureFlagsProvider: angular.featureflags.FeatureFlagsProvider) { +myApp.config(function(featureFlagsProvider: ng.featureflags.FeatureFlagsProvider) { featureFlagsProvider.setInitialFlags(flagsData); }); -myApp.run(function ($q: angular.IQService, $http: angular.IHttpService, featureFlags: angular.featureflags.FeatureFlagsService) { - let deferred = $q.defer(); - deferred.resolve(flagsData); - - featureFlags.set(deferred.promise); - +myApp.run(function( + $q: ng.IQService, + $http: ng.IHttpService, + featureFlags: ng.featureflags.FeatureFlagsService +) { + featureFlags.set($q.resolve(flagsData)); featureFlags.set($http.get('/data/flags.json')); -}); \ No newline at end of file + featureFlags.set($http.get>('/data/flags.json')); +}); diff --git a/types/angular-feature-flags/index.d.ts b/types/angular-feature-flags/index.d.ts index 2335bf0eba..0efb9379c6 100644 --- a/types/angular-feature-flags/index.d.ts +++ b/types/angular-feature-flags/index.d.ts @@ -1,14 +1,14 @@ // Type definitions for angular-feature-flags 1.4.0 // Project: https://github.com/mjt01/angular-feature-flags -// Definitions by: Borislav Zhivkov +// Definitions by: Borislav Zhivkov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 /// -import * as angular from "angular"; +import * as ng from 'angular'; -declare module "angular" { +declare module 'angular' { namespace featureflags { export interface FlagData { /** @@ -27,17 +27,22 @@ declare module "angular" { name: string; /** - * A long description of the flag to further explain the feature being toggled (only visible in the list of flags) + * A long description of the flag to further explain the feature being toggled + * (only visible in the list of flags) */ description: string; } export interface FeatureFlagsProvider { - setInitialFlags(flags: Array): void; + setInitialFlags(flags: ReadonlyArray): void; } export interface FeatureFlagsService { - set(flagsPromise: angular.IPromise | angular.IHttpPromise): void; + set( + flagsPromise: + | ng.IPromise> + | ng.IHttpPromise> + ): void; } } } diff --git a/types/angular-file-saver/index.d.ts b/types/angular-file-saver/index.d.ts index cee78df620..9ba224fba1 100644 --- a/types/angular-file-saver/index.d.ts +++ b/types/angular-file-saver/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for angular-file-saver 1.1 // Project: https://github.com/alferov/angular-file-saver -// Definitions by: Donald Nairn +// Definitions by: Donald Nairn // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/angular-gridster/angular-gridster-tests.ts b/types/angular-gridster/angular-gridster-tests.ts index f8c5a93c81..6c88263214 100644 --- a/types/angular-gridster/angular-gridster-tests.ts +++ b/types/angular-gridster/angular-gridster-tests.ts @@ -1,4 +1,3 @@ -import * as ng from "angular"; import * as angular from "angular"; import gridster from "angular-gridster"; diff --git a/types/angular-gridster/index.d.ts b/types/angular-gridster/index.d.ts index 3d4fbbe799..22c02b4050 100644 --- a/types/angular-gridster/index.d.ts +++ b/types/angular-gridster/index.d.ts @@ -89,13 +89,13 @@ declare module "angular" { handles?: string[]; // optional callback fired when drag is started - start?(event: angular.IAngularEvent, $element: angular.IAugmentedJQuery, options: any): void; + start?(event: IAngularEvent, $element: IAugmentedJQuery, options: any): void; // optional callback fired when item is resized - resize?(event: angular.IAngularEvent, $element: angular.IAugmentedJQuery, options: any): void; + resize?(event: IAngularEvent, $element: IAugmentedJQuery, options: any): void; // optional callback fired when item is finished dragging - stop?(event: angular.IAngularEvent, $element: angular.IAugmentedJQuery, options: any): void; + stop?(event: IAngularEvent, $element: IAugmentedJQuery, options: any): void; }; // options to pass to draggable handler @@ -113,13 +113,13 @@ declare module "angular" { handle?: string; // optional callback fired when drag is started - start?(event: angular.IAngularEvent, $element: angular.IAugmentedJQuery, options: any): void; + start?(event: IAngularEvent, $element: IAugmentedJQuery, options: any): void; // optional callback fired when item is moved, - drag?(event: angular.IAngularEvent, $element: angular.IAugmentedJQuery, options: any): void; + drag?(event: IAngularEvent, $element: IAugmentedJQuery, options: any): void; // optional callback fired when item is finished dragging - stop?(event: angular.IAngularEvent, $element: angular.IAugmentedJQuery, options: any): void; + stop?(event: IAngularEvent, $element: IAugmentedJQuery, options: any): void; }; } diff --git a/types/angular-hotkeys/index.d.ts b/types/angular-hotkeys/index.d.ts index 3db766706a..38ff06a969 100644 --- a/types/angular-hotkeys/index.d.ts +++ b/types/angular-hotkeys/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: Jason Zhao , Stefan Steinhart // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -//readme written by David Valentine +//readme written by David Valentine /// diff --git a/types/angular-localforage/package.json b/types/angular-localforage/package.json index 07bf3d2615..22ff6e6118 100644 --- a/types/angular-localforage/package.json +++ b/types/angular-localforage/package.json @@ -1,4 +1,5 @@ { + "private": true, "dependencies": { "localforage": "^1.5.0" } diff --git a/types/angular-material/angular-material-tests.ts b/types/angular-material/angular-material-tests.ts index 5766a81975..79f72f0b5d 100644 --- a/types/angular-material/angular-material-tests.ts +++ b/types/angular-material/angular-material-tests.ts @@ -49,7 +49,7 @@ myApp.config(( return c * t * t + b; }, easeFnIndeterminate(t, b, c, d) { - return c * Math.pow(2, 10 * (t / d - 1)) + b; + return c * Math.pow(2, (t / d - 1) * 10) + b; } }); }); diff --git a/types/angular-material/index.d.ts b/types/angular-material/index.d.ts index 58e1ae5dd6..a8808f92ff 100644 --- a/types/angular-material/index.d.ts +++ b/types/angular-material/index.d.ts @@ -18,7 +18,7 @@ declare module 'angular' { interface IBottomSheetOptions { templateUrl?: string; template?: string; - scope?: angular.IScope; // default: new child scope + scope?: IScope; // default: new child scope preserveScope?: boolean; // default: false controller?: string | Injectable; locals?: { [index: string]: any }; @@ -28,12 +28,12 @@ declare module 'angular' { escapeToClose?: boolean; resolve?: ResolveObject; controllerAs?: string; - parent?: ((scope: angular.IScope, element: JQuery) => Element | JQuery) | string | Element | JQuery; // default: root node + parent?: ((scope: IScope, element: JQuery) => Element | JQuery) | string | Element | JQuery; // default: root node disableParentScroll?: boolean; // default: true } interface IBottomSheetService { - show(options: IBottomSheetOptions): angular.IPromise; + show(options: IBottomSheetOptions): IPromise; hide(response?: any): void; cancel(response?: any): void; } @@ -47,7 +47,7 @@ declare module 'angular' { templateUrl(templateUrl?: string): T; template(template?: string): T; targetEvent(targetEvent?: MouseEvent): T; - scope(scope?: angular.IScope): T; // default: new child scope + scope(scope?: IScope): T; // default: new child scope preserveScope(preserveScope?: boolean): T; // default: false disableParentScroll(disableParentScroll?: boolean): T; // default: true hasBackdrop(hasBackdrop?: boolean): T; // default: true @@ -61,6 +61,9 @@ declare module 'angular' { controllerAs(controllerAs?: string): T; parent(parent?: string | Element | JQuery): T; // default: root node ariaLabel(ariaLabel: string): T; + openFrom(from: string | Element | Event | { top: number, left: number }): T; + closeTo(to: string | Element | { top: number, left: number }): T; + multiple(multiple: boolean): T; } // tslint:disable-next-line no-empty-interface @@ -95,7 +98,7 @@ declare module 'angular' { targetEvent?: MouseEvent; openFrom?: any; closeTo?: any; - scope?: angular.IScope; // default: new child scope + scope?: IScope; // default: new child scope preserveScope?: boolean; // default: false disableParentScroll?: boolean; // default: true hasBackdrop?: boolean; // default: true @@ -108,24 +111,24 @@ declare module 'angular' { resolve?: ResolveObject; controllerAs?: string; parent?: string | Element | JQuery; // default: root node - onShowing?(scope: angular.IScope, element: JQuery): void; - onComplete?(scope: angular.IScope, element: JQuery): void; - onRemoving?(element: JQuery, removePromise: angular.IPromise): void; + onShowing?(scope: IScope, element: JQuery): void; + onComplete?(scope: IScope, element: JQuery): void; + onRemoving?(element: JQuery, removePromise: IPromise): void; skipHide?: boolean; multiple?: boolean; fullscreen?: boolean; // default: false } interface IDialogService { - show(dialog: IDialogOptions | IAlertDialog | IConfirmDialog | IPromptDialog): angular.IPromise; + show(dialog: IDialogOptions | IAlertDialog | IConfirmDialog | IPromptDialog): IPromise; confirm(): IConfirmDialog; alert(): IAlertDialog; prompt(): IPromptDialog; - hide(response?: any): angular.IPromise; + hide(response?: any): IPromise; cancel(response?: any): void; } - type IIcon = (id: string) => angular.IPromise; // id is a unique ID or URL + type IIcon = (id: string) => IPromise; // id is a unique ID or URL interface IIconProvider { icon(id: string, url: string, viewBoxSize?: number): IIconProvider; // viewBoxSize default: 24 @@ -138,16 +141,16 @@ declare module 'angular' { type IMedia = (media: string) => boolean; interface ISidenavObject { - toggle(): angular.IPromise; - open(): angular.IPromise; - close(): angular.IPromise; + toggle(): IPromise; + open(): IPromise; + close(): IPromise; isOpen(): boolean; isLockedOpen(): boolean; onClose(onClose: () => void): void; } interface ISidenavService { - (component: string, enableWait: boolean): angular.IPromise; + (component: string, enableWait: boolean): IPromise; (component: string): ISidenavObject; } @@ -172,7 +175,7 @@ declare module 'angular' { templateUrl?: string; template?: string; autoWrap?: boolean; - scope?: angular.IScope; // default: new child scope + scope?: IScope; // default: new child scope preserveScope?: boolean; // default: false hideDelay?: number | false; // default (ms): 3000 position?: string; // any combination of 'bottom'/'left'/'top'/'right'/'fit'; default: 'bottom left' @@ -186,8 +189,8 @@ declare module 'angular' { } interface IToastService { - show(optionsOrPreset: IToastOptions | IToastPreset): angular.IPromise; - showSimple(content: string): angular.IPromise; + show(optionsOrPreset: IToastOptions | IToastPreset): IPromise; + showSimple(content: string): IPromise; simple(): ISimpleToastPreset; build(): IToastPreset; updateContent(newContent: string): void; @@ -303,7 +306,7 @@ declare module 'angular' { } interface IMenuService { - hide(response?: any, options?: any): angular.IPromise; + hide(response?: any, options?: any): IPromise; } interface IColorPalette { @@ -363,19 +366,19 @@ declare module 'angular' { isAttached: boolean; panelContainer: JQuery; panelEl: JQuery; - open(): angular.IPromise; - close(): angular.IPromise; - attach(): angular.IPromise; - detach(): angular.IPromise; - show(): angular.IPromise; - hide(): angular.IPromise; + open(): IPromise; + close(): IPromise; + attach(): IPromise; + detach(): IPromise; + show(): IPromise; + hide(): IPromise; destroy(): void; addClass(newClass: string): void; removeClass(oldClass: string): void; toggleClass(toggleClass: string): void; updatePosition(position: IPanelPosition): void; - registerInterceptor(type: string, callback: () => angular.IPromise): IPanelRef; - removeInterceptor(type: string, callback: () => angular.IPromise): IPanelRef; + registerInterceptor(type: string, callback: () => IPromise): IPanelRef; + removeInterceptor(type: string, callback: () => IPromise): IPanelRef; removeAllInterceptors(type?: string): IPanelRef; } @@ -404,7 +407,7 @@ declare module 'angular' { interface IPanelService { create(opt_config: IPanelConfig): IPanelRef; - open(opt_config: IPanelConfig): angular.IPromise; + open(opt_config: IPanelConfig): IPromise; newPanelPosition(): IPanelPosition; newPanelAnimation(): IPanelAnimation; xPosition: { diff --git a/types/angular-material/tslint.json b/types/angular-material/tslint.json index 8e8a076d2c..4c42fed648 100644 --- a/types/angular-material/tslint.json +++ b/types/angular-material/tslint.json @@ -1,7 +1,9 @@ { "extends": "dtslint/dt.json", "rules": { + // TODOs "interface-name": false, - "max-line-length": false + "max-line-length": false, + "no-void-expression": false } } \ No newline at end of file diff --git a/types/angular-mocks/index.d.ts b/types/angular-mocks/index.d.ts index 14571e2eba..ac9e6cece3 100644 --- a/types/angular-mocks/index.d.ts +++ b/types/angular-mocks/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Angular JS (ngMock, ngMockE2E module) 1.5 // Project: http://angularjs.org -// Definitions by: Diego Vilar , Tony Curtis +// Definitions by: Diego Vilar , Tony Curtis // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/angular-oauth2/index.d.ts b/types/angular-oauth2/index.d.ts index 1c5e3ac6ed..ef11ee3680 100644 --- a/types/angular-oauth2/index.d.ts +++ b/types/angular-oauth2/index.d.ts @@ -27,9 +27,9 @@ declare module 'angular' { interface OAuth { isAuthenticated(): boolean; - getAccessToken(data: Data, options?: any): angular.IPromise; - getRefreshToken(data?: Data, options?: any): angular.IPromise; - revokeToken(data?: Data, options?: any): angular.IPromise; + getAccessToken(data: Data, options?: any): IPromise; + getRefreshToken(data?: Data, options?: any): IPromise; + revokeToken(data?: Data, options?: any): IPromise; } interface OAuthTokenConfig { diff --git a/types/angular-pdfjs-viewer/index.d.ts b/types/angular-pdfjs-viewer/index.d.ts index 392164bb00..e9c41ef1fe 100644 --- a/types/angular-pdfjs-viewer/index.d.ts +++ b/types/angular-pdfjs-viewer/index.d.ts @@ -8,7 +8,7 @@ import * as angular from 'angular'; declare module 'angular' { namespace pdfjsViewer { - interface ConfigProvider extends angular.IServiceProvider { + interface ConfigProvider extends IServiceProvider { setWorkerSrc(src: string): void; setCmapDir(dir: string): void; setImageDir(dir: string): void; diff --git a/types/angular-promise-tracker/index.d.ts b/types/angular-promise-tracker/index.d.ts index ec2f7fd498..85a87bad63 100644 --- a/types/angular-promise-tracker/index.d.ts +++ b/types/angular-promise-tracker/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for angular-promise-tracker 2.2.2 // Project: https://github.com/ajoslin/angular-promise-tracker -// Definitions by: Rufus Linke +// Definitions by: Rufus Linke // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/angular-resource/angular-resource-tests.ts b/types/angular-resource/angular-resource-tests.ts index c5b71ee39f..c35f27a98d 100644 --- a/types/angular-resource/angular-resource-tests.ts +++ b/types/angular-resource/angular-resource-tests.ts @@ -32,7 +32,7 @@ interface IArticleResourceClass extends ng.resource.IResourceClass('/articles/:id', null, { + const articleResource: IArticleResourceClass = $resource('/articles/:id', null, { publish : publishDescriptor, unpublish : { method: 'POST' @@ -51,7 +51,7 @@ function MainController($resource: ng.resource.IResourceService): void { articleResource.unpublish({ id: 1 }); // IResourceClass.get() will be automatically available here - let article: IArticleResource = articleResource.get({id: 1}, function success(): void { + const article: IArticleResource = articleResource.get({id: 1}, function success(): void { // Again, default + custom action here... article.title = 'New Title'; article.$save(); @@ -59,10 +59,9 @@ function MainController($resource: ng.resource.IResourceService): void { }); } -import IHttpPromiseCallbackArg = angular.IHttpPromiseCallbackArg; +import IHttpResponse = angular.IHttpResponse; interface IMyData {} -interface IMyHttpPromiseCallbackArg extends IHttpPromiseCallbackArg {} interface IMyResource extends angular.resource.IResource {} interface IMyResourceClass extends angular.resource.IResourceClass {} @@ -87,7 +86,7 @@ angular.injector(['ng']).invoke(function ($cacheFactory: angular.ICacheFactorySe actionDescriptor.withCredentials = true; actionDescriptor.responseType = 'response type'; actionDescriptor.interceptor = { - response() { return {} as IMyHttpPromiseCallbackArg; }, + response() { return {} as IHttpResponse; }, responseError() {} }; actionDescriptor.cancellable = true; diff --git a/types/angular-resource/index.d.ts b/types/angular-resource/index.d.ts index 4bdc8cc007..1ebd198b82 100644 --- a/types/angular-resource/index.d.ts +++ b/types/angular-resource/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Angular JS (ngResource module) 1.5 // Project: http://angularjs.org -// Definitions by: Diego Vilar , Michael Jess +// Definitions by: Diego Vilar , Michael Jess // Definitions: https://github.com/daptiv/DefinitelyTyped // TypeScript Version: 2.3 @@ -74,10 +74,10 @@ declare module 'angular' { params?: any; url?: string; isArray?: boolean; - transformRequest?: angular.IHttpRequestTransformer | angular.IHttpRequestTransformer[]; - transformResponse?: angular.IHttpResponseTransformer | angular.IHttpResponseTransformer[]; + transformRequest?: IHttpRequestTransformer | IHttpRequestTransformer[]; + transformResponse?: IHttpResponseTransformer | IHttpResponseTransformer[]; headers?: any; - cache?: boolean | angular.ICacheObject; + cache?: boolean | ICacheObject; /** * Note: In contrast to $http.config, promises are not supported in $resource, because the same value * would be used for multiple requests. If you are looking for a way to cancel requests, you should @@ -118,15 +118,15 @@ declare module 'angular' { // it's gonna be considered data if the action method is POST, PUT or // PATCH (in other words, methods with body). Otherwise, it's going // to be considered as parameters to the request. - // https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L461-L465 + // https://github.com/angular/js/blob/v1.2.0/src/ngResource/resource.js#L461-L465 // // Only those methods with an HTTP body do have 'data' as first parameter: - // https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L463 + // https://github.com/angular/js/blob/v1.2.0/src/ngResource/resource.js#L463 // More specifically, those methods are POST, PUT and PATCH: - // https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L432 + // https://github.com/angular/js/blob/v1.2.0/src/ngResource/resource.js#L432 // // Also, static calls always return the IResource (or IResourceArray) retrieved - // https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L538-L549 + // https://github.com/angular/js/blob/v1.2.0/src/ngResource/resource.js#L538-L549 interface IResourceClass { new(dataOrParams?: any): T & IResource; get: IResourceMethod; @@ -141,32 +141,32 @@ declare module 'angular' { } // Instance calls always return the the promise of the request which retrieved the object - // https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L538-L546 + // https://github.com/angular/js/blob/v1.2.0/src/ngResource/resource.js#L538-L546 interface IResource { - $get(): angular.IPromise; - $get(params?: Object, success?: Function, error?: Function): angular.IPromise; - $get(success: Function, error?: Function): angular.IPromise; + $get(): IPromise; + $get(params?: Object, success?: Function, error?: Function): IPromise; + $get(success: Function, error?: Function): IPromise; - $query(): angular.IPromise>; - $query(params?: Object, success?: Function, error?: Function): angular.IPromise>; - $query(success: Function, error?: Function): angular.IPromise>; + $query(): IPromise>; + $query(params?: Object, success?: Function, error?: Function): IPromise>; + $query(success: Function, error?: Function): IPromise>; - $save(): angular.IPromise; - $save(params?: Object, success?: Function, error?: Function): angular.IPromise; - $save(success: Function, error?: Function): angular.IPromise; + $save(): IPromise; + $save(params?: Object, success?: Function, error?: Function): IPromise; + $save(success: Function, error?: Function): IPromise; - $remove(): angular.IPromise; - $remove(params?: Object, success?: Function, error?: Function): angular.IPromise; - $remove(success: Function, error?: Function): angular.IPromise; + $remove(): IPromise; + $remove(params?: Object, success?: Function, error?: Function): IPromise; + $remove(success: Function, error?: Function): IPromise; - $delete(): angular.IPromise; - $delete(params?: Object, success?: Function, error?: Function): angular.IPromise; - $delete(success: Function, error?: Function): angular.IPromise; + $delete(): IPromise; + $delete(params?: Object, success?: Function, error?: Function): IPromise; + $delete(success: Function, error?: Function): IPromise; $cancelRequest(): void; /** The promise of the original server interaction that created this instance. */ - $promise: angular.IPromise; + $promise: IPromise; $resolved: boolean; toJSON(): T; } @@ -178,18 +178,18 @@ declare module 'angular' { $cancelRequest(): void; /** The promise of the original server interaction that created this collection. */ - $promise: angular.IPromise>; + $promise: IPromise>; $resolved: boolean; } /** when creating a resource factory via IModule.factory */ interface IResourceServiceFactoryFunction { - ($resource: angular.resource.IResourceService): IResourceClass; - >($resource: angular.resource.IResourceService): U; + ($resource: IResourceService): IResourceClass; + >($resource: IResourceService): U; } // IResourceServiceProvider used to configure global settings - interface IResourceServiceProvider extends angular.IServiceProvider { + interface IResourceServiceProvider extends IServiceProvider { defaults: IResourceOptions; } } @@ -197,12 +197,12 @@ declare module 'angular' { /** extensions to base ng based on using angular-resource */ interface IModule { /** creating a resource service factory */ - factory(name: string, resourceServiceFactoryFunction: angular.resource.IResourceServiceFactoryFunction): IModule; + factory(name: string, resourceServiceFactoryFunction: resource.IResourceServiceFactoryFunction): IModule; } namespace auto { interface IInjectorService { - get(name: '$resource'): ng.resource.IResourceService; + get(name: '$resource'): resource.IResourceService; } } } diff --git a/types/angular-resource/tslint.json b/types/angular-resource/tslint.json index 7ebd5d5d2d..b4b1464296 100644 --- a/types/angular-resource/tslint.json +++ b/types/angular-resource/tslint.json @@ -5,8 +5,10 @@ "interface-name": false, "only-arrow-functions": false, "no-empty-interface": false, + "no-object-literal-type-assertion": false, "ban-types": false, "space-before-function-paren": false, - "unified-signatures": false + "unified-signatures": false, + "no-unnecessary-generics": false } } diff --git a/types/angular-sanitize/index.d.ts b/types/angular-sanitize/index.d.ts index 89273b42fb..ad42ec362e 100644 --- a/types/angular-sanitize/index.d.ts +++ b/types/angular-sanitize/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Angular JS (ngSanitize module) 1.3 // Project: http://angularjs.org -// Definitions by: Diego Vilar +// Definitions by: Diego Vilar // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/angular-strap/angular-strap-tests.ts b/types/angular-strap/angular-strap-tests.ts index c81e0056e9..64e51a238b 100644 --- a/types/angular-strap/angular-strap-tests.ts +++ b/types/angular-strap/angular-strap-tests.ts @@ -30,6 +30,8 @@ namespace angularStrapTests { myOtherModalOptions.scope = $scope; myOtherModalOptions.template = 'modal/docs/modal.demo.tpl.html'; myOtherModalOptions.show = false; + myOtherModalOptions.controller = demoCtrl; + myOtherModalOptions.controllerAs = "ctrl"; var myOtherModal = $modal(myOtherModalOptions); diff --git a/types/angular-strap/index.d.ts b/types/angular-strap/index.d.ts index f7749a049b..9aebcdf480 100644 --- a/types/angular-strap/index.d.ts +++ b/types/angular-strap/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for angular-strap v2.2.x +// Type definitions for angular-strap v2.3.x // Project: http://mgcrea.github.io/angular-strap/ // Definitions by: Sam Herrmann // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -42,6 +42,8 @@ declare namespace mgcrea.ngStrap { keyboard?: boolean; show?: boolean; container?: string | boolean; + controller?: any; + controllerAs?: string; template?: string; templateUrl?: string; contentTemplate?: string; diff --git a/types/angular-ui-bootstrap/index.d.ts b/types/angular-ui-bootstrap/index.d.ts index 7eca42520d..548f0e1ef9 100644 --- a/types/angular-ui-bootstrap/index.d.ts +++ b/types/angular-ui-bootstrap/index.d.ts @@ -312,7 +312,7 @@ declare module 'angular' { openClass?: string; } - interface IModalProvider extends IServiceProvider { + interface IModalProvider extends angular.IServiceProvider { /** * Default options all modals will use. */ @@ -876,7 +876,7 @@ declare module 'angular' { useContentExp?: boolean; } - interface ITooltipProvider extends IServiceProvider { + interface ITooltipProvider extends angular.IServiceProvider { /** * Provide a set of defaults for certain tooltip and popover attributes. */ diff --git a/types/angular-ui-router-default/angular-ui-router-default-tests.ts b/types/angular-ui-router-default/angular-ui-router-default-tests.ts deleted file mode 100644 index 39e792e3a1..0000000000 --- a/types/angular-ui-router-default/angular-ui-router-default-tests.ts +++ /dev/null @@ -1,39 +0,0 @@ -import * as angular from "angular"; - -angular.module("test", [ - "ui.router", - "ui.router.default" -]) - .config(function($stateProvider: angular.ui.IStateProvider) { - $stateProvider - .state('concrete', { - // no abstract or default - }) - .state('string', { - abstract: true, - default: 'concrete' - }) - .state('func_str', { - abstract: true, - default: function($rootScope): string { return $rootScope.test; } - }) - .state('func_promise', { - abstract: true, - default: function($q: ng.IQService): ng.IPromise { - return $q.when("concrete"); - } - }) - .state('injection_str', { - abstract: true, - default: ["$rootScope", function($rootScope) { - return $rootScope.test; - }] - }) - .state('injection_promise', { - abstract: true, - default: ["$q", function($q: ng.IQService) { - return $q.when("concrete"); - }] - }) - ; - }); diff --git a/types/angular-ui-router-default/index.d.ts b/types/angular-ui-router-default/index.d.ts deleted file mode 100644 index 98bb93b51b..0000000000 --- a/types/angular-ui-router-default/index.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -// Type definitions for angular-ui-router-default 0.5 -// Project: https://github.com/nonplus/angular-ui-router-default -// Definitions by: Stepan Riha -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 - -import * as aur from "angular-ui-router"; - -declare module "angular" { - namespace ui { - export type StateDefaultSpecifier = string - | ((...args: any[]) => string) - | ((...args: any[]) => ng.IPromise) - | (string | ((...args: any[]) => string))[] - | (string | ((...args: any[]) => ng.IPromise))[]; - interface IState { - default?: StateDefaultSpecifier - } - } -} diff --git a/types/angular-ui-router-default/tsconfig.json b/types/angular-ui-router-default/tsconfig.json deleted file mode 100644 index 7cda72ddf5..0000000000 --- a/types/angular-ui-router-default/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "angular-ui-router-default-tests.ts" - ] -} \ No newline at end of file diff --git a/types/angular-ui-router-uib-modal/angular-ui-router-uib-modal-tests.ts b/types/angular-ui-router-uib-modal/angular-ui-router-uib-modal-tests.ts deleted file mode 100644 index 2ca6e18806..0000000000 --- a/types/angular-ui-router-uib-modal/angular-ui-router-uib-modal-tests.ts +++ /dev/null @@ -1,28 +0,0 @@ -angular.module("test", [ - "ui.bootstrap", - "ui.router", - "ui.router.default" -]) - .config(function($stateProvider: angular.ui.IStateProvider) { - $stateProvider - .state('contacts', { - // no modal - resolve: { - a: function() { - return "a"; - }, - b: function() { - return ["a", "b"]; - } - } - }) - .state('contacts.contact', { - // boolean modal - modal: true - }) - .state('contacts.contact.edit', { - // string[] modal - modal: ["a", "b"] - }) - ; - }); diff --git a/types/angular-ui-router-uib-modal/index.d.ts b/types/angular-ui-router-uib-modal/index.d.ts deleted file mode 100644 index b0abfdb031..0000000000 --- a/types/angular-ui-router-uib-modal/index.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Type definitions for angular-ui-uib-modal (ui.router module) 0.11 -// Project: https://github.com/nonplus/angular-ui-router-uib-modal -// Definitions by: Stepan Riha -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 - -import * as auir from "angular-ui-router"; - -declare module "angular" { - namespace ui { - interface IState { - modal?: boolean | string[]; - } - } -} diff --git a/types/angular-ui-router-uib-modal/tsconfig.json b/types/angular-ui-router-uib-modal/tsconfig.json deleted file mode 100644 index 7924c64716..0000000000 --- a/types/angular-ui-router-uib-modal/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "angular-ui-router-uib-modal-tests.ts" - ] -} \ No newline at end of file diff --git a/types/angular-ui-router/angular-ui-router-tests.ts b/types/angular-ui-router/angular-ui-router-tests.ts index 174c319f97..8f9ec67486 100644 --- a/types/angular-ui-router/angular-ui-router-tests.ts +++ b/types/angular-ui-router/angular-ui-router-tests.ts @@ -157,7 +157,7 @@ class UrlLocatorTestService implements IUrlLocatorTestService { // Note that we do not concern ourselves with what to do if this request fails, // because if it fails, the web page will be redirected away to the login screen. - this.$http({ url: "/api/me", method: "GET" }).then((response: ng.IHttpPromiseCallbackArg) => { + this.$http({ url: "/api/me", method: "GET" }).then((response: ng.IHttpResponse) => { this.currentUser = response.data; // sync the ui-state with the location in the browser, which effectively diff --git a/types/angular/angular-component-router.d.ts b/types/angular/angular-component-router.d.ts index b8c939f7c8..b8cd8d097e 100644 --- a/types/angular/angular-component-router.d.ts +++ b/types/angular/angular-component-router.d.ts @@ -1,7 +1,7 @@ /* tslint:disable:dt-header variable-name */ // Type definitions for Angular JS 1.5 component router // Project: http://angularjs.org -// Definitions by: David Reher +// Definitions by: David Reher // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace angular { diff --git a/types/angular/angular-tests.ts b/types/angular/angular-tests.ts index 20de01f71f..c60da29504 100644 --- a/types/angular/angular-tests.ts +++ b/types/angular/angular-tests.ts @@ -61,31 +61,38 @@ angular.module('http-auth-interceptor', []) * $http interceptor. * On 401 response - it stores the request and broadcasts 'event:angular-auth-loginRequired'. */ - .config(['$httpProvider', 'authServiceProvider', ($httpProvider: ng.IHttpProvider, authServiceProvider: any) => { - $httpProvider.defaults.headers.common = {Authorization: 'Bearer token'}; - $httpProvider.defaults.headers.get['Authorization'] = 'Bearer token'; - $httpProvider.defaults.headers.post['Authorization'] = (config: ng.IRequestConfig) => 'Bearer token'; + .config([ + '$httpProvider', 'authServiceProvider', + ($httpProvider: ng.IHttpProvider, authServiceProvider: AuthService) => { + $httpProvider.defaults.headers.common = { Authorization: 'Bearer token' }; + $httpProvider.defaults.headers.get.Authorization = 'Bearer token'; + $httpProvider.defaults.headers.post['Authorization'] = (config: ng.IRequestConfig) => + 'Bearer token'; - const interceptor = ['$rootScope', '$q', ($rootScope: ng.IScope, $q: ng.IQService) => { - function success(response: ng.IHttpPromiseCallbackArg) { - return response; - } - - function error(response: ng.IHttpPromiseCallbackArg) { - if (response.status === 401) { - const deferred = $q.defer(); - authServiceProvider.pushToBuffer(response.config, deferred); - $rootScope.$broadcast('event:auth-loginRequired'); - return deferred.promise; + const interceptor = [ + '$rootScope', '$q', + ($rootScope: ng.IScope, $q: ng.IQService) => { + return { + request(config: ng.IRequestConfig) { + if (!config.params) config.params = {}; + config.params.rnd = Math.random(); + return config; + }, + responseError(rejection: any) { + if (rejection.status === 401) { + const deferred = $q.defer>(); + authServiceProvider.pushToBuffer(rejection.config, deferred); + $rootScope.$broadcast('event:auth-loginRequired'); + return deferred.promise; + } + return $q.reject(rejection); + } + }; } - // otherwise - return $q.reject(response); - } - - return (promise: ng.IHttpPromise) => promise.then(success, error); - }]; - $httpProvider.interceptors.push(interceptor); - }]); + ]; + $httpProvider.interceptors.push(interceptor); + } + ]); namespace HttpAndRegularPromiseTests { interface Person { @@ -105,7 +112,7 @@ namespace HttpAndRegularPromiseTests { function someController($scope: SomeControllerScope, $http: ng.IHttpService, $q: ng.IQService) { $http.get('http://somewhere/some/resource') - .then((response: ng.IHttpPromiseCallbackArg) => { + .then((response: ng.IHttpResponse) => { // typing lost, so something like // const i: number = response.data // would type check @@ -113,7 +120,7 @@ namespace HttpAndRegularPromiseTests { }); $http.get('http://somewhere/some/resource') - .then((response: ng.IHttpPromiseCallbackArg) => { + .then((response: ng.IHttpResponse) => { // typing lost, so something like // const i: number = response.data // would NOT type check @@ -339,12 +346,12 @@ namespace TestQ { result = $q.all<{a: number; b: string; }>({a: promiseAny, b: promiseAny}); } { - let result = $q.all({ num: $q.when(2), str: $q.when('test') }); + const result = $q.all({ num: $q.when(2), str: $q.when('test') }); // TS should infer that num is a number and str is a string result.then(r => (r.num * 2) + r.str.indexOf('s')); } { - let result = $q.all({ num: $q.when(2), str: 'test' }); + const result = $q.all({ num: $q.when(2), str: 'test' }); // TS should infer that num is a number and str is a string result.then(r => (r.num * 2) + r.str.indexOf('s')); } @@ -378,7 +385,7 @@ namespace TestQ { let result: angular.IPromise; result = $q.resolve(tResult); result = $q.resolve(promiseTResult); - let result2: angular.IPromise = $q.resolve(Math.random() > 0.5 ? tResult : promiseTOther); + const result2: angular.IPromise = $q.resolve(Math.random() > 0.5 ? tResult : promiseTOther); } // $q.when @@ -388,7 +395,6 @@ namespace TestQ { } { let result: angular.IPromise; - let other: angular.IPromise; let resultOther: angular.IPromise; result = $q.when(tResult); @@ -427,7 +433,7 @@ httpFoo.then((x) => { x.toFixed(); }); -httpFoo.then((response: ng.IHttpPromiseCallbackArg) => { +httpFoo.then((response: ng.IHttpResponse) => { const h = response.headers('test'); h.charAt(0); const hs = response.headers(); @@ -450,8 +456,8 @@ namespace TestDeferred { // deferred.resolve { let result: void; - result = deferred.resolve() as void; - result = deferred.resolve(tResult) as void; + result = deferred.resolve(); + result = deferred.resolve(tResult); } // deferred.reject @@ -488,7 +494,7 @@ namespace TestInjector { class Foobar { constructor($q) {} } - let result: Foobar = $injector.instantiate(Foobar); + const result: Foobar = $injector.instantiate(Foobar); } // $injector.invoke @@ -496,14 +502,14 @@ namespace TestInjector { function foobar(v: boolean): number { return 7; } - let result = $injector.invoke(foobar); + const result = $injector.invoke(foobar); if (!(typeof result === 'number')) { // This fails to compile if 'result' is not exactly a number. - let expectNever: never = result; + const expectNever: never = result; } - let anyFunction: Function = foobar; - let anyResult: string = $injector.invoke(anyFunction); + const anyFunction: Function = foobar; + const anyResult: string = $injector.invoke(anyFunction); } } @@ -566,7 +572,7 @@ namespace TestPromise { (reason) => anyOf3(reject, tresult, tresultPromise) )); - assertPromiseType>(promise.then((result) => tresultHttpPromise)); + assertPromiseType>(promise.then((result) => tresultHttpPromise)); assertPromiseType(promise.then((result) => result, (any) => tother)); assertPromiseType | angular.IPromise | TOther | angular.IPromise>(promise.then( @@ -581,8 +587,8 @@ namespace TestPromise { assertPromiseType(promise.then((result) => result, (any) => tother, (any) => any)); assertPromiseType(promise.then((result) => tresultPromise, (any) => totherPromise)); assertPromiseType(promise.then((result) => tresultPromise, (any) => totherPromise, (any) => any)); - assertPromiseType>(promise.then((result) => tresultHttpPromise, (any) => totherHttpPromise)); - assertPromiseType>(promise.then((result) => tresultHttpPromise, (any) => totherHttpPromise, (any) => any)); + assertPromiseType>(promise.then((result) => tresultHttpPromise, (any) => totherHttpPromise)); + assertPromiseType>(promise.then((result) => tresultHttpPromise, (any) => totherHttpPromise, (any) => any)); assertPromiseType(promise.then((result) => tother)); assertPromiseType(promise.then((result) => tother, (any) => any)); @@ -590,9 +596,9 @@ namespace TestPromise { assertPromiseType(promise.then((result) => totherPromise)); assertPromiseType(promise.then((result) => totherPromise, (any) => any)); assertPromiseType(promise.then((result) => totherPromise, (any) => any, (any) => any)); - assertPromiseType>(promise.then((result) => totherHttpPromise)); - assertPromiseType>(promise.then((result) => totherHttpPromise, (any) => any)); - assertPromiseType>(promise.then((result) => totherHttpPromise, (any) => any, (any) => any)); + assertPromiseType>(promise.then((result) => totherHttpPromise)); + assertPromiseType>(promise.then((result) => totherHttpPromise, (any) => any)); + assertPromiseType>(promise.then((result) => totherHttpPromise, (any) => any, (any) => any)); assertPromiseType(promise.then((result) => tresult, (any) => tother).then(ambiguous => isTResult(ambiguous) ? ambiguous.c : ambiguous.f)); @@ -603,10 +609,10 @@ namespace TestPromise { assertPromiseType>(promise.catch((err) => anyOf2(tresult, reject))); assertPromiseType(promise.catch((err) => anyOf3(tresult, tresultPromise, reject))); assertPromiseType(promise.catch((err) => tresultPromise)); - assertPromiseType>(promise.catch((err) => tresultHttpPromise)); + assertPromiseType>(promise.catch((err) => tresultHttpPromise)); assertPromiseType(promise.catch((err) => tother)); assertPromiseType(promise.catch((err) => totherPromise)); - assertPromiseType>(promise.catch((err) => totherHttpPromise)); + assertPromiseType>(promise.catch((err) => totherHttpPromise)); assertPromiseType(promise.catch((err) => tother).then(ambiguous => isTResult(ambiguous) ? ambiguous.c : ambiguous.f)); @@ -621,7 +627,7 @@ function test_angular_forEach() { const log: string[] = []; angular.forEach(values, (value, key, obj) => { obj[key] = value; - this.push(key + ': ' + value); + this.push(`${key}: ${value}`); }, log); // expect(log).toEqual(['name: misko', 'gender: male']); } @@ -1160,11 +1166,7 @@ function NgModelControllerTyping() { ngModel.$asyncValidators['uniqueUsername'] = (modelValue, viewValue) => { const value = modelValue || viewValue; return $http.get('/api/users/' + value). - then(function resolved() { - return $q.reject('exists'); - }, function rejected() { - return true; - }); + then(() => $q.reject('exists'), () => true); }; } diff --git a/types/angular/index.d.ts b/types/angular/index.d.ts index fcfcf183e2..8415c6e6b7 100644 --- a/types/angular/index.d.ts +++ b/types/angular/index.d.ts @@ -1,7 +1,7 @@ // Type definitions for Angular JS 1.6 // Project: http://angularjs.org -// Definitions by: Diego Vilar -// Georgii Dolzhykov +// Definitions by: Diego Vilar +// Georgii Dolzhykov // Caleb St-Denis // Leonard Thieu // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -9,6 +9,9 @@ /// +// NOTE: @types/angular technically doesn't require TypeScript 2.3, only TypeScript 2.1. +// It has a TypeScript 2.3 header so that merging tests with @types/jquery v3 will work. + declare var angular: angular.IAngularStatic; // Support for painless dependency injection @@ -974,7 +977,7 @@ declare namespace angular { // DocumentService // see http://docs.angularjs.org/api/ng.$document /////////////////////////////////////////////////////////////////////////// - interface IDocumentService extends JQuery { + interface IDocumentService extends JQLite { // Must return intersection type for index signature compatibility with JQuery [index: number]: HTMLElement & Document; } @@ -991,7 +994,7 @@ declare namespace angular { // RootElementService // see http://docs.angularjs.org/api/ng.$rootElement /////////////////////////////////////////////////////////////////////////// - interface IRootElementService extends JQuery {} + interface IRootElementService extends JQLite {} interface IQResolveReject { (): void; @@ -1035,6 +1038,12 @@ declare namespace angular { * Creates a Deferred object which represents a task which will finish in the future. */ defer(): IDeferred; + /** + * Returns a promise that resolves or rejects as soon as one of those promises resolves or rejects, with the value or reason from that promise. + * + * @param promises A list or hash of promises. + */ + race(promises: Array> | {[key: string]: IPromise}): IPromise; /** * Creates a promise that is resolved as rejected with the specified reason. This api should be used to forward rejection in a chain of promises. If you are dealing with the last promise in a promise chain, you don't need to worry about it. * @@ -1296,12 +1305,12 @@ declare namespace angular { interface ICloneAttachFunction { // Let's hint but not force cloneAttachFn's signature - (clonedElement?: JQuery, scope?: IScope): any; + (clonedElement?: JQLite, scope?: IScope): any; } // This corresponds to the "publicLinkFn" returned by $compile. interface ITemplateLinkingFunction { - (scope: IScope, cloneAttachFn?: ICloneAttachFunction, options?: ITemplateLinkingFunctionOptions): JQuery; + (scope: IScope, cloneAttachFn?: ICloneAttachFunction, options?: ITemplateLinkingFunctionOptions): JQLite; } interface ITemplateLinkingFunctionOptions { @@ -1319,9 +1328,9 @@ declare namespace angular { */ interface ITranscludeFunction { // If the scope is provided, then the cloneAttachFn must be as well. - (scope: IScope, cloneAttachFn: ICloneAttachFunction, futureParentElement?: JQuery, slotName?: string): JQuery; + (scope: IScope, cloneAttachFn: ICloneAttachFunction, futureParentElement?: JQuery, slotName?: string): JQLite; // If one argument is provided, then it's assumed to be the cloneAttachFn. - (cloneAttachFn?: ICloneAttachFunction, futureParentElement?: JQuery, slotName?: string): JQuery; + (cloneAttachFn?: ICloneAttachFunction, futureParentElement?: JQuery, slotName?: string): JQLite; /** * Returns true if the specified slot contains content (i.e. one or more DOM nodes) @@ -1514,23 +1523,27 @@ declare namespace angular { (data: T, status: number, headers: IHttpHeadersGetter, config: IRequestConfig): void; } - interface IHttpPromiseCallbackArg { - data?: T; - status?: number; - headers?: IHttpHeadersGetter; - config?: IRequestConfig; - statusText?: string; + interface IHttpResponse { + data: T; + status: number; + headers: IHttpHeadersGetter; + config: IRequestConfig; + statusText: string; + /** Added in AngularJS 1.6.6 */ + xhrStatus: 'complete' | 'error' | 'timeout' | 'abort'; } - interface IHttpPromise extends IPromise> { - } + /** @deprecated The old name of IHttpResponse. Kept for compatibility. */ + type IHttpPromiseCallbackArg = IHttpResponse; + + type IHttpPromise = IPromise>; // See the jsdoc for transformData() at https://github.com/angular/angular.js/blob/master/src/ng/http.js#L228 interface IHttpRequestTransformer { (data: any, headersGetter: IHttpHeadersGetter): any; } - // The definition of fields are the same as IHttpPromiseCallbackArg + // The definition of fields are the same as IHttpResponse interface IHttpResponseTransformer { (data: any, headersGetter: IHttpHeadersGetter, status: number): any; } @@ -1603,10 +1616,10 @@ declare namespace angular { } interface IHttpInterceptor { - request?(config: IRequestConfig): IRequestConfig|IPromise; - requestError?(rejection: any): any; - response?(response: IHttpPromiseCallbackArg): IPromise>|IHttpPromiseCallbackArg; - responseError?(rejection: any): any; + request?(config: IRequestConfig): IRequestConfig | IPromise; + requestError?(rejection: any): IRequestConfig | IPromise; + response?(response: IHttpResponse): IPromise> | IHttpResponse; + responseError?(rejection: any): IPromise> | IHttpResponse; } interface IHttpInterceptorFactory { @@ -1956,7 +1969,7 @@ declare namespace angular { interface IDirectiveLinkFn { ( scope: IScope, - instanceElement: JQuery, + instanceElement: JQLite, instanceAttributes: IAttributes, controller?: IController | IController[] | {[key: string]: IController}, transclude?: ITranscludeFunction @@ -1970,7 +1983,7 @@ declare namespace angular { interface IDirectiveCompileFn { ( - templateElement: JQuery, + templateElement: JQLite, templateAttributes: IAttributes, /** * @deprecated @@ -2002,9 +2015,9 @@ declare namespace angular { require?: string | string[] | {[controller: string]: string}; restrict?: string; scope?: boolean | {[boundProperty: string]: string}; - template?: string | ((tElement: JQuery, tAttrs: IAttributes) => string); + template?: string | ((tElement: JQLite, tAttrs: IAttributes) => string); templateNamespace?: string; - templateUrl?: string | ((tElement: JQuery, tAttrs: IAttributes) => string); + templateUrl?: string | ((tElement: JQLite, tAttrs: IAttributes) => string); terminal?: boolean; transclude?: boolean | 'element' | {[slot: string]: string}; } @@ -2017,7 +2030,7 @@ declare namespace angular { * See: http://docs.angularjs.org/api/angular.element */ interface IAugmentedJQueryStatic extends JQueryStatic {} - interface IAugmentedJQuery extends JQuery {} + interface IAugmentedJQuery extends JQLite {} /** * Same as IController. Keeping it for compatibility with older versions of these type definitions. diff --git a/types/angular/jqlite.d.ts b/types/angular/jqlite.d.ts index 150c50b5dd..858201fb18 100644 --- a/types/angular/jqlite.d.ts +++ b/types/angular/jqlite.d.ts @@ -25,6 +25,10 @@ // Definitions copied from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/0480c5ec87fab41aa23047a02b27f0ea71aaf975/types/jquery/v2/index.d.ts +interface JQLite extends JQuery { + [index: number]: HTMLElement; +} + interface JQuery { /** * Adds the specified class(es) to each of the set of matched elements. @@ -32,7 +36,7 @@ interface JQuery { * @param className One or more space-separated classes to be added to the class attribute of each matched element. * @see {@link https://api.jquery.com/addClass/#addClass-className} */ - addClass(className: string): JQuery; + addClass(className: string): this; /** * Insert content, specified by the parameter, after each element in the set of matched elements. @@ -41,14 +45,14 @@ interface JQuery { * @param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert after each element in the set of matched elements. * @see {@link https://api.jquery.com/after/#after-content-content} */ - after(content1: JQuery | any[] | Element | DocumentFragment | Text | string, ...content2: any[]): JQuery; + after(content1: JQuery | any[] | Element | DocumentFragment | Text | string, ...content2: any[]): this; /** * Insert content, specified by the parameter, after each element in the set of matched elements. * * @param func A function that returns an HTML string, DOM element(s), or jQuery object to insert after each element in the set of matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set. * @see {@link https://api.jquery.com/after/#after-function} */ - after(func: (index: number, html: string) => string | Element | JQuery): JQuery; + after(func: (index: number, html: string) => string | Element | JQuery): this; /** * Insert content, specified by the parameter, to the end of each element in the set of matched elements. @@ -57,14 +61,14 @@ interface JQuery { * @param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the end of each element in the set of matched elements. * @see {@link https://api.jquery.com/append/#append-content-content} */ - append(content1: JQuery | any[] | Element | DocumentFragment | Text | string, ...content2: any[]): JQuery; + append(content1: JQuery | any[] | Element | DocumentFragment | Text | string, ...content2: any[]): this; /** * Insert content, specified by the parameter, to the end of each element in the set of matched elements. * * @param func A function that returns an HTML string, DOM element(s), or jQuery object to insert at the end of each element in the set of matched elements. Receives the index position of the element in the set and the old HTML value of the element as arguments. Within the function, this refers to the current element in the set. * @see {@link https://api.jquery.com/append/#append-function} */ - append(func: (index: number, html: string) => string | Element | JQuery): JQuery; + append(func: (index: number, html: string) => string | Element | JQuery): this; /** * Get the value of an attribute for the first element in the set of matched elements. @@ -80,14 +84,14 @@ interface JQuery { * @param value A value to set for the attribute. If this is `null`, the attribute will be deleted. * @see {@link https://api.jquery.com/attr/#attr-attributeName-value} */ - attr(attributeName: string, value: string | number | null): JQuery; + attr(attributeName: string, value: string | number | null): this; /** * Set one or more attributes for the set of matched elements. * * @param attributes An object of attribute-value pairs to set. * @see {@link https://api.jquery.com/attr/#attr-attributes} */ - attr(attributes: Object): JQuery; + attr(attributes: Object): this; /** * Attach a handler to an event for the elements. @@ -96,7 +100,7 @@ interface JQuery { * @param handler A function to execute each time the event is triggered. * @see {@link https://api.jquery.com/bind/#bind-eventType-eventData-handler} */ - bind(eventType: string, handler: (eventObject: JQueryEventObject) => any): JQuery; + bind(eventType: string, handler: (eventObject: JQueryEventObject) => any): this; /** * Attach a handler to an event for the elements. * @@ -104,21 +108,21 @@ interface JQuery { * @param preventBubble Setting the third argument to false will attach a function that prevents the default action from occurring and stops the event from bubbling. The default is true. * @see {@link https://api.jquery.com/bind/#bind-eventType-eventData-preventBubble} */ - bind(eventType: string, preventBubble: boolean): JQuery; + bind(eventType: string, preventBubble: boolean): this; /** * Attach a handler to an event for the elements. * * @param events An object containing one or more DOM event types and functions to execute for them. * @see {@link https://api.jquery.com/bind/#bind-events} */ - bind(events: any): JQuery; + bind(events: any): this; /** * Get the children of each element in the set of matched elements, optionally filtered by a selector. * * @see {@link https://api.jquery.com/children/} */ - children(): JQuery; + children(): this; /** * Create a deep copy of the set of matched elements. @@ -127,13 +131,13 @@ interface JQuery { * @param deepWithDataAndEvents A Boolean indicating whether event handlers and data for all children of the cloned element should be copied. By default its value matches the first argument's value (which defaults to false). * @see {@link https://api.jquery.com/clone/} */ - clone(withDataAndEvents?: boolean, deepWithDataAndEvents?: boolean): JQuery; + clone(withDataAndEvents?: boolean, deepWithDataAndEvents?: boolean): this; /** * Get the children of each element in the set of matched elements, including text and comment nodes. * @see {@link https://api.jquery.com/contents/} */ - contents(): JQuery; + contents(): this; /** * Get the value of style properties for the first element in the set of matched elements. @@ -157,7 +161,7 @@ interface JQuery { * @param value A value to set for the property. * @see {@link https://api.jquery.com/css/#css-propertyName-value} */ - css(propertyName: string, value: string | number): JQuery; + css(propertyName: string, value: string | number): this; /** * Set one or more CSS properties for the set of matched elements. * @@ -165,14 +169,14 @@ interface JQuery { * @param value A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments. * @see {@link https://api.jquery.com/css/#css-propertyName-function} */ - css(propertyName: string, value: (index: number, value: string) => string | number): JQuery; + css(propertyName: string, value: (index: number, value: string) => string | number): this; /** * Set one or more CSS properties for the set of matched elements. * * @param properties An object of property-value pairs to set. * @see {@link https://api.jquery.com/css/#css-properties} */ - css(properties: JQLiteCssProperties): JQuery; + css(properties: JQLiteCssProperties): this; /** * Store arbitrary data associated with the matched elements. @@ -181,7 +185,7 @@ interface JQuery { * @param value The new data value; it can be any JavaScript type including Array or Object. * @see {@link https://api.jquery.com/data/#data-key-value} */ - data(key: string, value: any): JQuery; + data(key: string, value: any): this; /** * Return the value at the named data store for the first element in the jQuery collection, as set by data(name, value) or by an HTML5 data-* attribute. * @@ -195,7 +199,7 @@ interface JQuery { * @param obj An object of key-value pairs of data to update. * @see {@link https://api.jquery.com/data/#data-obj} */ - data(obj: { [key: string]: any; }): JQuery; + data(obj: { [key: string]: any; }): this; /** * Return the value at the named data store for the first element in the jQuery collection, as set by data(name, value) or by an HTML5 data-* attribute. * @see {@link https://api.jquery.com/data/#data} @@ -208,13 +212,13 @@ interface JQuery { * @param selector A selector expression that filters the set of matched elements to be removed. * @see {@link https://api.jquery.com/detach/} */ - detach(selector?: string): JQuery; + detach(selector?: string): this; /** * Remove all child nodes of the set of matched elements from the DOM. * @see {@link https://api.jquery.com/empty/} */ - empty(): JQuery; + empty(): this; /** * Reduce the set of matched elements to the one at the specified index. @@ -222,7 +226,7 @@ interface JQuery { * @param index An integer indicating the 0-based position of the element. OR An integer indicating the position of the element, counting backwards from the last element in the set. * @see {@link https://api.jquery.com/eq/} */ - eq(index: number): JQuery; + eq(index: number): this; /** * Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element. @@ -230,9 +234,9 @@ interface JQuery { * @param selector A string containing a selector expression to match elements against. * @see {@link https://api.jquery.com/find/#find-selector} */ - find(selector: string): JQuery; - find(element: any): JQuery; - find(obj: JQuery): JQuery; + find(selector: string): this; + find(element: any): this; + find(obj: JQuery): this; /** * Determine whether any of the matched elements are assigned the given class. @@ -253,21 +257,21 @@ interface JQuery { * @param htmlString A string of HTML to set as the content of each matched element. * @see {@link https://api.jquery.com/html/#html-htmlString} */ - html(htmlString: string): JQuery; + html(htmlString: string): this; /** * Set the HTML contents of each element in the set of matched elements. * * @param func A function returning the HTML content to set. Receives the index position of the element in the set and the old HTML value as arguments. jQuery empties the element before calling the function; use the oldhtml argument to reference the previous content. Within the function, this refers to the current element in the set. * @see {@link https://api.jquery.com/html/#html-function} */ - html(func: (index: number, oldhtml: string) => string): JQuery; + html(func: (index: number, oldhtml: string) => string): this; /** * Get the immediately following sibling of each element in the set of matched elements. If a selector is provided, it retrieves the next sibling only if it matches that selector. * * @see {@link https://api.jquery.com/next/} */ - next(): JQuery; + next(): this; /** * Attach an event handler function for one or more events to the selected elements. @@ -276,7 +280,7 @@ interface JQuery { * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. Rest parameter args is for optional parameters passed to jQuery.trigger(). Note that the actual parameters on the event handler function must be marked as optional (? syntax). * @see {@link https://api.jquery.com/on/#on-events-selector-data-handler} */ - on(events: string, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery; + on(events: string, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): this; /** * Attach an event handler function for one or more events to the selected elements. * @@ -285,7 +289,7 @@ interface JQuery { * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. * @see {@link https://api.jquery.com/on/#on-events-selector-data-handler} */ - on(events: string, data: any, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery; + on(events: string, data: any, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): this; /** * Attach an event handler function for one or more events to the selected elements. * @@ -294,7 +298,7 @@ interface JQuery { * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. * @see {@link https://api.jquery.com/on/#on-events-selector-data-handler} */ - on(events: string, selector: string, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): JQuery; + on(events: string, selector: string, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): this; /** * Attach an event handler function for one or more events to the selected elements. * @@ -304,7 +308,7 @@ interface JQuery { * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. * @see {@link https://api.jquery.com/on/#on-events-selector-data-handler} */ - on(events: string, selector: string, data: any, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): JQuery; + on(events: string, selector: string, data: any, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): this; /** * Attach an event handler function for one or more events to the selected elements. * @@ -313,7 +317,7 @@ interface JQuery { * @param data Data to be passed to the handler in event.data when an event occurs. * @see {@link https://api.jquery.com/on/#on-events-selector-data} */ - on(events: { [key: string]: (eventObject: JQueryEventObject, ...args: any[]) => any; }, selector?: string, data?: any): JQuery; + on(events: { [key: string]: (eventObject: JQueryEventObject, ...args: any[]) => any; }, selector?: string, data?: any): this; /** * Attach an event handler function for one or more events to the selected elements. * @@ -321,13 +325,13 @@ interface JQuery { * @param data Data to be passed to the handler in event.data when an event occurs. * @see {@link https://api.jquery.com/on/#on-events-selector-data} */ - on(events: { [key: string]: (eventObject: JQueryEventObject, ...args: any[]) => any; }, data?: any): JQuery; + on(events: { [key: string]: (eventObject: JQueryEventObject, ...args: any[]) => any; }, data?: any): this; /** * Remove an event handler. * @see {@link https://api.jquery.com/off/#off} */ - off(): JQuery; + off(): this; /** * Remove an event handler. * @@ -336,7 +340,7 @@ interface JQuery { * @param handler A handler function previously attached for the event(s), or the special value false. * @see {@link https://api.jquery.com/off/#off-events-selector-handler} */ - off(events: string, selector?: string, handler?: (eventObject: JQueryEventObject) => any): JQuery; + off(events: string, selector?: string, handler?: (eventObject: JQueryEventObject) => any): this; /** * Remove an event handler. * @@ -344,7 +348,7 @@ interface JQuery { * @param handler A handler function previously attached for the event(s), or the special value false. Takes handler with extra args that can be attached with on(). * @see {@link https://api.jquery.com/off/#off-events-selector-handler} */ - off(events: string, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery; + off(events: string, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): this; /** * Remove an event handler. * @@ -352,7 +356,7 @@ interface JQuery { * @param handler A handler function previously attached for the event(s), or the special value false. * @see {@link https://api.jquery.com/off/#off-events-selector-handler} */ - off(events: string, handler: (eventObject: JQueryEventObject) => any): JQuery; + off(events: string, handler: (eventObject: JQueryEventObject) => any): this; /** * Remove an event handler. * @@ -360,7 +364,7 @@ interface JQuery { * @param selector A selector which should match the one originally passed to .on() when attaching event handlers. * @see {@link https://api.jquery.com/off/#off-events-selector} */ - off(events: { [key: string]: any; }, selector?: string): JQuery; + off(events: { [key: string]: any; }, selector?: string): this; /** * Attach a handler to an event for the elements. The handler is executed at most once per element per event type. @@ -369,7 +373,7 @@ interface JQuery { * @param handler A function to execute at the time the event is triggered. * @see {@link https://api.jquery.com/one/#one-events-data-handler} */ - one(events: string, handler: (eventObject: JQueryEventObject) => any): JQuery; + one(events: string, handler: (eventObject: JQueryEventObject) => any): this; /** * Attach a handler to an event for the elements. The handler is executed at most once per element per event type. * @@ -378,7 +382,7 @@ interface JQuery { * @param handler A function to execute at the time the event is triggered. * @see {@link https://api.jquery.com/one/#one-events-data-handler} */ - one(events: string, data: Object, handler: (eventObject: JQueryEventObject) => any): JQuery; + one(events: string, data: Object, handler: (eventObject: JQueryEventObject) => any): this; /** * Attach a handler to an event for the elements. The handler is executed at most once per element per event type. * @@ -387,7 +391,7 @@ interface JQuery { * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. * @see {@link https://api.jquery.com/one/#one-events-selector-data-handler} */ - one(events: string, selector: string, handler: (eventObject: JQueryEventObject) => any): JQuery; + one(events: string, selector: string, handler: (eventObject: JQueryEventObject) => any): this; /** * Attach a handler to an event for the elements. The handler is executed at most once per element per event type. * @@ -397,7 +401,7 @@ interface JQuery { * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. * @see {@link https://api.jquery.com/one/#one-events-selector-data-handler} */ - one(events: string, selector: string, data: any, handler: (eventObject: JQueryEventObject) => any): JQuery; + one(events: string, selector: string, data: any, handler: (eventObject: JQueryEventObject) => any): this; /** * Attach a handler to an event for the elements. The handler is executed at most once per element per event type. * @@ -406,7 +410,7 @@ interface JQuery { * @param data Data to be passed to the handler in event.data when an event occurs. * @see {@link https://api.jquery.com/one/#one-events-selector-data} */ - one(events: { [key: string]: any; }, selector?: string, data?: any): JQuery; + one(events: { [key: string]: any; }, selector?: string, data?: any): this; /** * Attach a handler to an event for the elements. The handler is executed at most once per element per event type. * @@ -414,14 +418,14 @@ interface JQuery { * @param data Data to be passed to the handler in event.data when an event occurs. * @see {@link https://api.jquery.com/one/#one-events-selector-data} */ - one(events: { [key: string]: any; }, data?: any): JQuery; + one(events: { [key: string]: any; }, data?: any): this; /** * Get the parent of each element in the current set of matched elements, optionally filtered by a selector. * * @see {@link https://api.jquery.com/parent/} */ - parent(): JQuery; + parent(): this; /** * Insert content, specified by the parameter, to the beginning of each element in the set of matched elements. @@ -430,14 +434,14 @@ interface JQuery { * @param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the beginning of each element in the set of matched elements. * @see {@link https://api.jquery.com/prepend/#prepend-content-content} */ - prepend(content1: JQuery | any[] | Element | DocumentFragment | Text | string, ...content2: any[]): JQuery; + prepend(content1: JQuery | any[] | Element | DocumentFragment | Text | string, ...content2: any[]): this; /** * Insert content, specified by the parameter, to the beginning of each element in the set of matched elements. * * @param func A function that returns an HTML string, DOM element(s), or jQuery object to insert at the beginning of each element in the set of matched elements. Receives the index position of the element in the set and the old HTML value of the element as arguments. Within the function, this refers to the current element in the set. * @see {@link https://api.jquery.com/prepend/#prepend-function} */ - prepend(func: (index: number, html: string) => string | Element | JQuery): JQuery; + prepend(func: (index: number, html: string) => string | Element | JQuery): this; /** * Get the value of a property for the first element in the set of matched elements. @@ -453,14 +457,14 @@ interface JQuery { * @param value A value to set for the property. * @see {@link https://api.jquery.com/prop/#prop-propertyName-value} */ - prop(propertyName: string, value: string | number | boolean): JQuery; + prop(propertyName: string, value: string | number | boolean): this; /** * Set one or more properties for the set of matched elements. * * @param properties An object of property-value pairs to set. * @see {@link https://api.jquery.com/prop/#prop-properties} */ - prop(properties: Object): JQuery; + prop(properties: Object): this; /** * Set one or more properties for the set of matched elements. * @@ -468,7 +472,7 @@ interface JQuery { * @param func A function returning the value to set. Receives the index position of the element in the set and the old property value as arguments. Within the function, the keyword this refers to the current element. * @see {@link https://api.jquery.com/prop/#prop-propertyName-function} */ - prop(propertyName: string, func: (index: number, oldPropertyValue: any) => any): JQuery; + prop(propertyName: string, func: (index: number, oldPropertyValue: any) => any): this; /** * Specify a function to execute when the DOM is fully loaded. @@ -476,7 +480,7 @@ interface JQuery { * @param handler A function to execute after the DOM is ready. * @see {@link https://api.jquery.com/ready/} */ - ready(handler: (jQueryAlias?: JQueryStatic) => any): JQuery; + ready(handler: (jQueryAlias?: JQueryStatic) => any): this; /** * Remove the set of matched elements from the DOM. @@ -484,7 +488,7 @@ interface JQuery { * @param selector A selector expression that filters the set of matched elements to be removed. * @see {@link https://api.jquery.com/remove/} */ - remove(selector?: string): JQuery; + remove(selector?: string): this; /** * Remove an attribute from each element in the set of matched elements. @@ -492,7 +496,7 @@ interface JQuery { * @param attributeName An attribute to remove; as of version 1.7, it can be a space-separated list of attributes. * @see {@link https://api.jquery.com/removeAttr/} */ - removeAttr(attributeName: string): JQuery; + removeAttr(attributeName: string): this; /** * Remove a single class, multiple classes, or all classes from each element in the set of matched elements. @@ -500,7 +504,7 @@ interface JQuery { * @param className One or more space-separated classes to be removed from the class attribute of each matched element. * @see {@link https://api.jquery.com/removeClass/#removeClass-className} */ - removeClass(className?: string): JQuery; + removeClass(className?: string): this; /** * Remove a previously-stored piece of data. @@ -508,19 +512,19 @@ interface JQuery { * @param name A string naming the piece of data to delete or space-separated string naming the pieces of data to delete. * @see {@link https://api.jquery.com/removeData/#removeData-name} */ - removeData(name: string): JQuery; + removeData(name: string): this; /** * Remove a previously-stored piece of data. * * @param list An array of strings naming the pieces of data to delete. * @see {@link https://api.jquery.com/removeData/#removeData-list} */ - removeData(list: string[]): JQuery; + removeData(list: string[]): this; /** * Remove all previously-stored piece of data. * @see {@link https://api.jquery.com/removeData/} */ - removeData(): JQuery; + removeData(): this; /** * Replace each element in the set of matched elements with the provided new content and return the set of elements that was removed. @@ -528,14 +532,14 @@ interface JQuery { * @param newContent The content to insert. May be an HTML string, DOM element, array of DOM elements, or jQuery object. * @see {@link https://api.jquery.com/replaceWith/#replaceWith-newContent} */ - replaceWith(newContent: JQuery | any[] | Element | Text | string): JQuery; + replaceWith(newContent: JQuery | any[] | Element | Text | string): this; /** * Replace each element in the set of matched elements with the provided new content and return the set of elements that was removed. * * @param func A function that returns content with which to replace the set of matched elements. * @see {@link https://api.jquery.com/replaceWith/#replaceWith-function} */ - replaceWith(func: () => Element | JQuery): JQuery; + replaceWith(func: () => Element | JQuery): this; /** * Get the combined text contents of each element in the set of matched elements, including their descendants. @@ -548,14 +552,14 @@ interface JQuery { * @param text The text to set as the content of each matched element. When Number or Boolean is supplied, it will be converted to a String representation. * @see {@link https://api.jquery.com/text/#text-text} */ - text(text: string | number | boolean): JQuery; + text(text: string | number | boolean): this; /** * Set the content of each element in the set of matched elements to the specified text. * * @param func A function returning the text content to set. Receives the index position of the element in the set and the old text value as arguments. * @see {@link https://api.jquery.com/text/#text-function} */ - text(func: (index: number, text: string) => string): JQuery; + text(func: (index: number, text: string) => string): this; /** * Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the switch argument. @@ -564,14 +568,14 @@ interface JQuery { * @param swtch A Boolean (not just truthy/falsy) value to determine whether the class should be added or removed. * @see {@link https://api.jquery.com/toggleClass/#toggleClass-className} */ - toggleClass(className: string, swtch?: boolean): JQuery; + toggleClass(className: string, swtch?: boolean): this; /** * Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the switch argument. * * @param swtch A boolean value to determine whether the class should be added or removed. * @see {@link https://api.jquery.com/toggleClass/#toggleClass-state} */ - toggleClass(swtch?: boolean): JQuery; + toggleClass(swtch?: boolean): this; /** * Execute all handlers attached to an element for an event. @@ -597,7 +601,7 @@ interface JQuery { * @param handler The function that is to be no longer executed. * @see {@link https://api.jquery.com/unbind/#unbind-eventType-handler} */ - unbind(eventType?: string, handler?: (eventObject: JQueryEventObject) => any): JQuery; + unbind(eventType?: string, handler?: (eventObject: JQueryEventObject) => any): this; /** * Remove a previously-attached event handler from the elements. * @@ -605,14 +609,14 @@ interface JQuery { * @param fls Unbinds the corresponding 'return false' function that was bound using .bind( eventType, false ). * @see {@link https://api.jquery.com/unbind/#unbind-eventType-false} */ - unbind(eventType: string, fls: boolean): JQuery; + unbind(eventType: string, fls: boolean): this; /** * Remove a previously-attached event handler from the elements. * * @param evt A JavaScript event object as passed to an event handler. * @see {@link https://api.jquery.com/unbind/#unbind-event} */ - unbind(evt: any): JQuery; + unbind(evt: any): this; /** * Get the current value of the first element in the set of matched elements. @@ -625,14 +629,14 @@ interface JQuery { * @param value A string of text, an array of strings or number corresponding to the value of each matched element to set as selected/checked. * @see {@link https://api.jquery.com/val/#val-value} */ - val(value: string | string[] | number): JQuery; + val(value: string | string[] | number): this; /** * Set the value of each element in the set of matched elements. * * @param func A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments. * @see {@link https://api.jquery.com/val/#val-function} */ - val(func: (index: number, value: string) => string): JQuery; + val(func: (index: number, value: string) => string): this; /** * Wrap an HTML structure around each element in the set of matched elements. @@ -640,14 +644,14 @@ interface JQuery { * @param wrappingElement A selector, element, HTML string, or jQuery object specifying the structure to wrap around the matched elements. * @see {@link https://api.jquery.com/wrap/#wrap-wrappingElement} */ - wrap(wrappingElement: JQuery | Element | string): JQuery; + wrap(wrappingElement: JQuery | Element | string): this; /** * Wrap an HTML structure around each element in the set of matched elements. * * @param func A callback function returning the HTML content or jQuery object to wrap around the matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set. * @see {@link https://api.jquery.com/wrap/#wrap-function} */ - wrap(func: (index: number) => string | JQuery): JQuery; + wrap(func: (index: number) => string | JQuery): this; // Undocumented length: number; @@ -657,17 +661,30 @@ interface JQuery { controller(name?: string): any; injector(): ng.auto.IInjectorService; - /** It's declared generic for custom scope interfaces */ + /** + * Returns the `$scope` of the element. + * + * **IMPORTANT**: Requires `debugInfoEnabled` to be true. + * + * See https://docs.angularjs.org/guide/production#disabling-debug-data for more information. + */ scope(): T; + /** + * Returns the `$scope` of the element. + * + * **IMPORTANT**: Requires `debugInfoEnabled` to be true. + * + * See https://docs.angularjs.org/guide/production#disabling-debug-data for more information. + */ isolateScope(): T; - inheritedData(key: string, value: any): JQuery; - inheritedData(obj: { [key: string]: any; }): JQuery; + inheritedData(key: string, value: any): this; + inheritedData(obj: { [key: string]: any; }): this; inheritedData(key?: string): any; } interface JQueryStatic { - (element: string | Element | Document | JQuery | ArrayLike): JQuery; + (element: string | Element | Document | JQuery | ArrayLike): JQLite; } /** diff --git a/types/angular/test/jqlite-tests.ts b/types/angular/test/jqlite-tests.ts new file mode 100644 index 0000000000..11d46d6fe7 --- /dev/null +++ b/types/angular/test/jqlite-tests.ts @@ -0,0 +1,7 @@ +import * as angular from 'angular'; + +function JQLite() { + function indexSignature() { + angular.element('p')[0]; // $ExpectType HTMLElement + } +} diff --git a/types/angular/test/jquery3-merging-tests.ts b/types/angular/test/jquery3-merging-tests.ts index d539c8bbed..510519466b 100644 --- a/types/angular/test/jquery3-merging-tests.ts +++ b/types/angular/test/jquery3-merging-tests.ts @@ -2,6 +2,10 @@ import $ = require('jquery'); import * as angular from 'angular'; function JQuery() { + function indexSignature() { + $('p')[0]; // $ExpectType HTMLElement + } + function addClass() { // $ExpectType JQuery $('p').addClass('className'); diff --git a/types/angular/tsconfig.json b/types/angular/tsconfig.json index 33c9531cab..f102aff22f 100644 --- a/types/angular/tsconfig.json +++ b/types/angular/tsconfig.json @@ -3,6 +3,7 @@ "index.d.ts", "jqlite.d.ts", "angular-tests.ts", + "test/jqlite-tests.ts", "test/jquery3-merging-tests.ts" ], "compilerOptions": { diff --git a/types/angular/tslint.json b/types/angular/tslint.json index 50c4474b7c..77b236700e 100644 --- a/types/angular/tslint.json +++ b/types/angular/tslint.json @@ -14,6 +14,8 @@ "max-line-length": false, "no-empty-interface": false, "no-namespace": false, + "no-unnecessary-qualifier": false, + "no-void-expression": false, "unified-signatures": false, "void-return": false } diff --git a/types/angularfire/index.d.ts b/types/angularfire/index.d.ts index e27cbf5721..de1482b0e3 100644 --- a/types/angularfire/index.d.ts +++ b/types/angularfire/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for AngularFire 0.8.2 // Project: http://angularfire.com -// Definitions by: Dénes Harmath +// Definitions by: Dénes Harmath // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/angularlocalstorage/index.d.ts b/types/angularlocalstorage/index.d.ts index 67b84b925e..63a9731dd0 100644 --- a/types/angularlocalstorage/index.d.ts +++ b/types/angularlocalstorage/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for AngularLocalStorage 0.1.7 // Project: https://github.com/agrublev/angularLocalStorage -// Definitions by: Horiuchi_H +// Definitions by: Horiuchi_H // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/animejs/animejs-tests.ts b/types/animejs/animejs-tests.ts new file mode 100644 index 0000000000..697c79f738 --- /dev/null +++ b/types/animejs/animejs-tests.ts @@ -0,0 +1,71 @@ +import * as anime from 'animejs'; + +const test1 = anime({ + targets: 'div', + duration: 40, + color: "#FFFFFF" +}); + +const callback = (anim: any) => { + console.log(anim.completed); +}; + +const test2 = anime({ + targets: 'div', + translateX: (el: HTMLElement, i: number, index: number) => { + return 0; + }, + translateY: '40px', + color: [ + {value: '#FF0000', duration: 2000}, + {value: '#00FF00', duration: 2000}, + {value: '#0000FF', duration: 2000}, + ], + duration: () => { + return 1000000000000; + }, + update: callback, + complete: callback +}); + +const someNodes = document.querySelector('button'); + +const test3 = anime({ + targets: someNodes, + top: "-5000000em" +}); + +const tl = anime.timeline({ + loop: false, + direction: 'normal' +}); + +tl.add({ + targets: ".tiny-divvy-div", + scale: 10000000 +}); + +const path = anime.path('#motionPath path'); + +test1.play(); +test2.reverse(); +test3.pause(); +tl.seek(4000); + +tl.finished.then(() => { + console.log("I wonder if anyone will ever actually read this."); +}); + +const usesEnums = anime({ + targets: ".usingEnumsIsAReallyHandyThing", + direction: "reverse", + easing: "inoutexpo", + someProperty: "+=4000" +}); + +const bezier = anime.bezier(0, 0, 100, 100); +// anime.speed = 100000000; +(anime as any).speed = 4000; +anime.easings['hello'] = anime.bezier(0, 0, 1900, 3020); +const runningAnims = anime.running; +anime.remove(".tiny-divvy-div"); diff --git a/types/animejs/index.d.ts b/types/animejs/index.d.ts new file mode 100644 index 0000000000..a975f59513 --- /dev/null +++ b/types/animejs/index.d.ts @@ -0,0 +1,137 @@ +// Type definitions for animejs 2.0 +// Project: http://animejs.com +// Definitions by: Andrew Babin +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +type FunctionBasedParamter = (element: HTMLElement, index: number, length: number) => number; +type AnimeCallbackFunction = (anim: anime.AnimeInstance) => void; +// Allowing null is necessary because DOM queries may not return anything. +type AnimeTarget = string | object | HTMLElement | SVGElement | NodeList | null; + +declare namespace anime { + type EasingOptions = + | "linear" + | "easeInQuad" + | "easeInCubic" + | "easeInQuart" + | "easeInQuint" + | "easeInSine" + | "easeInExpo" + | "easeInCirc" + | "easeInBack" + | "easeInElastic" + | "easeOutQuad" + | "easeOutCubic" + | "easeOutQuart" + | "easeOutQuint" + | "easeOutSine" + | "easeOutExpo" + | "easeOutCirc" + | "easeOutBack" + | "easeOutElastic" + | "easeInOutQuad" + | "easeInOutCubic" + | "easeInOutQuart" + | "easeInOutQuint" + | "easeInOutSine" + | "easeInOutExpo" + | "easeInOutCirc" + | "easeInOutBack" + | "easeInOutElastic"; + type DirectionOptions = "reverse" | "alternate" | "normal"; + + interface AnimeInstanceParams { + loop?: number | boolean; + autoplay?: boolean; + direction?: DirectionOptions | string; + + begin?: AnimeCallbackFunction; + run?: AnimeCallbackFunction; + update?: AnimeCallbackFunction; + complete?: AnimeCallbackFunction; + } + + interface AnimeAnimParams { + targets: AnimeTarget | ReadonlyArray; + + duration?: number | FunctionBasedParamter; + delay?: number | FunctionBasedParamter; + elasticity?: number | FunctionBasedParamter; + round?: number | boolean | FunctionBasedParamter; + + easing?: EasingOptions | string | ReadonlyArray; + + begin?: AnimeCallbackFunction; + run?: AnimeCallbackFunction; + update?: AnimeCallbackFunction; + complete?: AnimeCallbackFunction; + [AnyAnimatedProperty: string]: any; + } + + interface AnimeParams extends AnimeInstanceParams, AnimeAnimParams { + // Just need this to merge both Params interfaces. + } + + interface AnimeInstance { + play(): void; + pause(): void; + restart(): void; + reverse(): void; + seek(time: number): void; + + began: boolean; + paused: boolean; + completed: boolean; + finished: Promise; + + begin: AnimeCallbackFunction; + run: AnimeCallbackFunction; + update: AnimeCallbackFunction; + complete: AnimeCallbackFunction; + + autoplay: boolean; + currentTime: number; + delay: number; + direction: string; + duration: number; + loop: number | boolean; + offset: number; + progress: number; + remaining: number; + reversed: boolean; + + animatables: ReadonlyArray; + animations: ReadonlyArray; + } + + interface AnimeTimelineAnimParams extends AnimeAnimParams { + offset: number | string | FunctionBasedParamter; + } + + interface AnimeTimelineInstance extends AnimeInstance { + add(params: AnimeAnimParams): AnimeTimelineInstance; + } + + // Helpers + const speed: number; + const running: AnimeInstance[]; + const easings: { [EasingFunction: string]: (t: number) => any }; + function remove(targets: AnimeTarget | ReadonlyArray): void; + function getValue(targets: AnimeTarget, prop: string): string | number; + function path(path: string | HTMLElement | SVGElement | null, percent?: number): (prop: string) => { + el: HTMLElement | SVGElement, + property: string, + totalLength: number + }; + function setDashoffset(el: HTMLElement | SVGElement | null): number; + function bezier(x1: number, y1: number, x2: number, y2: number): (t: number) => number; + // Timeline + function timeline(params?: AnimeInstanceParams | ReadonlyArray): AnimeTimelineInstance; + function random(min: number, max: number): number; +} + +declare function anime(params: anime.AnimeParams): anime.AnimeInstance; + +export = anime; +export as namespace anime; diff --git a/types/animejs/tsconfig.json b/types/animejs/tsconfig.json new file mode 100644 index 0000000000..506b75ade3 --- /dev/null +++ b/types/animejs/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "animejs-tests.ts" + ] +} diff --git a/types/animejs/tslint.json b/types/animejs/tslint.json new file mode 100644 index 0000000000..2750cc0197 --- /dev/null +++ b/types/animejs/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } \ No newline at end of file diff --git a/types/annyang/annyang-tests.ts b/types/annyang/annyang-tests.ts new file mode 100644 index 0000000000..b394d20856 --- /dev/null +++ b/types/annyang/annyang-tests.ts @@ -0,0 +1,71 @@ +import { Annyang, CommandOption } from 'annyang'; + +declare const annyang: Annyang; +declare const console: any; + +// Tests based on API documentation at https://github.com/TalAter/annyang/blob/master/docs/README.md + +function testStartListening() { + annyang.start({ autoRestart: false }); // $ExpectType void + annyang.start({ autoRestart: false, continuous: false }); // $ExpectType void +} + +function testAddComments() { + const helloFunction = (): string => { + return 'hello'; + }; + + const commands: CommandOption = {'hello :name': helloFunction, howdy: helloFunction}; + const commands2: CommandOption = {hi: helloFunction}; + + annyang.addCommands(commands); // $ExpectType void + annyang.addCommands(commands2); // $ExpectType void + annyang.removeCommands(); // $ExpectType void + annyang.addCommands(commands); // $ExpectType void + annyang.removeCommands('hello'); // $ExpectType void + annyang.removeCommands(['howdy', 'hi']); // $ExpectType void +} + +const notConnected = () => { console.error('network connection error'); }; + +function testAddCallback() { + annyang.addCallback('error', () => console.error('There was an error!')); // $ExpectType void + + // $ExpectType void + annyang.addCallback('resultMatch', (userSaid, commandText, phrases) => { + console.log(userSaid); + console.log(commandText); + console.log(phrases); + }); + + annyang.addCallback('errorNetwork', notConnected, annyang); // $ExpectType void +} + +function testRemoveCallback() { + const start = () => { console.log('start'); }; + const end = () => { console.log('end'); }; + + annyang.addCallback('start', start); // $ExpectType void + annyang.addCallback('end', end); // $ExpectType void + + annyang.removeCallback(); // $ExpectType void + + annyang.removeCallback('end'); // $ExpectType void + + annyang.removeCallback('start', start); // $ExpectType void + + annyang.removeCallback(undefined, start); // $ExpectType void +} + +function testTrigger() { + annyang.trigger('Time for some thrilling heroics'); + + // $ExpectType void + annyang.trigger( + ['Time for some thrilling heroics', 'Time for some thrilling aerobics'] + ); +} + +function testIsListening() { + annyang.isListening(); // $ExpectType boolean +} diff --git a/types/annyang/index.d.ts b/types/annyang/index.d.ts new file mode 100644 index 0000000000..fee0cb9acb --- /dev/null +++ b/types/annyang/index.d.ts @@ -0,0 +1,230 @@ +// Type definitions for annyang 2.6 +// Project: https://www.talater.com/annyang/ +// Definitions by: Hisham Al-Shurafa +// Lukas Klinzing +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * Options for function `start` + * + * @export + * @interface StartOptions + */ +export interface StartOptions { + /** + * Should annyang restart itself if it is closed indirectly, because of silence or window conflicts? + * + * @type {boolean} + */ + autoRestart?: boolean; + /** + * Allow forcing continuous mode on or off. Annyang is pretty smart about this, so only set this if you know what you're doing. + * + * @type {boolean} + */ + continuous?: boolean; +} + +/** + * A command option that supports custom regular expressions + * + * @export + * @interface CommandOptionRegex + */ +export interface CommandOptionRegex { + /** + * @type {RegExp} + */ + regexp: RegExp; + /** + * @type {() => any} + */ + callback(): void; +} + +/** + * Commands that annyang should listen to + * + * #### Examples: + * ````javascript + * {'hello :name': helloFunction, 'howdy': helloFunction}; + * {'hi': helloFunction}; + * ```` + * @export + * @interface CommandOption + */ +export interface CommandOption { + [command: string]: CommandOptionRegex | (() => void); +} + +/** + * Supported Events that will be triggered to listeners, you attach using `annyang.addCallback()` + * + * `start` - Fired as soon as the browser's Speech Recognition engine starts listening + * `error` - Fired when the browser's Speech Recogntion engine returns an error, this generic error callback will be followed by more accurate error callbacks (both will fire if both are defined) + * `errorNetwork` - Fired when Speech Recognition fails because of a network error + * `errorPermissionBlocked` - Fired when the browser blocks the permission request to use Speech Recognition. + * `errorPermissionDenied` - Fired when the user blocks the permission request to use Speech Recognition. + * `end` - Fired when the browser's Speech Recognition engine stops + * `result` - Fired as soon as some speech was identified. This generic callback will be followed by either the `resultMatch` or `resultNoMatch` callbacks. + * Callback functions registered to this event will include an array of possible phrases the user said as the first argument + * `resultMatch` - Fired when annyang was able to match between what the user said and a registered command + * Callback functions registered to this event will include three arguments in the following order: + * * The phrase the user said that matched a command + * * The command that was matched + * * An array of possible alternative phrases the user might've said + * `resultNoMatch` - Fired when what the user said didn't match any of the registered commands. + * Callback functions registered to this event will include an array of possible phrases the user might've said as the first argument + */ +export type Events = + 'start' | + 'soundstart' | + 'error' | + 'end' | + 'result' | + 'resultMatch' | + 'resultNoMatch' | + 'errorNetwork' | + 'errorPermissionBlocked' | + 'errorPermissionDenied'; + +export interface Annyang { + /** + * Start listening. + * It's a good idea to call this after adding some commands first, but not mandatory. + * + * @param {StartOptions} options + */ + start(options?: StartOptions): void; + + /** + * Stop listening, and turn off mic. + * + */ + abort(): void; + + /** + * Pause listening. annyang will stop responding to commands (until the resume or start methods are called), without turning off the browser's SpeechRecognition engine or the mic. + * + */ + pause(): void; + + /** + * Resumes listening and restores command callback execution when a result matches. + * If SpeechRecognition was aborted (stopped), start it. + * + */ + resume(): void; + + /** + * Turn on output of debug messages to the console. Ugly, but super-handy! + * + * @export + * @param {boolean} [newState=true] Turn on/off debug messages + */ + debug(newState?: boolean): void; + + /** + * Set the language the user will speak in. If this method is not called, defaults to 'en-US'. + * + * @param {string} lang + * @see [Languages](https://github.com/TalAter/annyang/blob/master/docs/FAQ.md#what-languages-are-supported) + */ + setLanguage(lang: string): void; + + /** + * Add commands that annyang will respond to. Similar in syntax to init(), but doesn't remove existing commands. + * + * #### Examples: + * ````javascript + * var commands = {'hello :name': helloFunction, 'howdy': helloFunction}; + * var commands2 = {'hi': helloFunction}; + * + * annyang.addCommands(commands); + * annyang.addCommands(commands2); + * // annyang will now listen to all three commands + * ```` + * + * @param {CommandOption} commands + */ + addCommands(commands: CommandOption): void; + + /** + * Removes all existing commands or a specific command + * #### Examples: + * ````javascript + * var commands : annyang.CommandOption = {'hello': helloFunction, 'howdy': helloFunction, 'hi': helloFunction}; + * + * // Don't respond to hello + * annyang.removeCommands('hello'); + * + * // Remove all existing commands + * annyang.removeCommands(); + * ```` + * @param {string} command + */ + removeCommands(command?: string): void; + + /** + * Removes a list of commands + * #### Examples: + * ````javascript + * var commands : annyang.CommandOption = {'hello': helloFunction, 'howdy': helloFunction, 'hi': helloFunction}; + * // Add some commands + * annyang.addCommands(commands); + * // Don't respond to howdy or hi + * annyang.removeCommands(['howdy', 'hi']); + * ```` + * + * @param {string[]} command + */ + removeCommands(command: string[]): void; + + /** + * @param {Events} event + * @param {(userSaid : string, commandText : string, results : string[]) => void} callback + * @param {*} [context] + */ + addCallback(event: Events, callback: (userSaid?: string, commandText?: string, results?: string[]) => void, context?: any): void; + + /** + * @param {Events} [event] + * @param {Function} [callback] + */ + removeCallback(event?: Events, callback?: (userSaid: string, commandText: string, results: string[]) => void): void; + + /** + * Returns true if speech recognition is currently on. + * Returns false if speech recognition is off or annyang is paused. + * + * @returns {boolean} + */ + isListening(): boolean; + + /** + * Returns the instance of the browser's SpeechRecognition object used by annyang. + * Useful in case you want direct access to the browser's Speech Recognition engine. + * + * @returns {*} + */ + getSpeechRecognizer(): any; + + /** + * Simulate speech being recognized. This will trigger the same events and behavior as when the Speech Recognition + * detects speech. + * + * Can accept either a string containing a single sentence, or an array containing multiple sentences to be checked + * in order until one of them matches a command (similar to the way Speech Recognition Alternatives are parsed) + * + * #### Examples: + * ````javascript + * annyang.trigger('Time for some thrilling heroics'); + * annyang.trigger( + * ['Time for some thrilling heroics', 'Time for some thrilling aerobics'] + * ); + * ```` + * + * @param {string} command + */ + trigger(command: string | string[]): void; +} diff --git a/types/annyang/tsconfig.json b/types/annyang/tsconfig.json new file mode 100644 index 0000000000..f54c7cd18c --- /dev/null +++ b/types/annyang/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "annyang-tests.ts" + ] +} diff --git a/types/annyang/tslint.json b/types/annyang/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/annyang/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/anydb-sql-migrations/index.d.ts b/types/anydb-sql-migrations/index.d.ts index ae922c37ae..f6e12ed752 100644 --- a/types/anydb-sql-migrations/index.d.ts +++ b/types/anydb-sql-migrations/index.d.ts @@ -20,7 +20,7 @@ export interface MigrationTask { down: MigFn; name: string; } -export declare function create(db: AnydbSql, tasks: any): { +export declare function create(db: AnydbSql, tasks: string | MigrationTask[]): { run: () => Promise; migrateTo: (target?: string) => Promise; check: (f: (m: { diff --git a/types/anydb-sql-migrations/package.json b/types/anydb-sql-migrations/package.json index 5557c21ec8..7ce063c332 100644 --- a/types/anydb-sql-migrations/package.json +++ b/types/anydb-sql-migrations/package.json @@ -1,5 +1,6 @@ { - "dependencies": { - "anydb-sql": "^0.6.53" - } -} + "private": true, + "dependencies": { + "anydb-sql": "^0.6.53" + } +} \ No newline at end of file diff --git a/types/anymatch/anymatch-tests.ts b/types/anymatch/anymatch-tests.ts new file mode 100644 index 0000000000..3333903760 --- /dev/null +++ b/types/anymatch/anymatch-tests.ts @@ -0,0 +1,43 @@ +import anymatch = require('anymatch'); + +const matchers = [ + 'path/to/file.js', + 'path/anyjs/**/*.js', + /foo\.js$/, + (str: string) => str.indexOf('bar') !== -1 && str.length > 10 +]; + +// $ExpectType boolean +anymatch(matchers, 'path/to/file.js'); +// $ExpectType boolean +anymatch(matchers, 'path/to/file.js', false); +// $ExpectType boolean +anymatch(matchers, 'path/to/file.js', false, 1); +// $ExpectType boolean +anymatch(matchers, 'path/to/file.js', false, 1, 2); + +// $ExpectType number +anymatch(matchers, 'foo.js', true); +// $ExpectType number +anymatch(matchers, 'path/anyjs/foo.js', true, 2); +// $ExpectType number +anymatch(matchers, 'path/anyjs/foo.js', true, 2, 3); + +const matcher = anymatch(matchers); +// $ExpectType boolean +matcher('path/to/file.js'); +// $ExpectType boolean +matcher('path/to/file.js', false); +// $ExpectType boolean +matcher('path/to/file.js', false, 1); +// $ExpectType boolean +matcher('path/to/file.js', false, 1, 2); +// $ExpectType number +matcher('path/anyjs/baz.js', true); +// $ExpectType number +matcher('path/anyjs/baz.js', true, 2); +// $ExpectType number +matcher('path/anyjs/baz.js', true, 2, 3); + +// tslint:disable-next-line no-unnecessary-callback-wrapper +['foo.js', 'bar.js'].filter(str => matcher(str)); diff --git a/types/anymatch/index.d.ts b/types/anymatch/index.d.ts new file mode 100644 index 0000000000..4eb90734a4 --- /dev/null +++ b/types/anymatch/index.d.ts @@ -0,0 +1,20 @@ +// Type definitions for anymatch 1.3 +// Project: https://github.com/es128/anymatch +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = anymatch; + +declare function anymatch(matcher: anymatch.Matcher): CurrriedMatcher; +declare function anymatch(matcher: anymatch.Matcher, testString: string | string[], returnIndex: true, startIndex?: number, endIndex?: number): number; +declare function anymatch(matcher: anymatch.Matcher, testString: string | string[], returnIndex?: boolean, startIndex?: number, endIndex?: number): boolean; + +declare namespace anymatch { + type Matcher = MatcherType | MatcherType[]; + type MatcherType = string | RegExp | ((...testStrings: string[]) => boolean); +} + +interface CurrriedMatcher { + (testString: string | string[], returnIndex: true, startIndex?: number, endIndex?: number): number; + (testString: string | string[], returnIndex?: boolean, startIndex?: number, endIndex?: number): boolean; +} diff --git a/types/anymatch/tsconfig.json b/types/anymatch/tsconfig.json new file mode 100644 index 0000000000..e4fad1c219 --- /dev/null +++ b/types/anymatch/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "anymatch-tests.ts" + ] +} diff --git a/types/anymatch/tslint.json b/types/anymatch/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/anymatch/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/applepayjs/applepayjs-tests.ts b/types/applepayjs/applepayjs-tests.ts index 5adf61e45c..505dbd2daf 100644 --- a/types/applepayjs/applepayjs-tests.ts +++ b/types/applepayjs/applepayjs-tests.ts @@ -6,7 +6,7 @@ declare function it(desc: string, fn: () => void): void; describe("ApplePaySession", () => { it("the constants are defined", () => { - let status = 0; + const status = 0; switch (status) { case ApplePaySession.STATUS_FAILURE: case ApplePaySession.STATUS_INVALID_BILLING_POSTAL_ADDRESS: @@ -43,8 +43,8 @@ describe("ApplePaySession", () => { it("can call static methods", () => { const merchantIdentifier = "MyMerchantId"; - let canMakePayments: boolean = ApplePaySession.canMakePayments(); - let supported: boolean = ApplePaySession.supportsVersion(2); + const canMakePayments: boolean = ApplePaySession.canMakePayments(); + const supported: boolean = ApplePaySession.supportsVersion(2); ApplePaySession.canMakePaymentsWithActiveCard(merchantIdentifier) .then((status: boolean) => { @@ -168,7 +168,7 @@ describe("ApplePaySession", () => { }); describe("ApplePayPaymentRequest", () => { it("can create a new instance", () => { - let paymentRequest: ApplePayJS.ApplePayPaymentRequest = { + const paymentRequest: ApplePayJS.ApplePayPaymentRequest = { applicationData: "ApplicationData", countryCode: "GB", currencyCode: "GBP", @@ -181,8 +181,8 @@ describe("ApplePayPaymentRequest", () => { "amex", "discover", "jcb", - "master​Card", - "private​Label", + "masterCard", + "privateLabel", "visa" ], total: { diff --git a/types/applepayjs/index.d.ts b/types/applepayjs/index.d.ts index 34d3c41a99..f705a4fad2 100644 --- a/types/applepayjs/index.d.ts +++ b/types/applepayjs/index.d.ts @@ -10,7 +10,7 @@ declare class ApplePaySession extends EventTarget { /** * Creates a new instance of the ApplePaySession class. * @param version - The version of the ApplePay JS API you are using. - * @param paymentRequest - An Apple​Pay​Payment​Request object that contains the information that is displayed on the Apple Pay payment sheet. + * @param paymentRequest - An ApplePayPaymentRequest object that contains the information that is displayed on the Apple Pay payment sheet. */ constructor(version: number, paymentRequest: ApplePayJS.ApplePayPaymentRequest); @@ -95,8 +95,8 @@ declare class ApplePaySession extends EventTarget { /** * Call after a payment method has been selected. - * @param newTotal - An Apple​Pay​Line​Item dictionary representing the total price for the purchase. - * @param newLineItems - A sequence of Apple​Pay​Line​Item dictionaries. + * @param newTotal - An ApplePayLineItem dictionary representing the total price for the purchase. + * @param newLineItems - A sequence of ApplePayLineItem dictionaries. */ completePaymentMethodSelection(newTotal: ApplePayJS.ApplePayLineItem, newLineItems: ApplePayJS.ApplePayLineItem[]): void; @@ -104,8 +104,8 @@ declare class ApplePaySession extends EventTarget { * Call after a shipping contact has been selected. * @param status - The status of the shipping contact update. * @param newShippingMethods - A sequence of ApplePayShippingMethod dictionaries. - * @param newTotal - An Apple​Pay​Line​Item dictionary representing the total price for the purchase. - * @param newLineItems - A sequence of Apple​Pay​Line​Item dictionaries. + * @param newTotal - An ApplePayLineItem dictionary representing the total price for the purchase. + * @param newLineItems - A sequence of ApplePayLineItem dictionaries. */ completeShippingContactSelection( status: number, @@ -116,8 +116,8 @@ declare class ApplePaySession extends EventTarget { /** * Call after the shipping method has been selected. * @param status - The status of the shipping method update. - * @param newTotal - An Apple​Pay​Line​Item dictionary representing the total price for the purchase. - * @param newLineItems - A sequence of Apple​Pay​Line​Item dictionaries. + * @param newTotal - An ApplePayLineItem dictionary representing the total price for the purchase. + * @param newLineItems - A sequence of ApplePayLineItem dictionaries. */ completeShippingMethodSelection(status: number, newTotal: ApplePayJS.ApplePayLineItem, newLineItems: ApplePayJS.ApplePayLineItem[]): void; @@ -204,7 +204,7 @@ declare namespace ApplePayJS { } /** - * The Apple​Pay​Payment​Authorized​Event class defines the attributes contained by the ApplePaySession.onpaymentauthorized callback function. + * The ApplePayPaymentAuthorizedEvent class defines the attributes contained by the ApplePaySession.onpaymentauthorized callback function. */ abstract class ApplePayPaymentAuthorizedEvent extends Event { /** @@ -279,7 +279,7 @@ declare namespace ApplePayJS { /** * A string, suitable for display, that is the name of the payment network backing the card. - * The value is one of the supported networks specified in the supported​Networks property of the Apple​Pay​Payment​Request. + * The value is one of the supported networks specified in the supportedNetworks property of the ApplePayPaymentRequest. */ network: string; @@ -295,7 +295,7 @@ declare namespace ApplePayJS { } /** - * The Apple​Pay​Payment​Method​Selected​Event class defines the attributes contained by the ApplePaySession.onpaymentmethodselected callback function. + * The ApplePayPaymentMethodSelectedEvent class defines the attributes contained by the ApplePaySession.onpaymentmethodselected callback function. */ abstract class ApplePayPaymentMethodSelectedEvent extends Event { /** @@ -426,7 +426,7 @@ declare namespace ApplePayJS { } /** - * The Apple​Pay​Shipping​Contact​Selected​Event class defines the attributes contained by the ApplePaySession.onshippingcontactselected callback function. + * The ApplePayShippingContactSelectedEvent class defines the attributes contained by the ApplePaySession.onshippingcontactselected callback function. */ abstract class ApplePayShippingContactSelectedEvent extends Event { /** @@ -461,7 +461,7 @@ declare namespace ApplePayJS { } /** - * The Apple​Pay​Shipping​Method​Selected​Event class defines the attribute contained by the ApplePaySession.onshippingmethodselected callback function. + * The ApplePayShippingMethodSelectedEvent class defines the attribute contained by the ApplePaySession.onshippingmethodselected callback function. */ abstract class ApplePayShippingMethodSelectedEvent extends Event { /** @@ -471,7 +471,7 @@ declare namespace ApplePayJS { } /** - * The Apple​Pay​Validate​Merchant​Event class defines the attributes contained by the ApplePaySession.onvalidatemerchant callback function. + * The ApplePayValidateMerchantEvent class defines the attributes contained by the ApplePaySession.onvalidatemerchant callback function. */ abstract class ApplePayValidateMerchantEvent extends Event { /** diff --git a/types/applepayjs/tslint.json b/types/applepayjs/tslint.json index 3db14f85ea..65c83fb1e3 100644 --- a/types/applepayjs/tslint.json +++ b/types/applepayjs/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "dt-header": false + } +} diff --git a/types/applicationinsights-js/applicationinsights-js-tests.ts b/types/applicationinsights-js/applicationinsights-js-tests.ts index ecefb6d41a..49c68181f8 100644 --- a/types/applicationinsights-js/applicationinsights-js-tests.ts +++ b/types/applicationinsights-js/applicationinsights-js-tests.ts @@ -123,7 +123,7 @@ context.addTelemetryInitializer(envelope => { }); // a sample from: https://github.com/Microsoft/ApplicationInsights-JS/blob/master/API-reference.md#example context.addTelemetryInitializer(envelope => { - let telemetryItem = envelope.data.baseData; + const telemetryItem = envelope.data.baseData; if (envelope.name === Microsoft.ApplicationInsights.Telemetry.PageView.envelopeType) { telemetryItem.url = "URL CENSORED"; } diff --git a/types/applicationinsights-js/tslint.json b/types/applicationinsights-js/tslint.json index 0cc2f62b56..4b24c7ab0a 100644 --- a/types/applicationinsights-js/tslint.json +++ b/types/applicationinsights-js/tslint.json @@ -1,8 +1,11 @@ { "extends": "dtslint/dt.json", "rules": { - "interface-name": [ false ], + // All are TODOs + "interface-name": false, "no-internal-module": false, - "no-single-declare-module": false + "no-mergeable-namespace": false, + "no-single-declare-module": false, + "no-unnecessary-qualifier": false } } diff --git a/types/applicationinsights/index.d.ts b/types/applicationinsights/index.d.ts index 45c89556a6..471089a96f 100644 --- a/types/applicationinsights/index.d.ts +++ b/types/applicationinsights/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Application Insights v0.15.12 // Project: https://github.com/Microsoft/ApplicationInsights-node.js -// Definitions by: Scott Southwood +// Definitions by: Scott Southwood // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped interface AutoCollectConsole { @@ -341,9 +341,9 @@ interface Client { trackMetric(name: string, value: number, count?:number, min?: number, max?: number, stdDev?: number, properties?: { [key: string]: string; }): void; - + /** - * Log an incoming http request to your server. The request data will be tracked during the response "finish" event if it is successful or the request "error" + * Log an incoming http request to your server. The request data will be tracked during the response "finish" event if it is successful or the request "error" * event if it fails. The request duration is automatically calculated as the timespan between when the trackRequest method was called, and when the response "finish" * or request "error" events were fired. * @param request The http.IncomingMessage object to track @@ -353,7 +353,7 @@ interface Client { trackRequest(request: any /* http.IncomingMessage */, response: any /* http.ServerResponse */, properties?: { [key: string]: string; }): void; - + /** * Log an incoming http request to your server. The request data is tracked synchronously rather than waiting for the response "finish"" or request "error"" events. * Use this if you need your request telemetry to respect custom app insights operation and user context (for example if you set any appInsights.client.context.tags). @@ -365,7 +365,7 @@ interface Client { */ trackRequestSync(request: any /*http.IncomingMessage */, response: any /*http.ServerResponse */, ellapsedMilliseconds?: number, properties?: { [key: string]: string;}, error?: any) : void; - + /** * Log information about a dependency of your app. Typically used to track the time database calls or outgoing http requests take from your server. * @param name The name of the dependency (i.e. "myDatabse") diff --git a/types/arcgis-to-geojson-utils/tslint.json b/types/arcgis-to-geojson-utils/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/arcgis-to-geojson-utils/tslint.json +++ b/types/arcgis-to-geojson-utils/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/archiver/tslint.json b/types/archiver/tslint.json index a62d0d4e68..10e16aef18 100644 --- a/types/archiver/tslint.json +++ b/types/archiver/tslint.json @@ -1,6 +1,8 @@ { "extends": "dtslint/dt.json", "rules": { - "ban-types": false + // TODOs + "ban-types": false, + "dt-header": false } } diff --git a/types/archy/index.d.ts b/types/archy/index.d.ts index 82b101236c..6dedf21db2 100644 --- a/types/archy/index.d.ts +++ b/types/archy/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for archy // Project: https://github.com/substack/node-archy -// Definitions by: vvakame +// Definitions by: vvakame // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/are-we-there-yet/are-we-there-yet-tests.ts b/types/are-we-there-yet/are-we-there-yet-tests.ts index 1750cac0c2..463ca428c4 100644 --- a/types/are-we-there-yet/are-we-there-yet-tests.ts +++ b/types/are-we-there-yet/are-we-there-yet-tests.ts @@ -1,6 +1,6 @@ import { Tracker, TrackerStream, TrackerGroup } from "are-we-there-yet"; -let simple = new Tracker("simple"); +const simple = new Tracker("simple"); simple.addListener("change", (name, completed, tracker) => { console.log(`name: ${name}, completed: ${completed}`); }); @@ -8,13 +8,13 @@ simple.addWork(10); simple.completeWork(1); console.log(simple.completed() < 1); -let group = new TrackerGroup("group"); +const group = new TrackerGroup("group"); group.addUnit(simple); -let subgroup = group.newGroup("subgroup"); +const subgroup = group.newGroup("subgroup"); console.log(group.completed()); -let stream = new TrackerStream("stream", 100, { encoding: "utf8" }); +const stream = new TrackerStream("stream", 100, { encoding: "utf8" }); subgroup.addUnit(stream); stream.addListener("change", (name, completed, tracker) => { diff --git a/types/argparse/argparse-tests.ts b/types/argparse/argparse-tests.ts index f5b9e76f81..aef18b665b 100644 --- a/types/argparse/argparse-tests.ts +++ b/types/argparse/argparse-tests.ts @@ -1,25 +1,24 @@ - // near copy of each of the tests from https://github.com/nodeca/argparse/tree/master/examples import { ArgumentParser, RawDescriptionHelpFormatter } from 'argparse'; -var args: any; +let args: any; -var simpleExample = new ArgumentParser({ - version: '0.0.1', - addHelp: true, - description: 'Argparse example', +const simpleExample = new ArgumentParser({ + version: '0.0.1', + addHelp: true, + description: 'Argparse example', }); simpleExample.addArgument( - ['-f', '--foo'], - { - help: 'foo bar', - } + ['-f', '--foo'], + { + help: 'foo bar', + } ); simpleExample.addArgument( - ['-b', '--bar'], - { - help: 'bar foo', - } + ['-b', '--bar'], + { + help: 'bar foo', + } ); simpleExample.printHelp(); @@ -35,13 +34,10 @@ args = simpleExample.parseArgs('--foo 5 --bar 6'.split(' ')); console.dir(args); console.log('-----------'); - - - -var choicesExample = new ArgumentParser({ - version: '0.0.1', - addHelp: true, - description: 'Argparse examples: choice' +const choicesExample = new ArgumentParser({ + version: '0.0.1', + addHelp: true, + description: 'Argparse examples: choice' }); choicesExample.addArgument(['foo'], { choices: 'abc' }); @@ -55,56 +51,53 @@ console.log('-----------'); // choicesExample.parseArgs(['X']); // console.dir(args); - - - -var constantExample = new ArgumentParser({ - version: '0.0.1', - addHelp: true, - description: 'Argparse examples: constant' +const constantExample = new ArgumentParser({ + version: '0.0.1', + addHelp: true, + description: 'Argparse examples: constant' }); constantExample.addArgument( - ['-a'], - { - action: 'storeConst', - dest: 'answer', - help: 'store constant', - constant: 42 - } + ['-a'], + { + action: 'storeConst', + dest: 'answer', + help: 'store constant', + constant: 42 + } ); constantExample.addArgument( - ['--str'], - { - action: 'appendConst', - dest: 'types', - help: 'append constant "str" to types', - constant: 'str' - } + ['--str'], + { + action: 'appendConst', + dest: 'types', + help: 'append constant "str" to types', + constant: 'str' + } ); constantExample.addArgument( - ['--int'], - { - action: 'appendConst', - dest: 'types', - help: 'append constant "int" to types', - constant: 'int' - } + ['--int'], + { + action: 'appendConst', + dest: 'types', + help: 'append constant "int" to types', + constant: 'int' + } ); constantExample.addArgument( - ['--true'], - { - action: 'storeTrue', - help: 'store true constant' - } + ['--true'], + { + action: 'storeTrue', + help: 'store true constant' + } ); constantExample.addArgument( - ['--false'], - { - action: 'storeFalse', - help: 'store false constant' - } + ['--false'], + { + action: 'storeFalse', + help: 'store false constant' + } ); constantExample.printHelp(); @@ -113,27 +106,24 @@ console.log('-----------'); args = constantExample.parseArgs('-a --str --int --true'.split(' ')); console.dir(args); - - - -var nargsExample = new ArgumentParser({ - version: '0.0.1', - addHelp: true, - description: 'Argparse examples: nargs' +const nargsExample = new ArgumentParser({ + version: '0.0.1', + addHelp: true, + description: 'Argparse examples: nargs' }); nargsExample.addArgument( - ['-f', '--foo'], - { - help: 'foo bar', - nargs: 1 - } + ['-f', '--foo'], + { + help: 'foo bar', + nargs: 1 + } ); nargsExample.addArgument( - ['-b', '--bar'], - { - help: 'bar foo', - nargs: '*' - } + ['-b', '--bar'], + { + help: 'bar foo', + nargs: '*' + } ); nargsExample.printHelp(); @@ -145,40 +135,34 @@ console.log('-----------'); args = nargsExample.parseArgs('--bar b c f --foo a'.split(' ')); console.dir(args); - - - -var parent_parser = new ArgumentParser({ addHelp: false }); +const parent_parser = new ArgumentParser({ addHelp: false }); // note addHelp:false to prevent duplication of the -h option parent_parser.addArgument( - ['--parent'], - { type: 'int', help: 'parent' } + ['--parent'], + { type: 'int', help: 'parent' } ); -var foo_parser = new ArgumentParser({ - parents: [parent_parser], - description: 'child1' +const foo_parser = new ArgumentParser({ + parents: [parent_parser], + description: 'child1' }); foo_parser.addArgument(['foo']); args = foo_parser.parseArgs(['--parent', '2', 'XXX']); console.log(args); -var bar_parser = new ArgumentParser({ - parents: [parent_parser], - description: 'child2' +const bar_parser = new ArgumentParser({ + parents: [parent_parser], + description: 'child2' }); bar_parser.addArgument(['--bar']); args = bar_parser.parseArgs(['--bar', 'YYY']); console.log(args); - - - -var prefixCharsExample = new ArgumentParser({ - version: '0.0.1', - addHelp: true, - description: 'Argparse examples: prefix_chars', - prefixChars: '-+' +const prefixCharsExample = new ArgumentParser({ + version: '0.0.1', + addHelp: true, + description: 'Argparse examples: prefix_chars', + prefixChars: '-+' }); prefixCharsExample.addArgument(['+f', '++foo']); prefixCharsExample.addArgument(['++bar'], { action: 'storeTrue' }); @@ -193,39 +177,36 @@ console.dir(args); args = prefixCharsExample.parseArgs(['++foo', '2', '++bar']); console.dir(args); - - - -var subparserExample = new ArgumentParser({ - version: '0.0.1', - addHelp: true, - description: 'Argparse examples: sub-commands' +const subparserExample = new ArgumentParser({ + version: '0.0.1', + addHelp: true, + description: 'Argparse examples: sub-commands' }); -var subparsers = subparserExample.addSubparsers({ - title: 'subcommands', - dest: "subcommand_name" +const subparsers = subparserExample.addSubparsers({ + title: 'subcommands', + dest: "subcommand_name" }); -var bar = subparsers.addParser('c1', { addHelp: true, help: 'c1 help' }); +let bar = subparsers.addParser('c1', { addHelp: true, help: 'c1 help' }); bar.addArgument( - ['-f', '--foo'], - { - action: 'store', - help: 'foo3 bar3' - } + ['-f', '--foo'], + { + action: 'store', + help: 'foo3 bar3' + } ); -var bar = subparsers.addParser( - 'c2', - { aliases: ['co'], addHelp: true, help: 'c2 help' } +bar = subparsers.addParser( + 'c2', + { aliases: ['co'], addHelp: true, help: 'c2 help' } ); bar.addArgument( - ['-b', '--bar'], - { - action: 'store', - type: 'int', - help: 'foo3 bar3' - } + ['-b', '--bar'], + { + action: 'store', + type: 'int', + help: 'foo3 bar3' + } ); subparserExample.printHelp(); console.log('-----------'); @@ -241,66 +222,51 @@ console.dir(args); console.log('-----------'); subparserExample.parseArgs(['c1', '-h']); - - - -var functionExample = new ArgumentParser({ description: 'Process some integers.' }); +const functionExample = new ArgumentParser({ description: 'Process some integers.' }); function sum(arr: number[]) { - return arr.reduce(function(a, b) { - return a + b; - }, 0); + return arr.reduce((a, b) => a + b, 0); } function max(arr: number[]) { - return Math.max.apply(Math, arr); + return Math.max.apply(Math, arr); } - functionExample.addArgument(['integers'], { - metavar: 'N', - type: 'int', - nargs: '+', - help: 'an integer for the accumulator' + metavar: 'N', + type: 'int', + nargs: '+', + help: 'an integer for the accumulator' }); functionExample.addArgument(['--sum'], { - dest: 'accumulate', - action: 'storeConst', - constant: sum, - defaultValue: max, - help: 'sum the integers (default: find the max)' + dest: 'accumulate', + action: 'storeConst', + constant: sum, + defaultValue: max, + help: 'sum the integers (default: find the max)' }); args = functionExample.parseArgs('--sum 1 2 -1'.split(' ')); console.log(args.accumulate(args.integers)); - - - -var formatterExample = new ArgumentParser({ - prog: 'PROG', - formatterClass: RawDescriptionHelpFormatter, - description: 'Keep the formatting\n' + - ' exactly as it is written\n' + - '\n' + - 'here\n' +const formatterExample = new ArgumentParser({ + prog: 'PROG', + formatterClass: RawDescriptionHelpFormatter, + description: `Keep the formatting\nexactly as it is written\n\nhere\n`, }); formatterExample.addArgument(['--foo'], { - help: ' foo help should not\n' + - ' retain this odd formatting' + help: `foo help should not\nretain this odd formatting`, }); formatterExample.addArgument(['spam'], { - 'help': 'spam help' + help: 'spam help', }); -var group = formatterExample.addArgumentGroup({ - title: 'title', - description: ' This text\n' + - ' should be indented\n' + - ' exactly like it is here\n' +const group = formatterExample.addArgumentGroup({ + title: 'title', + description: `This text\nshould be indented\nexactly like it is here\n`, }); group.addArgument(['--bar'], { - help: 'bar help' + help: 'bar help' }); formatterExample.printHelp(); diff --git a/types/argparse/index.d.ts b/types/argparse/index.d.ts index 845d5d8fd3..f19aadbe96 100644 --- a/types/argparse/index.d.ts +++ b/types/argparse/index.d.ts @@ -1,31 +1,39 @@ -// Type definitions for argparse v1.0.3 +// Type definitions for argparse 1.0 // Project: https://github.com/nodeca/argparse -// Definitions by: Andrew Schurman +// Definitions by: Andrew Schurman +// Tomasz Łaziuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 - -export declare class ArgumentParser extends ArgumentGroup { +export class ArgumentParser extends ArgumentGroup { constructor(options?: ArgumentParserOptions); - addSubparsers(options?: SubparserOptions): SubParser; - parseArgs(args?: string[], ns?: Namespace | Object): any; + parseArgs(args?: string[], ns?: Namespace | object): any; printUsage(): void; printHelp(): void; formatUsage(): string; formatHelp(): string; - parseKnownArgs(args?: string[], ns?: Namespace | Object): any[]; + parseKnownArgs(args?: string[], ns?: Namespace | object): any[]; convertArgLineToArg(argLine: string): string[]; exit(status: number, message: string): void; error(err: string | Error): void; } -interface Namespace { } +export class Namespace { + constructor(options: object); + get(key: K, defaultValue?: D): this[K] | D; + isset(key: K): boolean; + set(key: K, value: V): this; + set(key: K, value: V): this & Record; + set(obj: K): this & K; + unset(key: K, defaultValue?: D): this[K] | D; +} -declare class SubParser { +export class SubParser { addParser(name: string, options?: SubArgumentParserOptions): ArgumentParser; } -declare class ArgumentGroup { +export class ArgumentGroup { addArgument(args: string[], options?: ArgumentOptions): void; addArgumentGroup(options?: ArgumentGroupOptions): ArgumentGroup; addMutuallyExclusiveGroup(options?: { required: boolean }): ArgumentGroup; @@ -33,7 +41,7 @@ declare class ArgumentGroup { getDefault(dest: string): any; } -interface SubparserOptions { +export interface SubparserOptions { title?: string; description?: string; prog?: string; @@ -44,12 +52,12 @@ interface SubparserOptions { metavar?: string; } -interface SubArgumentParserOptions extends ArgumentParserOptions { +export interface SubArgumentParserOptions extends ArgumentParserOptions { aliases?: string[]; help?: string; } -interface ArgumentParserOptions { +export interface ArgumentParserOptions { description?: string; epilog?: string; addHelp?: boolean; @@ -62,26 +70,27 @@ interface ArgumentParserOptions { version?: string; } -interface ArgumentGroupOptions { +export interface ArgumentGroupOptions { prefixChars?: string; argumentDefault?: any; title?: string; description?: string; } -export declare class HelpFormatter { } -export declare class ArgumentDefaultsHelpFormatter { } -export declare class RawDescriptionHelpFormatter { } -export declare class RawTextHelpFormatter { } +export class HelpFormatter { } +export class ArgumentDefaultsHelpFormatter { } +export class RawDescriptionHelpFormatter { } +export class RawTextHelpFormatter { } -interface ArgumentOptions { +export interface ArgumentOptions { action?: string; optionStrings?: string[]; dest?: string; nargs?: string | number; constant?: any; defaultValue?: any; - type?: string | Function; + // type may be a string (primitive) or a Function (constructor) + type?: string | Function; // tslint:disable-line:ban-types choices?: string | string[]; required?: boolean; help?: string; diff --git a/types/argparse/tslint.json b/types/argparse/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/argparse/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/ascii2mathml/ascii2mathml-tests.ts b/types/ascii2mathml/ascii2mathml-tests.ts new file mode 100644 index 0000000000..7280900922 --- /dev/null +++ b/types/ascii2mathml/ascii2mathml-tests.ts @@ -0,0 +1,17 @@ +import * as ascii2mathml from 'ascii2mathml'; + +const fn = ascii2mathml({}); // $ExpectType any +fn(''); // $ExpectType string +ascii2mathml('', {}); // $ExpectType string + +// $ExpectType string +ascii2mathml('', { + decimalMark: '.', + colSep: ',', + rowSep: ';', + display: 'inline', + dir: 'ltr', + bare: false, + standalone: false, + annotate: false +}); diff --git a/types/ascii2mathml/index.d.ts b/types/ascii2mathml/index.d.ts new file mode 100644 index 0000000000..2b02dfea15 --- /dev/null +++ b/types/ascii2mathml/index.d.ts @@ -0,0 +1,35 @@ +// Type definitions for ascii2mathml 0.5 +// Project: https://github.com/runarberg/ascii2mathml +// Definitions by: Muhammad Ragib Hasin +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = A2MML; + +declare var A2MML: ascii2mathml; + +interface Options { + decimalMark?: string; + colSep?: string; + rowSep?: string; + display?: 'inline' | 'block'; + dir?: 'ltr' | 'rtl'; + bare?: boolean; + standalone?: boolean; + annotate?: boolean; +} + +interface ascii2mathml { + /** + * Generates a function with default options set to convert + * ASCIIMath expression to MathML markup. + * @param options Options + */ + (options: Options): ascii2mathml; + + /** + * Converts ASCIIMath expression to MathML markup. + * @param asciimath {string} ASCIIMath expression + * @param options Options + */ + (asciimath: string, options?: Options): string; +} diff --git a/types/ascii2mathml/tsconfig.json b/types/ascii2mathml/tsconfig.json new file mode 100644 index 0000000000..22e7823b58 --- /dev/null +++ b/types/ascii2mathml/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "ascii2mathml-tests.ts" + ] +} diff --git a/types/ascii2mathml/tslint.json b/types/ascii2mathml/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/ascii2mathml/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/asenv/asenv-tests.ts b/types/asenv/asenv-tests.ts new file mode 100644 index 0000000000..0448672d10 --- /dev/null +++ b/types/asenv/asenv-tests.ts @@ -0,0 +1,26 @@ +import { unlessProduction, isDevelopment, isTest, isProduction, getEnv, setEnv } from 'asenv'; +import { equal, throws } from 'assert'; + +// Test isDevelopment() +setEnv('development'); +equal(getEnv(), 'development', 'Should return be true'); +equal(isDevelopment(), true, 'NODE_ENV should be "development"'); +equal(isTest(), false, 'NODE_ENV should be "development"'); +equal(isProduction(), false, 'NODE_ENV should be "development"'); +equal(unlessProduction(() => true), true, "Shound return true"); + +// Test isTest() +setEnv('test'); +equal(getEnv(), 'test', 'Should return be true'); +equal(isDevelopment(), false, 'NODE_ENV should be "test"'); +equal(isTest(), true, 'NODE_ENV should be "test"'); +equal(isProduction(), false, 'NODE_ENV should be "test"'); +equal(unlessProduction(() => true), true, "Shound return true"); + +// Test isProduction() +setEnv('production'); +equal(getEnv(), 'production', 'Should return be true'); +equal(isDevelopment(), false, 'NODE_ENV should be "production"'); +equal(isTest(), false, 'NODE_ENV should be "production"'); +equal(isProduction(), true, 'NODE_ENV should be "production"'); +equal(unlessProduction(() => true), false, "Shound return false"); diff --git a/types/asenv/index.d.ts b/types/asenv/index.d.ts new file mode 100644 index 0000000000..f127664d13 --- /dev/null +++ b/types/asenv/index.d.ts @@ -0,0 +1,18 @@ +// Type definitions for asenv 1.1 +// Project: https://github.com/a-labo/asenv#readme +// Definitions by: Remisery +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +export function getEnv(): string; + +export function isDevelopment(): boolean; + +export function isProduction(): boolean; + +export function isTest(): boolean; + +export function setEnv(env: string): void; + +export function unlessProduction(handle: () => any): any; diff --git a/types/asenv/tsconfig.json b/types/asenv/tsconfig.json new file mode 100644 index 0000000000..129dd1caf0 --- /dev/null +++ b/types/asenv/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "asenv-tests.ts" + ] +} diff --git a/types/asenv/tslint.json b/types/asenv/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/asenv/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/askmethat-rating/askmethat-rating-tests.ts b/types/askmethat-rating/askmethat-rating-tests.ts index af0ab3cb88..af985d6358 100644 --- a/types/askmethat-rating/askmethat-rating-tests.ts +++ b/types/askmethat-rating/askmethat-rating-tests.ts @@ -1,6 +1,6 @@ import { AskmethatRating, AskmethatRatingSteps } from "askmethat-rating"; -let options = { +const options = { backgroundColor: "#e5e500", hoverColor: "#ffff66", fontClass: "fa fa-star", @@ -11,8 +11,8 @@ let options = { inputName: "AskmethatRating" }; -let div = document.createElement("div"); -let amcRating = new AskmethatRating(div, 2 , options); +const div = document.createElement("div"); +const amcRating = new AskmethatRating(div, 2 , options); options.readonly = true; amcRating.defaultOptions = options; diff --git a/types/askmethat-rating/index.d.ts b/types/askmethat-rating/index.d.ts index 43a59957bd..a183ecdc30 100644 --- a/types/askmethat-rating/index.d.ts +++ b/types/askmethat-rating/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for askmethat-rating 0.3 // Project: https://alexteixeira.github.io/Askmethat-Rating/ -// Definitions by: Alexandre Teixeira +// Definitions by: Alexandre Teixeira // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/assets-webpack-plugin/assets-webpack-plugin-tests.ts b/types/assets-webpack-plugin/assets-webpack-plugin-tests.ts new file mode 100644 index 0000000000..6851f853f2 --- /dev/null +++ b/types/assets-webpack-plugin/assets-webpack-plugin-tests.ts @@ -0,0 +1,25 @@ +import * as webpack from 'webpack'; +import * as AssetsPlugin from 'assets-webpack-plugin'; + +const config: webpack.Configuration = { + plugins: [ + new AssetsPlugin(), + new AssetsPlugin({ + filename: 'assets.json' + }), + new AssetsPlugin({ + filename: 'assets.json', + fullPath: false, + includeManifest: true, + path: '/foo/bar', + prettyPrint: true, + processOutput: (assets) => ( + 'window.assets = ' + JSON.stringify(assets) + ), + update: true, + metadata: { + meta: 'data' + }, + }) + ] +}; diff --git a/types/assets-webpack-plugin/index.d.ts b/types/assets-webpack-plugin/index.d.ts new file mode 100644 index 0000000000..660fbc6052 --- /dev/null +++ b/types/assets-webpack-plugin/index.d.ts @@ -0,0 +1,76 @@ +// Type definitions for assets-webpack-plugin 3.5 +// Project: https://github.com/sporto/assets-webpack-plugin +// Definitions by: Michael Strobel +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +import * as webpack from 'webpack'; + +declare namespace AssetsWebpackPlugin { + interface Assets { + [name: string]: { + [ext: string]: string; + }; + } + + type ProcessOutputFn = (assets: Assets) => string; + + interface Options { + /** + * Name for the created json file. + * "webpack-assets.json" by default + */ + filename?: string; + + /** + * If false the output will not include the full path of the generated file. + * true by default + */ + fullPath?: boolean; + + /** + * Inserts the manifest javascript as a text property in your assets. + * Accepts the name of your manifest chunk. + * A manifest is the last CommonChunk that only contains the webpack bootstrap code. + * This is useful for production use when you want to inline the manifest + * in your HTML skeleton for long-term caching. + * false by default + */ + includeManifest?: boolean; + + /** + * Inject metadata into the output file. All values will be injected into the key "metadata" + */ + metadata?: object; + + /** + * Path where to save the created JSON file. + * Defaults to the current directory + */ + path?: string; + + /** + * Whether to format the JSON output for readability. + * false by default + */ + prettyPrint?: boolean; + + /** + * Formats the assets output. + * Defaults to JSON.stringify + */ + processOutput?: ProcessOutputFn; + + /** + * When set to true, the output JSON file will be updated instead of overwritten. + * false by default + */ + update?: boolean; + } +} + +declare class AssetsWebpackPlugin extends webpack.Plugin { + constructor(options?: AssetsWebpackPlugin.Options); +} + +export = AssetsWebpackPlugin; diff --git a/types/assets-webpack-plugin/tsconfig.json b/types/assets-webpack-plugin/tsconfig.json new file mode 100644 index 0000000000..0d71c8ce0b --- /dev/null +++ b/types/assets-webpack-plugin/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "assets-webpack-plugin-tests.ts" + ] +} diff --git a/types/assets-webpack-plugin/tslint.json b/types/assets-webpack-plugin/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/assets-webpack-plugin/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/async-cache/async-cache-tests.ts b/types/async-cache/async-cache-tests.ts new file mode 100644 index 0000000000..58a1b565f2 --- /dev/null +++ b/types/async-cache/async-cache-tests.ts @@ -0,0 +1,26 @@ +import AsyncCache = require('async-cache'); + +const stats = new AsyncCache({ + max: 1000, + maxAge: 1000 * 60 * 10, + load(key, cb) { + key; // $ExpectType string + cb; // $ExpectType (error: any, asyncValue: number, maxAge?: number | undefined) => void + } +}); +AsyncCache({ + load(key, cb) {} +}); + +stats.get('', (er, stat) => { + er; // $ExpectType any + stat; // $ExpectType number +}); + +stats.keys(); // $ExpectType string[] +stats.set('', 1); // $ExpectType boolean +stats.set('', 1, 1); +stats.reset(); +stats.has(''); // $ExpectType boolean +stats.del(''); +stats.peek(''); // $ExpectType number | undefined diff --git a/types/async-cache/index.d.ts b/types/async-cache/index.d.ts new file mode 100644 index 0000000000..1e00f35d51 --- /dev/null +++ b/types/async-cache/index.d.ts @@ -0,0 +1,34 @@ +// Type definitions for async-cache 1.1 +// Project: https://github.com/isaacs/async-cache#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import { Options as LRUOptions } from 'lru-cache'; + +export = AsyncCache; + +declare const AsyncCache: AsyncCacheFactory; + +interface AsyncCacheFactory { + (options: AsyncCache.Options): AsyncCache.Cache; + new (options: AsyncCache.Options): AsyncCache.Cache; +} + +declare namespace AsyncCache { + interface Cache { + readonly itemCount: number; + + get(key: string, cb: (error: any, value: T) => void): void; + keys(): string[]; + set(key: string, value: T, maxAge?: number): boolean; + reset(): void; + has(key: string): boolean; + del(key: string): void; + peek(key: string): T | undefined; + } + + interface Options extends LRUOptions { + load(key: string, callback: (error: any, asyncValue: T, maxAge?: number) => void): void; + } +} diff --git a/types/async-cache/tsconfig.json b/types/async-cache/tsconfig.json new file mode 100644 index 0000000000..1358c8a3e4 --- /dev/null +++ b/types/async-cache/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "async-cache-tests.ts" + ] +} diff --git a/types/async-cache/tslint.json b/types/async-cache/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/async-cache/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/async-lock/index.d.ts b/types/async-lock/index.d.ts index 296307300c..4a19590d73 100644 --- a/types/async-lock/index.d.ts +++ b/types/async-lock/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for async-lock // Project: https://github.com/rain1017/async-lock -// Definitions by: Elisée MAURER +// Definitions by: Elisée MAURER // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/async-polling/index.d.ts b/types/async-polling/index.d.ts index 640c863874..78789aeafc 100644 --- a/types/async-polling/index.d.ts +++ b/types/async-polling/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for AsyncPolling // Project: https://github.com/cGuille/async-polling -// Definitions by: Zlatko Andonovski +// Definitions by: Zlatko Andonovski // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace AsyncPolling { diff --git a/types/async/index.d.ts b/types/async/index.d.ts index 33bb1a6c0e..139689ea2f 100644 --- a/types/async/index.d.ts +++ b/types/async/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Async 2.0.1 // Project: https://github.com/caolan/async -// Definitions by: Boris Yankov , Arseniy Maximov , Joe Herman , Angus Fenying , Pascal Martin +// Definitions by: Boris Yankov , Arseniy Maximov , Joe Herman , Angus Fenying , Pascal Martin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped interface Dictionary { [key: string]: T; } @@ -28,7 +28,7 @@ interface AsyncQueue { idle(): boolean; concurrency: number; push(task: T, callback?: ErrorCallback): void; - push(task: T, callback?: AsyncResultCallback): void; + push(task: T, callback?: AsyncResultCallback): void; push(task: T[], callback?: ErrorCallback): void; unshift(task: T, callback?: ErrorCallback): void; unshift(task: T[], callback?: ErrorCallback): void; @@ -53,8 +53,8 @@ interface AsyncPriorityQueue { concurrency: number; started: boolean; paused: boolean; - push(task: T, priority: number, callback?: AsyncResultArrayCallback): void; - push(task: T[], priority: number, callback?: AsyncResultArrayCallback): void; + push(task: T, priority: number, callback?: AsyncResultArrayCallback): void; + push(task: T[], priority: number, callback?: AsyncResultArrayCallback): void; saturated: () => any; empty: () => any; drain: () => any; diff --git a/types/async/test/index.ts b/types/async/test/index.ts index b30ca4c7ba..60234a0ca4 100644 --- a/types/async/test/index.ts +++ b/types/async/test/index.ts @@ -271,9 +271,9 @@ async.waterfall([ ], function (err, result) { }); -var q = async.queue(function (task: any, callback: () => void) { +var q = async.queue(function (task: any, callback: (err?:Error,msg?:string) => void) { console.log('hello ' + task.name); - callback(); + callback(undefined,'a message.'); }, 2); @@ -291,6 +291,10 @@ q.push([{ name: 'baz' }, { name: 'bay' }, { name: 'bax' }], function (err) { console.log('finished processing bar'); }); +q.push({name: 'foo'}, function (err,msg) { + console.log('foo finished with a message "'+ msg! + '"'); +}); + q.unshift({ name: 'foo' }); q.unshift({ name: 'bar' }, function (err) { diff --git a/types/asyncblock/index.d.ts b/types/asyncblock/index.d.ts index c4f8d3da21..e848f509fb 100644 --- a/types/asyncblock/index.d.ts +++ b/types/asyncblock/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for asyncblock 2.1.23 // Project: https://github.com/scriby/asyncblock -// Definitions by: Hiroki Horiuchi +// Definitions by: Hiroki Horiuchi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/atmosphere/index.d.ts b/types/atmosphere/index.d.ts index e62df1ea64..5e88c2c8fb 100644 --- a/types/atmosphere/index.d.ts +++ b/types/atmosphere/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Atmosphere v2.1.5 // Project: https://github.com/Atmosphere/atmosphere-javascript -// Definitions by: Kai Toedter +// Definitions by: Kai Toedter // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace Atmosphere { diff --git a/types/atom-keymap/index.d.ts b/types/atom-keymap/index.d.ts index c066867a5b..58d75ec709 100644 --- a/types/atom-keymap/index.d.ts +++ b/types/atom-keymap/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for atom-keymap v5.1.5 // Project: https://github.com/atom/atom-keymap/ -// Definitions by: Vadim Macagon +// Definitions by: Vadim Macagon // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// diff --git a/types/atom/index.d.ts b/types/atom/index.d.ts index 30aa6b881b..718cc2747a 100644 --- a/types/atom/index.d.ts +++ b/types/atom/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Atom // Project: https://atom.io/ -// Definitions by: vvakame +// Definitions by: vvakame // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/auth0-js/auth0-js-tests.ts b/types/auth0-js/auth0-js-tests.ts index 5356dc605a..73426dbd37 100644 --- a/types/auth0-js/auth0-js-tests.ts +++ b/types/auth0-js/auth0-js-tests.ts @@ -130,7 +130,10 @@ webAuth.signupAndAuthorize({ connection: 'the_connection', email: 'me@example.com', password: '123456', - scope: 'openid' + scope: 'openid', + user_metadata: { + foo: 'bar' + } }, function (err, data) { }); diff --git a/types/auth0-js/index.d.ts b/types/auth0-js/index.d.ts index 4e6afded1d..37914e887f 100644 --- a/types/auth0-js/index.d.ts +++ b/types/auth0-js/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for Auth0.js 8.6 // Project: https://github.com/auth0/auth0.js // Definitions by: Adrian Chia +// Matt Durrant // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export as namespace auth0; @@ -624,6 +625,7 @@ interface DbSignUpOptions { password: string; connection: string; scope?: string; + user_metadata?: any; } interface ParseHashOptions { diff --git a/types/auth0-lock/auth0-lock-tests.ts b/types/auth0-lock/auth0-lock-tests.ts index 3abe93a7c2..0642453a13 100644 --- a/types/auth0-lock/auth0-lock-tests.ts +++ b/types/auth0-lock/auth0-lock-tests.ts @@ -4,7 +4,7 @@ import Auth0Lock from 'auth0-lock'; const CLIENT_ID = "YOUR_AUTH0_APP_CLIENTID"; const DOMAIN = "YOUR_DOMAIN_AT.auth0.com"; -var lock: Auth0LockStatic = new Auth0Lock(CLIENT_ID, DOMAIN); +const lock: Auth0LockStatic = new Auth0Lock(CLIENT_ID, DOMAIN); lock.show(); lock.hide(); @@ -12,7 +12,7 @@ lock.logout(() => {}); // Show supports UI arguments -var showOptions : Auth0LockShowOptions = { +const showOptions : Auth0LockShowOptions = { allowedConnections: [ "twitter", "facebook" ], allowSignUp: true, allowForgotPassword: false, @@ -63,7 +63,7 @@ lock.on("authenticated", function(authResult : any) { // test theme -var themeOptions : Auth0LockConstructorOptions = { +const themeOptions : Auth0LockConstructorOptions = { theme: { authButtons: { fooProvider: { @@ -86,7 +86,7 @@ new Auth0Lock(CLIENT_ID, DOMAIN, themeOptions); // test empty theme -var themeOptionsEmpty : Auth0LockConstructorOptions = { +const themeOptionsEmpty : Auth0LockConstructorOptions = { theme: { } }; @@ -94,7 +94,7 @@ new Auth0Lock(CLIENT_ID, DOMAIN, themeOptions); // test authentication -var authOptions : Auth0LockConstructorOptions = { +const authOptions : Auth0LockConstructorOptions = { auth: { params: { state: "foo" }, redirect: true, @@ -108,7 +108,7 @@ new Auth0Lock(CLIENT_ID, DOMAIN, authOptions); // test multi-variant example -var multiVariantOptions : Auth0LockConstructorOptions = { +const multiVariantOptions : Auth0LockConstructorOptions = { container: "myContainer", closable: false, languageDictionary: { @@ -122,7 +122,7 @@ new Auth0Lock(CLIENT_ID, DOMAIN, multiVariantOptions); // test text-field additional sign up field -var textFieldOptions : Auth0LockConstructorOptions = { +const textFieldOptions : Auth0LockConstructorOptions = { additionalSignUpFields: [{ name: "address", placeholder: "enter your address", @@ -142,7 +142,7 @@ new Auth0Lock(CLIENT_ID, DOMAIN, textFieldOptions); // test select-field additional sign up field -var selectFieldOptions : Auth0LockConstructorOptions = { +const selectFieldOptions : Auth0LockConstructorOptions = { additionalSignUpFields: [{ type: "select", name: "location", @@ -162,7 +162,7 @@ new Auth0Lock(CLIENT_ID, DOMAIN, selectFieldOptions); // test select-field additional sign up field with callbacks for -var selectFieldOptionsWithCallbacks : Auth0LockConstructorOptions = { +const selectFieldOptionsWithCallbacks : Auth0LockConstructorOptions = { additionalSignUpFields: [{ type: "select", name: "location", @@ -171,7 +171,7 @@ var selectFieldOptionsWithCallbacks : Auth0LockConstructorOptions = { // obtain options, in case of error you call cb with the error in the // first arg instead of null - let options = [ + const options = [ {value: "us", label: "United States"}, {value: "fr", label: "France"}, {value: "ar", label: "Argentina"} @@ -184,7 +184,7 @@ var selectFieldOptionsWithCallbacks : Auth0LockConstructorOptions = { // obtain prefill, in case of error you call cb with the error in the // first arg instead of null - let prefill = "us"; + const prefill = "us"; cb(null, prefill); } @@ -195,13 +195,13 @@ new Auth0Lock(CLIENT_ID, DOMAIN, selectFieldOptionsWithCallbacks); // test Avatar options -var avatarOptions : Auth0LockConstructorOptions = { +const avatarOptions : Auth0LockConstructorOptions = { avatar: { url: (email : string, cb : Auth0LockAvatarUrlCallback) => { // obtain url for email, in case of error you call cb with the error in // the first arg instead of null - let url = "url"; + const url = "url"; cb(null, url); }, @@ -209,7 +209,7 @@ var avatarOptions : Auth0LockConstructorOptions = { // obtain displayName for email, in case of error you call cb with the // error in the first arg instead of null - let displayName = "displayName"; + const displayName = "displayName"; cb(null, displayName); } @@ -218,7 +218,7 @@ var avatarOptions : Auth0LockConstructorOptions = { new Auth0Lock(CLIENT_ID, DOMAIN, avatarOptions); -var authResult : AuthResult = { +const authResult : AuthResult = { accessToken: 'fake_access_token', idToken: 'fake_id_token', idTokenPayload: { diff --git a/types/auth0-lock/index.d.ts b/types/auth0-lock/index.d.ts index e49c23a308..0a57d988ce 100644 --- a/types/auth0-lock/index.d.ts +++ b/types/auth0-lock/index.d.ts @@ -155,7 +155,7 @@ interface Auth0LockStatic { getProfile(token: string, callback: (error: auth0.Auth0Error, profile: auth0.Auth0UserProfile) => void): void; getUserInfo(token: string, callback: (error: auth0.Auth0Error, profile: auth0.Auth0UserProfile) => void): void; // https://github.com/auth0/lock#resumeauthhash-callback - resumeAuth( hash: string, callback: (error: auth0.Auth0Error, authResult: AuthResult) => void): void; + resumeAuth(hash: string, callback: (error: auth0.Auth0Error, authResult: AuthResult) => void): void; show(options?: Auth0LockShowOptions): void; hide(): void; logout(query: any): void; diff --git a/types/auth0/index.d.ts b/types/auth0/index.d.ts index 07a316268a..cb84c7a6bd 100644 --- a/types/auth0/index.d.ts +++ b/types/auth0/index.d.ts @@ -360,6 +360,7 @@ export class ManagementClient { // Users getUsers(params?: GetUsersData): Promise; + getUsers(cb: (err: Error, users: User[]) => void): void; getUsers(params?: GetUsersData, cb?: (err: Error, users: User[]) => void): void; getUser(params: ObjectWithId): Promise; diff --git a/types/auto-sni/auto-sni-tests.ts b/types/auto-sni/auto-sni-tests.ts index a271a1a1ad..6be54148fb 100644 --- a/types/auto-sni/auto-sni-tests.ts +++ b/types/auto-sni/auto-sni-tests.ts @@ -1,5 +1,5 @@ import * as autosni from "auto-sni"; -let a = autosni({ +const a = autosni({ agreeTos: true, email: '', domains: [''] diff --git a/types/autobahn/index.d.ts b/types/autobahn/index.d.ts index 6741bcccd1..7f01a53e3a 100644 --- a/types/autobahn/index.d.ts +++ b/types/autobahn/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for AutobahnJS v0.9.7 // Project: http://autobahn.ws/js/ -// Definitions by: Elad Zelingher , Andy Hawkins , Wladimir Totino +// Definitions by: Elad Zelingher , Andy Hawkins , Wladimir Totino // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -205,7 +205,7 @@ declare namespace autobahn { type DeferFactory = () => When.Promise; - type OnChallengeHandler = (session: Session, method: string, extra: any) => When.Promise; + type OnChallengeHandler = (session: Session, method: string, extra: any) => string; interface IConnectionOptions { use_es6_promises?: boolean; diff --git a/types/autobind-decorator/index.d.ts b/types/autobind-decorator/index.d.ts index 51ba89c9bf..d8d74bbfec 100644 --- a/types/autobind-decorator/index.d.ts +++ b/types/autobind-decorator/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for autobind-decorator v1.3.3 // Project: https://github.com/andreypopp/autobind-decorator -// Definitions by: Ivo Stratev +// Definitions by: Ivo Stratev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module 'autobind-decorator' { diff --git a/types/autoprefixer/package.json b/types/autoprefixer/package.json index aa284a6db8..c4c2b4c357 100644 --- a/types/autoprefixer/package.json +++ b/types/autoprefixer/package.json @@ -1,5 +1,6 @@ { - "dependencies": { - "postcss": "^5.2.15" - } + "private": true, + "dependencies": { + "postcss": "^5.2.15" + } } diff --git a/types/autosize/index.d.ts b/types/autosize/index.d.ts index 0886904e3f..a189b32817 100644 --- a/types/autosize/index.d.ts +++ b/types/autosize/index.d.ts @@ -1,20 +1,66 @@ -// Type definitions for jquery.autosize 3.0.7 +// Type definitions for jquery.autosize 3.0 // Project: http://www.jacklmoore.com/autosize/ -// Definitions by: Aaron T. King , keika299 +// Definitions by: Aaron T. King , keika299 , NeekSandhu // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/// + +/** + * Attach autosize to NodeList + * @param elements + */ +declare function autosize(elements: NodeList): NodeList; +/** + * Attach autosize to Element + * @param element + */ +declare function autosize(element: Element): Element; +/** + * Attach autosize to JQuery collection + * @param collection + */ +declare function autosize(collection: JQuery): JQuery; declare namespace autosize { - interface AutosizeStatic { - (el: Element): void; - (el: NodeList): void; - update(el: Element): void; - update(el: NodeList): void; - destroy(el: Element): void; - destroy(el: NodeList): void; - } -} + /** + * Triggers the height adjustment for an assigned textarea element. + * Autosize will automatically adjust the textarea height on keyboard and window resize events. + * There is no efficient way for Autosize to monitor for when another script has changed the textarea value or for changes in layout that impact the textarea element. + * @param elements + */ + function update(elements: NodeList): NodeList; + /** + * Triggers the height adjustment for an assigned textarea element. + * Autosize will automatically adjust the textarea height on keyboard and window resize events. + * There is no efficient way for Autosize to monitor for when another script has changed the textarea value or for changes in layout that impact the textarea element. + * @param element + */ + function update(element: Element): Element; + /** + * Triggers the height adjustment for an assigned textarea element. + * Autosize will automatically adjust the textarea height on keyboard and window resize events. + * There is no efficient way for Autosize to monitor for when another script has changed the textarea value or for changes in layout that impact the textarea element. + * @param collection + */ + function update(collection: JQuery): JQuery; -declare var autosize: autosize.AutosizeStatic; + /** + * Removes Autosize and reverts any changes it made to the textarea element. + * @param elements + */ + function destroy(elements: NodeList): NodeList; + /** + * Removes Autosize and reverts any changes it made to the textarea element. + * @param element + */ + function destroy(element: Element): Element; + /** + * Removes Autosize and reverts any changes it made to the textarea element. + * @param collection + */ + function destroy(collection: JQuery): JQuery; +} export = autosize; export as namespace autosize; diff --git a/types/autosize/tslint.json b/types/autosize/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/autosize/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/awesomplete/awesomplete-tests.ts b/types/awesomplete/awesomplete-tests.ts index 6cea0e1bca..f9ff4fed77 100644 --- a/types/awesomplete/awesomplete-tests.ts +++ b/types/awesomplete/awesomplete-tests.ts @@ -35,7 +35,7 @@ new Awesomplete('input[type="email"]', { "hotmail.co.uk", "mac.com", "me.com", "mail.com", "msn.com", "live.com", "sbcglobal.net", "verizon.net", "yahoo.com", "yahoo.co.uk"], data: (text: string, input: string) => { - return input.slice(0, input.indexOf("@")) + "@" + text; + return `${input.slice(0, input.indexOf("@"))}@${text}`; }, filter: Awesomplete.FILTER_STARTSWITH }); @@ -47,7 +47,7 @@ new Awesomplete('input[data-multiple]', { replace: (text: string) => { const before = this.input.value.match(/^.+,\s*|/)[0]; - this.input.value = before + text + ", "; + this.input.value = `${before}${text}, `; } }); diff --git a/types/awesomplete/index.d.ts b/types/awesomplete/index.d.ts index 4612d66210..149b87e9f6 100644 --- a/types/awesomplete/index.d.ts +++ b/types/awesomplete/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Awesomplete 1.1 // Project: https://leaverou.github.io/awesomplete/ -// Definitions by: webbiesdk , Ben Dixon , Trevor Bekolay +// Definitions by: webbiesdk , Ben Dixon , Trevor Bekolay // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare class Awesomplete { diff --git a/types/awesomplete/tslint.json b/types/awesomplete/tslint.json index 3db14f85ea..d9d49e375e 100644 --- a/types/awesomplete/tslint.json +++ b/types/awesomplete/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-any-union": false + } +} diff --git a/types/aws-lambda-mock-context/tslint.json b/types/aws-lambda-mock-context/tslint.json index f93cf8562a..bafaae7817 100644 --- a/types/aws-lambda-mock-context/tslint.json +++ b/types/aws-lambda-mock-context/tslint.json @@ -1,3 +1,7 @@ { - "extends": "dtslint/dt.json" + "extends": "dtslint/dt.json", + "rules": { + // TODO + "dt-header": false + } } diff --git a/types/aws-lambda/aws-lambda-tests.ts b/types/aws-lambda/aws-lambda-tests.ts index 10b4fa1073..4e404fcd55 100644 --- a/types/aws-lambda/aws-lambda-tests.ts +++ b/types/aws-lambda/aws-lambda-tests.ts @@ -130,6 +130,7 @@ num = proxyResult.statusCode; proxyResult.headers["example"] = str; proxyResult.headers["example"] = b; proxyResult.headers["example"] = num; +b = proxyResult.isBase64Encoded; str = proxyResult.body; /* API Gateway CustomAuthorizer AuthResponse */ diff --git a/types/aws-lambda/index.d.ts b/types/aws-lambda/index.d.ts index 1da094ac46..0c8f0fc26d 100644 --- a/types/aws-lambda/index.d.ts +++ b/types/aws-lambda/index.d.ts @@ -288,6 +288,7 @@ interface ProxyResult { [header: string]: boolean | number | string; }, body: string; + isBase64Encoded?: boolean; } /** diff --git a/types/aws-serverless-express/aws-serverless-express-tests.ts b/types/aws-serverless-express/aws-serverless-express-tests.ts index 97d236e043..4770163b3b 100644 --- a/types/aws-serverless-express/aws-serverless-express-tests.ts +++ b/types/aws-serverless-express/aws-serverless-express-tests.ts @@ -5,7 +5,7 @@ import { eventContext } from 'aws-serverless-express/middleware'; const app = express(); app.use(eventContext()); -const server = awsServerlessExpress.createServer(app, () => {}); +const server = awsServerlessExpress.createServer(app, () => {}, []); const mockEvent = { key: 'value' diff --git a/types/aws-serverless-express/index.d.ts b/types/aws-serverless-express/index.d.ts index db49e6ca6b..e612d5d8d6 100644 --- a/types/aws-serverless-express/index.d.ts +++ b/types/aws-serverless-express/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for aws-serverless-express 2.1 // Project: https://github.com/awslabs/aws-serverless-express -// Definitions by: Ben Speakman , Josh Caffey +// Definitions by: Ben Speakman , Josh Caffey , Matthias Meyer // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -9,7 +9,8 @@ import * as lambda from 'aws-lambda'; export function createServer( requestListener: (request: http.IncomingMessage, response: http.ServerResponse) => http.Server, - serverListenCallback?: () => any + serverListenCallback?: () => any, + binaryMimeTypes?: string[] ): http.Server; export function proxy( diff --git a/types/azure-mobile-services-client/index.d.ts b/types/azure-mobile-services-client/index.d.ts index 8dbb12d2e4..2109633a69 100644 --- a/types/azure-mobile-services-client/index.d.ts +++ b/types/azure-mobile-services-client/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Microsoft Windows AzureMobile Service 1.0.0 // Project: http://www.windowsazure.com/en-us/develop/mobile/ -// Definitions by: Morosinotto Daniele +// Definitions by: Morosinotto Daniele // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace Microsoft.WindowsAzure { diff --git a/types/azure-sb/index.d.ts b/types/azure-sb/index.d.ts index 1c8b087815..bae1af04a9 100644 --- a/types/azure-sb/index.d.ts +++ b/types/azure-sb/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for azure-sb // Project: https://github.com/Azure/azure-sdk-for-node/tree/master/lib/services/serviceBus -// Definitions by: Microsoft Azure +// Definitions by: Microsoft Azure // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace Azure.ServiceBus { diff --git a/types/babel-core/babel-core-tests.ts b/types/babel-core/babel-core-tests.ts index 45fc649549..b3839d151f 100644 --- a/types/babel-core/babel-core-tests.ts +++ b/types/babel-core/babel-core-tests.ts @@ -8,7 +8,7 @@ result.map; // Sourcemap result.ast; // AST // Examples from http://babeljs.io/docs/usage/api/ -let options: babel.TransformOptions = { +const options: babel.TransformOptions = { plugins: [ "es2015-arrow-functions", "es2015-block-scoped-functions", @@ -27,3 +27,20 @@ babel.transformFile("filename.js", options, (err, result) => { }); babel.transformFileSync("filename.js", options).code; + +// Slightly modified example from https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md#-pre-and-post-in-plugins +export default function(): babel.PluginObj<{ cache: Map}> { + return { + pre(state) { + this.cache = new Map(); + }, + visitor: { + StringLiteral(path) { + this.cache.set(path.node.value, 1); + } + }, + post(state) { + return this.cache; + } + }; +} diff --git a/types/babel-core/index.d.ts b/types/babel-core/index.d.ts index d3b3053a84..a2476245c1 100644 --- a/types/babel-core/index.d.ts +++ b/types/babel-core/index.d.ts @@ -6,12 +6,29 @@ // TypeScript Version: 2.3 import * as t from 'babel-types'; -export {t as types}; +export { t as types }; export type Node = t.Node; export import template = require('babel-template'); export const version: string; -import traverse, { Visitor } from "babel-traverse"; +import traverse, { Visitor, NodePath } from "babel-traverse"; export { traverse, Visitor }; +import { BabylonOptions } from "babylon"; +export { BabylonOptions }; +import { GeneratorOptions } from "babel-generator"; +export { GeneratorOptions }; + +// A babel plugin is a simple function which must return an object matching +// the following interface. Babel will throw if it finds unknown properties. +// The list of allowed plugin keys is here: +// https://github.com/babel/babel/blob/4e50b2d9d9c376cee7a2cbf56553fe5b982ea53c/packages/babel-core/src/config/option-manager.js#L71 +export interface PluginObj { + name?: string; + manipulateOptions?(opts: any, parserOpts: any): void; + pre?(this: S, state: any): void; + visitor: Visitor; + post?(this: S, state: any): void; + inherits?: any; +} /** Transforms the passed in `code`. Returning an object with the generated code, source map, and AST. */ export function transform(code: string, opts?: TransformOptions): BabelFileResult; @@ -25,14 +42,29 @@ export function transformFileSync(filename: string, opts?: TransformOptions): Ba export function transformFromAst(ast: Node, code?: string, opts?: TransformOptions): BabelFileResult; export interface TransformOptions { - /** Filename to use when reading from stdin - this will be used in source-maps, errors etc. Default: "unknown". */ - filename?: string; + /** Include the AST in the returned object. Default: `true`. */ + ast?: boolean; - /** Filename relative to `sourceRoot`. */ - filenameRelative?: string; + /** Attach a comment after all non-user injected code. */ + auxiliaryCommentAfter?: string; - /** A source map object that the output source map will be based on. */ - inputSourceMap?: object; + /** Attach a comment before all non-user injected code. */ + auxiliaryCommentBefore?: string; + + /** Specify whether or not to use `.babelrc` and `.babelignore` files. Default: `true`. */ + babelrc?: boolean; + + /** Enable code generation. Default: `true`. */ + code?: boolean; + + /** write comments to generated output. Default: `true`. */ + comments?: boolean; + + /** + * Do not include superfluous whitespace characters and line terminators. When set to `"auto"`, `compact` is set to + * `true` on input sizes of >100KB. + */ + compact?: boolean | "auto"; /** * This is an object of keys that represent different environments. For example, you may have: @@ -42,38 +74,68 @@ export interface TransformOptions { */ env?: object; - /** Retain line numbers - will result in really ugly code. Default: `false` */ - retainLines?: boolean; + /** A path to an .babelrc file to extend. */ + extends?: string; + + /** Filename to use when reading from stdin - this will be used in source-maps, errors etc. Default: "unknown". */ + filename?: string; + + /** Filename relative to `sourceRoot`. */ + filenameRelative?: string; + + /** An object containing the options to be passed down to the babel code generator, babel-generator. Default: `{}` */ + generatorOpts?: GeneratorOptions; + + /** + * Specify a custom callback to generate a module id with. Called as `getModuleId(moduleName)`. + * If falsy value is returned then the generated module id is used. + */ + getModuleId?(moduleName: string): string; /** Enable/disable ANSI syntax highlighting of code frames. Default: `true`. */ highlightCode?: boolean; - /** List of presets (a set of plugins) to load and use. */ - presets?: any[]; - - /** List of plugins to load and use. */ - plugins?: any[]; - /** list of glob paths to **not** compile. Opposite to the `only` option. */ ignore?: string[]; + /** A source map object that the output source map will be based on. */ + inputSourceMap?: object; + + /** Should the output be minified. Default: `false` */ + minified?: boolean; + + /** Specify a custom name for module ids. */ + moduleId?: string; + + /** + * If truthy, insert an explicit id for modules. By default, all modules are anonymous. + * (Not available for `common` modules). + */ + moduleIds?: boolean; + + /** Optional prefix for the AMD module formatter that will be prepend to the filename on module definitions. */ + moduleRoot?: string; + /** * A glob, regex, or mixed array of both, matching paths to only compile. Can also be an array of arrays containing * paths to explicitly match. When attempting to compile a non-matching file it's returned verbatim. */ only?: string | RegExp | Array; - /** Enable code generation. Default: `true`. */ - code?: boolean; + /** Babylon parser options. */ + parserOpts?: BabylonOptions; - /** Include the AST in the returned object. Default: `true`. */ - ast?: boolean; + /** List of plugins to load and use. */ + plugins?: any[]; - /** A path to an .babelrc file to extend. */ - extends?: string; + /** List of presets (a set of plugins) to load and use. */ + presets?: any[]; - /** write comments to generated output. Default: `true`. */ - comments?: boolean; + /** Retain line numbers - will result in really ugly code. Default: `false` */ + retainLines?: boolean; + + /** Resolve a module source ie. import "SOURCE"; to a custom value. */ + resolveModuleSource?(source: string, filename: string): string; /** * An optional callback that controls whether a comment should be output or not. Called as @@ -81,11 +143,8 @@ export interface TransformOptions { */ shouldPrintComment?(comment: string): boolean; - /** - * Do not include superfluous whitespace characters and line terminators. When set to `"auto"`, `compact` is set to - * `true` on input sizes of >100KB. - */ - compact?: boolean | "auto"; + /** Set `sources[0]` on returned source map. */ + sourceFileName?: string; /** * If truthy, adds a `map` property to returned output. If set to `"inline"`, a comment with a `sourceMappingURL` @@ -97,38 +156,16 @@ export interface TransformOptions { /** Set `file` on returned source map. */ sourceMapTarget?: string; - /** Set `sources[0]` on returned source map. */ - sourceFileName?: string; - /** The root from which all sources are relative. */ sourceRoot?: string; - /** Specify whether or not to use `.babelrc` and `.babelignore` files. Default: `true`. */ - babelrc?: boolean; + /** Indicate the mode the code should be parsed in. Can be either “script” or “module”. Default: "module" */ + sourceType?: "script" | "module"; - /** Attach a comment before all non-user injected code. */ - auxiliaryCommentBefore?: string; - - /** Attach a comment after all non-user injected code. */ - auxiliaryCommentAfter?: string; - - /** - * Specify a custom callback to generate a module id with. Called as `getModuleId(moduleName)`. - * If falsy value is returned then the generated module id is used. + /** An optional callback that can be used to wrap visitor methods. + * NOTE: This is useful for things like introspection, and not really needed for implementing anything. */ - getModuleId?(moduleName: string): string; - - /** Optional prefix for the AMD module formatter that will be prepend to the filename on module definitions. */ - moduleRoot?: string; - - /** - * If truthy, insert an explicit id for modules. By default, all modules are anonymous. - * (Not available for `common` modules). - */ - moduleIds?: boolean; - - /** Specify a custom name for module ids. */ - moduleId?: string; + wrapPluginVisitorMethod?(pluginAlias: string, visitorType: 'enter' | 'exit', callback: (path: NodePath, state: any) => void): (path: NodePath, state: any) => void ; } export interface BabelFileResult { diff --git a/types/babel-generator/babel-generator-tests.ts b/types/babel-generator/babel-generator-tests.ts index 1aeec38831..5efb98ba24 100644 --- a/types/babel-generator/babel-generator-tests.ts +++ b/types/babel-generator/babel-generator-tests.ts @@ -11,7 +11,7 @@ ast.loc.start; const output = generate(ast, { /* options */ }, code); // Example from https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md#babel-generator -let result = generate(ast, { +const result = generate(ast, { retainLines: false, compact: "auto", concise: false, diff --git a/types/babel-plugin-react-pug/babel-plugin-react-pug-tests.tsx b/types/babel-plugin-react-pug/babel-plugin-react-pug-tests.tsx new file mode 100644 index 0000000000..23d8205d4b --- /dev/null +++ b/types/babel-plugin-react-pug/babel-plugin-react-pug-tests.tsx @@ -0,0 +1,4 @@ +// $ExpectType any +pug` + p Hello pug! +`; diff --git a/types/babel-plugin-react-pug/index.d.ts b/types/babel-plugin-react-pug/index.d.ts new file mode 100644 index 0000000000..2cc311d627 --- /dev/null +++ b/types/babel-plugin-react-pug/index.d.ts @@ -0,0 +1,6 @@ +// Type definitions for babel-plugin-react-pug 0.5 +// Project: https://github.com/ljbc1994/babel-plugin-react-pug +// Definitions by: John Papandriopoulos +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare var pug: any; diff --git a/types/babel-plugin-react-pug/tsconfig.json b/types/babel-plugin-react-pug/tsconfig.json new file mode 100644 index 0000000000..9e1bdd2e0c --- /dev/null +++ b/types/babel-plugin-react-pug/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react" + }, + "files": [ + "index.d.ts", + "babel-plugin-react-pug-tests.tsx" + ] +} diff --git a/types/babel-plugin-react-pug/tslint.json b/types/babel-plugin-react-pug/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/babel-plugin-react-pug/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/babel-traverse/babel-traverse-tests.ts b/types/babel-traverse/babel-traverse-tests.ts index 571620fd09..1dd95060e4 100644 --- a/types/babel-traverse/babel-traverse-tests.ts +++ b/types/babel-traverse/babel-traverse-tests.ts @@ -29,7 +29,7 @@ const ast = babylon.parse(code); traverse(ast, { enter(path) { - let node = path.node; + const node = path.node; if (t.isIdentifier(node) && node.name === "n") { node.name = "x"; } @@ -85,10 +85,10 @@ const v1: Visitor = { // ... } - let id1 = path.scope.generateUidIdentifier("uid"); + const id1 = path.scope.generateUidIdentifier("uid"); id1.type; id1.name; - let id2 = path.scope.generateUidIdentifier("uid"); + const id2 = path.scope.generateUidIdentifier("uid"); id2.type; id2.name; diff --git a/types/babel-traverse/index.d.ts b/types/babel-traverse/index.d.ts index bf92ae899f..682550b161 100644 --- a/types/babel-traverse/index.d.ts +++ b/types/babel-traverse/index.d.ts @@ -8,7 +8,7 @@ import * as t from 'babel-types'; export type Node = t.Node; -export default function traverse(parent: Node | Node[], opts?: TraverseOptions, scope?: Scope, state?: any, parentPath?: NodePath): void; +export default function traverse(parent: Node | Node[], opts?: TraverseOptions, scope?: Scope, state?: any, parentPath?: NodePath): void; export interface TraverseOptions extends Visitor { scope?: Scope; @@ -16,8 +16,8 @@ export interface TraverseOptions extends Visitor { } export class Scope { - constructor(path: NodePath, parentScope?: Scope); - path: NodePath; + constructor(path: NodePath, parentScope?: Scope); + path: NodePath; block: Node; parentBlock: Node; parent: Scope; @@ -61,13 +61,13 @@ export class Scope { toArray(node: Node, i?: number): Node; - registerDeclaration(path: NodePath): void; + registerDeclaration(path: NodePath): void; buildUndefinedNode(): Node; - registerConstantViolation(path: NodePath): void; + registerConstantViolation(path: NodePath): void; - registerBinding(kind: string, path: NodePath, bindingPath?: NodePath): void; + registerBinding(kind: string, path: NodePath, bindingPath?: NodePath): void; addGlobal(node: Node): void; @@ -98,9 +98,9 @@ export class Scope { bindingIdentifierEquals(name: string, node: Node): boolean; - getBinding(name: string): Binding; + getBinding(name: string): Binding | undefined; - getOwnBinding(name: string): Binding; + getOwnBinding(name: string): Binding | undefined; getBindingIdentifier(name: string): t.Identifier; @@ -121,195 +121,200 @@ export class Scope { } export class Binding { - constructor(opts: { existing: Binding; identifier: t.Identifier; scope: Scope; path: NodePath; kind: 'var' | 'let' | 'const'; }); + constructor(opts: { existing: Binding; identifier: t.Identifier; scope: Scope; path: NodePath; kind: 'var' | 'let' | 'const'; }); identifier: t.Identifier; scope: Scope; - path: NodePath; + path: NodePath; kind: 'var' | 'let' | 'const' | 'module'; referenced: boolean; references: number; - referencePaths: Array>; + referencePaths: NodePath[]; constant: boolean; - constantViolations: Array>; + constantViolations: NodePath[]; } -export interface Visitor extends VisitNodeObject { - ArrayExpression?: VisitNode; - AssignmentExpression?: VisitNode; - LVal?: VisitNode; - Expression?: VisitNode; - BinaryExpression?: VisitNode; - Directive?: VisitNode; - DirectiveLiteral?: VisitNode; - BlockStatement?: VisitNode; - BreakStatement?: VisitNode; - Identifier?: VisitNode; - CallExpression?: VisitNode; - CatchClause?: VisitNode; - ConditionalExpression?: VisitNode; - ContinueStatement?: VisitNode; - DebuggerStatement?: VisitNode; - DoWhileStatement?: VisitNode; - Statement?: VisitNode; - EmptyStatement?: VisitNode; - ExpressionStatement?: VisitNode; - File?: VisitNode; - Program?: VisitNode; - ForInStatement?: VisitNode; - VariableDeclaration?: VisitNode; - ForStatement?: VisitNode; - FunctionDeclaration?: VisitNode; - FunctionExpression?: VisitNode; - IfStatement?: VisitNode; - LabeledStatement?: VisitNode; - StringLiteral?: VisitNode; - NumericLiteral?: VisitNode; - NullLiteral?: VisitNode; - BooleanLiteral?: VisitNode; - RegExpLiteral?: VisitNode; - LogicalExpression?: VisitNode; - MemberExpression?: VisitNode; - NewExpression?: VisitNode; - ObjectExpression?: VisitNode; - ObjectMethod?: VisitNode; - ObjectProperty?: VisitNode; - RestElement?: VisitNode; - ReturnStatement?: VisitNode; - SequenceExpression?: VisitNode; - SwitchCase?: VisitNode; - SwitchStatement?: VisitNode; - ThisExpression?: VisitNode; - ThrowStatement?: VisitNode; - TryStatement?: VisitNode; - UnaryExpression?: VisitNode; - UpdateExpression?: VisitNode; - VariableDeclarator?: VisitNode; - WhileStatement?: VisitNode; - WithStatement?: VisitNode; - AssignmentPattern?: VisitNode; - ArrayPattern?: VisitNode; - ArrowFunctionExpression?: VisitNode; - ClassBody?: VisitNode; - ClassDeclaration?: VisitNode; - ClassExpression?: VisitNode; - ExportAllDeclaration?: VisitNode; - ExportDefaultDeclaration?: VisitNode; - ExportNamedDeclaration?: VisitNode; - Declaration?: VisitNode; - ExportSpecifier?: VisitNode; - ForOfStatement?: VisitNode; - ImportDeclaration?: VisitNode; - ImportDefaultSpecifier?: VisitNode; - ImportNamespaceSpecifier?: VisitNode; - ImportSpecifier?: VisitNode; - MetaProperty?: VisitNode; - ClassMethod?: VisitNode; - ObjectPattern?: VisitNode; - SpreadElement?: VisitNode; - Super?: VisitNode; - TaggedTemplateExpression?: VisitNode; - TemplateLiteral?: VisitNode; - TemplateElement?: VisitNode; - YieldExpression?: VisitNode; - AnyTypeAnnotation?: VisitNode; - ArrayTypeAnnotation?: VisitNode; - BooleanTypeAnnotation?: VisitNode; - BooleanLiteralTypeAnnotation?: VisitNode; - NullLiteralTypeAnnotation?: VisitNode; - ClassImplements?: VisitNode; - ClassProperty?: VisitNode; - DeclareClass?: VisitNode; - DeclareFunction?: VisitNode; - DeclareInterface?: VisitNode; - DeclareModule?: VisitNode; - DeclareTypeAlias?: VisitNode; - DeclareVariable?: VisitNode; - ExistentialTypeParam?: VisitNode; - FunctionTypeAnnotation?: VisitNode; - FunctionTypeParam?: VisitNode; - GenericTypeAnnotation?: VisitNode; - InterfaceExtends?: VisitNode; - InterfaceDeclaration?: VisitNode; - IntersectionTypeAnnotation?: VisitNode; - MixedTypeAnnotation?: VisitNode; - NullableTypeAnnotation?: VisitNode; - NumericLiteralTypeAnnotation?: VisitNode; - NumberTypeAnnotation?: VisitNode; - StringLiteralTypeAnnotation?: VisitNode; - StringTypeAnnotation?: VisitNode; - ThisTypeAnnotation?: VisitNode; - TupleTypeAnnotation?: VisitNode; - TypeofTypeAnnotation?: VisitNode; - TypeAlias?: VisitNode; - TypeAnnotation?: VisitNode; - TypeCastExpression?: VisitNode; - TypeParameterDeclaration?: VisitNode; - TypeParameterInstantiation?: VisitNode; - ObjectTypeAnnotation?: VisitNode; - ObjectTypeCallProperty?: VisitNode; - ObjectTypeIndexer?: VisitNode; - ObjectTypeProperty?: VisitNode; - QualifiedTypeIdentifier?: VisitNode; - UnionTypeAnnotation?: VisitNode; - VoidTypeAnnotation?: VisitNode; - JSXAttribute?: VisitNode; - JSXIdentifier?: VisitNode; - JSXNamespacedName?: VisitNode; - JSXElement?: VisitNode; - JSXExpressionContainer?: VisitNode; - JSXClosingElement?: VisitNode; - JSXMemberExpression?: VisitNode; - JSXOpeningElement?: VisitNode; - JSXEmptyExpression?: VisitNode; - JSXSpreadAttribute?: VisitNode; - JSXText?: VisitNode; - Noop?: VisitNode; - ParenthesizedExpression?: VisitNode; - AwaitExpression?: VisitNode; - BindExpression?: VisitNode; - Decorator?: VisitNode; - DoExpression?: VisitNode; - ExportDefaultSpecifier?: VisitNode; - ExportNamespaceSpecifier?: VisitNode; - RestProperty?: VisitNode; - SpreadProperty?: VisitNode; - Binary?: VisitNode; - Scopable?: VisitNode; - BlockParent?: VisitNode; - Block?: VisitNode; - Terminatorless?: VisitNode; - CompletionStatement?: VisitNode; - Conditional?: VisitNode; - Loop?: VisitNode; - While?: VisitNode; - ExpressionWrapper?: VisitNode; - For?: VisitNode; - ForXStatement?: VisitNode; - Function?: VisitNode; - FunctionParent?: VisitNode; - Pureish?: VisitNode; - Literal?: VisitNode; - Immutable?: VisitNode; - UserWhitespacable?: VisitNode; - Method?: VisitNode; - ObjectMember?: VisitNode; - Property?: VisitNode; - UnaryLike?: VisitNode; - Pattern?: VisitNode; - Class?: VisitNode; - ModuleDeclaration?: VisitNode; - ExportDeclaration?: VisitNode; - ModuleSpecifier?: VisitNode; - Flow?: VisitNode; - FlowBaseAnnotation?: VisitNode; - FlowDeclaration?: VisitNode; - JSX?: VisitNode; - Scope?: VisitNode; +// The Visitor has to be generic because babel binds `this` for each property. +// `this` is usually used in babel plugins to pass plugin state from +// `pre` -> `visitor` -> `post`. An example of this can be seen in the official +// babel handbook: +// https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md#-pre-and-post-in-plugins +export interface Visitor extends VisitNodeObject { + ArrayExpression?: VisitNode; + AssignmentExpression?: VisitNode; + LVal?: VisitNode; + Expression?: VisitNode; + BinaryExpression?: VisitNode; + Directive?: VisitNode; + DirectiveLiteral?: VisitNode; + BlockStatement?: VisitNode; + BreakStatement?: VisitNode; + Identifier?: VisitNode; + CallExpression?: VisitNode; + CatchClause?: VisitNode; + ConditionalExpression?: VisitNode; + ContinueStatement?: VisitNode; + DebuggerStatement?: VisitNode; + DoWhileStatement?: VisitNode; + Statement?: VisitNode; + EmptyStatement?: VisitNode; + ExpressionStatement?: VisitNode; + File?: VisitNode; + Program?: VisitNode; + ForInStatement?: VisitNode; + VariableDeclaration?: VisitNode; + ForStatement?: VisitNode; + FunctionDeclaration?: VisitNode; + FunctionExpression?: VisitNode; + IfStatement?: VisitNode; + LabeledStatement?: VisitNode; + StringLiteral?: VisitNode; + NumericLiteral?: VisitNode; + NullLiteral?: VisitNode; + BooleanLiteral?: VisitNode; + RegExpLiteral?: VisitNode; + LogicalExpression?: VisitNode; + MemberExpression?: VisitNode; + NewExpression?: VisitNode; + ObjectExpression?: VisitNode; + ObjectMethod?: VisitNode; + ObjectProperty?: VisitNode; + RestElement?: VisitNode; + ReturnStatement?: VisitNode; + SequenceExpression?: VisitNode; + SwitchCase?: VisitNode; + SwitchStatement?: VisitNode; + ThisExpression?: VisitNode; + ThrowStatement?: VisitNode; + TryStatement?: VisitNode; + UnaryExpression?: VisitNode; + UpdateExpression?: VisitNode; + VariableDeclarator?: VisitNode; + WhileStatement?: VisitNode; + WithStatement?: VisitNode; + AssignmentPattern?: VisitNode; + ArrayPattern?: VisitNode; + ArrowFunctionExpression?: VisitNode; + ClassBody?: VisitNode; + ClassDeclaration?: VisitNode; + ClassExpression?: VisitNode; + ExportAllDeclaration?: VisitNode; + ExportDefaultDeclaration?: VisitNode; + ExportNamedDeclaration?: VisitNode; + Declaration?: VisitNode; + ExportSpecifier?: VisitNode; + ForOfStatement?: VisitNode; + ImportDeclaration?: VisitNode; + ImportDefaultSpecifier?: VisitNode; + ImportNamespaceSpecifier?: VisitNode; + ImportSpecifier?: VisitNode; + MetaProperty?: VisitNode; + ClassMethod?: VisitNode; + ObjectPattern?: VisitNode; + SpreadElement?: VisitNode; + Super?: VisitNode; + TaggedTemplateExpression?: VisitNode; + TemplateLiteral?: VisitNode; + TemplateElement?: VisitNode; + YieldExpression?: VisitNode; + AnyTypeAnnotation?: VisitNode; + ArrayTypeAnnotation?: VisitNode; + BooleanTypeAnnotation?: VisitNode; + BooleanLiteralTypeAnnotation?: VisitNode; + NullLiteralTypeAnnotation?: VisitNode; + ClassImplements?: VisitNode; + ClassProperty?: VisitNode; + DeclareClass?: VisitNode; + DeclareFunction?: VisitNode; + DeclareInterface?: VisitNode; + DeclareModule?: VisitNode; + DeclareTypeAlias?: VisitNode; + DeclareVariable?: VisitNode; + ExistentialTypeParam?: VisitNode; + FunctionTypeAnnotation?: VisitNode; + FunctionTypeParam?: VisitNode; + GenericTypeAnnotation?: VisitNode; + InterfaceExtends?: VisitNode; + InterfaceDeclaration?: VisitNode; + IntersectionTypeAnnotation?: VisitNode; + MixedTypeAnnotation?: VisitNode; + NullableTypeAnnotation?: VisitNode; + NumericLiteralTypeAnnotation?: VisitNode; + NumberTypeAnnotation?: VisitNode; + StringLiteralTypeAnnotation?: VisitNode; + StringTypeAnnotation?: VisitNode; + ThisTypeAnnotation?: VisitNode; + TupleTypeAnnotation?: VisitNode; + TypeofTypeAnnotation?: VisitNode; + TypeAlias?: VisitNode; + TypeAnnotation?: VisitNode; + TypeCastExpression?: VisitNode; + TypeParameterDeclaration?: VisitNode; + TypeParameterInstantiation?: VisitNode; + ObjectTypeAnnotation?: VisitNode; + ObjectTypeCallProperty?: VisitNode; + ObjectTypeIndexer?: VisitNode; + ObjectTypeProperty?: VisitNode; + QualifiedTypeIdentifier?: VisitNode; + UnionTypeAnnotation?: VisitNode; + VoidTypeAnnotation?: VisitNode; + JSXAttribute?: VisitNode; + JSXIdentifier?: VisitNode; + JSXNamespacedName?: VisitNode; + JSXElement?: VisitNode; + JSXExpressionContainer?: VisitNode; + JSXClosingElement?: VisitNode; + JSXMemberExpression?: VisitNode; + JSXOpeningElement?: VisitNode; + JSXEmptyExpression?: VisitNode; + JSXSpreadAttribute?: VisitNode; + JSXText?: VisitNode; + Noop?: VisitNode; + ParenthesizedExpression?: VisitNode; + AwaitExpression?: VisitNode; + BindExpression?: VisitNode; + Decorator?: VisitNode; + DoExpression?: VisitNode; + ExportDefaultSpecifier?: VisitNode; + ExportNamespaceSpecifier?: VisitNode; + RestProperty?: VisitNode; + SpreadProperty?: VisitNode; + Binary?: VisitNode; + Scopable?: VisitNode; + BlockParent?: VisitNode; + Block?: VisitNode; + Terminatorless?: VisitNode; + CompletionStatement?: VisitNode; + Conditional?: VisitNode; + Loop?: VisitNode; + While?: VisitNode; + ExpressionWrapper?: VisitNode; + For?: VisitNode; + ForXStatement?: VisitNode; + Function?: VisitNode; + FunctionParent?: VisitNode; + Pureish?: VisitNode; + Literal?: VisitNode; + Immutable?: VisitNode; + UserWhitespacable?: VisitNode; + Method?: VisitNode; + ObjectMember?: VisitNode; + Property?: VisitNode; + UnaryLike?: VisitNode; + Pattern?: VisitNode; + Class?: VisitNode; + ModuleDeclaration?: VisitNode; + ExportDeclaration?: VisitNode; + ModuleSpecifier?: VisitNode; + Flow?: VisitNode; + FlowBaseAnnotation?: VisitNode; + FlowDeclaration?: VisitNode; + JSX?: VisitNode; + Scope?: VisitNode; } -export type VisitNode = VisitNodeFunction | VisitNodeObject; +export type VisitNode = VisitNodeFunction | VisitNodeObject; -export type VisitNodeFunction = (path: NodePath, state: any) => void; +export type VisitNodeFunction = (this: T, path: NodePath

      , state: any) => void; export interface VisitNodeObject { enter?(path: NodePath, state: any): void; @@ -328,7 +333,7 @@ export class NodePath { state: any; opts: object; skipKeys: object; - parentPath: NodePath; + parentPath: NodePath; context: TraversalContext; container: object | object[]; listKey: string; @@ -362,15 +367,15 @@ export class NodePath { * Call the provided `callback` with the `NodePath`s of all the parents. * When the `callback` returns a truthy value, we return that node path. */ - findParent(callback: (path: NodePath) => boolean): NodePath; + findParent(callback: (path: NodePath) => boolean): NodePath; - find(callback: (path: NodePath) => boolean): NodePath; + find(callback: (path: NodePath) => boolean): NodePath; /** Get the parent function of the current path. */ - getFunctionParent(): NodePath; + getFunctionParent(): NodePath; /** Walk up the tree until we hit a parent node path in a list. */ - getStatementParent(): NodePath; + getStatementParent(): NodePath; /** * Get the deepest common ancestor and then from it, get the earliest relationship path @@ -379,20 +384,20 @@ export class NodePath { * Earliest is defined as being "before" all the other nodes in terms of list container * position and visiting key. */ - getEarliestCommonAncestorFrom(paths: Array>): Array>; + getEarliestCommonAncestorFrom(paths: NodePath[]): NodePath[]; /** Get the earliest path in the tree where the provided `paths` intersect. */ getDeepestCommonAncestorFrom( - paths: Array>, - filter?: (deepest: Node, i: number, ancestries: Array>) => NodePath - ): NodePath; + paths: NodePath[], + filter?: (deepest: Node, i: number, ancestries: NodePath[]) => NodePath + ): NodePath; /** * Build an array of node paths containing the entire ancestry of the current node path. * * NOTE: The current node path is included in this. */ - getAncestry(): Array>; + getAncestry(): NodePath[]; inType(...candidateTypes: string[]): boolean; @@ -404,7 +409,7 @@ export class NodePath { couldBeBaseType(name: string): boolean; - baseTypeStrictlyMatches(right: NodePath): boolean; + baseTypeStrictlyMatches(right: NodePath): boolean; isGenericType(genericName: string): boolean; @@ -428,7 +433,7 @@ export class NodePath { replaceWithSourceString(replacement: any): void; /** Replace the current node with another. */ - replaceWith(replacement: Node | NodePath): void; + replaceWith(replacement: Node | NodePath): void; /** * This method takes an array of statements nodes and then explodes it @@ -573,13 +578,13 @@ export class NodePath { hoist(scope: Scope): void; // ------------------------- family ------------------------- - getOpposite(): NodePath; + getOpposite(): NodePath; - getCompletionRecords(): Array>; + getCompletionRecords(): NodePath[]; - getSibling(key: string): NodePath; + getSibling(key: string): NodePath; - get(key: string, context?: boolean | TraversalContext): NodePath; + get(key: string, context?: boolean | TraversalContext): NodePath; getBindingIdentifiers(duplicates?: boolean): Node[]; @@ -960,7 +965,7 @@ export class Hub { } export interface TraversalContext { - parentPath: NodePath; + parentPath: NodePath; scope: Scope; state: any; opts: any; diff --git a/types/babel-types/babel-types-tests.ts b/types/babel-types/babel-types-tests.ts index 0ef79f39f4..af8ab2d0b7 100644 --- a/types/babel-types/babel-types-tests.ts +++ b/types/babel-types/babel-types-tests.ts @@ -2,11 +2,11 @@ import traverse from "babel-traverse"; import * as t from "babel-types"; -let ast: t.Node; +declare const ast: t.Node; traverse(ast, { enter(path) { - let node = path.node; + const node = path.node; if (t.isIdentifier(node, { name: "n" })) { node.name = "x"; } @@ -31,7 +31,7 @@ const exp: t.Expression = t.nullLiteral(); // https://github.com/babel/babel/blob/4e50b2d9d9c376cee7a2cbf56553fe5b982ea53c/packages/babel-plugin-transform-react-inline-elements/src/index.js#L61 traverse(ast, { JSXElement(path, file) { - const { node } = path; + const { node } = path; const open = node.openingElement; // init diff --git a/types/babylon/babylon-tests.ts b/types/babylon/babylon-tests.ts index d844b9a8f7..2a5ddfcb57 100644 --- a/types/babylon/babylon-tests.ts +++ b/types/babylon/babylon-tests.ts @@ -6,7 +6,7 @@ const code = `function square(n) { return n * n; }`; -let node = babylon.parse(code); +const node = babylon.parse(code); assert(node.type === "File"); assert(node.start === 0); assert(node.end === 38); diff --git a/types/backbone-associations/index.d.ts b/types/backbone-associations/index.d.ts index 9d0aa36614..d0681c6651 100644 --- a/types/backbone-associations/index.d.ts +++ b/types/backbone-associations/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Backbone-associations 0.6.4 // Project: https://github.com/dhruvaray/backbone-associations/ -// Definitions by: Craig Brett +// Definitions by: Craig Brett // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -25,14 +25,14 @@ declare module 'backbone' { interface IRelation { /** The type of model for this relationship */ - relatedModel: string|typeof Backbone.Associations.AssociatedModel; + relatedModel: string | (new() => AssociatedModel); /** The key for this relationship on this model */ key: string; // meh, no string enums in TS. Just have to trust the user not to be a fool /** The cardinality of this relationship. */ type: string; /** Determines the type of collection used. If used, the relatedModel property is ignored */ - collectionType?: typeof Backbone.Collection|string; + collectionType?: string | (new() => Backbone.Collection); /** If set to true, then the attribute will not be serialized in toJSON() calls. Defaults to false */ isTransient?: boolean; /** Specify remoteKey to serialize the key to a different key name in toJSON() calls. Useful in ROR nested-attributes like scenarios. */ diff --git a/types/backbone-fetch-cache/index.d.ts b/types/backbone-fetch-cache/index.d.ts index c5e8d84426..e5e6ebf751 100644 --- a/types/backbone-fetch-cache/index.d.ts +++ b/types/backbone-fetch-cache/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for backbone-fetch-cache 1.4.0 // Project: https://github.com/madglory/backbone-fetch-cache -// Definitions by: delphinus +// Definitions by: delphinus // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/backbone-relational/index.d.ts b/types/backbone-relational/index.d.ts index b51c46f1d7..a1c8c3eefb 100644 --- a/types/backbone-relational/index.d.ts +++ b/types/backbone-relational/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Backbone-relational 0.8.5 // Project: http://backbonerelational.org/ -// Definitions by: Eirik Hoem +// Definitions by: Eirik Hoem // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/backbone.layoutmanager/index.d.ts b/types/backbone.layoutmanager/index.d.ts index f4eb340e7c..7e35de1192 100644 --- a/types/backbone.layoutmanager/index.d.ts +++ b/types/backbone.layoutmanager/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Backbone.LayoutManager 0.9.5 // Project: http://layoutmanager.org/ -// Definitions by: He Jiang +// Definitions by: He Jiang // Definitions: https://github.com/hejiang2000/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/backbone.localstorage/index.d.ts b/types/backbone.localstorage/index.d.ts index 9fd089cdec..94bb53c65a 100644 --- a/types/backbone.localstorage/index.d.ts +++ b/types/backbone.localstorage/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for backbone.localStorage 1.0.0 // Project: https://github.com/jeromegn/Backbone.localStorage -// Definitions by: Louis Grignon +// Definitions by: Louis Grignon // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/backbone.marionette/backbone.marionette-tests.ts b/types/backbone.marionette/backbone.marionette-tests.ts index a7da55495b..23a037d49c 100644 --- a/types/backbone.marionette/backbone.marionette-tests.ts +++ b/types/backbone.marionette/backbone.marionette-tests.ts @@ -6,12 +6,12 @@ class DestroyWarn extends Marionette.Behavior { // just like you can in your Backbone Models // they will be overriden if you pass in an option with the same key defaults = { - "message": "you are destroying!" + message: 'you are destroying!' }; // behaviors have events that are bound to the views DOM events = { - "click @ui.destroy": "warnBeforeDestroy" + 'click @ui.destroy': 'warnBeforeDestroy' }; warnBeforeDestroy() { @@ -22,34 +22,32 @@ class DestroyWarn extends Marionette.Behavior { } } - Marionette.Behaviors.getBehaviorClass = (options, key) => { - if (key === "DestroyWarn") + if (key === 'DestroyWarn') return DestroyWarn; return undefined; }; class MyRouter extends Marionette.AppRouter { - // "someMethod" must exist at controller.someMethod + // 'someMethod' must exist at controller.someMethod appRoutes = { - "some/route": "someMethod" + 'some/route': 'someMethod' }; /* standard routes can be mixed with appRoutes/Controllers above */ routes = { - "some/otherRoute": "someOtherMethod" + 'some/otherRoute': 'someOtherMethod' }; someOtherMethod() { // do something here. } - } class MyApplication extends Marionette.Application { initialize(options?: any) { - console.log("initializing application"); + console.log('initializing application'); this.layoutView = new AppLayoutView(); } @@ -60,12 +58,16 @@ class MyApplication extends Marionette.Application { this.mainRegion = new Marionette.Region({ el: '#main' }); this.layoutView.addRegion('main', this.mainRegion); this.layoutView.render(); - this.layoutView.showChildView('main', new MyView(new MyModel)); + this.layoutView.showChildView('main', new MyView(new MyModel())); let view: Backbone.View = this.layoutView.getChildView('main'); let regions: {[key: string]: Marionette.Region} = this.layoutView.getRegions(); - let prefix: string = this.layoutView.childViewEventPrefix; let region: Marionette.Region = this.layoutView.removeRegion('main'); let layout: Marionette.View = this.layoutView.destroy(); + + let prefix: string; + if (typeof this.layoutView.childViewEventPrefix === 'string') { + this.layoutView.childViewEventPrefix; + } } } @@ -75,16 +77,15 @@ class AppLayoutView extends Marionette.View { } template() { - return "

      "; + return '
      '; } initialize(options?: any) { - console.log("initializing layoutview"); + console.log('initializing layoutview'); } } class MyModel extends Backbone.Model { - constructor(options?: any) { super(options); } @@ -99,22 +100,20 @@ class MyModel extends Backbone.Model { } class MyBaseView extends Marionette.View { - constructor() { - super(); - this.getOption('foo'); - this.triggers = { - 'click .foo': 'bar' - }; + super(); + this.getOption('foo'); + this.triggers = { + 'click .foo': 'bar' + }; } - } class MyView extends Marionette.View { behaviors: any; constructor(model: MyModel) { - super({ model: model }); + super({ model }); this.ui = { destroy: '.destroy' @@ -130,8 +129,7 @@ class MyView extends Marionette.View { template() { return '

      ' + this.model.getName() + '

      '; } -}; - +} class MainRegion extends Marionette.Region { constructor() { @@ -140,7 +138,6 @@ class MainRegion extends Marionette.Region { } } - class MyObject extends Marionette.Object { name: string; options: any; @@ -153,13 +150,13 @@ class MyObject extends Marionette.Object { name: 'Foo' }; - this.on("before:destroy", () => { - console.log("before:destroy"); + this.on('before:destroy', () => { + console.log('before:destroy'); }); } onBeforeDestroy(arg: any) { - console.log("in onBeforeDestroy with arg " + arg); + console.log('in onBeforeDestroy with arg ' + arg); } } @@ -180,7 +177,7 @@ class MyJQueryRegion extends Marionette.Region { class MyHtmlElRegion extends Marionette.Region { constructor() { super(); - this.el = document.querySelector("body"); + this.el = document.querySelector('body'); } } @@ -189,77 +186,48 @@ class MyCollectionView extends Marionette.CollectionView { super(); this.childView = MyView; this.childViewEvents = { - render: function () { - console.log("a childView has been rendered"); + render() { + console.log('a childView has been rendered'); } }; - this.childViewOptions = function (model: any, index: any): any { + this.childViewOptions = (model: any, index: any): any => { // do some calculations based on the model return { - foo: "bar", - childIndex: index - } + id: 'bar' + }; }; this.childViewOptions = { - foo: "bar" + id: 'bar' }; - this.childViewEventPrefix = "some:prefix"; - - this.on('some:prefix:render', function () { + this.childViewEventPrefix = 'some:prefix'; + this.on('some:prefix:render', () => { }); - } } -var app: MyApplication; +let app: MyApplication; function ApplicationTests() { app = new MyApplication(); app.start(); - var view = new MyView(new MyModel()); + let view = new MyView(new MyModel()); app.mainRegion.show(view); } function ObjectTests() { - var obj = new MyObject(); + let obj = new MyObject(); console.log(obj.getOption('name')); - obj.destroy("goodbye"); -} - -function RegionManagerTests() { - var rm = new Marionette.RegionManager(); - rm.addRegions({ - contentRegion: { - el: '#content', - regionClass: MainRegion - }, - - navigationRegion: { - el: '#navigation', - regionClass: MainRegion, - - // Options passed to instance of `MyOtherRegion` for - // the `navigationRegion` on `App` - navigationOption: 42, - anotherNavigationOption: 'foo' - }, - - footerRegion: { - regionClass: MainRegion, - someOption: 42, - someValue: 'value' - } - }); + obj.destroy('goodbye'); } function RegionTests() { - var myView: Marionette.View = new MyView(new MyModel()); + let myView: Marionette.View = new MyView(new MyModel()); // render and display the view app.mainRegion.show(myView); @@ -268,28 +236,27 @@ function RegionTests() { app.mainRegion.empty(); myView = new MyView(new MyModel()); - app.mainRegion.show(myView, { preventDestroy: true, forceShow: true, triggerAttach: true, triggerBeforeAttach: false }); + app.mainRegion.show(myView, { preventDestroy: true }); - var hasView: boolean = app.mainRegion.hasView(); + let hasView: boolean = app.mainRegion.hasView(); app.mainRegion.reset(); - Marionette.Region.prototype.attachHtml = function (view: any): void { + Marionette.Region.prototype.attachHtml = (view: any): void => { this.$el.empty().append(view.el); - } + }; myView = new Marionette.View({ - el: $("#existing-view-stuff") + el: $('#existing-view-stuff') }); - app.mainRegion.attachView(myView); + app.mainRegion.show(myView); - app.mainRegion.on("empty", function (view: any, region: any, options: any) { + app.mainRegion.on('empty', (view: any, region: any, options: any) => { // manipulate the `view` or do something extra // with the `region` // you also have access to the `options` that were passed to the Region.show call }); - } function ViewTests() { @@ -301,29 +268,27 @@ function ViewTests() { } function CollectionViewTests() { - var cv = new MyCollectionView(); + let cv = new MyCollectionView(); cv.collection.add(new MyModel()); - app.mainRegion.attachView(cv); - cv.addEmptyView(new MyModel, MyView); - cv.proxyChildEvents(new MyView(new MyModel)); - let children: Backbone.ChildViewContainer> = cv.destroyChildren(); - let view: Marionette.CollectionView> = cv.destroy(); + app.mainRegion.show(cv); + cv.emptyView = MyView; + let view: Marionette.CollectionView = cv.destroy(); } -class MyController extends Marionette.Controller { +class MyController { + doFoo() { } + doBar() { } } function AppRouterTests() { - var myController = new MyController(); - var router = new MyRouter(); + let myController = new MyController(); + let router = new MyRouter(); - router.appRoute("/foo", "fooThat"); + router.appRoute('/foo', 'fooThat'); router.processAppRoutes(myController, { - "foo": "doFoo", - "bar/:id": "doBar" + foo: 'doFoo', + 'bar/:id': 'doBar' }); - } - diff --git a/types/backbone.marionette/index.d.ts b/types/backbone.marionette/index.d.ts index ad623aa078..5292a4bfe7 100644 --- a/types/backbone.marionette/index.d.ts +++ b/types/backbone.marionette/index.d.ts @@ -1,131 +1,199 @@ -// Type definitions for Marionette +// Type definitions for Marionette 3.3 // Project: https://github.com/marionettejs/ // Definitions by: Zeeshan Hamid , Natan Vivo , Sven Tschui // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 import * as Backbone from 'backbone'; +import * as JQuery from 'jquery'; import * as Radio from 'backbone.radio'; export as namespace Marionette; export = Marionette; -// declarations for Backbone.BabySitter and Backbone.Wreqr, different projects but included in MarionetteJS -declare module 'backbone' { - // Backbone.BabySitter - class ChildViewContainer> { +// These mixins mirror Marionette source and ensure that Marionette classes that +// extend these mixins have the correct methods attached. +interface CommonMixin { + normalizeMethods: any; + mergeOptions: any; + getOption: any; + bindEvents: any; + unbindEvents: any; +} - constructor(initialViews?: any[]); +interface RadioMixinOptions { + /** + * Defines the Radio channel that will be used for the requests and/or + * events. + */ + channelName?: string; - add(view: TView, customIndex?: number): void; - findByModel(model: TModel): TView; - findByModelCid(modelCid: string): TView; - findByCustom(index: number): TView; - findByIndex(index: number): TView; - findByCid(cid: string): TView; - remove(view: TView): void; + /** + * Defines an events hash with the events to be listened and its respective + * handlers. + */ + radioEvents?: any; - //mixins from Collection (copied from Backbone's Collection declaration) + /** + * Defines an events hash with the requests to be replied and its respective + * handlers + */ + radioRequests?: any; +} - all(iterator: (element: TView, index: number) => boolean, context?: any): boolean; - any(iterator: (element: TView, index: number) => boolean, context?: any): boolean; - contains(value: any): boolean; - detect(iterator: (item: any) => boolean, context?: any): any; - each(iterator: (element: TView, index: number, list?: any) => void, context?: any): any; - every(iterator: (element: TView, index: number) => boolean, context?: any): boolean; - filter(iterator: (element: TView, index: number) => boolean, context?: any): TView[]; - find(iterator: (element: TView, index: number) => boolean, context?: any): TView; - first(): TView; - forEach(iterator: (element: TView, index: number, list?: any) => void, context?: any): void; - include(value: any): boolean; - initial(): TView; - initial(n: number): TView[]; - invoke(methodName: string, args?: any[]): any; - isEmpty(object: any): boolean; - last(): TView; - last(n: number): TView[]; - lastIndexOf(element: TView, fromIndex?: number): number; - map(iterator: (element: TView, index: number, context?: any) => U, context?: any): U[]; - pluck(attribute: string): any[]; - reject(iterator: (element: TView, index: number) => boolean, context?: any): TView[]; - rest(): TView; - rest(n: number): TView[]; - select(iterator: any, context?: any): any[]; - some(iterator: (element: TView, index: number) => boolean, context?: any): boolean; - toArray(): any[]; - without(...values: any[]): TView[]; - } +interface RadioMixin { + getChannel: any; + bindEvents: any; + unbindEvents: any; + bindRequests: any; + unbindRequests: any; +} - // Backbone.Wreqr - namespace Wreqr { +interface DomMixin { + createBuffer: any; + appendChildren: any; + beforeEl: any; + replaceEl: any; + detachContents: any; + setInnerContent: any; + detachEl: any; + removeEl: any; + findEls: any; +} - namespace radio { +interface ViewMixinOptions { + /** + * Behavior objects to assign to this View. + */ + behaviors?: Marionette.Behavior[]; - function channel(channelName: string): Channel; + /** + * Customize the event prefix for events that are forwarded through the + * collection view. + */ + childViewEventPrefix?: string | false; - } + /** + * Use the childViewEvents attribute to map child events to methods on the + * parent view. + */ + childViewEvents?: Marionette.EventsHash; - class Channel { + /** + * A childViewTriggers hash or method permits proxying of child view events + * without manually setting bindings. The values of the hash should be a + * string of the event to trigger on the parent. + */ + childViewTriggers?: Marionette.EventsHash; - constructor(channelName: string); + /** + * Bind to events that occur on attached collections. + */ + collectionEvents?: Marionette.EventsHash; - vent: Backbone.Wreqr.EventAggregator; - reqres: Backbone.Wreqr.RequestResponse; - commands: Backbone.Wreqr.Commands; - channelName: string; + /** + * Bind to events that occur on attached models. + */ + modelEvents?: Marionette.EventsHash; - reset(): Channel; - connectEvents(hash: string, context: any): Channel; - connectCommands(hash: string, context: any): Channel; - connectRequests(hash: string, context: any): Channel; + /** + * The view triggers attribute binds DOM events to Marionette View events + * that can be responded to at the view or parent level. + */ + triggers?: Marionette.EventsHash; - } + /** + * Name parts of your template to be used + * throughout the view with the ui attribute. + */ + ui?: any; +} - class Handlers extends Backbone.Events { +interface ViewMixin extends DomMixin, CommonMixin { + supportsRenderLifecycle: any; + supportsDestroyLifecycle: any; + isDestroyed: any; + isRendered: any; + isAttached: any; + delegateEvents: any; + getTriggers: any; + delegateEntityEvents: any; + undelegateEntityEvents: any; + destroy: any; + bindUIElements: any; + unbindUIElements: any; + childViewEventPrefix: any; + triggerMethod: any; +} - constructor(options?: any); +interface RegionsMixin { + regionClass: any; + addRegion: any; + addRegions: any; + removeRegion: any; + removeRegions: any; + emptyRegions: any; + hasRegion: any; + getRegion: any; + getRegions: any; + showChildView: any; + detachChildView: any; + getChildView: any; +} - options: any; +declare class Container { + /** + * Find a view by it's cid. + */ + findByCid(cid: string): TView; - setHandler(name: string, handler: any, context?: any): void; - hasHandler(name: string): boolean; - getHandler(name: string): Function; - removeHandler(name: string): void; - removeAllHandlers(): void; - } + /** + * Find a view by model. + */ + findByModel(model: TModel): TView; - class CommandStorage { + /** + * Find a view by model cid. + */ + findByModelCid(modelCid: string): TView; - constructor(options?: any); + /** + * Find by custom key. + */ + findByCustom(key: string): TView; - getCommands(commandName: string): Commands; - addCommand(commandName: string, args: any): void; - clearCommands(commandName: string): void; - } + /** + * Find by numeric index (unstable). + */ + findByIndex(index: number): TView; - class Commands extends Handlers { + /** + * Find a view by it's cid. + */ + add(view: TView, customIndex?: number): void; - constructor(options?: any); - - storageType: CommandStorage; - execute(name: string, ...args: any[]): void; - } - - class RequestResponse extends Handlers { - - constructor(options?: any); - - request(...args: any[]): any; - } - - class EventAggregator extends Backbone.Events { - - constructor(options?: any); - } - } + /** + * Find a view by it's cid. + */ + remove(view: TView): void; } declare namespace Marionette { + /** + * Alias of Backbones extend function. + */ + function extend(properties: any, classProperties?: any): any; + + /** + * Determines whether the passed-in node is a child of the document or not. + */ + function isNodeAttached(el: HTMLElement): boolean; + + /** + * A handy function to pluck certain options and attach them directly to an + * instance. + */ + function mergeOptions(target: any, options: any, keys: any): void; /** * Retrieve an object's attribute either directly from the object, or @@ -139,7 +207,7 @@ declare namespace Marionette { * to both the event and the method, with the exception of the event name not * being passed to the corresponding method. */ - function triggerMethod(name: string, ...args: any[]): any; + function triggerMethod(target: any, name: string, ...args: any[]): any; /** * Invoke triggerMethod on a specific context. @@ -147,50 +215,126 @@ declare namespace Marionette { */ function triggerMethodOn(ctx: any, name: string, ...args: any[]): any; - /** - * Monitor a view's state, and after it has been rendered and shown in the DOM, - * trigger a "dom:refresh" event every time it is re-rendered. - */ - function MonitorDOMRefresh(view: Backbone.View): void; - /** * This method is used to bind a backbone "entity" (collection/model) to methods on a target object. * @param target An object that must have a listenTo method from the EventBinder object. * @param entity The entity (Backbone.Model or Backbone.Collection) to bind the events from. * @param bindings a hash of { "event:name": "eventHandler" } configuration. Multiple handlers can be separated by a space. A function can be supplied instead of a string handler name. */ - function bindEntityEvents(target: any, entity: any, bindings: any): void; + function bindEvents(target: any, entity: any, bindings: any): void; /** - * This method can be used to unbind callbacks from entities' (collection/model) events. It's the opposite of bindEntityEvents + * This method can be used to unbind callbacks from entities' (collection/model) events. It's the opposite of bindEvents * @param target An object that must have a listenTo method from the EventBinder object. * @param entity The entity (Backbone.Model or Backbone.Collection) to bind the events from. * @param bindings a hash of { "event:name": "eventHandler" } configuration. Multiple handlers can be separated by a space. A function can be supplied instead of a string handler name. */ - function unbindEntityEvents(target: any, entity: any, bindings: any): void; + function unbindEvents(target: any, entity: any, bindings: any): void; - class Callbacks { - add(callback: Function, contextOverride: any): void; - run(options: any, context: any): void; - reset(): void; + /** + * This method is used to bind a radio requests to methods on a target + * object. + */ + function bindRequests(target: any, channel: Radio.Channel, bindings: any): void; + + /** + * This method is used to unbind a radio requests to methods on a target + * object. + */ + function unbindRequests(target: any, channel: Radio.Channel, bindings: any): void; + + /** + * Receives a hash of event names and functions and/or function names, and + * returns the same hash with the function names replaced with the function + * references themselves. + */ + function normalizeMethods(target: any, hash: any): T; + + /** + * Allows you to run multiple instances of Marionette in the same + * application. + */ + function noConflict(): void; + + /** + * Overrides Backbone.EventsHash as JQueryEventObject is deprecated and + * doesn't allow you to set the event target + */ + interface EventsHash extends Backbone.EventsHash { + [selector: string]: string | ((eventObject: JQuery.Event) => void); + } + + interface ObjectOptions extends RadioMixinOptions { + /** + * Initialize is called immediately after the Object has been instantiated, + * and is invoked with the same arguments that the constructor received. + */ + initialize?(options?: ObjectOptions): void; + + [index: string]: any; } /** * A base class which other classes can extend from. Object incorporates many * backbone conventions and utilities like initialize and Backbone.Events. */ - class Object extends Backbone.Events { + class Object extends Backbone.Events implements CommonMixin, RadioMixin { + constructor(options?: ObjectOptions); /** - * Defines the Radio channel that will be used for the requests and/or events + * Receives a hash of event names and functions and/or function names, + * and returns the same hash with the function names replaced with the + * function references themselves. */ - channelName: string; + normalizeMethods(hash: any): T; + + /** + * A handy function to pluck certain options and attach them directly + * to an instance. + */ + mergeOptions(options: any, keys: any): void; + + /** + * Retrieve an object's attribute either directly from the object, or from + * the object's this.options, with this.options taking precedence. + * @param optionName the name of the option to retrieve. + */ + getOption(optionName: string): any; + + /** + * This method is used to bind a backbone "entity" (collection/model) to + * methods on a target object. + */ + bindEvents(entity: any, bindings: any): void; + + /** + * This method can be used to unbind callbacks from entities' + * (collection/model) events. + */ + unbindEvents(entity: any, bindings: any): void; /** * Returns a Radio.Channel instance using 'channelName' */ getChannel(): Backbone.Radio.Channel; + /** + * This method is used to bind a radio requests to methods on a target + * object. + */ + bindRequests(channel: Radio.Channel, bindings: any): void; + + /** + * This method is used to unbind a radio requests to methods on a target + * object. + */ + unbindRequests(channel: Radio.Channel, bindings: any): void; + + /** + * Defines the Radio channel that will be used for the requests and/or events + */ + channelName: string; + /** * Defines an events hash with the events to be listened and its respective handlers */ @@ -201,18 +345,16 @@ declare namespace Marionette { */ radioRequests: any; + /** + * Check if this Oject has been destroyed. + */ + isDestroyed(): boolean; + /** * Initialize is called immediately after the Object has been instantiated, * and is invoked with the same arguments that the constructor received. */ - initialize(options?: any): void; - - /** - * Retrieve an object's attribute either directly from the object, or from - * the object's this.options, with this.options taking precedence. - * @param optionName the name of the option to retrieve. - */ - getOption(optionName: string): any; + initialize(options?: ObjectOptions): void; /** * Objects have a destroy method that unbind the events that are directly @@ -223,436 +365,92 @@ declare namespace Marionette { * onBeforeDestroy. */ destroy(...args: any[]): void; - } - - /** - * A Controller is an object used in the Marionette Router. Controllers are - * where you store your Router's callbacks. - */ - class Controller extends Backbone.Events { - /** - * @param options Options that should be stored in this options. Can be retreived via - * getOption. - */ - constructor(options?: any); /** - * Handles unbinding all of the events that are directly attached to the - * controller instance, as well as those that are bound using the - * EventBinder from the controller. - * - * Invoking the destroy method will trigger the "before:destroy" and - * "destroy" events and the corresponding onBeforeDestory and onDestroy - * method calls. These calls will be passed any arguments destroy was - * invoked with. + * Trigger an event and a corresponding method on the target object. + * All arguments that are passed to the triggerMethod call are passed + * along to both the event and the method, with the exception of the + * event name not being passed to the corresponding method. */ - destroy(...args: any[]): void; - - /** - * Retrieve an object's attribute either directly from the object, or from - * the object's this.options, with this.options taking precedence. - * @param optionName the name of the option to retrieve. - */ - getOption(optionName: string): any; - triggerMethod(name: string, ...args: any[]): any; } - interface RegionConstructionOptions { - /** - * Specifies the element for the region to manage. This may be - * a selector string, a raw DOM node reference or a jQuery wrapped - * DOM node. - */ - el?: any; - } - - interface RegionShowOptions { - /** - * If you replace the current view with a new view by calling show, by - * default it will automatically destroy the previous view. You can - * prevent this behavior by setting this option to true. - */ - preventDestroy?: boolean; - - /** - * If you re-call show with the same view, by default nothing will happen - * because the view is already in the region. You can force the view to be - * re-shown by setting this option to true. - */ - forceShow?: boolean; - - /** - * Regions that are attached to the document when you execute show are - * special in that the views that they show will also become attached - * to the document. These regions fire a pair of triggerMethods on all - * of the views that are about to be attached � even the nested ones. - * This can cause a performance issue if you're rendering hundreds or - * thousands of views at once. - * If you think these events might be causing some lag in your app, you - * can selectively turn them off with the triggerBeforeAttach - * and triggerAttach properties. - */ - triggerBeforeAttach?: boolean; - - /** - * Regions that are attached to the document when you execute show are - * special in that the views that they show will also become attached - * to the document. These regions fire a pair of triggerMethods on all - * of the views that are about to be attached � even the nested ones. - * This can cause a performance issue if you're rendering hundreds or - * thousands of views at once. - * If you think these events might be causing some lag in your app, you - * can selectively turn them off with the triggerBeforeAttach - * and triggerAttach properties. - */ - triggerAttach?: boolean; - } - - interface RegionEmptyOptions { - /** - * If you would like to prevent the view currently shown in the region - * from being destroyed you can set this option to true to prevent the - * default destroy behavior. - */ - preventDestroy?: boolean; - } - - /** - * Regions provide consistent methods to manage, show and destroy views in - * your applications and layouts. They use a jQuery selector to show your - * views in the correct place. - */ - class Region extends Marionette.Object { - - /** - * Build an instance of a region by passing in a configuration object and - * a default region class to use if none is specified in the config. - * The config object should either be a string as a jQuery DOM selector, - * a Region class directly, or an object literal that specifies a selector, - * a custom regionClass, and any options to be supplied to the region - */ - static buildRegion(regionConfig: any, defaultRegionType: any): Region; - - /** - * You can specify an el for the region to manage at the time the region - * is instantiated. - */ - constructor(options?: RegionConstructionOptions); - - /** - * Contains the element that this region should manage. - */ - el: any; - - /** - * Renders and displays the specified view in this region. - * @param view the view to display. - */ - show(view: Backbone.View, options?: RegionShowOptions): void; - - /** - * Attaches an existing view to a region, without rendering or showing the view, - * and without replacing the HTML content of the region. - */ - attachView(view: Backbone.View, options?: RegionShowOptions): any; - - /** - * Override this method to change how the new view is - * appended to the `$el` that the region is managing - */ - attachHtml(view: Backbone.View): void; - - /** - * A region can be reset at any time. This destroys any existing view - * being displayed, and deletes the cached el. The next time the region - * shows a view, the region's el is queried from the DOM. - */ - reset(): any; - - /** - * If you wish to check whether a region has a view, you can use the hasView function. This will return a boolean value depending whether or not the region is showing a view. - */ - hasView(): boolean; - - /** - * Empties the current view from the region. - */ - empty(options?: RegionEmptyOptions): any; - - /** - * @returns view that this region has. - */ - currentView: Backbone.View; - } - - interface RegionDefaults { - /** - * A selector string indicating which element to assign the region two. - */ - selector?: string; - - /** - * A selector string, a jQuery object, or an HTML node indicating which element - * the region should use. - */ - el?: any; - - /** - * A custom region class. - */ - regionClass?: any; - - /** - * Ordinarily regions enforce the presence of a backing DOM element. In - * some instances it may be desirable to allow regions to be instantiated - * and used without an element, such as when regions defined by a parent - * LayoutView class are used by only some of its subclasses. In these - * instances, the region can be defined with this option set to true, - * suppressing the missing element error and causing show calls to the - * region to be treated as no-ops. - */ - allowMissingEl?: boolean; - } - - /** - * Region managers provide a consistent way to manage a number of Marionette.Region - * objects within an application. The RegionManager is intended to be used by - * other objects, to facilitate the addition, storage, retrieval, and removal of - * regions from that object. - */ - class RegionManager extends Controller { - - /** - * Constructor. - * @param options May contain an optional `regions` option. These regions - * are passed directly into addRegions for this instance. - */ - constructor(options?: any); - - /** - * Adds one or more regions to this RegionManager instance. - * @param regionDefinitions a function returning an object literal with the region definitions. The function will - * be called with the RegionManager instance context and all the arguments passed to addRegions. - * @param defaults Specifies default options that will be applied to every region added. - * @returns an object literal with all the created regions. - */ - addRegions(regionDefinitions: Function, defaults?: RegionDefaults): any; - - /** - * Adds one or more regions to this RegionManager instance. - * @param regionDefinitions an object literal containing region names as keys and region - * definitions as values. - * @param defaults Specifies default options that will be applied to every region added. - * @returns an object literal with all the created regions. - */ - addRegions(regionDefinitions: { [regionName: string]: any }, defaults?: RegionDefaults): any; - - /** - * Adds a region to this RegionManager. - * @param name the region name. - * @param definition the region definition. This may be a selector, object literal - * with various region creation options or an instance of a region object. - */ - addRegion(name: string, definition: any): Region; - - /** - * Gets the region with the specified name from this RegionManager. - */ - get(name: string): Region; - - /** - * Removes the region with the specified name from this RegionManager. - */ - removeRegion(name: string): void; - - /** - * Removes all regions from the RegionManager. - */ - removeRegions(): void; - - /** - * Empties all regions from the RegionManager instance. - */ - emptyRegions(): void; - - /** - * Destroys the RegionManager instance entierly which both destroys and - * removes all regions from the RegionManager instance. - */ - destroy(): void; - - //mixins from Collection (copied from Backbone's Collection declaration) - - /** - * Returns true if all of the values in the list pass the predicate truth test. - * @alias every - */ - all(iterator: (element: Region, index: number) => boolean, context?: any): boolean; - - /** - * Returns true if any of the values in the list pass the predicate truth test. Short-circuits and stops traversing the list if a true element is found. - */ - any(iterator: (element: Region, index: number) => boolean, context?: any): boolean; - - /** - * Returns true if the value is present in the list. - * @alias include - */ - contains(value: any): boolean; - - /** - * Looks through each value in the list, returning the first one that passes a truth test (predicate), or undefined if no value passes the test.The function returns as soon as it finds an acceptable element, and doesn't traverse the entire list. - * @alias find - */ - detect(iterator: (item: any) => boolean, context?: any): any; - - /** - * Iterates over the regions in this instance, yielding each in turn to an - * iterator function. The iterator is bound to the context object, if one - * is passed. - * @alias forEach - */ - each(iterator: (element: Region, index: number, list?: any) => void, context?: any): void; - - /** - * Returns true if all of the values in the list pass the predicate truth test. - * @alias all - */ - every(iterator: (element: Region, index: number) => boolean, context?: any): boolean; - - /** - * Looks through each Region in the collection, returning an array of all - * the values that pass a truth test (predicate). - * @alias select - */ - filter(iterator: (element: Region, index: number) => boolean, context?: any): Region[]; - - /** - * Looks through each Region in this instance, returning the first one that passes a truth test (predicate), or undefined if no value passes the test.The function returns as soon as it finds an acceptable element, and doesn't traverse the entire list. - * @alias detect - */ - find(iterator: (element: Region, index: number) => boolean, context?: any): Region; - - /** - * Returns the first Region of this RegionManager. - */ - first(): Region; - - /** - * Returns the first n Regions of this RegionManager. - */ - first(n: number): Region[]; - - /** - * Iterates over the regions in this instance, yielding each in turn to an - * iterator function. The iterator is bound to the context object, if one - * is passed. - * @alias each - */ - forEach(iterator: (element: Region, index: number, list?: any) => void, context?: any): void; - - /** - * Returns true if the value is present in the list. - * @alias contains - */ - include(value: any): boolean; - - /** - * Returns everything but the last n Regions of this instance. - * @param n if specified determines the number of regions to exclude, - * otherwise only the last element is excluded. - */ - initial(n: number): Region[]; - - /** - * Calls the method named by methodName on each value in the collection. Any extra - * arguments passed to invoke will be forwarded on to the method invocation. - */ - invoke(methodName: string, args?: any[]): any; - - /** - * Returns true if the RegionManager contains no regions. - */ - isEmpty(object: any): boolean; - - /** - * Returns the last element of a collection. - */ - last(): Region; - - /** - * Returns the last n elements of the collection. - */ - last(n: number): Region[]; - - /** - * Returns the index of the last occurrence of element in the collection, or -1 if - * element is not present. - * @param fromIndex if specified starts the search at the given index. - */ - lastIndexOf(element: Region, fromIndex?: number): number; - - /** - * Produces a new array of values by mapping each value in the collection through a - * transformation function (iterator). - * @alias collect - */ - map(iterator: (element: Region, index: number, context?: any) => any[], context?: any): any[]; - - /** - * Pluck an attribute from each model in the collection. Equivalent to - * calling map and returning a single attribute from the iterator. - */ - pluck(attribute: string): any[]; - - /** - * Returns the values in the collection without the elements that the truth test - * (predicate) passes. The opposite of filter. - */ - reject(iterator: (element: Region, index: number) => boolean, context?: any): Region[]; - - /** - * Returns the rest of the elements of the collection. - * Pass an index to return the values of the array from that index onward. If not - * specified the first item in the collection is dropped. - * @alias tail, drop - */ - rest(n: number): Region[]; - - /** - * Looks through each value in the collection, returning an array of all - * the values that pass a truth test (predicate). - * @alias filter - */ - select(iterator: any, context?: any): Region[]; - - /** - * Returns true if any of the values in the list pass the predicate truth test. Short-circuits and stops traversing the list if a true element is found. - * @alias any - */ - some(iterator: (element: Region, index: number) => boolean, context?: any): boolean; - - /** - * Creates an array containing the regions in this instance. - */ - toArray(): Region[]; - - /** - * Returns an array of all the regions in the RegionManager except the ones specified. - */ - without(...values: any[]): Region[]; - } - /** * The TemplateCache provides a cache for retrieving templates from script blocks * in your HTML. This will improve the speed of subsequent calls to get a template. */ - class TemplateCache { + class TemplateCache implements DomMixin { /** - * To use the TemplateCache, call the get method on TemplateCache directly. Internally, instances of the TemplateCache class will be created and stored but you do not have to manually create these instances yourself. get will return a compiled template function. + * Returns a new HTML DOM node instance. The resulting node can be + * passed into the other DOM functions. */ - static get(templateId: string): any; + createBuffer(): DocumentFragment; + + /** + * Takes the DOM node el and appends the rendered children to the end of + * the element's contents. + * @param el is a jQuery argument: https://api.jquery.com/jQuery/ + * @param children is jQuery.append argument: http://api.jquery.com/append/ + */ + appendChildren(el: any, children: any): void; + + /** + * Add sibling to the DOM immediately before the DOM node el. The + * sibling will be at the same level as el. + * @param el is a jQuery argument: https://api.jquery.com/jQuery/ + * @param sibling is jQuery.before argument: http://api.jquery.com/before/ + */ + beforeEl(el: any, sibling: any): void; + + /** + * Remove oldEl from the DOM and put newEl in its place. + */ + replaceEl(newEl: HTMLElement, oldEL: HTMLElement): void; + + /** + * Remove the inner contents of el from the DOM while leaving el itself + * in the DOM. + * @param el is a jQuery argument: https://api.jquery.com/jQuery/ + */ + detachContents(el: any): void; + + /** + * Replace the contents of el with the HTML string of html. Unlike other + * DOM functions, this takes a literal string for its second argument. + * @param el is a jQuery argument: https://api.jquery.com/jQuery/ + * @param html is a jQuery.html argument: https://api.jquery.com/html/ + */ + setInnerContent(el: any, html: string): void; + + /** + * Detach el from the DOM. + * @param el is a jQuery argument: https://api.jquery.com/jQuery/ + */ + detachEl(el: any): void; + + /** + * Remove el from the DOM. + * @param el is a jQuery argument: https://api.jquery.com/jQuery/ + */ + removeEl(el: any): void; + + /** + * Lookup the selector string within the DOM node for context. The + * optional context argument will come in as a DOM Node reference to run + * the selector search. If context hasn't been set, then findEls should + * search the entire document for the selector. + * @param selector is a jQuery argument: https://api.jquery.com/jQuery/ + * @param context is a jQuery argument: https://api.jquery.com/jQuery/ + */ + findEls(selector: any, context: any): void; + + /** + * To use the TemplateCache, call the get method on TemplateCache + * directly. Internally, instances of the TemplateCache class will be + * created and stored but you do not have to manually create these + * instances yourself. get will return a compiled template function. + */ + static get(templateId: string, options?: any): any; /** * You can clear one or more, or all items from the cache using the clear @@ -662,27 +460,238 @@ declare namespace Marionette { */ static clear(...templateId: string[]): void; + /** + * Initial method to load the template. (undocumented) + */ + load(options?: any): any; + /** * The default template retrieval is to select the template contents from the * DOM using jQuery. If you wish to change the way this works, you can * override this method on the TemplateCache object. + * Note that the options argument seems to be unused in the source. */ - loadTemplate(templateId: string): any; + loadTemplate(templateId: string, options?: any): any; /** - * he default template compilation passes the results from loadTemplate to + * The default template compilation passes the results from loadTemplate to * the compileTemplate function, which returns an underscore.js compiled * template function. When overriding compileTemplate remember that it * must return a function which takes an object of parameters and values * and returns a formatted HTML string. */ - compileTemplate(rawTemplate: any): any; + compileTemplate(rawTemplate: any, options?: any): any; + } + + interface RegionConstructionOptions { + /** + * Specifies the element for the region to manage. This may be + * a selector string, a raw DOM node reference or a jQuery wrapped + * DOM node. + */ + el?: any; + + /** + * Prevents error on missing element. (undocumented) + */ + allowMissingEl?: boolean; + + /** + * Element to use as context when finding el via jQuery. Defaults to the + * the document. (undocumented) + */ + parentEl?: string; + + /** + * Overwrite the parent el of the region with the rendered contents of + * the inner View. + */ + replaceElement?: string; + } + + interface RegionViewOptions { + /** + * DEPRECATED: If you replace the current view with a new view by calling show, by + * default it will automatically destroy the previous view. You can + * prevent this behavior by setting this option to true. + */ + preventDestroy?: boolean; } /** - * The Renderer object was extracted from the ItemView rendering process, in - * order to create a consistent and re-usable method of rendering a template - * with or without data. + * Regions provide consistent methods to manage, show and destroy views in + * your applications and layouts. They use a jQuery selector to show your + * views in the correct place. + */ + class Region extends Object implements DomMixin { + /** + * Returns a new HTML DOM node instance. The resulting node can be + * passed into the other DOM functions. + */ + createBuffer(): DocumentFragment; + + /** + * Takes the DOM node el and appends the rendered children to the end of + * the element's contents. + * @param el is a jQuery argument: https://api.jquery.com/jQuery/ + * @param children is jQuery.append argument: http://api.jquery.com/append/ + */ + appendChildren(el: any, children: any): void; + + /** + * Add sibling to the DOM immediately before the DOM node el. The + * sibling will be at the same level as el. + * @param el is a jQuery argument: https://api.jquery.com/jQuery/ + * @param sibling is jQuery.before argument: http://api.jquery.com/before/ + */ + beforeEl(el: any, sibling: any): void; + + /** + * Remove oldEl from the DOM and put newEl in its place. + */ + replaceEl(newEl: HTMLElement, oldEL: HTMLElement): void; + + /** + * Remove the inner contents of el from the DOM while leaving el itself + * in the DOM. + * @param el is a jQuery argument: https://api.jquery.com/jQuery/ + */ + detachContents(el: any): void; + + /** + * Replace the contents of el with the HTML string of html. Unlike other + * DOM functions, this takes a literal string for its second argument. + * @param el is a jQuery argument: https://api.jquery.com/jQuery/ + * @param html is a jQuery.html argument: https://api.jquery.com/html/ + */ + setInnerContent(el: any, html: string): void; + + /** + * Detach el from the DOM. + * @param el is a jQuery argument: https://api.jquery.com/jQuery/ + */ + detachEl(el: any): void; + + /** + * Remove el from the DOM. + * @param el is a jQuery argument: https://api.jquery.com/jQuery/ + */ + removeEl(el: any): void; + + /** + * Lookup the selector string within the DOM node for context. The + * optional context argument will come in as a DOM Node reference to run + * the selector search. If context hasn't been set, then findEls should + * search the entire document for the selector. + * @param selector is a jQuery argument: https://api.jquery.com/jQuery/ + * @param context is a jQuery argument: https://api.jquery.com/jQuery/ + */ + findEls(selector: any, context: any): void; + + /** + * You can specify an el for the region to manage at the time the region + * is instantiated. + */ + constructor(options?: RegionConstructionOptions); + + /** + * Defaults to 'mnr' (undocumented) + */ + cidPrefix: string; + + /** + * Overwrite the parent el of the region with the rendered contents of + * the inner View. + */ + replaceElement: boolean; + + /** + * Contains the element that this region should manage. + */ + el: any; + + /** + * Renders and displays the specified view in this region. + * @param view the view to display. + */ + show(view: Backbone.View, options?: RegionViewOptions): void; + + /** + * Override this method to change how the region finds the DOM element + * that it manages. Return a jQuery selector object scoped to a provided + * parent el or the document if none exists. (undocumented) + */ + getEl(): any; + + /** + * Check to see if the region’s el was replaced. (undocumented) + */ + isReplaced(): boolean; + + /** + * Check to see if a view is being swapped by another. + */ + isSwappingView(): boolean; + + /** + * Override this method to change how the new view is appended to the + * `$el` that the region is managing + */ + attachHtml(view: Backbone.View): void; + + /** + * Destroy the current view, clean up any event handlers and remove it + * from the DOM. When a region is emptied empty events are triggered. + */ + empty(options?: RegionViewOptions): any; + + /** + * Destroys the view taking into consideration if is a View descendant + * or vanilla Backbone view. + */ + destroyView(view: Backbone.View): Backbone.View; + + /** + * Override the region's removeView method to change how and when the + * view is destroyed / removed from the DOM. + */ + removeView(view: Backbone.View): void; + + /** + * Empties the Region without destroying the view, returns the detached + * view. + */ + detachView(): Backbone.View; + + /** + * Override this method to change how the region detaches current + * content. + */ + detachHtml(): void; + + /** + * If you wish to check whether a region has a view, you can use the + * hasView function. This will return a boolean value depending whether + * or not the region is showing a view. + */ + hasView(): boolean; + + /** + * A region can be reset at any time. This destroys any existing view + * being displayed, and deletes the cached el. The next time the region + * shows a view, the region's el is queried from the DOM. + */ + reset(): any; + + /** + * @returns view that this region has. + */ + currentView: Backbone.View; + } + + /** + * Render a template with data by passing in the template selector and the + * data to render. This is the default renderer that is used by Marionette. */ class Renderer { /** @@ -699,257 +708,495 @@ declare namespace Marionette { static render(template: any, data: any): string; } + interface ViewOptions extends Backbone.ViewOptions, ViewMixinOptions { + /** + * The events attribute binds DOM events to actions to perform on the + * view. It takes DOM event key and a mapping to the handler. + */ + events?: EventsHash; + + /** + * If you've created a custom region class, you can use it to define + * your region. + */ + regionClass?: any; + + /** + * Add regions to this View. + */ + regions?: any; + + /** + * Set the template of this View. + */ + template?: any; + + /** + * The templateContext attribute can be used to add extra information to + * your templates + */ + templateContext?: any; + } + /** - * This base view provides some common and core functionality for other views - * to take advantage of. - * Note: The Marionette.View class is not intended to be used directly. It - * exists as a base view for other view classes to be extended from, and to - * provide a common location for behaviors that are shared across all views. + * A View is a view that represents an item to be displayed with a template. + * This is typically a Backbone.Model, Backbone.Collection, or nothing at + * all. Views are also used to build up your application hierarchy - you can + * easily nest multiple views through the regions attribute. */ - class View extends Backbone.View { + class View extends Backbone.View implements ViewMixin, RegionsMixin { + constructor(options?: ViewOptions); - constructor(options?: Backbone.ViewOptions); + events(): EventsHash; /** - * Defines behaviors attached to this view. + * Returns a new HTML DOM node instance. The resulting node can be + * passed into the other DOM functions. */ - behaviors: any; + createBuffer(): DocumentFragment; /** - * Defines `triggers` to forward DOM events to view - * events. `triggers: {"click .foo": "do:foo"}` + * Takes the DOM node el and appends the rendered children to the end of + * the element's contents. + * @param el is a jQuery argument: https://api.jquery.com/jQuery/ + * @param children is jQuery.append argument: http://api.jquery.com/append/ */ - triggers:{[key:string]:any}; + appendChildren(el: any, children: any): void; /** - * A configuration hash for models. The left side is the event on - * the model, and the right side is the name of the - * method on the view or a function to handle the event. This property - * can also be a function that returns the hash described above. + * Add sibling to the DOM immediately before the DOM node el. The + * sibling will be at the same level as el. + * @param el is a jQuery argument: https://api.jquery.com/jQuery/ + * @param sibling is jQuery.before argument: http://api.jquery.com/before/ */ - modelEvents: any; + beforeEl(el: any, sibling: any): void; /** - * A configuration hash for collections. The left side is the event on - * the collection, and the right side is the name of the - * method on the view or a function to handle the event. This property - * can also be a function that returns the hash described above. + * Remove oldEl from the DOM and put newEl in its place. */ - collectionEvents: any; + replaceEl(newEl: HTMLElement, oldEL: HTMLElement): void; /** - * In several cases you need to access ui elements inside the view to - * retrieve their data or manipulate them. For example you have a certain - * div element you need to show/hide based on some state, or other ui - * element that you wish to set a css class to it. Instead of having - * jQuery selectors hanging around in the view's code you can define a - * ui hash that contains a mapping between the ui element's name and its - * jQuery selector. Afterwards you can simply access it via - * this.ui.elementName. + * Remove the inner contents of el from the DOM while leaving el itself + * in the DOM. + * @param el is a jQuery argument: https://api.jquery.com/jQuery/ */ - ui: any; + detachContents(el: any): void; /** - * There may be some cases where you need to change the template that is - * used for a view, based on some simple logic such as the value of a - * specific attribute in the view's model. To do this, you can provide a - * getTemplate function on your views and use this to return the template - * that you need. + * Replace the contents of el with the HTML string of html. Unlike other + * DOM functions, this takes a literal string for its second argument. + * @param el is a jQuery argument: https://api.jquery.com/jQuery/ + * @param html is a jQuery.html argument: https://api.jquery.com/html/ */ - getTemplate(): any; - + setInnerContent(el: any, html: string): void; /** - * Retrieve an object's attribute either directly from the object, or - * from the object's this.options, with this.options taking precedence. + * Detach el from the DOM. + * @param el is a jQuery argument: https://api.jquery.com/jQuery/ */ - getOption(optionName:string): T; - - mixinTemplateHelpers(target?: any): any; - configureTriggers(): any; + detachEl(el: any): void; /** - * View implements a destroy method, which is called by the region managers automatically. As part of the implementation. + * Remove el from the DOM. + * @param el is a jQuery argument: https://api.jquery.com/jQuery/ + */ + removeEl(el: any): void; + + /** + * Lookup the selector string within the DOM node for context. The + * optional context argument will come in as a DOM Node reference to run + * the selector search. If context hasn't been set, then findEls should + * search the entire document for the selector. + * @param selector is a jQuery argument: https://api.jquery.com/jQuery/ + * @param context is a jQuery argument: https://api.jquery.com/jQuery/ + */ + findEls(selector: any, context: any): void; + + /** + * Receives a hash of event names and functions and/or function names, + * and returns the same hash with the function names replaced with the + * function references themselves. + */ + normalizeMethods(hash: any): T; + + /** + * A handy function to pluck certain options and attach them directly + * to an instance. + */ + mergeOptions(options: any, keys: any): void; + + /** + * Retrieve an object's attribute either directly from the object, or from + * the object's this.options, with this.options taking precedence. + * @param optionName the name of the option to retrieve. + */ + getOption(optionName: string): any; + + /** + * This method is used to bind a backbone "entity" (collection/model) to + * methods on a target object. + */ + bindEvents(entity: any, bindings: any): void; + + /** + * This method can be used to unbind callbacks from entities' + * (collection/model) events. + */ + unbindEvents(entity: any, bindings: any): void; + + /** + * Internal property. (undocumented) + */ + supportsRenderLifecycle: boolean; + + /** + * Internal property. (undocumented) + */ + supportsDestroyLifecycle: boolean; + + /** + * Check if this View has been destroyed. + */ + isDestroyed(): boolean; + + /** + * Check if this View has been rendered. + */ + isRendered(): boolean; + + /** + * Check if this View is attached to the DOM. + */ + isAttached(): boolean; + + /** + * Overrides Backbone.View.delegateEvents. By default Marionette uses + * this to add handlers for events and triggers. (undocumented) + */ + delegateEvents(eventsArg: any): View; + + /** + * Get the triggers that are currently attached to this view. + * (undocumented) + */ + getTriggers(): EventsHash; + + /** + * Delegate entity events. (undocumented) + */ + delegateEntityEvents(): View; + + /** + * Undelegate entity events. (undocumented) + */ + undelegateEntityEvents(): View; + + /** + * Manually destroy a view by calling the destroy method. The method + * unbinds the UI elements, removes the view and its children from the + * DOM and unbinds the listeners. It also triggers lifecycle events. */ destroy(...args: any[]): View; /** - * In several cases you need to access ui elements inside the view to - * retrieve their data or manipulate them. For example you have a certain - * div element you need to show/hide based on some state, or other ui - * element that you wish to set a css class to it. Instead of having jQuery - * selectors hanging around in the view's code you can define a ui hash - * that contains a mapping between the ui element's name and its jQuery - * selector. Afterwards you can simply access it via this.ui.elementName. - * This functionality is provided via the bindUIElements method. - * Since View doesn't implement the render method, then if you directly - * extend from View you will need to invoke this method from your render - * method. In ItemView and CompositeView this is already taken care of. + * Bind UI elements to this view. By default this is called in the + * render method. (undocumented) */ bindUIElements(): any; + /** + * Bind UI elements from this view. (undocumented) + */ unbindUIElements(): any; + /** + * Customize the event prefix for events that are forwarded through the + * collection view. + */ + childViewEventPrefix: string | false; + + /** + * Trigger an event and a corresponding method on the target object. + * All arguments that are passed to the triggerMethod call are passed + * along to both the event and the method, with the exception of the + * event name not being passed to the corresponding method. + */ triggerMethod(name: string, ...args: any[]): any; /** - * Item views will serialize a model or collection, by default, by calling - * .toJSON on either the model or collection. If both a model and - * collection are attached to an item view, the model will be used as the - * data source. The results of the data serialization will be passed to - * the template that is rendered. - * - * If you need custom serialization for your data, you can provide a serializeData - * method on your view. It must return a valid JSON object, as if you had - * called .toJSON on a model or collection. - */ - serializeData(): any; - - /** - * Renders the view. It is unwise to override the render method of any - * Marionette view. Instead, you should use the onBeforeRender and - * onRender callbacks to layer in additional functionality to the - * rendering of your view. - */ - render(): any; - - /** - * Triggered before an ItemView is rendered. - */ - onBeforeRender(): void; - - /** - * Triggered after the view has been rendered. You can implement this in - * your view to provide custom code for dealing with the view's el after - * it has been rendered. - */ - onRender(): void; - - /** - * Triggered just after the view has been destroyed. - */ - onDestroy(): void; - - /** - * When destroying a view, an onBeforeDestroy method will be called, if - * it has been provided, just before the view destroys. It will be passed - * any arguments that destroy was invoked with. - */ - onBeforeDestroy(...args: any[]): void; - - /** - * Called anytime that showing the view in a Region causes it to be - * attached to the document. - */ - onAttach(): void; - - /** - * Triggered right before the view is attached to the document. - */ - onBeforeAttach(): void; - - /** - * Triggered after the view has been rendered, has been shown in the DOM via a Marionette.Region, and has been re-rendered. - * This event / callback is useful for DOM-dependent UI plugins such as jQueryUI or KendoUI. - */ - onDomRefresh(): void; - - /** - * Internal properties extended in Marionette.View. - */ - isDestroyed(): boolean; - isRendered(): boolean; - isAttached(): boolean; - delegateEntityEvents(): View; - supportsRenderLifecycle: boolean; - supportsDestroyLifecycle: boolean; - - /** - * If you have the need to replace the Region with a region class of your - * own implementation, you can specify an alternate class to use with this - * property. + * Define the region class used for this View. */ regionClass: any; /** - * Regions hash or a method returning the regions hash that maps - * regions/selectors to methods on your View. - **/ - regions(): any; - - /** Adds a region to the layout view. */ - addRegion(name: string, definition: any): Region; + * Add a region to this View. + */ + addRegion(regionName: string, element: any): any; /** - * Add multiple regions as a {name: definition, name2: def2} object literal. + * Add multiple regions to this View. */ addRegions(regions: any): any; - /** Returns a region from the layout view */ - getRegion(name: string): Region; + /** + * Remove a region from this View. + */ + removeRegion(regionName: string): any; /** - * Removes the region with the specified name. - * @param name the name of the region to remove. + * Remove all regions from this View. */ - removeRegion(name: string): Region; - - /** Enable easy overriding of the default `RegionManager` - * for customized region interactions and business specific - * view logic for better control over single regions. - */ - getRegionManager(): RegionManager; + removeRegions(): any; /** - * Show a view into the region specified by `regionName`. + * Empty all regions from this View. */ - showChildView(regionName: string, view: any, options?: RegionShowOptions): void; + emptyRegions(): any; /** - * Get the current view that is shown in the region specified by - * `regionName`. + * Check if this View has a particular region. */ - getChildView(regionName: string): Backbone.View; + hasRegion(regionName: string): any; /** - * Returns all regions from the layout view. The results contains an - * Object hash that has `string`s as keys and `Region`s as values. + * Return a region from this View. */ - getRegions(): {[key: string]: Region}; + getRegion(regionName: string): Region; /** - * You can customize the event prefix for events that are forwarded through - * the layout view with this property. + * Returns all regions from this View. */ - childViewEventPrefix: string; + getRegions(): any; + + /** + * Show a view inside a region. + */ + showChildView(regionName: string, view: any, options?: RegionViewOptions): void; + + /** + * Detach a view from a region. + */ + detachChildView(regionName: string): Backbone.View; + + /** + * Get the view from a region. + */ + getChildView(regionName: string): Backbone.View; + + /** + * The results of this method ared passed to this View's template. By + * default Marionette will attempt to pass either an attached model or + * collection which has been converted to JSON. + */ + serializeData(): any; + + /** + * Method used by this.serializeData to serialize this View's model + * data. + */ + serializeModel(): any; + + /** + * Method used by this.serializeData to serialize this View's collection + * data. + */ + serializeCollection(): any; + + /** + * Rebind this View to a new element. Overriding Backbone.View’s + * setElement to handle if an element was previously defined. + * (undocumented) + */ + setElement(element: any): View; + + /** + * Renders the view. Given a template this method will build your HTML + * from that template, mixing in model information and any extra + * template context. + */ + render(): View; + + /** + * Used to determine which template to use. Override this method to add + * logic for using multiple templates. + */ + getTemplate(): any; + + /** + * Mix in template context methods. Looks for a templateContext + * attribute, which can either be an object literal, or a function that + * returns an object literal. All methods and attributes from this + * object are copies to the object passed in. (undocumented) + */ + mixinTemplateContext(...args: any[]): any; + + /** + * Used to attached the rendered template to this View's element. + */ + attachElContent(html: string): View; + + /** + * Used to set the renderer for this View. The rendere function is + * passed the template and the data and is expected to return an html + * string. By default this is set to use Renderer. + */ + setRenderer(renderer: (template: any, data: any) => string): void; + + /** + * Event that is triggered before this View is rendered. + */ + onBeforeRender(view: View): void; + + /** + * Event that is triggered after this View is rendered. + */ + onRender(view: View): void; + + /** + * Event that is triggered before this View is added to the DOM. + */ + onBeforeAttach(view: View): void; + + /** + * Event that is triggered after this View's element has been added to + * the DOM. + */ + onAttach(view: View): void; + + /** + * Event that is triggered after this View's content has been added to + * the DOM. Is also triggered every time this.render() is called. + */ + onDomRefresh(view: View): void; + + /** + * Event that is triggered before this View is destroyed. + */ + onBeforeDestroy(view: View, ...args: any[]): void; + + /** + * Event that is triggered before this View's element is removed from + * the DOM. + */ + onBeforeDetach(view: View): void; + + /** + * Event that is triggered before this View's content is removed from + * the DOM. + */ + onDomRemove(view: View): void; + + /** + * Event that is triggered after this View's element has been removed + * from the DOM. + */ + onDetach(view: View): void; + + /** + * Event that is triggered after this View is destroyed. + */ + onDestroy(view: View, ...args: any[]): void; + + /** + * Event that is triggered before a Region is added. + */ + onBeforeAddRegion(regionName: string, region: Region): void; + + /** + * Event that is triggered after a Region has been added. + */ + onAddRegion(regionName: string, region: Region): void; + + /** + * Event that is triggered before a Region is removed. + */ + onBeforeRemoveRegion(regionName: string, region: Region): void; + + /** + * Event that is triggered after a Region has been removed. + */ + onRemoveRegion(regionName: string, region: Region): void; + + /** + * Behavior objects to assign to this View. + */ + behaviors: Behavior[] | { [index: string]: typeof Behavior; } | Array<{ + behaviorClass: typeof Behavior; + [index: string]: any; + }>; + + /** + * Bind to events that occur on attached models. + */ + modelEvents: EventsHash; + + /** + * The view triggers attribute binds DOM events to Marionette View events + * that can be responded to at the view or parent level. + */ + triggers: EventsHash; + + /** + * Name parts of your template to be used + * throughout the view with the ui attribute. + */ + ui: any; } - - interface CollectionViewOptions extends Backbone.ViewOptions { + interface CollectionViewOptions< + TModel extends Backbone.Model, + TCollection extends Backbone.Collection = Backbone.Collection + > extends Backbone.ViewOptions, ViewMixinOptions { + /** + * Specify a child view to use. + */ + childView?: (() => typeof Backbone.View) | typeof Backbone.View; /** - * By default the CollectionView will maintain a sorted collection's order - * in the DOM. This behavior can be disabled by specifying {sort: false} - * on initialize. + * Define options to pass to the childView constructor. + */ + childViewOptions?: (() => ViewOptions) | ViewOptions; + + /** + * The events attribute binds DOM events to actions to perform on the + * view. It takes DOM event key and a mapping to the handler. + */ + events?: EventsHash; + + /** + * Prevent some of the underlying collection's models from being + * rendered as child views. + */ + filter?(child?: TModel, index?: number, collection?: TCollection): boolean; + + /** + * Specify a view to use if the collection has no children. + */ + emptyView?: (() => typeof Backbone.View) | typeof Backbone.View; + + /** + * Define options to pass to the emptyView constructor. + */ + emptyViewOptions?: (() => ViewOptions) | ViewOptions; + + /** + * If true when you sort your collection there will be no re-rendering, + * only the DOM nodes will be reordered. + */ + reorderOnSort?: boolean; + + /** + * If false the collection view will not maintain a sorted collection's + * order in the DOM. */ sort?: boolean; /** - * This option is useful when you have performance issues when you - * resort your CollectionView. Without this option, your CollectionView - * will be completely re-rendered, which can be costly if you have a - * large number of elements or if your ChildViews are complex. If this - * option is activated, when you sort your Collection, there will be no - * re-rendering, only the DOM nodes will be reordered. This can be a - * problem if your ChildViews use their collection's index in their - * rendering. In this case, you cannot use this option as you need to - * re-render each ChildView. - * - * If you combine this option with a filter that changes the views that - * are to be displayed, reorderOnSort will be bypassed to render new - * children and remove those that are rejected by the filter. + * Render your collection view's children with a different sort order + * than the underlying Backbone collection. */ - reorderOnSort?: boolean; + viewComparator?: string | ((element: TModel) => number | string) | ((compare: TModel, to?: TModel) => number); // Mirrors Backbone.Collection.comparator } /** @@ -960,174 +1207,177 @@ declare namespace Marionette { * DOM. This behavior can be disabled by specifying {sort: false} on * initialize. */ - class CollectionView> extends View { - constructor(options?: CollectionViewOptions); + class CollectionView, TCollection extends Backbone.Collection = Backbone.Collection> extends View { + constructor(options?: CollectionViewOptions); /** - * Specify a childView in your collection view definition. This must be a - * Backbone view object definition, not an instance. It can be any - * Backbone.View or be derived from Marionette.ItemView + * Specify a child view to use. */ - childView: new (...args:any[]) => TView; + childView: (() => { new(...args: any[]): TView }) | { new(...args: any[]): TView }; /** - * There may be scenarios where you need to pass data from your parent - * collection view in to each of the childView instances. To do this, - * provide a childViewOptions definition on your collection view as an - * object literal. This will be passed to the constructor of your childView - * as part of the options. - * - * You can also specify the childViewOptions as a function, if you need to - * calculate the values to return at runtime. The model will be passed - * into the function should you need access to it when calculating - * childViewOptions. The function must return an object, and the attributes of - * the object will be copied to the childView instance's options. + * Define options to pass to the childView constructor. */ - childViewOptions: any; + childViewOptions: ((model: TModel, index: number) => ViewOptions) | ViewOptions; /** - * You can customize the event prefix for events that are forwarded through - * the collection view. To do this, set the childViewEventPrefix on the - * collection view. + * Prevent some of the underlying collection's models from being + * rendered as child views. */ - childViewEventPrefix: string; + filter: (child?: TModel, index?: number, collection?: TCollection) => boolean; /** - * You can specify a childViewEvents hash or method which allows you to - * capture all bubbling childViewEvents without having to manually set bindings. - * The keys of the hash can either be a function or a string that is the - * name of a method on the collection view. + * Modify the CollectionView's filter attribute, and renders the new + * ChildViews in a efficient way, instead of rendering the whole DOM + * structure again. */ - childViewEvents: any; + setFilter: (filter: (child?: TModel, index?: number, collection?: TCollection) => boolean, options: { preventRender: boolean }) => void; /** - * When a collection has no children, and you need to render a view other than - * the list of childViews, you can specify an emptyView attribute on your collection - * view. + * Remove a filter from the CollectionView. */ - emptyView: any; + removeFilter: (options: { preventRender: boolean }) => void; /** - * Similar to childView and childViewOptions, there is an emptyViewOptions - * property that will be passed to the emptyView constructor. It can be - * provided as an object literal or as a function. If emptyViewOptions - * aren't provided the CollectionView will default to passing the - * childViewOptions to the emptyView. + * Specify a view to use if the collection has no children. */ - emptyViewOptions: any; + emptyView: (() => { new(...args: any[]): Backbone.View }) | { new(...args: any[]): Backbone.View }; /** - * The CollectionView uses Backbone.BabySitter to store and manage its - * child views. This allows you to easily access the views within the - * collection view, iterate them, find them by a given indexer such as the - * view's model or collection, and more. + * Define options to pass to the emptyView constructor. */ - children: Backbone.ChildViewContainer; + emptyViewOptions: ((model: TModel, index: number) => ViewOptions) | ViewOptions; /** - * The render method of the collection view is responsible for rendering the - * entire collection. It loops through each of the children in the collection - * and renders them individually as an childView. - */ - render(): CollectionView; - - /** - * The addChild method is responsible for rendering the childViews and - * adding them to the HTML for the collectionView instance. It is also - * responsible for triggering the events per ChildView. In most cases you - * should not override this method. - */ - addChild(item: any, ChildView: TView, index: Number): void; - - /** Render the child view */ - renderChildView(view: TView, index: Number): void; - - /** - * When a custom view instance needs to be created for the childView that - * represents a child, override the buildChildView method. This method - * takes three parameters and returns a view instance to be used as the - * child view. - */ - buildChildView(child: any, ItemViewType: any, itemViewOptions: any): TView; - - /** - * Remove the child view and destroy it. This function also updates the indices of - * later views in the collection in order to keep the children in sync with the collection. - */ - removeChildView(view: TView): TView; - - /** - * Determines if the view is empty. If you want to control when the empty - * view is rendered, you can override isEmpty. + * Method used to determine when emptyView is rendered. */ isEmpty(): boolean; /** - * If empty, show the empty view + * The render method of the collection view is responsible for rendering + * the entire collection. It loops through each of the children in the + * collection and renders them individually as an childView. */ - checkEmpty(): void; + render(): CollectionView; /** - * Destroy the child views that this collection view - * is holding on to, if any. This returns destroyed children. + * This method is used move the HTML from the element buffer into the + * collection view's el. */ - destroyChildren(): Backbone.ChildViewContainer; + attachHtml(collectionView: CollectionView, childView: TView, index: number): void; /** - * By default the CollectionView will maintain the order of its collection - * in the DOM. However on occasions the view may need to re-render to make - * this possible, for example if you were to change the comparator on the - * collection. By default CollectionView will call render when this happens, - * but there are cases where this may not be suitable. For instance when - * sorting the children in a CompositeView, you want to only render the - * internal collection. + * When overriding attachHtml it may be necessary to also override how + * the buffer is attached. */ - resortView(): void; + attachBuffer(collectionView: CollectionView, buffer: DocumentFragment): void; /** - * By default the collection view will append the HTML of each ChildView - * into the element buffer, and then call jQuery's .append once at the end - * to move the HTML into the collection view's el. - * You can override this by specifying an attachHtml method in your view - * definition. - * @param collectionView the instance of the collection view that will receive the HTML. - * @param childView the current child view instance. - * @param index he index of the model that this childView instance represents, - * in the collection that the model came from. This is useful for sorting - * a collection and displaying the sorted list in the correct order on the - * screen. + * Customize the event prefix for events that are forwarded through the + * collection view. */ - attachHtml(collectionView: CollectionView, childView: TView, index: number): void; - - /** Serialize a collection by serializing each of its models. */ - serializeCollection(): any; + childViewEventPrefix: string | false; /** - * Reorder DOM after sorting. When your element's rendering - * do not use their index, you can pass reorderOnSort: true - * to only reorder the DOM after a sort instead of rendering - * all the collectionView + * Use the childViewEvents attribute to map child events to methods on the + * parent view. + */ + childViewEvents: EventsHash; + + /** + * A childViewTriggers hash or method permits proxying of child view events + * without manually setting bindings. The values of the hash should be a + * string of the event to trigger on the parent. + */ + childViewTriggers: EventsHash; + + /** + * Bind to events that occur on attached collections. + */ + collectionEvents: EventsHash; + + /** + * Bind to events that occur on attached models. + */ + modelEvents: EventsHash; + + /** + * The view triggers attribute binds DOM events to Marionette View events + * that can be responded to at the view or parent level. + */ + triggers: EventsHash; + + /** + * If true when you sort your collection there will be no re-rendering, + * only the DOM nodes will be reordered. + */ + reorderOnSort: boolean; + + /** + * If reorderOnSort is set to true, this function will be used instead + * of re-rendering all children. */ reorder(): void; /** - * Render and show the emptyView. Similar to addChild method - * but "add:child" events are not fired, and the event from - * emptyView are not forwarded + * By default the CollectionView will maintain the order of its + * collection in the DOM. However on occasions the view may need to + * re-render to make this possible, for example if you were to change + * the comparator on the collection. The CollectionView will re-render + * its children or reorder them depending on reorderOnSort. */ - addEmptyView(child: TModel, EmptyView: new (...args: any[]) => any): void; + resortView(): void; /** - * Handle cleanup and other destroying needs for the collection of views + * Render your collection view's children with a different sort order + * than the underlying Backbone collection. */ - destroy(): CollectionView; + viewComparator: string | ((element: TModel) => number | string) | ((compare: TModel, to?: TModel) => number); // Mirrors Backbone.Collection.comparator /** - * Set up the child view event forwarding. Uses a "childview:" - * prefix in front of all forwarded events. - * @param view it might be ChildView or EmptyView. + * Override this method to determine which viewComparator to use. */ - proxyChildEvents(view: any): void; + getViewComparator: () => (string | ((element: TModel) => number | string) | ((compare: TModel, to?: TModel) => number)); // Mirrors Backbone.Collection.comparator + + /** + * Behavior objects to assign to this View. + */ + behaviors: Behavior[] | { [index: string]: typeof Behavior; } | Array<{ + behaviorClass: typeof Behavior; + [index: string]: any; + }>; + + /** + * Name parts of your template to be used throughout the view with the + * ui attribute. + */ + ui: any; + + /** + * The CollectionView can store and manage its child views. This allows + * you to easily access the views within the collection view, iterate + * them, find them by a given indexer such as the view's model or + * collection, and more. + */ + children: Container; + + /** + * The buildChildView is responsible for taking the ChildView class and + * instantiating it with the appropriate data. + */ + buildChildView(child: TModel, childViewClass: { new(...args: any[]): TView }, childViewOptions: ViewOptions): void; + + /** + * The addChildView method can be used to add a view that is independent + * of your Backbone.Collection. + */ + addChildView(childView: TView, index: number): void; + + /** + * The removeChildView method is useful if you need to remove a view + * from the CollectionView without affecting the view's collection. + */ + removeChildView(childView: TView): void; /** * Called just prior to rendering the collection view. @@ -1167,151 +1417,137 @@ declare namespace Marionette { * instance has been deleted or removed from the collection. */ onRemoveChild(childView: TView): void; + + /** + * Automatically destroys this Collection's children and cleans up + * listeners. + */ + destroy(...args: any[]): CollectionView; } - interface AppRouterOptions extends Backbone.RouterOptions { + interface AppRoutes { + [index: string]: string; + } + + interface AppRouterOptions { /** - * The appRoutes. + * Define the app routes and the method names on the controller that + * will be called when accessing the routes. */ - appRoutes?: any; + appRoutes?: AppRoutes; /** - * The controller to associate with this router. + * Define the app routes and the method names on the router that will be + * called when accessing the routes. + */ + routes?: AppRoutes; + + /** + * An object that contains the methods specified in appRoutes. */ controller?: any; } /** - * Reduce the boilerplate code of handling route events and then calling a - * single method on another object. Have your routers configured to call - * the method on your object, directly. + * The Marionette AppRouter is typically used to set up your app when the + * user loads a specific endpoint directly. */ class AppRouter extends Backbone.Router { - - /** - * Configure an AppRouter with appRoutes. The route definition - * is passed on to Backbone's standard routing handlers. This means - * that you define routes like you normally would. However, instead of - * providing a callback method that exists on the router, you provide a - * callback method that exists on the controller, which you specify for - * the router instance (see below.) - */ constructor(options?: AppRouterOptions); /** - * You can specify a controller with the multiple routes at runtime with - * this method. However, In this case the current controller of AppRouter - * will not change. - */ - processAppRoutes(controller: any, appRoutes: any): void; - - /** - * Adds an app route at runtime to this instance. It works the same as the - * built-in router.route() call from Backbone's Router, but has all the - * same semantics and behavior of the appRoutes configuration. + * Add an app route at runtime. */ appRoute(route: string, methodName: string): void; + + /** + * Specify a controller with the multiple routes at runtime. This will + * preserve the existing controller as well. + */ + processAppRoutes(controller: any, appRoutes: AppRoutes): void; + + /** + * An object that contains the methods specified in appRoutes. + */ + controller: any; + + /** + * Fires whenever the user navigates to a new route in your application + * that matches a route. + */ + onRoute(name: string, path: string, args: any[]): void; + } + + interface ApplicationOptions extends ObjectOptions { + /** + * Root entry point for the View tree of your Application. + */ + region: string; } /** - * The Backbone.Marionette.Application object is the hub of your composite - * application. It organizes, initializes and coordinates the various pieces - * of your app. It also provides a starting point for you to call into from - * your HTML script block, or directly from your JavaScript files if you - * prefer to go that route. The Application is meant to be instantiated - * directly, although you can extend it to add your own functionality. + * The Application is used to model your Marionette application under a + * single entry point. The application provides: + * - An obvious entry point to your app + * - A clear hook for global events e.g. the AppRouter + * - An interface to let you inject variables from the wider context into + * your app */ - class Application extends Backbone.Events { - - constructor(options?: any); + class Application extends Object { + constructor(options?: ApplicationOptions); /** - * The Event Aggregator is available through this property. It is - * convenient for passively sharing information between pieces of your - * application as events occur. - * Note! To access this application channel from other objects within your - * app you are encouraged to get a handle of the systems through the - * Wreqr API instead of the Application instance itself. + * Root entry point for the View tree of your Application. */ - vent: Backbone.Wreqr.EventAggregator; - - /** - * Commands are used to make any component tell another component to - * perform an action without a direct reference to it. - */ - commands: Backbone.Wreqr.Commands; - - /** - * Request Response is a means for any component to request information - * from another component without being tightly coupled. - */ - reqres: Backbone.Wreqr.RequestResponse; - - submodules: any; - - /** Command execution, facilitated by Backbone.Wreqr.Commands */ - execute(...args: any[]): void; - - /** Request/response, facilitated by Backbone.Wreqr.RequestResponse */ - request(...args: any[]): any; - - /** Deprecated! Initializers, you should use events to manage start-up logic. */ - addInitializer(initializer: any): void; - - /** - * Once you have your application configured, you can kick everything off - * by calling this method. - * @param options This parameter will be passed to each of your initializer functions, as well as the initialize events. This allows you to provide extra configuration for various parts of your app throughout the initialization sequence. - */ - start(options?: any): void; - - /** Root region of the application*/ region: string; - /** Get the root region */ + /** + * Called immediately after the Application has been instantiated, and + * is invoked with the same arguments that the constructor received. + */ + initialize(options: ApplicationOptions): void; + + /** + * Fired just before the application is started. + */ + onBeforeStart(options: ApplicationOptions): void; + + /** + * Fired as part of the application startup. + */ + onStart(options: ApplicationOptions): void; + + /** + * Once you have your application configured, you can kick everything + * off by calling this method. + */ + start(options?: any): void; + + /** + * Return the attached region object for the Application. + */ getRegion(): Region; - /** Show a view in the root region */ - showView(view: Backbone.View): void; - - /** Get the view from the root region*/ - getView(): any; - - module(moduleNames: any, moduleDefinition: any): Module; + /** + * Display View in the region attached to the Application. This runs the + * View lifecycle. + */ + showView(view: View): void; /** - * Called just before the Application starts and before the initializers are executed. + * Return the view currently being displayed in the Application's + * attached region. If the Application is not currently displaying a + * view, this method returns undefined. */ - onBeforeStart(options?: any): void; - - /** - * Called after the Application has started and after the initializers have been executed. - */ - onStart(options?: any): void; - } - - // modules mapped for convenience, but you should probably use TypeScript modules instead - class Module extends Backbone.Events { - - constructor(moduleName: string, app: Application); - - submodules: any; - triggerMethod(name: string, ...args: any[]): any; - - addInitializer(callback: any): void; - addFinalizer(callback: any): void; - start(options?: any): void; - addDefinition(moduleDefinition: any, customArgs: any): any; + getView(): View; } /** - * A Behavior is an isolated set of DOM / user interactions that can be mixed - * into any View or another Behavior. Behaviors allow you to blackbox View - * specific interactions into portable logical chunks, keeping your views - * simple and your code DRY. + * A Behavior provides a clean separation of concerns to your view logic, + * allowing you to share common user-facing operations between your views. */ - class Behavior extends Marionette.Object { - constructor(options?: any, view?: any); + class Behavior extends Object { + constructor(options?: any); options: any; @@ -1327,23 +1563,26 @@ declare namespace Marionette { /** * Any triggers you define on the Behavior will be triggered in response to the appropriate event on the view. */ - triggers: any; + triggers: EventsHash; /** * modelEvents will respond to the view's model events. */ - modelEvents: any; + modelEvents: EventsHash; /** * collectionEvents will respond to the view's collection events. */ - collectionEvents: any; + collectionEvents: EventsHash; /** * The behaviors key allows a behavior to group multiple behaviors * together. */ - behaviors: any; + behaviors: Behavior[] | { [index: string]: typeof Behavior; } | Array<{ + behaviorClass: typeof Behavior; + [index: string]: any; + }>; /** * defaults can be a hash or function to define the default options for @@ -1363,8 +1602,10 @@ declare namespace Marionette { */ $el: JQuery; - /** A reference to the view instance that the behavior is on. */ - view: any; + /** + * The View that this behavior is attached to. + */ + view: View; /** * $ is a direct proxy of the views $ lookup method. @@ -1373,10 +1614,7 @@ declare namespace Marionette { } /** - * Marionette.Behaviors' is a utility class that takes care of glueing your - * behavior instances to their given View. The most important part of this - * class is that you MUST override the class level behaviorsLookup method or - * set the option behaviorClass for things to work properly. + * DEPRECATED */ class Behaviors { /** diff --git a/types/backbone.marionette/tslint.json b/types/backbone.marionette/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/backbone.marionette/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/backbone.paginator/index.d.ts b/types/backbone.paginator/index.d.ts index fc7c39e995..66b43c0b69 100644 --- a/types/backbone.paginator/index.d.ts +++ b/types/backbone.paginator/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for backbone.paginator 2.0.2 // Project: https://github.com/backbone-paginator/backbone.paginator -// Definitions by: Nyamazing +// Definitions by: Nyamazing // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/backbone.radio/index.d.ts b/types/backbone.radio/index.d.ts index 61c996f6de..12fc6d384f 100644 --- a/types/backbone.radio/index.d.ts +++ b/types/backbone.radio/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Backbone.Radio v0.8.3 // Project: https://github.com/marionettejs/backbone.radio -// Definitions by: Peter Palotas +// Definitions by: Peter Palotas // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/backbone/index.d.ts b/types/backbone/index.d.ts index f151b2f42e..806086943e 100644 --- a/types/backbone/index.d.ts +++ b/types/backbone/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Backbone 1.3.3 // Project: http://backbonejs.org/ -// Definitions by: Boris Yankov , Natan Vivo +// Definitions by: Boris Yankov , Natan Vivo // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -111,7 +111,7 @@ declare namespace Backbone { /** * Do not use, prefer TypeScript's extend functionality. **/ - private static extend(properties: any, classProperties?: any): any; + public static extend(properties: any, classProperties?: any): any; attributes: any; changed: any[]; @@ -205,7 +205,7 @@ declare namespace Backbone { /** * Do not use, prefer TypeScript's extend functionality. **/ - private static extend(properties: any, classProperties?: any): any; + public static extend(properties: any, classProperties?: any): any; model: new (...args:any[]) => TModel; models: TModel[]; @@ -322,7 +322,7 @@ declare namespace Backbone { /** * Do not use, prefer TypeScript's extend functionality. **/ - private static extend(properties: any, classProperties?: any): any; + public static extend(properties: any, classProperties?: any): any; /** * Routes hash or a method returning the routes hash that maps URLs with parameters to methods on your Router. @@ -388,7 +388,7 @@ declare namespace Backbone { /** * Do not use, prefer TypeScript's extend functionality. **/ - private static extend(properties: any, classProperties?: any): any; + public static extend(properties: any, classProperties?: any): any; constructor(options?: ViewOptions); initialize(options?: ViewOptions): void; diff --git a/types/backgrid/index.d.ts b/types/backgrid/index.d.ts index fdf7785b59..bd8cad018c 100644 --- a/types/backgrid/index.d.ts +++ b/types/backgrid/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Backgrid 0.2.6 // Project: http://backgridjs.com/ -// Definitions by: Jeremy Lujan +// Definitions by: Jeremy Lujan // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/backoff/backoff-tests.ts b/types/backoff/backoff-tests.ts new file mode 100644 index 0000000000..86da837721 --- /dev/null +++ b/types/backoff/backoff-tests.ts @@ -0,0 +1,351 @@ +import * as backoff from 'backoff'; + +const fibonacciBackoff = backoff.fibonacci(); +fibonacciBackoff; // $ExpectType Backoff +backoff.fibonacci({ + randomisationFactor: 0, + initialDelay: 10, + maxDelay: 300 +}); +backoff.fibonacci({randomisationFactor: 0}); +backoff.fibonacci({initialDelay: 10}); +backoff.fibonacci({maxDelay: 300}); + +backoff.exponential(); // $ExpectType Backoff +backoff.exponential({ + factor: 1, + randomisationFactor: 0, + initialDelay: 10, + maxDelay: 300 +}); +backoff.exponential({factor: 1}); +backoff.exponential({randomisationFactor: 0}); +backoff.exponential({initialDelay: 10}); +backoff.exponential({maxDelay: 300}); + +const fibonacciStrategy = new backoff.FibonacciStrategy(); +new backoff.FibonacciStrategy({ + randomisationFactor: 0, + initialDelay: 10, + maxDelay: 300 +}); +new backoff.FibonacciStrategy({randomisationFactor: 0}); +new backoff.FibonacciStrategy({initialDelay: 10}); +new backoff.FibonacciStrategy({maxDelay: 300}); + +fibonacciStrategy.next(); // $ExpectType number +fibonacciStrategy.reset(); + +const exponentialStrategy = new backoff.ExponentialStrategy(); +new backoff.ExponentialStrategy({ + factor: 1, + randomisationFactor: 0, + initialDelay: 10, + maxDelay: 300 +}); +new backoff.ExponentialStrategy({factor: 1}); +new backoff.ExponentialStrategy({randomisationFactor: 0}); +new backoff.ExponentialStrategy({initialDelay: 10}); +new backoff.ExponentialStrategy({maxDelay: 300}); + +exponentialStrategy.next(); // $ExpectType number +exponentialStrategy.reset(); + +class MyStrategy extends backoff.BackoffStrategy { + constructor() { + super({ + randomisationFactor: 0, + initialDelay: 10, + maxDelay: 300 + }); + } + + protected next_() { + return 1; + } + + protected reset_() { + } +} + +const myStrategy = new MyStrategy(); +exponentialStrategy.next(); // $ExpectType number +exponentialStrategy.reset(); + +// $ExpectType TypedFunctionCall +backoff.call((cb: (err: Error) => void) => {}, (err) => { + err; // $ExpectType Error +}); +// $ExpectType TypedFunctionCall +backoff.call((cb: (err: Error, r1: string) => void) => {}, (err, r1) => { + r1; // $ExpectType string + err; // $ExpectType Error +}); +// TypedFunctionCall +backoff.call((cb: (err: Error, r1: string, r2: number) => void) => {}, (err, r1, r2) => { + r1; // $ExpectType string + r2; // $ExpectType number + err; // $ExpectType Error +}); +// TypedFunctionCall +backoff.call((cb: (err: Error, r1: string, r2: number, r3: boolean) => void) => {}, (err, r1, r2, r3) => { + r1; // $ExpectType string + r2; // $ExpectType number + r3; // $ExpectType boolean + err; // $ExpectType Error +}); +// TypedFunctionCall<[number], Error, string, undefined, undefined> +backoff.call( + (t1: number, cb: (err: Error, r1: string) => void) => { + }, + 1, + (err, r1) => { + r1; // $ExpectType string + err; // $ExpectType Error + }); +// TypedFunctionCall<[number], Error, string, number, undefined> +backoff.call( + (t1: number, cb: (err: Error, r1: string, r2: number) => void) => { + }, + 1, + (err, r1, r2) => { + r1; // $ExpectType string + r2; // $ExpectType number + err; // $ExpectType Error + }); +// TypedFunctionCall<[number], Error, string, number, boolean> +backoff.call( + (t1: number, cb: (err: Error, r1: string, r2: number, r3: boolean) => void) => { + }, + 1, + (err, r1, r2, r3) => { + r1; // $ExpectType string + r2; // $ExpectType number + r3; // $ExpectType boolean + err; // $ExpectType Error + }); +// TypedFunctionCall<[number, string], Error, string, undefined, undefined> +backoff.call( + (t1: number, t2: string, cb: (err: Error, r1: string) => void) => { + }, + 1, 'foo', + (err, r1) => { + r1; // $ExpectType string + err; // $ExpectType Error + }); +// TypedFunctionCall<[number, string], Error, string, number, undefined> +backoff.call( + (t1: number, t2: string, cb: (err: Error, r1: string, r2: number) => void) => { + }, + 1, 'foo', + (err, r1, r2) => { + r1; // $ExpectType string + r2; // $ExpectType number + err; // $ExpectType Error + }); +// TypedFunctionCall<[number, string], Error, string, number, boolean> +backoff.call( + (t1: number, t2: string, cb: (err: Error, r1: string, r2: number, r3: boolean) => void) => { + }, + 1, 'foo', + (err, r1, r2, r3) => { + r1; // $ExpectType string + r2; // $ExpectType number + r3; // $ExpectType boolean + err; // $ExpectType Error + }); +// TypedFunctionCall<[number, string, boolean], Error, string, undefined, undefined> +backoff.call( + (t1: number, t2: string, t3: boolean, cb: (err: Error, r1: string) => void) => { + }, + 1, 'foo', true, + (err, r1) => { + r1; // $ExpectType string + err; // $ExpectType Error + }); +// TypedFunctionCall<[number, string, boolean], Error, string, number, undefined> +backoff.call( + (t1: number, t2: string, t3: boolean, cb: (err: Error, r1: string, r2: number) => void) => { + }, + 1, 'foo', true, + (err, r1, r2) => { + r1; // $ExpectType string + r2; // $ExpectType number + err; // $ExpectType Error + }); +// TypedFunctionCall<[number, string, boolean], Error, string, number, boolean> +backoff.call( + (t1: number, t2: string, t3: boolean, cb: (err: Error, r1: string, r2: number, r3: boolean) => void) => { + }, + 1, 'foo', true, + (err, r1, r2, r3) => { + r1; // $ExpectType string + r2; // $ExpectType number + r3; // $ExpectType boolean + err; // $ExpectType Error + }); +// $ExpectType FunctionCallAny +backoff.call( + (t1: number, t2: string, t3: boolean, t4: string, cb: (err: Error, r1: string, r2: number, r3: boolean) => void) => { + }, + 1, 'foo', true, 'bar', + (err: Error, r1: string, r2: number, r3: boolean) => {}); + +fibonacciBackoff.failAfter(10); +fibonacciBackoff.backoff(new Error('foo')); +fibonacciBackoff.reset(); + +fibonacciBackoff.on('backoff', (number, delay) => { + number; // $ExpectType number + delay; // $ExpectType number +}); +fibonacciBackoff.on('ready', (number, delay) => { + number; // $ExpectType number + delay; // $ExpectType number +}); +fibonacciBackoff.on('fail', (err) => { + err; // $ExpectType any +}); + +// TypedFunctionCall +new backoff.FunctionCall((cb: (err: Error) => void) => {}, [], (err) => { + err; // $ExpectType Error +}); +// TypedFunctionCall +new backoff.FunctionCall((cb: (err: Error, r1: string) => void) => {}, [], (err, r1) => { + r1; // $ExpectType string + err; // $ExpectType Error +}); +// TypedFunctionCall +new backoff.FunctionCall((cb: (err: Error, r1: string, r2: number) => void) => {}, [], (err, r1, r2) => { + r1; // $ExpectType string + r2; // $ExpectType number + err; // $ExpectType Error +}); +// TypedFunctionCall +new backoff.FunctionCall((cb: (err: Error, r1: string, r2: number, r3: boolean) => void) => {}, [], (err, r1, r2, r3) => { + r1; // $ExpectType string + r2; // $ExpectType number + r3; // $ExpectType boolean + err; // $ExpectType Error +}); +// TypedFunctionCall<[number], Error, string, undefined, undefined> +new backoff.FunctionCall( + (t1: number, cb: (err: Error, r1: string) => void) => { + }, + [1], + (err, r1) => { + r1; // $ExpectType string + err; // $ExpectType Error + }); +// TypedFunctionCall<[number], Error, string, number, undefined> +new backoff.FunctionCall( + (t1: number, cb: (err: Error, r1: string, r2: number) => void) => { + }, + [1], + (err, r1, r2) => { + r1; // $ExpectType string + r2; // $ExpectType number + err; // $ExpectType Error + }); +// TypedFunctionCall<[number], Error, string, number, boolean> +new backoff.FunctionCall( + (t1: number, cb: (err: Error, r1: string, r2: number, r3: boolean) => void) => { + }, + [1], + (err, r1, r2, r3) => { + r1; // $ExpectType string + r2; // $ExpectType number + r3; // $ExpectType boolean + err; // $ExpectType Error + }); +// TypedFunctionCall<[number, string], Error, string, undefined, undefined> +new backoff.FunctionCall( + (t1: number, t2: string, cb: (err: Error, r1: string) => void) => { + }, + [1, 'foo'], + (err, r1) => { + r1; // $ExpectType string + err; // $ExpectType Error + }); +// TypedFunctionCall<[number, string], Error, string, number, undefined> +new backoff.FunctionCall( + (t1: number, t2: string, cb: (err: Error, r1: string, r2: number) => void) => { + }, + [1, 'foo'], + (err, r1, r2) => { + r1; // $ExpectType string + r2; // $ExpectType number + err; // $ExpectType Error + }); +// TypedFunctionCall<[number, string], Error, string, number, boolean> +new backoff.FunctionCall( + (t1: number, t2: string, cb: (err: Error, r1: string, r2: number, r3: boolean) => void) => { + }, + [1, 'foo'], + (err, r1, r2, r3) => { + r1; // $ExpectType string + r2; // $ExpectType number + r3; // $ExpectType boolean + err; // $ExpectType Error + }); +// TypedFunctionCall<[number, string, boolean], Error, string, undefined, undefined> +new backoff.FunctionCall( + (t1: number, t2: string, t3: boolean, cb: (err: Error, r1: string) => void) => { + }, + [1, 'foo', true], + (err, r1) => { + r1; // $ExpectType string + err; // $ExpectType Error + }); +// TypedFunctionCall<[number, string, boolean], Error, string, number, undefined> +new backoff.FunctionCall( + (t1: number, t2: string, t3: boolean, cb: (err: Error, r1: string, r2: number) => void) => { + }, + [1, 'foo', true], + (err, r1, r2) => { + r1; // $ExpectType string + r2; // $ExpectType number + err; // $ExpectType Error + }); +const functionCall = new backoff.FunctionCall( + (t1: number, t2: string, t3: boolean, cb: (err: Error, r1: string, r2: number, r3: boolean) => void) => { + }, + [1, 'foo', true], + (err, r1, r2, r3) => { + r1; // $ExpectType string + r2; // $ExpectType number + r3; // $ExpectType boolean + err; // $ExpectType Error + }); +functionCall; // TypedFunctionCall<[number, string, boolean], Error, string, number, boolean> +// $ExpectType FunctionCallAny +new backoff.FunctionCall( + (t1: number, t2: string, t3: boolean, t4: string, cb: (err: Error, r1: string, r2: number, r3: boolean) => void) => { + }, + [1, 'foo', true, 'bar'], + (err: Error, r1: string, r2: number, r3: boolean) => {}); + +functionCall.isPending(); // $ExpectType boolean +functionCall.isRunning(); // $ExpectType boolean +functionCall.isCompleted(); // $ExpectType boolean +functionCall.isAborted(); // $ExpectType boolean +functionCall.setStrategy(myStrategy); // $ExpectType TypedFunctionCall<[number, string, boolean], Error, string, number, boolean> +functionCall.retryIf(err => err.status === 503); // $ExpectType TypedFunctionCall<[number, string, boolean], Error, string, number, boolean> +functionCall.failAfter(10); // $ExpectType TypedFunctionCall<[number, string, boolean], Error, string, number, boolean> +functionCall.getLastResult(); // $ExpectType [Error, string, number, boolean] +functionCall.getNumRetries(); // $ExpectType number +functionCall.start(); +functionCall.abort(); +functionCall.on('call', args => { + args; // $ExpectType [number, string, boolean] +}); +functionCall.on('callback', args => { + args; // $ExpectType [Error, string, number, boolean] +}); +functionCall.on('backoff', (number, delay, err) => { + number; // $ExpectType number + delay; // $ExpectType number + err; // $ExpectType any +}); +functionCall.on('abort', () => {}); diff --git a/types/backoff/index.d.ts b/types/backoff/index.d.ts new file mode 100644 index 0000000000..1c2f1ea605 --- /dev/null +++ b/types/backoff/index.d.ts @@ -0,0 +1,525 @@ +// Type definitions for backoff 2.5 +// Project: https://github.com/MathieuTurcotte/node-backoff#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 +/// +import { EventEmitter } from 'events'; + +/** + * Constructs a Fibonacci backoff (10, 10, 20, 30, 50, etc.). + * + * @param options.randomisationFactor: defaults to 0, must be between 0 and 1 + * @param options.initialDelay: defaults to 100 ms + * @param options.maxDelay: defaults to 10000 ms + * + * With these values, the backoff delay will increase from 100 ms to 10000 ms. The + * randomisation factor controls the range of randomness and must be between 0 + * and 1. By default, no randomisation is applied on the backoff delay. + */ +export function fibonacci(options?: Options): Backoff; + +/** + * Constructs an exponential backoff (10, 20, 40, 80, etc.). + * + * @param options.randomisationFactor: defaults to 0, must be between 0 and 1 + * @param options.initialDelay: defaults to 100 ms + * @param options.maxDelay: defaults to 10000 ms + * @param options.factor: defaults to 2, must be greater than 1 + * + * With these values, the backoff delay will increase from 100 ms to 10000 ms. The + * randomisation factor controls the range of randomness and must be between 0 + * and 1. By default, no randomisation is applied on the backoff delay. + */ +export function exponential(options?: ExponentialOptions): Backoff; + +export interface Options { + randomisationFactor?: number; + initialDelay?: number; + maxDelay?: number; +} + +export interface ExponentialOptions extends Options { + factor?: number; +} + +/** + * Constructs a `FunctionCall` instance for the given function. The wrapped + * function will get retried until it succeds or reaches the maximum number + * of backoffs. In both cases, the callback function will be invoked with the + * last result returned by the wrapped function. + * + * It is the caller's responsability to initiate the call by invoking the + * `start` method on the returned `FunctionCall` instance. + * + * @param wrappedFunction: function to call in a backoff handler, i.e. the wrapped function + * @param args: function's arguments + * @param callback: function's callback accepting an error as its first argument + * + */ +export function call(wrappedFunction: (cb: (err: E, r1: R1, r2: R2, r3: R3) => void) => void, + callback: (error: E, r1: R1, r2: R2, r3: R3) => void): TypedFunctionCall; +export function call(wrappedFunction: (cb: (err: E, r1: R1, r2: R2) => void) => void, + callback: (error: E, r1: R1, r2: R2) => void): TypedFunctionCall; +export function call(wrappedFunction: (cb: (err: E, r1: R1) => void) => void, + callback: (error: E, r1: R1) => void): TypedFunctionCall; +export function call(wrappedFunction: (cb: (err: E) => void) => void, + callback: (err: E) => void): TypedFunctionCall; +export function call(wrappedFunction: (t1: T1, cb: (err: E, r1: R1, r2: R2, r3: R3) => void) => void, + t1: T1, + callback: (error: E, r1: R1, r2: R2, r3: R3) => void): TypedFunctionCall<[T1], E, R1, R2, R3>; +export function call(wrappedFunction: (t1: T1, cb: (err: E, r1: R1, r2: R2) => void) => void, + t1: T1, + callback: (error: E, r1: R1, r2: R2) => void): TypedFunctionCall<[T1], E, R1, R2>; +export function call(wrappedFunction: (t1: T1, cb: (err: E, r1: R1) => void) => void, + t1: T1, + callback: (error: E, r1: R1) => void): TypedFunctionCall<[T1], E, R1>; +export function call(wrappedFunction: (t1: T1, cb: (err: E) => void) => void, + t1: T1, + callback: (err: E) => void): TypedFunctionCall<[T1], E>; +export function call(wrappedFunction: (t1: T1, t2: T2, cb: (err: E, r1: R1, r2: R2, r3: R3) => void) => void, + t1: T1, t2: T2, + callback: (error: E, r1: R1, r2: R2, r3: R3) => void): TypedFunctionCall<[T1, T2], E, R1, R2, R3>; +export function call(wrappedFunction: (t1: T1, t2: T2, cb: (err: E, r1: R1, r2: R2) => void) => void, + t1: T1, t2: T2, + callback: (error: E, r1: R1, r2: R2) => void): TypedFunctionCall<[T1, T2], E, R1, R2>; +export function call(wrappedFunction: (t1: T1, t2: T2, cb: (err: E, r1: R1) => void) => void, + t1: T1, t2: T2, + callback: (error: E, r1: R1) => void): TypedFunctionCall<[T1, T2], E, R1>; +export function call(wrappedFunction: (t1: T1, t2: T2, cb: (err: E) => void) => void, + t1: T1, t2: T2, + callback: (err: E) => void): TypedFunctionCall<[T1, T2], E>; +export function call(wrappedFunction: (t1: T1, t2: T2, t3: T3, cb: (err: E, r1: R1, r2: R2, r3: R3) => void) => void, + t1: T1, t2: T2, t3: T3, + callback: (error: E, r1: R1, r2: R2, r3: R3) => void): TypedFunctionCall<[T1, T2, T3], E, R1, R2, R3>; +export function call(wrappedFunction: (t1: T1, t2: T2, t3: T3, cb: (err: E, r1: R1, r2: R2) => void) => void, + t1: T1, t2: T2, t3: T3, + callback: (error: E, r1: R1, r2: R2) => void): TypedFunctionCall<[T1, T2, T3], E, R1, R2>; +export function call(wrappedFunction: (t1: T1, t2: T2, t3: T3, cb: (err: E, r1: R1) => void) => void, + t1: T1, t2: T2, t3: T3, + callback: (error: E, r1: R1) => void): TypedFunctionCall<[T1, T2, T3], E, R1>; +export function call(wrappedFunction: (t1: T1, t2: T2, t3: T3, cb: (err: E) => void) => void, + t1: T1, t2: T2, t3: T3, + callback: (err: E) => void): TypedFunctionCall<[T1, T2, T3], E>; +export function call(wrappedFunction: (...args: any[]) => void, ...args: any[]): FunctionCallAny; + +export class Backoff extends EventEmitter { + /** + * Constructs a new backoff object from a specific backoff strategy. The backoff + * strategy must implement the `BackoffStrategy`interface defined bellow. + * + * @param strategy: the backoff strategy to use + */ + constructor(strategy: BackoffStrategy); + + /** + * Sets a limit on the maximum number of backoffs that can be performed before + * a fail event gets emitted and the backoff instance is reset. By default, there + * is no limit on the number of backoffs that can be performed. + * + * @param numberOfBackoffs: maximum number of backoffs before the fail event gets + * emitted, must be greater than 0 + */ + failAfter(numberOfBackoffs: number): void; + + /** + * Starts a backoff operation. If provided, the error parameter will be emitted + * as the last argument of the `backoff` and `fail` events to let the listeners + * know why the backoff operation was attempted. + * + * An error will be thrown if a backoff operation is already in progress. + * + * In practice, this method should be called after a failed attempt to perform a + * sensitive operation (connecting to a database, downloading a resource over the + * network, etc.). + */ + backoff(error?: any): void; + + /** + * Resets the backoff delay to the initial backoff delay and stop any backoff + * operation in progress. After reset, a backoff instance can and should be + * reused. + * + * In practice, this method should be called after having successfully completed + * the sensitive operation guarded by the backoff instance or if the client code + * request to stop any reconnection attempt. + */ + reset(): void; + + /** + * Emitted when a backoff operation is started. Signals to the client how long + * the next backoff delay will be. + * @param number: number of backoffs since last reset, starting at 0 + * @param delay: backoff delay in milliseconds + * @param err: optional error parameter passed to `backoff.backoff([err])` + */ + addListener(event: 'backoff', listener: (number: number, delay: number, error?: any) => void): this; + /** + * Emitted when a backoff operation is done. Signals that the failing operation + * should be retried. + * + * @param number: number of backoffs since last reset, starting at 0 + * @param delay: backoff delay in milliseconds + */ + addListener(event: 'ready', listener: (number: number, delay: number) => void): this; + /** + * Emitted when the maximum number of backoffs is reached. This event will only + * be emitted if the client has set a limit on the number of backoffs by calling + * `backoff.failAfter(numberOfBackoffs)`. The backoff instance is automatically + * reset after this event is emitted. + * + * @param err: optional error parameter passed to `backoff.backoff([err])` + */ + addListener(event: 'fail', listener: (error?: any) => void): this; + on(event: 'backoff', listener: (number: number, delay: number, error?: any) => void): this; + on(event: 'ready', listener: (number: number, delay: number) => void): this; + on(event: 'fail', listener: (error?: any) => void): this; + once(event: 'backoff', listener: (number: number, delay: number, error?: any) => void): this; + once(event: 'ready', listener: (number: number, delay: number) => void): this; + once(event: 'fail', listener: (error?: any) => void): this; + prependListener(event: 'backoff', listener: (number: number, delay: number, error?: any) => void): this; + prependListener(event: 'ready', listener: (number: number, delay: number) => void): this; + prependListener(event: 'fail', listener: (error?: any) => void): this; + prependOnceListener(event: 'backoff', listener: (number: number, delay: number, error?: any) => void): this; + prependOnceListener(event: 'ready', listener: (number: number, delay: number) => void): this; + prependOnceListener(event: 'fail', listener: (error?: any) => void): this; + removeListener(event: 'backoff', listener: (number: number, delay: number, error?: any) => void): this; + removeListener(event: 'ready', listener: (number: number, delay: number) => void): this; + removeListener(event: 'fail', listener: (error?: any) => void): this; + removeAllListeners(event?: 'backoff' | 'ready' | 'fail'): this; + listeners(event: 'backoff'): Array<(number: number, delay: number, error?: any) => void>; + listeners(event: 'ready'): Array<(number: number, delay: number) => void>; + listeners(event: 'fail'): Array<(error?: any) => void>; + emit(event: 'backoff', number: number, delay: number, error?: any): boolean; + emit(event: 'ready', number: number, delay: number): boolean; + emit(event: 'fail', error?: any): boolean; + eventNames(): Array<'backoff' | 'ready' | 'fail'>; + listenerCount(type: 'backoff' | 'ready' | 'fail'): number; +} + +export abstract class BackoffStrategy { + /** + * The options are the following. + * + * @param options.randomisationFactor: defaults to 0, must be between 0 and 1 + * @param options.initialDelay: defaults to 100 ms + * @param options.maxDelay: defaults to 10000 ms + */ + constructor(options?: Options); + getMaxDelay(): number; + getInitialDelay(): number; + + /** + * Computes and returns the next backoff delay. + */ + next(): number; + + /** + * Resets the backoff delay to its initial value. + */ + reset(): void; + protected abstract next_(): number; + protected abstract reset_(): void; +} + +/** + * Exponential (10, 20, 40, 80, etc.) backoff strategy implementation. + */ +export class ExponentialStrategy extends BackoffStrategy { + /** + * The options are the following. + * + * @param options.randomisationFactor: defaults to 0, must be between 0 and 1 + * @param options.initialDelay: defaults to 100 ms + * @param options.maxDelay: defaults to 10000 ms + * @param options.factor: defaults to 2, must be greater than 1 + */ + constructor(options?: ExponentialOptions); + /** + * Computes and returns the next backoff delay. + */ + next(): number; + /** + * Resets the backoff delay to its initial value. + */ + reset(): void; + protected next_(): number; + protected reset_(): number; +} + +/** + * Fibonacci (10, 10, 20, 30, 50, etc.) backoff strategy implementation. + */ +export class FibonacciStrategy extends BackoffStrategy { + /** + * The options are the following. + * + * @param options.randomisationFactor: defaults to 0, must be between 0 and 1 + * @param options.initialDelay: defaults to 100 ms + * @param options.maxDelay: defaults to 10000 ms + */ + constructor(options?: Options); + next(): number; + reset(): void; + protected next_(): number; + protected reset_(): number; +} + +/** + * This class manages the calling of an asynchronous function within a backoff + * loop. + * + * This class should rarely be instantiated directly since the factory method + * `backoff.call(fn, [args, ...], callback)` offers a more convenient and safer + * way to create `FunctionCall` instances. + */ +export const FunctionCall: FunctionCallConstructor; + +/** + * Constructs a function handler for the given asynchronous function. + * + * @param fn: asynchronous function to call + * @param args: an array containing fn's args + * @param callback: fn's callback + */ +export interface FunctionCallConstructor { + new (wrappedFunction: (cb: (err: E, r1: R1, r2: R2, r3: R3) => void) => void, + args: undefined[], + callback: (error: E, r1: R1, r2: R2, r3: R3) => void): TypedFunctionCall; + new (wrappedFunction: (cb: (err: E, r1: R1, r2: R2) => void) => void, + args: undefined[], + callback: (error: E, r1: R1, r2: R2) => void): TypedFunctionCall; + new (wrappedFunction: (cb: (err: E, r1: R1) => void) => void, + args: undefined[], + callback: (error: E, r1: R1) => void): TypedFunctionCall; + new (wrappedFunction: (cb: (err: E) => void) => void, + args: undefined[], + callback: (err: E) => void): TypedFunctionCall; + + new (wrappedFunction: (t1: T1, cb: (err: E, r1: R1, r2: R2, r3: R3) => void) => void, + args: [T1], + callback: (error: E, r1: R1, r2: R2, r3: R3) => void): TypedFunctionCall<[T1], E, R1, R2, R3>; + new (wrappedFunction: (t1: T1, cb: (err: E, r1: R1, r2: R2) => void) => void, + args: [T1], + callback: (error: E, r1: R1, r2: R2) => void): TypedFunctionCall<[T1], E, R1, R2>; + new (wrappedFunction: (t1: T1, cb: (err: E, r1: R1) => void) => void, + args: [T1], + callback: (error: E, r1: R1) => void): TypedFunctionCall<[T1], E, R1>; + new (wrappedFunction: (t1: T1, cb: (err: E) => void) => void, + args: [T1], + callback: (err: E) => void): TypedFunctionCall<[T1], E>; + + new (wrappedFunction: (t1: T1, t2: T2, cb: (err: E, r1: R1, r2: R2, r3: R3) => void) => void, + args: [T1, T2], + callback: (error: E, r1: R1, r2: R2, r3: R3) => void): TypedFunctionCall<[T1, T2], E, R1, R2, R3>; + new (wrappedFunction: (t1: T1, t2: T2, cb: (err: E, r1: R1, r2: R2) => void) => void, + args: [T1, T2], + callback: (error: E, r1: R1, r2: R2) => void): TypedFunctionCall<[T1, T2], E, R1, R2>; + new (wrappedFunction: (t1: T1, t2: T2, cb: (err: E, r1: R1) => void) => void, + args: [T1, T2], + callback: (error: E, r1: R1) => void): TypedFunctionCall<[T1, T2], E, R1>; + new (wrappedFunction: (t1: T1, t2: T2, cb: (err: E) => void) => void, + args: [T1, T2], + callback: (err: E) => void): TypedFunctionCall<[T1, T2], E>; + + new (wrappedFunction: (t1: T1, t2: T2, t3: T3, cb: (err: E, r1: R1, r2: R2, r3: R3) => void) => void, + args: [T1, T2, T3], + callback: (error: E, r1: R1, r2: R2, r3: R3) => void): TypedFunctionCall<[T1, T2, T3], E, R1, R2, R3>; + new (wrappedFunction: (t1: T1, t2: T2, t3: T3, cb: (err: E, r1: R1, r2: R2) => void) => void, + args: [T1, T2, T3], + callback: (error: E, r1: R1, r2: R2) => void): TypedFunctionCall<[T1, T2, T3], E, R1, R2>; + new (wrappedFunction: (t1: T1, t2: T2, t3: T3, cb: (err: E, r1: R1) => void) => void, + args: [T1, T2, T3], + callback: (error: E, r1: R1) => void): TypedFunctionCall<[T1, T2, T3], E, R1>; + new (wrappedFunction: (t1: T1, t2: T2, t3: T3, cb: (err: E) => void) => void, + args: [T1, T2, T3], + callback: (err: E) => void): TypedFunctionCall<[T1, T2, T3], E>; + + new (wrappedFunction: (...args: any[]) => void, + args: any[], + callback: (error: any, ...resArgs: any[]) => void): FunctionCallAny; +} + +export type TypedFunctionCall = FunctionCall & FunctionCallArgs; +export type FunctionCallAny = FunctionCall & FunctionCallArgsAny; + +export interface FunctionCall extends EventEmitter { + /** + * Returns whether the call is pending, i.e. hasn't been started. + */ + isPending(): boolean; + + /** + * Returns whether the call is in progress. + */ + isRunning(): boolean; + + /** + * Returns whether the call is completed. + */ + isCompleted(): boolean; + + /** + * Returns whether the call is aborted. + */ + isAborted(): boolean; + + /** + * Sets the backoff strategy to use. This method should be called before + * `call.start()` otherwise an exception will be thrown. + * + * @param strategy: strategy instance to use, defaults to `FibonacciStrategy`. + */ + setStrategy(strategy: BackoffStrategy): this; + + /** + * Sets the maximum number of backoffs before the call is aborted. By default, + * there is no limit on the number of backoffs that can be performed. + * + * This method should be called before `call.start()` otherwise an exception will + * be thrown. + * + * @param maxNumberOfBackoffs: maximum number of backoffs before the call is aborted + */ + failAfter(maxNumberOfBackoffs: number): this; + + /** + * Sets the predicate which will be invoked to determine whether a given error + * should be retried or not, e.g. a network error would be retriable while a type + * error would stop the function call. By default, all errors are considered to be + * retriable. + * + * This method should be called before `call.start()` otherwise an exception will + * be thrown. + * + * @param predicate: a function which takes in as its argument the error returned + * by the wrapped function and determines whether it is retriable. + */ + retryIf(predicate: (error: any) => boolean): this; + + /** + * Returns the number of times the wrapped function call was retried. For a + * wrapped function that succeeded immediately, this would return 0. This + * method can be called at any point in time during the call life cycle, i.e. + * before, during and after the wrapped function invocation. + */ + getNumRetries(): number; + + /** + * Initiates the call the wrapped function. This method should only be called + * once otherwise an exception will be thrown. + */ + start(): void; + + /** + * Aborts the call and causes the completion callback to be invoked with an abort + * error if the call was pending or running; does nothing otherwise. This method + * can safely be called multiple times. + */ + abort(): void; + + /** + * Emitted each time the wrapped function is called. + * @param args: wrapped function's arguments + */ + addListener(event: 'call', listener: (args: T) => void): this; + + /** + * Emitted each time a backoff operation is started. + * + * @param number: backoff number, starts at 0 + * @param delay: backoff delay in milliseconds + * @param err: the error that triggered the backoff operation + */ + addListener(event: 'backoff', listener: (number: number, delay: number, error?: any) => void): this; + + /** + * Emitted when a call is aborted. + */ + addListener(event: 'abort', listener: () => void): this; + on(event: 'call', listener: (args: T) => void): this; + on(event: 'backoff', listener: (number: number, delay: number, error?: any) => void): this; + on(event: 'abort', listener: () => void): this; + once(event: 'call', listener: (args: T) => void): this; + once(event: 'backoff', listener: (number: number, delay: number, error?: any) => void): this; + once(event: 'abort', listener: () => void): this; + prependListener(event: 'call', listener: (args: T) => void): this; + prependListener(event: 'backoff', listener: (number: number, delay: number, error?: any) => void): this; + prependListener(event: 'abort', listener: () => void): this; + prependOnceListener(event: 'call', listener: (args: T) => void): this; + prependOnceListener(event: 'backoff', listener: (number: number, delay: number, error?: any) => void): this; + prependOnceListener(event: 'abort', listener: () => void): this; + removeListener(event: 'call', listener: (args: T) => void): this; + removeListener(event: 'backoff', listener: (number: number, delay: number, error?: any) => void): this; + removeListener(event: 'abort', listener: () => void): this; + removeAllListeners(event?: 'call' | 'callback' | 'backoff' | 'abort'): this; + listeners(event: 'call'): Array<(args: T) => void>; + listeners(event: 'backoff'): Array<(number: number, delay: number, error?: any) => void>; + listeners(event: 'abort'): Array<() => void>; + emit(event: 'call', args: T): boolean; + emit(event: 'backoff', number: number, delay: number, error?: any): boolean; + emit(event: 'abort'): boolean; + eventNames(): Array<'call' | 'callback' | 'backoff' | 'abort'>; + listenerCount(type: 'call' | 'callback' | 'backoff' | 'abort'): number; +} + +// Waiting for https://github.com/Microsoft/TypeScript/pull/17884 +export interface FunctionCallArgs { + /** + * Returns an array containing the last arguments passed to the completion callback + * of the wrapped function. For example, to get the error code returned by the last + * call, one would do the following. + * + * ``` js + * var results = call.getLastResult(); + * // The error code is the first parameter of the callback. + * var error = results[0]; + * ``` + * + * Note that if the call was aborted, it will contain the abort error and not the + * last error returned by the wrapped function. + */ + getLastResult(): [E, R1, R2, R3]; + /** + * Emitted each time the wrapped function invokes its callback + * @param results: wrapped function's return values + */ + addListener(event: 'callback', listener: (results: [E, R1, R2, R3]) => void): this; + on(event: 'callback', listener: (results: [E, R1, R2, R3]) => void): this; + once(event: 'callback', listener: (results: [E, R1, R2, R3]) => void): this; + prependListener(event: 'callback', listener: (results: [E, R1, R2, R3]) => void): this; + prependOnceListener(event: 'callback', listener: (results: [E, R1, R2, R3]) => void): this; + removeListener(event: 'callback', listener: (results: [E, R1, R2, R3]) => void): this; + listeners(event: 'callback'): Array<(results: [E, R1, R2, R3]) => void>; + emit(event: 'callback', results: [E, R1, R2, R3]): boolean; +} + +export interface FunctionCallArgsAny { + /** + * Returns an array containing the last arguments passed to the completion callback + * of the wrapped function. For example, to get the error code returned by the last + * call, one would do the following. + * + * ``` js + * var results = call.getLastResult(); + * // The error code is the first parameter of the callback. + * var error = results[0]; + * ``` + * + * Note that if the call was aborted, it will contain the abort error and not the + * last error returned by the wrapped function. + */ + getLastResult(): any[]; + /** + * Emitted each time the wrapped function invokes its callback + * @param results: wrapped function's return values + */ + addListener(event: 'callback', listener: (results: any[]) => void): this; + on(event: 'callback', listener: (results: any[]) => void): this; + once(event: 'callback', listener: (results: any[]) => void): this; + prependListener(event: 'callback', listener: (results: any[]) => void): this; + prependOnceListener(event: 'callback', listener: (results: any[]) => void): this; + removeListener(event: 'callback', listener: (results: any[]) => void): this; + listeners(event: 'callback'): Array<(results: any[]) => void>; + emit(event: 'callback', results: any[]): boolean; +} diff --git a/types/backoff/tsconfig.json b/types/backoff/tsconfig.json new file mode 100644 index 0000000000..ed5117f056 --- /dev/null +++ b/types/backoff/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "backoff-tests.ts" + ] +} diff --git a/types/backoff/tslint.json b/types/backoff/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/backoff/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/bagpipes/bagpipes-tests.ts b/types/bagpipes/bagpipes-tests.ts index af7dfa0a31..eaa412d56b 100755 --- a/types/bagpipes/bagpipes-tests.ts +++ b/types/bagpipes/bagpipes-tests.ts @@ -56,11 +56,11 @@ const pipesConfigFullEmpty: Bagpipes.Config = { userViewsDirs: [] }; -let pipesA = Bagpipes.create(perDefsMixed, { +const pipesA = Bagpipes.create(perDefsMixed, { connectMiddlewareDirs: ['some_dir', 'ssssss'], swaggerNodeRunner: {} }); -let pipeA = pipesA.getPipe('HelloWorld'); +const pipeA = pipesA.getPipe('HelloWorld'); // log the output to standard out pipeA.fit((context, cb) => { @@ -81,7 +81,7 @@ const pipeErrTest = pipesEnty.pipes['any'].fit((context, cb) => { pipesEnty.play(pipeErrTest, {}); const fittingsC = ["xxxx", "aaa"].map((name) => { - let fittingDef = {} as Bagpipes.PipeDefMap; + const fittingDef = {} as Bagpipes.PipeDefMap; fittingDef[name] = 'nothing'; return fittingDef; }); @@ -95,6 +95,6 @@ bagpipesD.play(bagpipesD.getPipe('objPipe'), {}); // Test full create const userFittingsDirs = ['./fixtures/fittings']; const pipeWithString = ['emit']; -let contextPlain = {}; +const contextPlain = {}; const bagpipesWithPipeAndFittings = Bagpipes.create({ myCustomPipe: pipeWithString }, { userFittingsDirs }); bagpipesWithPipeAndFittings.play(bagpipesWithPipeAndFittings.getPipe('myCustomPipe'), contextPlain); diff --git a/types/bagpipes/tslint.json b/types/bagpipes/tslint.json index a4bcc87748..03a7f353ed 100755 --- a/types/bagpipes/tslint.json +++ b/types/bagpipes/tslint.json @@ -1,6 +1,8 @@ { "extends": "dtslint/dt.json", "rules": { - "callable-types": false + // TODOs + "callable-types": false, + "no-object-literal-type-assertion": false } } diff --git a/types/baidumap-web-sdk/baidumap-web-sdk-tests.ts b/types/baidumap-web-sdk/baidumap-web-sdk-tests.ts index cc525509c6..8ac6457975 100644 --- a/types/baidumap-web-sdk/baidumap-web-sdk-tests.ts +++ b/types/baidumap-web-sdk/baidumap-web-sdk-tests.ts @@ -4,8 +4,8 @@ namespace BMapTests { //document: http://lbsyun.baidu.com/index.php?title=jspopular public createMap(container: string | HTMLElement) { navigator.geolocation.getCurrentPosition((position: Position) => { - let point = new BMap.Point(position.coords.longitude, position.coords.latitude); - let map = new BMap.Map(container); + const point = new BMap.Point(position.coords.longitude, position.coords.latitude); + const map = new BMap.Map(container); map.centerAndZoom(point, 15); }, console.log, { maximumAge: 3000, timeout: 5000, enableHighAccuracy: true }); } @@ -16,7 +16,7 @@ namespace BMapTests { map.addControl(new BMap.OverviewMapControl({ isOpen: true, anchor: BMAP_ANCHOR_BOTTOM_RIGHT })); } public addMarker(map: BMap.Map, point: BMap.Point) { - var marker = new BMap.Marker(point); + const marker = new BMap.Marker(point); map.addOverlay(marker); marker.setAnimation(BMAP_ANIMATION_BOUNCE); } diff --git a/types/baidumap-web-sdk/baidumap.overlay.d.ts b/types/baidumap-web-sdk/baidumap.overlay.d.ts index d723ac5e48..0cff89c694 100644 --- a/types/baidumap-web-sdk/baidumap.overlay.d.ts +++ b/types/baidumap-web-sdk/baidumap.overlay.d.ts @@ -43,7 +43,8 @@ declare namespace BMap { displayOnMinLevel?: number displayOnMaxLevel?: number } - class Marker implements Overlay { + interface Marker extends Overlay {} + class Marker { constructor(point: Point, opts?: MarkerOptions) openInfoWindow(infoWnd: InfoWindow): void closeInfoWindow(): void @@ -100,7 +101,8 @@ declare namespace BMap { class IconSequence { constructor(symbol: Symbol, offset?: string, repeat?: string, fixedRotation?: boolean) } - class PointCollection implements Overlay { + interface PointCollection extends Overlay {} + class PointCollection { constructor(points: Point[], opts?: PointCollectionOption) setPoints(points: Point[]): void setStyles(styles: PointCollectionOption): void @@ -121,7 +123,8 @@ declare namespace BMap { shadow?: Icon title?: string } - class InfoWindow implements Overlay { + interface InfoWindow extends Overlay {} + class InfoWindow { constructor(content: string | HTMLElement, opts?: InfoWindowOptions) setWidth(width: number): void setHeight(height: number): void @@ -149,7 +152,8 @@ declare namespace BMap { onrestore: (event: { type: string, target: any }) => void onclickclose: (event: { type: string, target: any }) => void } - class Polygon implements Overlay { + interface Polygon extends Overlay {} + class Polygon { constructor(points: Array, opts?: PolygonOptions) setPath(path: Point[]): void getPath(): Point[] @@ -213,7 +217,8 @@ declare namespace BMap { enableClicking?: boolean } type ShapeType = number - class Icon implements Overlay { + interface Icon extends Overlay {} + class Icon { constructor(url: string, size: Size, opts?: IconOptions) anchor: Size size: Size @@ -230,7 +235,8 @@ declare namespace BMap { setInfoWindowAnchor(anchor: Size): void setPrintImageUrl(url: string): void } - class Label implements Overlay { + interface Label extends Overlay {} + class Label { constructor(content: string, opts?: LabelOptions) setStyle(styles: Object): void setContent(content: string): void @@ -256,7 +262,8 @@ declare namespace BMap { onremove: (event: { type: string, target: any }) => void onrightclick: (event: { type: string, target: any }) => void } - class Circle implements Overlay { + interface Circle extends Overlay {} + class Circle { constructor(center: Point, radius: number, opts?: CircleOptions) setCenter(center: Point): void getCenter(): Point @@ -315,7 +322,8 @@ declare namespace BMap { enableEditing?: boolean enableClicking?: boolean } - class Hotspot implements Overlay { + interface Hotspot extends Overlay {} + class Hotspot { constructor(position: Point, opts?: HotspotOptions) setPosition(position: Point): void getPosition(): Point @@ -324,7 +332,8 @@ declare namespace BMap { setUserData(data: any): void getUserData(): any } - class Symbol implements Overlay { + interface Symbol extends Overlay {} + class Symbol { constructor(path: string | SymbolShapeType, opts?: SymbolOptions) setPath(path: string | SymbolShapeType): void setAnchor(anchor: Size): void @@ -336,7 +345,8 @@ declare namespace BMap { setFillOpacity(opacity: number): void setFillColor(color: string): void } - class Polyline implements Overlay { + interface Polyline extends Overlay {} + class Polyline { constructor(points: Point[], opts?: PolylineOptions) setPath(path: Point[]): void getPath(): Point[] @@ -371,7 +381,8 @@ declare namespace BMap { onremove: (event: { type: string, target: any }) => void onlineupdate: (event: { type: string, target: any }) => void } - class GroundOverlay implements Overlay { + interface GroundOverlay extends Overlay {} + class GroundOverlay { constructor(bounds: Bounds, opts?: GroundOverlayOptions) setBounds(bounds: Bounds): void getBounds(): Bounds diff --git a/types/base64-js/base64-js-tests.ts b/types/base64-js/base64-js-tests.ts index 402ce43e88..f9bb761f22 100644 --- a/types/base64-js/base64-js-tests.ts +++ b/types/base64-js/base64-js-tests.ts @@ -2,4 +2,4 @@ import * as base64js from "base64-js"; base64js.byteLength(""); // $ExpectType number base64js.toByteArray(""); // $ExpectType Uint8Array -base64js.fromByteArray(new Uint8Array(0)); // $ExpectTpe string +base64js.fromByteArray(new Uint8Array(0)); // $ExpectType string diff --git a/types/base64url/base64url-tests.ts b/types/base64url/base64url-tests.ts deleted file mode 100644 index f9f206fbc9..0000000000 --- a/types/base64url/base64url-tests.ts +++ /dev/null @@ -1,24 +0,0 @@ -import * as base64url from "base64url"; - -// default -let str = base64url("some value"); -str = base64url("some value", "hex"); -str = base64url(new Buffer("some value")); - -// encode -str = base64url.encode("some value"); -str = base64url.encode("some value", "hex"); -str = base64url.encode(new Buffer("some value")); - -// decode -str = base64url.decode("ADA="); -str = base64url.decode("ADA=", "binary"); - -// toBase64 -str = base64url.toBase64("ADA="); -str = base64url.toBase64(new Buffer("ADA=", "base64")); - -// fromBase64 -str = base64url.fromBase64("ADA="); - -let buf = base64url.toBase64("ADA="); \ No newline at end of file diff --git a/types/base64url/index.d.ts b/types/base64url/index.d.ts deleted file mode 100644 index e99ae3d2b3..0000000000 --- a/types/base64url/index.d.ts +++ /dev/null @@ -1,72 +0,0 @@ -// Type definitions for base64url v2.0.0 -// Project: https://github.com/brianloveswords/base64url -// Definitions by: Stepan Miroshin -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -/// - -/** - * For encoding and decoding base64url! - * v2.0.0 - */ - -/** - * Encoding type - */ -declare type Encoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "utf16le" | "base64" | "binary" | "hex" - -interface IBase64Url { - /** - * Encode input to base64url - * @param {string} input Incoming input - * @param {Encoding} encoding Default 'utf8' - * @return {string} - */ - (input: string, encoding?: Encoding): string; - /** - * Encode input to base64url - * @param {Buffer} input Incoming value - */ - (inout: Buffer): string; - /** - * Encode input to base64url - * - * @param {string} input Incoming input - * @param {Encoding} encoding Default 'utf8' - * @returns {string} - */ - encode(input: string, encoding?: Encoding): string; - /** - * Encode input to base64url - * @param {Buffer} input Incoming value - */ - encode(input: Buffer): string; - /** - * Convert a base64url encoded string into a raw string. - * @param {string} base64url base64url encoded string - * @param {Encoding} encoding Encoding defaults to 'utf8' - * @returns {string} - */ - decode(base64url: string, encoding?: string): string; - /** - * Convert a base64url encoded string to a base64 encoded string - * @param {string | Buffer} base64url base64url encoded value - * @returns {string} - */ - toBase64(base64url: string | Buffer): string; - /** - * Convert a base64 encoded string to a base64url encoded string - * @param {string} base64 encoded string - * @returns {string} - */ - fromBase64(base64: string): string; - /** - * Convert a base64url encoded string to a Buffer - * @param {string} base64url encoded string - * @returns {Buffer} - */ - toBuffer(base64url: string): Buffer; -} - -declare const base64url: IBase64Url; -export = base64url; \ No newline at end of file diff --git a/types/base64url/tsconfig.json b/types/base64url/tsconfig.json deleted file mode 100644 index d362086905..0000000000 --- a/types/base64url/tsconfig.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "base64url-tests.ts" - ] -} \ No newline at end of file diff --git a/types/basic-auth/index.d.ts b/types/basic-auth/index.d.ts index 276b5b8af6..3af8f5a699 100644 --- a/types/basic-auth/index.d.ts +++ b/types/basic-auth/index.d.ts @@ -19,7 +19,7 @@ declare namespace auth { /** * Parse basic auth to object. */ - function parse(authorizationHeader: string): auth.BasicAuthResult | undefined; + function parse(authorizationHeader: string): BasicAuthResult | undefined; } export = auth; diff --git a/types/batch-stream/index.d.ts b/types/batch-stream/index.d.ts index 26c433a04b..2ab8c6b8c5 100644 --- a/types/batch-stream/index.d.ts +++ b/types/batch-stream/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for batch-stream 0.1.2 // Project: https://github.com/segmentio/batch-stream -// Definitions by: Nicholas Penree +// Definitions by: Nicholas Penree // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// diff --git a/types/bcryptjs/index.d.ts b/types/bcryptjs/index.d.ts index c081ed33fd..b19413c92d 100644 --- a/types/bcryptjs/index.d.ts +++ b/types/bcryptjs/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for bcryptjs v2.4.0 // Project: https://github.com/dcodeIO/bcrypt.js -// Definitions by: Joshua Filby , Rafael Kraut +// Definitions by: Joshua Filby , Rafael Kraut // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/bem-cn/tslint.json b/types/bem-cn/tslint.json index f93cf8562a..091817f734 100644 --- a/types/bem-cn/tslint.json +++ b/types/bem-cn/tslint.json @@ -1,3 +1,7 @@ { - "extends": "dtslint/dt.json" + "extends": "dtslint/dt.json", + "rules": { + // TODO + "no-duplicate-imports": false + } } diff --git a/types/better-sqlite3/better-sqlite3-tests.ts b/types/better-sqlite3/better-sqlite3-tests.ts new file mode 100644 index 0000000000..43d78e1503 --- /dev/null +++ b/types/better-sqlite3/better-sqlite3-tests.ts @@ -0,0 +1,32 @@ +import * as Database from 'better-sqlite3'; + +const integer = Database.Integer(1); +const err = new Database.SqliteError('ok', 'ok'); + +let db = Database('.'); +db = new Database('.', {memory: true}); +db.exec('CREATE TABLE test (id INTEGER PRIMARY KEY NOT NULL, name TEXT NOT NULL);'); +db.exec('INSERT INTO test(name) VALUES("name");'); +db.pragma('data_version', true); +db.checkpoint(); +db.checkpoint('main'); +db.register(() => {}); +db.register({name: 'noop', deterministic: true, varargs: true}, () => {}); +db.defaultSafeIntegers(); +db.defaultSafeIntegers(true); + +const stmt = db.prepare('SELECT * FROM test WHERE name == ?;'); +stmt.get(['name']); +stmt.all({name: 'name'}); +stmt.each('name', (row: {name: string}) => {}); +stmt.each((row: {name: string}) => {}); +stmt.pluck(); +stmt.pluck(true); +stmt.bind('name'); +stmt.safeIntegers(); +stmt.safeIntegers(true); + +const trans = db.transaction(['INSERT INTO test(name) VALUES(?);']); +trans.run('name'); +trans.bind('name'); +trans.run(); diff --git a/types/better-sqlite3/index.d.ts b/types/better-sqlite3/index.d.ts new file mode 100644 index 0000000000..98de770ccf --- /dev/null +++ b/types/better-sqlite3/index.d.ts @@ -0,0 +1,89 @@ +// Type definitions for better-sqlite3 3.1 +// Project: http://github.com/JoshuaWise/better-sqlite3 +// Definitions by: Ben Davies +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import * as Integer from 'integer'; + +interface RunResult { + changes: number; + lastInsertROWID: Integer.IntLike; +} + +declare class Statement { + database: Database; + source: string; + returnsData: boolean; + constructor(db: Database, sources: string[]); + + run(...params: any[]): RunResult; + get(...params: any[]): any; + all(...params: any[]): any[]; + each(params: any, cb: (row: any) => void): void; + each(cb: (row: any) => void): void; + each(...params: any[]): void; + pluck(toggleState?: boolean): this; + bind(...params: any[]): this; + safeIntegers(toggleState?: boolean): this; +} + +declare class Transaction { + database: Database; + source: string; + constructor(db: Database, sources: string[]); + + run(...params: any[]): RunResult; + bind(...params: any[]): this; + safeIntegers(toggleState?: boolean): this; +} + +interface DatabaseOptions { + memory?: boolean; + readonly?: boolean; +} + +interface RegistrationOptions { + name?: string; + varargs?: boolean; + deterministic?: boolean; + safeIntegers?: boolean; +} + +interface Database { + memory: boolean; + readonly: boolean; + name: string; + open: boolean; + inTransaction: boolean; + + prepare(source: string): Statement; + transaction(sources: string[]): Transaction; + exec(source: string): this; + pragma(source: string, simplify?: boolean): any; + checkpoint(databaseName?: string): this; + register(cb: (...params: any[]) => any): this; + register(options: RegistrationOptions, cb: (...params: any[]) => any): this; + close(): this; + defaultSafeIntegers(toggleState?: boolean): this; +} + +declare class SqliteError implements Error { + name: string; + message: string; + code: string; + constructor(message: string, code: string); +} + +interface DatabaseConstructor { + new(filename: string, options?: DatabaseOptions): Database; + (filename: string, options?: DatabaseOptions): Database; + prototype: Database; + + Integer: typeof Integer; + SqliteError: typeof SqliteError; +} + +declare const Database: DatabaseConstructor; +export = Database; diff --git a/types/better-sqlite3/tsconfig.json b/types/better-sqlite3/tsconfig.json new file mode 100644 index 0000000000..fa406408e4 --- /dev/null +++ b/types/better-sqlite3/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "better-sqlite3-tests.ts" + ] +} diff --git a/types/better-sqlite3/tslint.json b/types/better-sqlite3/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/better-sqlite3/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/bezier-easing/index.d.ts b/types/bezier-easing/index.d.ts index 2a742daf1e..e714e55535 100644 --- a/types/bezier-easing/index.d.ts +++ b/types/bezier-easing/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for bezier-easing // Project: https://github.com/gre/bezier-easing -// Definitions by: brian ridley +// Definitions by: brian ridley // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare interface Easing { diff --git a/types/big.js/index.d.ts b/types/big.js/index.d.ts index e08ee7bc57..92eb845b98 100644 --- a/types/big.js/index.d.ts +++ b/types/big.js/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for big.js // Project: https://github.com/MikeMcl/big.js/ -// Definitions by: Steve Ognibene +// Definitions by: Steve Ognibene // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/bignumber.js/bignumber.js-tests.ts b/types/bignumber.js/bignumber.js-tests.ts index 8ea0775dba..424665d8ba 100644 --- a/types/bignumber.js/bignumber.js-tests.ts +++ b/types/bignumber.js/bignumber.js-tests.ts @@ -182,7 +182,7 @@ x.floor(); y = new BigNumber(-1.3); y.floor(); -0.1 > (0.3 - 0.2); +0.1 > (0.3 - 0.2); // tslint:disable-line binary-expression-operand-order x = new BigNumber(0.1); x.greaterThan(BigNumber(0.3).minus(0.2)); BigNumber(0).gt(x); diff --git a/types/bignumber.js/index.d.ts b/types/bignumber.js/index.d.ts index d627ad136c..ae7ec5b6f7 100644 --- a/types/bignumber.js/index.d.ts +++ b/types/bignumber.js/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for bignumber.js 4.0 // Project: https://github.com/MikeMcl/bignumber.js/ -// Definitions by: Viktor Smirnov +// Definitions by: Viktor Smirnov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 diff --git a/types/bigscreen/index.d.ts b/types/bigscreen/index.d.ts index 6d240729c5..0807cc61e5 100644 --- a/types/bigscreen/index.d.ts +++ b/types/bigscreen/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for BigScreen 2.0.4 // Project: http://brad.is/coding/BigScreen/ -// Definitions by: Douglas Eichelberger +// Definitions by: Douglas Eichelberger // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export as namespace BigScreen; diff --git a/types/bip21/index.d.ts b/types/bip21/index.d.ts index 06e61a6944..7561551e7a 100644 --- a/types/bip21/index.d.ts +++ b/types/bip21/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for bip21 v1.1.2 // Project: https://github.com/bitcoinjs/bip21 -// Definitions by: Stefan Huber +// Definitions by: Stefan Huber // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace bip21 { diff --git a/types/bitcoinjs-lib/bitcoinjs-lib-tests.ts b/types/bitcoinjs-lib/bitcoinjs-lib-tests.ts index 6723a7e577..549de76507 100644 --- a/types/bitcoinjs-lib/bitcoinjs-lib-tests.ts +++ b/types/bitcoinjs-lib/bitcoinjs-lib-tests.ts @@ -53,7 +53,7 @@ describe('bitcoinjs-lib (basic)', () => { const tx = new bitcoin.TransactionBuilder(); tx.addInput('aa94ab02c182214f090e99a0d57021caffd0f195a81c24602b1028b130b63e31', 0); - tx.addOutput('1Gokm82v6DmtwKEB8AiVhm82hyFSsEvBDK', 15000); + tx.addOutput(Buffer.from('1Gokm82v6DmtwKEB8AiVhm82hyFSsEvBDK'), 15000); tx.sign(0, keyPair); // tslint:disable-next-line:max-line-length diff --git a/types/bitcoinjs-lib/index.d.ts b/types/bitcoinjs-lib/index.d.ts index dc2af73403..986bb75e0b 100644 --- a/types/bitcoinjs-lib/index.d.ts +++ b/types/bitcoinjs-lib/index.d.ts @@ -10,35 +10,27 @@ /// import BigInteger = require("bigi"); -export interface Utxo { - address: string; - amount: number; - scriptPubKey: Buffer; - txid: string; - vout: number; -} - export interface Output { script: Buffer; value: number; } export interface Input { - script: Buffer; - hash: Buffer; - index: number; - sequence: number; + script: Buffer; + hash: Buffer; + index: number; + sequence: number; } export interface Network { - bip32: { - public: number; - private: number; - }; - messagePrefix: string; - pubKeyHash: number; - scriptHash: number; - wif: number; + bip32: { + public: number; + private: number; + }; + messagePrefix: string; + pubKeyHash: number; + scriptHash: number; + wif: number; } export class Block { @@ -80,7 +72,7 @@ export class ECPair { getPublicKeyBuffer(): Buffer; - sign(hash: Buffer): Buffer; + sign(hash: Buffer): ECSignature; toWIF(): string; @@ -164,7 +156,7 @@ export class Transaction { addInput(hash: Buffer, index: number, sequence?: number, scriptSig?: Buffer): number; - addOutput(scriptPubKey: Buffer, value: number): number; + addOutput(scriptPubKey: Buffer | string, value: number): number; byteLength(): number; @@ -186,7 +178,7 @@ export class Transaction { setWitness(index: number, witness: any, ...args: any[]): void; - toBuffer(buffer: Buffer, initialOffset?: number): Buffer; + toBuffer(buffer?: Buffer, initialOffset?: number): Buffer; toHex(): string; @@ -216,7 +208,7 @@ export class TransactionBuilder { addInput(txhash: Buffer | string | Transaction, vout: number, sequence?: number, prevOutScript?: Buffer): number; - addOutput(scriptPubKey: Buffer | string, value: number): number; + addOutput(scriptPubKey: Buffer, value: number): number; build(): Transaction; @@ -360,11 +352,11 @@ export const opcodes: { export namespace address { function fromBase58Check(address: string): { hash: Buffer, version: number }; - function fromOutputScript(outputScript: Buffer, network?: Network): { hash: Buffer, version: number }; + function fromOutputScript(outputScript: Buffer, network?: Network): Buffer; function toBase58Check(hash: Buffer, version: number): string; - function toOutputScript(address: string, network?: Network): string; + function toOutputScript(address: string, network?: Network): Buffer; } export namespace bufferutils { @@ -400,7 +392,7 @@ export namespace crypto { } export namespace script { - function classifyInput(script: Buffer | Array, allowIncomplete: boolean): "pubkeyhash" | "scripthash" | "multisig" | "pubkey" | "nonstandard"; + function classifyInput(script: Buffer | Array, allowIncomplete?: boolean): "pubkeyhash" | "scripthash" | "multisig" | "pubkey" | "nonstandard"; function classifyOutput(script: Buffer | Array): "witnesspubkeyhash" | "witnessscripthash" | "pubkeyhash" | "scripthash" | "multisig" | "pubkey" | "witnesscommitment" | "nulldata" | "nonstandard"; @@ -430,4 +422,111 @@ export namespace script { function encode(number: number): Buffer; } + + const multisig: { + input: { + check(script: Buffer, allowIncomplete: boolean): boolean; + decode(buffer: Buffer): Array; + decodeStack(stack: Buffer[], allowIncomplete: boolean): Array; + encode(signatures: ECSignature[], scriptPubKey: Buffer): Buffer; + encodeStack(signatures: ECSignature[], scriptPubKey: Buffer): ECSignature[]; + }; + output: { + check(script: Buffer, allowIncomplete: boolean): boolean; + decode(buffer: Buffer, allowIncomplete: boolean): { m: number; pubKeys: Array }; + encode(m: number, pubKeys: Array): Buffer; + }; + }; + + const pubKey: { + input: { + check(script: Buffer): boolean; + decode(buffer: Buffer): Array; + decodeStack(stack: Buffer[]): Array; + encode(signature: ECSignature): Buffer; + encodeStack(signature: ECSignature): ECSignature[]; + }; + + output: { + check(script: Buffer): boolean; + decode(buffer: Buffer): Buffer | number; + encode(pubKey: Buffer): Buffer; + }; + }; + + const pubKeyHash: { + input: { + check(script: Buffer): boolean; + decode(buffer: Buffer): { signature: ECSignature; pubKey: Buffer }; + decodeStack(stack: Buffer[]): { signature: ECSignature; pubKey: Buffer }; + encode(signature: ECSignature, pubKey: Buffer): Buffer; + encodeStack(signature: ECSignature, pubKey: Buffer): [ECSignature, Buffer]; + }; + + output: { + check(script: Buffer): boolean; + decode(buffer: Buffer): Buffer; + encode(pubKeyHash: Buffer): Buffer; + }; + }; + + const scriptHash: { + input: { + check(script: Buffer, allowIncomplete: boolean): boolean; + decode(buffer: Buffer): { redeemScriptStack: Buffer[]; redeemScript: Buffer }; + decodeStack(stack: Buffer[]): { redeemScriptStack: Buffer[]; redeemScript: Buffer }; + encode(redeemScriptSig: Array, redeemScript: Buffer): Buffer; + encodeStack(redeemScriptStack: Buffer[], redeemScript: Buffer): Buffer; + }; + + output: { + check(script: Buffer): boolean; + decode(buffer: Buffer): Buffer; + encode(scriptHash: Buffer): Buffer; + }; + }; + + const witnessCommitment: { + output: { + check(script: Buffer): boolean; + decode(buffer: Buffer): Buffer[]; + encode(commitment: Buffer): Buffer; + }; + }; + + const witnessPubKeyHash: { + input: { + check(script: Buffer): boolean; + decodeStack(stack: Buffer[]): { signature: ECSignature; pubKey: Buffer }; + encodeStack(signature: ECSignature, pubKey: Buffer): [ECSignature, Buffer]; + }; + + output: { + check(script: Buffer): boolean; + decode(buffer: Buffer): Buffer; + encode(pubKeyHash: Buffer): Buffer; + }; + }; + + const witnessScriptHash: { + input: { + check(script: Buffer, allowIncomplete: boolean): boolean; + decodeStack(stack: Buffer[]): { redeemScriptStack: Buffer[]; redeemScript: Buffer }; + encodeStack(redeemScriptStack: Buffer[], redeemScript: Buffer): Buffer; + }; + + output: { + check(script: Buffer): boolean; + decode(buffer: Buffer): Buffer; + encode(scriptHash: Buffer): Buffer; + }; + }; + + const nullData: { + output: { + check(script: Buffer): boolean; + decode(buffer: Buffer): Buffer; + encode(data: Buffer[]): Buffer; + }; + }; } diff --git a/types/bittorrent-protocol/tslint.json b/types/bittorrent-protocol/tslint.json index dfea11be1a..62d2486032 100644 --- a/types/bittorrent-protocol/tslint.json +++ b/types/bittorrent-protocol/tslint.json @@ -1,6 +1,8 @@ { "extends": "dtslint/dt.json", "rules": { - "no-misused-new": false + // TODOs + "no-misused-new": false, + "no-any-union": false } } diff --git a/types/bl/index.d.ts b/types/bl/index.d.ts index 12bbf0bec5..5d34052b80 100644 --- a/types/bl/index.d.ts +++ b/types/bl/index.d.ts @@ -9,7 +9,7 @@ import stream = require('stream'); declare class BufferList extends stream.Duplex { - new(callback?: (err: Error, buffer: Buffer) => void): void; + constructor(callback?: (err: Error, buffer: Buffer) => void); append(buffer: Buffer): void; get(index: number): number; diff --git a/types/bleno/bleno-tests.ts b/types/bleno/bleno-tests.ts index 7dcb47ff35..bd4b6971ee 100644 --- a/types/bleno/bleno-tests.ts +++ b/types/bleno/bleno-tests.ts @@ -45,7 +45,7 @@ Bleno.on('stateChange', (state: string) => { } }); -let characteristic = new EchoCharacteristic(); +const characteristic = new EchoCharacteristic(); Bleno.on('advertisingStart', (error: string) => { if (!error) { Bleno.setServices( diff --git a/types/bleno/tslint.json b/types/bleno/tslint.json index 3db14f85ea..26bcea6634 100644 --- a/types/bleno/tslint.json +++ b/types/bleno/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "dt-header": false + } +} diff --git a/types/bloomfilter/bloomfilter-tests.ts b/types/bloomfilter/bloomfilter-tests.ts index 650cc97eb4..96ee0443b6 100644 --- a/types/bloomfilter/bloomfilter-tests.ts +++ b/types/bloomfilter/bloomfilter-tests.ts @@ -1,7 +1,7 @@ import { BloomFilter } from 'bloomfilter'; function test_bloomfilter() { - const m: number = 10; - const k: number = 2; + const m = 10; + const k = 2; const bloomFilter = new BloomFilter(m, k); const array: Int32Array[] = bloomFilter.buckets; diff --git a/types/bluebird-global/tslint.json b/types/bluebird-global/tslint.json index b936b5e2b9..1d81af2349 100644 --- a/types/bluebird-global/tslint.json +++ b/types/bluebird-global/tslint.json @@ -5,6 +5,7 @@ "no-empty-interface": false, "array-type": false, "unified-signatures": false, - "ban-types": false + "ban-types": false, + "no-unnecessary-generics": false } } diff --git a/types/bluebird/bluebird-tests.ts b/types/bluebird/bluebird-tests.ts index 8aef9daa66..32ad2dcb4b 100644 --- a/types/bluebird/bluebird-tests.ts +++ b/types/bluebird/bluebird-tests.ts @@ -589,8 +589,10 @@ Promise.props({ num: 1, str: Promise.resolve('a') }).then(val => { propsValue = Promise.props(Promise.props({ num: 1, str: Promise.resolve('a') })).then(val => { propsValue = val }); var propsMapValue: Map; -Promise.resolve(new Map>()).props().then(val => { propsMapValue = val }); -Promise.props(new Map>()).then(val => { propsMapValue = val }); +Promise.resolve(new Map()).props().then(val => { propsMapValue = val }); +Promise.resolve(new Map>()).props().then(val => { propsMapValue = val }); +Promise.props(new Map()).then(val => { propsMapValue = val }); +Promise.props(new Map>()).then(val => { propsMapValue = val }); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/types/bluebird/index.d.ts b/types/bluebird/index.d.ts index 844dad53d4..77327127d1 100644 --- a/types/bluebird/index.d.ts +++ b/types/bluebird/index.d.ts @@ -46,7 +46,7 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { * Promises/A+ `.then()`. Returns a new promise chained from this promise. The new promise will be rejected or resolved dedefer on the passed `fulfilledHandler`, `rejectedHandler` and the state of this promise. */ // Based on PromiseLike.then, but returns a Bluebird instance. - then(onFulfill?: (value: R) => U | Bluebird.Thenable, onReject?: (error: any) => U | Bluebird.Thenable): Bluebird; // For simpler signature help. + then(onFulfill?: (value: R) => U | PromiseLike, onReject?: (error: any) => U | PromiseLike): Bluebird; // For simpler signature help. then(onfulfilled?: ((value: R) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): Bluebird; /** @@ -620,7 +620,7 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { /** * Same as calling `Promise.props(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. */ - props(this: PromiseLike | V>>): Bluebird>; + props(this: PromiseLike | V>>): Bluebird>; props(this: PromiseLike>): Bluebird; /** @@ -749,12 +749,12 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { * * If you pass a `receiver`, the `nodeFunction` will be called as a method on the `receiver`. */ - static promisify(func: (callback: (err: any, result: T) => void) => void, options?: Bluebird.PromisifyOptions): () => Bluebird; - static promisify(func: (arg1: A1, callback: (err: any, result: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1) => Bluebird; - static promisify(func: (arg1: A1, arg2: A2, callback: (err: any, result: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1, arg2: A2) => Bluebird; - static promisify(func: (arg1: A1, arg2: A2, arg3: A3, callback: (err: any, result: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1, arg2: A2, arg3: A3) => Bluebird; - static promisify(func: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, callback: (err: any, result: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1, arg2: A2, arg3: A3, arg4: A4) => Bluebird; - static promisify(func: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5, callback: (err: any, result: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => Bluebird; + static promisify(func: (callback: (err: any, result?: T) => void) => void, options?: Bluebird.PromisifyOptions): () => Bluebird; + static promisify(func: (arg1: A1, callback: (err: any, result?: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1) => Bluebird; + static promisify(func: (arg1: A1, arg2: A2, callback: (err: any, result?: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1, arg2: A2) => Bluebird; + static promisify(func: (arg1: A1, arg2: A2, arg3: A3, callback: (err: any, result?: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1, arg2: A2, arg3: A3) => Bluebird; + static promisify(func: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, callback: (err: any, result?: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1, arg2: A2, arg3: A3, arg4: A4) => Bluebird; + static promisify(func: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5, callback: (err: any, result?: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => Bluebird; static promisify(nodeFunction: Function, options?: Bluebird.PromisifyOptions): Function; /** diff --git a/types/body-parser/index.d.ts b/types/body-parser/index.d.ts index be10668973..2056c89b22 100644 --- a/types/body-parser/index.d.ts +++ b/types/body-parser/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for body-parser 1.16 // Project: https://github.com/expressjs/body-parser -// Definitions by: Santi Albo , Vilic Vane , Jonathan Häberle , Gevik Babakhani , Tomasz Łaziuk +// Definitions by: Santi Albo , Vilic Vane , Jonathan Häberle , Gevik Babakhani , Tomasz Łaziuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// diff --git a/types/bonjour/index.d.ts b/types/bonjour/index.d.ts index 0c2578121e..61b97e4ee8 100644 --- a/types/bonjour/index.d.ts +++ b/types/bonjour/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for bonjour 3.5 // Project: https://github.com/watson/bonjour -// Definitions by: Quentin Lampin , Nicolas Voigt +// Definitions by: Quentin Lampin , Nicolas Voigt // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// diff --git a/types/bookshelf/bookshelf-tests.ts b/types/bookshelf/bookshelf-tests.ts index f42a1bf784..77af31461b 100644 --- a/types/bookshelf/bookshelf-tests.ts +++ b/types/bookshelf/bookshelf-tests.ts @@ -182,10 +182,10 @@ exports.down = (knex: Knex) => { { class Site extends bookshelf.Model { - get tableName() { return 'sites'; } - photo(): Photo { - return this.morphOne(Photo, 'imageable'); - } + get tableName() { return 'sites'; } + photo(): Photo { + return this.morphOne(Photo, 'imageable'); + } } class Post extends bookshelf.Model { @@ -867,6 +867,10 @@ model.where('favorite_color', 'red').fetch().then(() => { model.where({favorite_color: 'red', shoe_size: 12}).fetch().then(() => { //... }); +// or +model.where('favorite_color', 'in', ['red', 'green']).fetch().then(() => { + // ... +}); /* Lodash methods, see http://bookshelfjs.org/#Model-subsection-lodash-methods */ @@ -1197,6 +1201,13 @@ ships.trigger('fetched'); /* collection.where(), see http://bookshelfjs.org/#Collection-instance-where */ +(new Author()) + .where('first_name', 'in', ['User', 'Resu']) + .fetchAll() + .then(() => { + // ... + }) + /* collection.withPivot(), see http://bookshelfjs.org/#Collection-instance-withPivot */ { diff --git a/types/bookshelf/index.d.ts b/types/bookshelf/index.d.ts index 55be61ba9e..bb817d3074 100644 --- a/types/bookshelf/index.d.ts +++ b/types/bookshelf/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for bookshelfjs v0.9.3 // Project: http://bookshelfjs.org/ -// Definitions by: Andrew Schurman , Vesa Poikajärvi +// Definitions by: Andrew Schurman , Vesa Poikajärvi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -84,6 +84,10 @@ declare namespace Bookshelf { values(): any[]; } + interface ModelSubclass { + new(): Model; + } + class Model> extends ModelBase { static collection>(models?: T[], options?: CollectionOptions): Collection; static count(column?: string, options?: SyncOptions): BlueBird; @@ -93,10 +97,10 @@ declare namespace Bookshelf { /** @deprecated should use `new` objects instead. */ static forge(attributes?: any, options?: ModelOptions): T; static where(properties: { [key: string]: any }): T; - static where(key: string, operatorOrValue: string | number | boolean, valueIfOperator?: string | number | boolean): T; + static where(key: string, operatorOrValue: string | number | boolean, valueIfOperator?: string | string[] | number | number[] | boolean): T; belongsTo>(target: { new (...args: any[]): R }, foreignKey?: string, foreignKeyTarget?: string): R; - belongsToMany>(target: { new (...args: any[]): R }, table?: string, foreignKey?: string, otherKey?: string): Collection; + belongsToMany>(target: { new (...args: any[]): R }, table?: string, foreignKey?: string, otherKey?: string, foreignKeyTarget?: string, otherKeyTarget?: string): Collection; count(column?: string, options?: SyncOptions): BlueBird; destroy(options?: DestroyOptions): BlueBird; fetch(options?: FetchOptions): BlueBird; @@ -106,8 +110,8 @@ declare namespace Bookshelf { load(relations: string | string[], options?: LoadOptions): BlueBird; morphMany>(target: { new (...args: any[]): R }, name?: string, columnNames?: string[], morphValue?: string): Collection; morphOne>(target: { new (...args: any[]): R }, name?: string, columnNames?: string[], morphValue?: string): R; - morphTo(name: string, columnNames?: string[], ...target: typeof Model[]): T; - morphTo(name: string, ...target: typeof Model[]): T; + morphTo(name: string, columnNames?: string[], ...target: ModelSubclass[]): T; + morphTo(name: string, ...target: ModelSubclass[]): T; orderBy(column: string, order?: SortOrder): T; // Declaration order matters otherwise TypeScript gets confused between query() and query(...query: string[]) @@ -120,9 +124,9 @@ declare namespace Bookshelf { resetQuery(): T; save(key?: string, val?: any, options?: SaveOptions): BlueBird; save(attrs?: { [key: string]: any }, options?: SaveOptions): BlueBird; - through>(interim: typeof Model, throughForeignKey?: string, otherKey?: string): R; + through>(interim: ModelSubclass, throughForeignKey?: string, otherKey?: string): R; where(properties: { [key: string]: any }): T; - where(key: string, operatorOrValue: string | number | boolean, valueIfOperator?: string | number | boolean): T; + where(key: string, operatorOrValue: string | number | boolean, valueIfOperator?: string | string[] | number | number[] | boolean): T; // See https://github.com/tgriesser/bookshelf/blob/0.9.4/src/errors.js // See https://github.com/tgriesser/bookshelf/blob/0.9.4/src/model.js#L1280 @@ -255,7 +259,7 @@ declare namespace Bookshelf { query(query: { [key: string]: any }): Collection; resetQuery(): Collection; - through>(interim: typeof Model, throughForeignKey?: string, otherKey?: string): Collection; + through>(interim: ModelSubclass, throughForeignKey?: string, otherKey?: string): Collection; updatePivot(attributes: any, options?: PivotOptions): BlueBird; withPivot(columns: string[]): Collection; diff --git a/types/boom/boom-tests.ts b/types/boom/boom-tests.ts index 38dc39058f..1819be25cb 100644 --- a/types/boom/boom-tests.ts +++ b/types/boom/boom-tests.ts @@ -136,7 +136,8 @@ const gatewayTimeoutError = Boom.gatewayTimeout('message', {some: 'data'}); gatewayTimeoutError.data.some; const gatewayTimeoutError2: Boom.BoomError = Boom.gatewayTimeout('message'); -// wrap and create +// boomify, wrap, and create +const boomifiedError = Boom.boomify(new Error('test'), { statusCode: 400, message: 'some message' }) const wrappedError = Boom.wrap(new Error('test'), 400, 'some message'); diff --git a/types/boom/index.d.ts b/types/boom/index.d.ts index b8f41a85be..8025a7ddab 100644 --- a/types/boom/index.d.ts +++ b/types/boom/index.d.ts @@ -1,6 +1,8 @@ // Type definitions for boom 4.3 -// Project: http://github.com/hapijs/boom -// Definitions by: Igor Rogatty , AJP +// Project: https://github.com/hapijs/boom +// Definitions by: Igor Rogatty +// AJP +// Jinesh Shah // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -53,6 +55,14 @@ declare namespace Boom { // Excluded this to aid typing of the other values. See tests for example casting to a custom interface to manipulate the payload // [anyContent: string]: any; } + + /** + * Decorates an error with the boom properties + * @param error the error object to wrap. If error is already a boom object, it defaults to overriding the object with the new status code and message. + * @param options optional additional options + * @see {@link https://github.com/hapijs/boom#boomifyerror-options} + */ + export function boomify(error: Error, options?: { statusCode?: number, message?: string, override?: boolean }): BoomError; /** * Decorates an error with the boom properties diff --git a/types/boom/v3/index.d.ts b/types/boom/v3/index.d.ts index 2c0a3ce21d..adf433c9f4 100644 --- a/types/boom/v3/index.d.ts +++ b/types/boom/v3/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for boom 3.2 -// Project: http://github.com/hapijs/boom -// Definitions by: Igor Rogatty +// Project: https://github.com/hapijs/boom +// Definitions by: Igor Rogatty // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// diff --git a/types/bootbox/index.d.ts b/types/bootbox/index.d.ts index 7007d80feb..ba5cc8c23b 100644 --- a/types/bootbox/index.d.ts +++ b/types/bootbox/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Bootbox 4.4.0 // Project: https://github.com/makeusabrew/bootbox -// Definitions by: Vincent Bortone , Kon Pik , Anup Kattel , Dominik Schroeter , Troy McKinnon , Stanny Nuytkens +// Definitions by: Vincent Bortone , Kon Pik , Anup Kattel , Dominik Schroeter , Troy McKinnon , Stanny Nuytkens // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/bootpag/index.d.ts b/types/bootpag/index.d.ts index 20fee59ff2..af47cc3219 100644 --- a/types/bootpag/index.d.ts +++ b/types/bootpag/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for jQuery-Bootpag 1.0.7 // Project: http://botmonster.com/jquery-bootpag/ -// Definitions by: MAF.DAP / Romain Deneau +// Definitions by: MAF.DAP / Romain Deneau // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/bootstrap-datepicker/index.d.ts b/types/bootstrap-datepicker/index.d.ts index 34a40d60fa..02eda0fba8 100644 --- a/types/bootstrap-datepicker/index.d.ts +++ b/types/bootstrap-datepicker/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for bootstrap-datepicker // Project: https://github.com/eternicode/bootstrap-datepicker -// Definitions by: Boris Yankov +// Definitions by: Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/bootstrap-notify/index.d.ts b/types/bootstrap-notify/index.d.ts index 441bb33c39..0517b62cf8 100644 --- a/types/bootstrap-notify/index.d.ts +++ b/types/bootstrap-notify/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for bootstrap-notify v3.1.3 // Project: http://bootstrap-notify.remabledesigns.com/ -// Definitions by: Blake Niemyjski , Robert McIntosh , Robert Voica +// Definitions by: Blake Niemyjski , Robert McIntosh , Robert Voica // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/bootstrap-slider/bootstrap-slider-tests.ts b/types/bootstrap-slider/bootstrap-slider-tests.ts index 8b59a25a36..2073a3de9d 100644 --- a/types/bootstrap-slider/bootstrap-slider-tests.ts +++ b/types/bootstrap-slider/bootstrap-slider-tests.ts @@ -12,7 +12,7 @@ $(() => { $('#ex2').slider({}); const RGBChange = () => { - $('#RGB').css('background', 'rgb(' + r.getValue() + ',' + g.getValue() + ',' + b.getValue() + ')'); + $('#RGB').css('background', `rgb(${r.getValue()},${g.getValue()},${b.getValue()})`); }; const r = $('#R').slider() diff --git a/types/bootstrap-table/index.d.ts b/types/bootstrap-table/index.d.ts index 166289f14f..8f29583e56 100644 --- a/types/bootstrap-table/index.d.ts +++ b/types/bootstrap-table/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Bootstrap Table v1.11.0 // Project: http://bootstrap-table.wenzhixin.net.cn/ -// Definitions by: Talat Baig +// Definitions by: Talat Baig // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/bootstrap-treeview/bootstrap-treeview-tests.ts b/types/bootstrap-treeview/bootstrap-treeview-tests.ts new file mode 100644 index 0000000000..421df3b9dc --- /dev/null +++ b/types/bootstrap-treeview/bootstrap-treeview-tests.ts @@ -0,0 +1,105 @@ +// A example tree structure + +let data: BootstrapTreeViewNodeData[] = [ + { + text: "Parent 1", + nodes: [ + { + text: "Child 1", + nodes: [ + { + text: "Grandchild 1" + }, + { + text: "Node 1", + icon: "glyphicon glyphicon-stop", + selectedIcon: "glyphicon glyphicon-stop", + color: "#000000", + backColor: "#FFFFFF", + href: "#node-1", + selectable: true, + state: { + checked: true, + disabled: true, + expanded: true, + selected: true + }, + tags: ['available'] + } + ] + }, + { + text: "Child 2" + } + ] + }, + { + text: "Parent 2" + }, + { + text: "Parent 3" + }, + { + text: "Parent 4" + }, + { + text: "Parent 5" + } +]; + +// Example for treeview init with options + +$('#tree').treeview({ + data, + levels: 5, + backColor: 'green' +}); + +// Treeview functions. + +let nodeId = 5; + +let node: BootstrapTreeViewNodeData = data[0]; + +$('#tree').treeview('checkAll', { silent: true }); +$('#tree').treeview('checkNode', [ nodeId, { silent: true } ]); +$('#tree').treeview('clearSearch'); +$('#tree').treeview('collapseAll', { silent: true }); +$('#tree').treeview('collapseNode', [ nodeId, { silent: true, ignoreChildren: false } ]); +$('#tree').treeview('disableAll', { silent: true }); +$('#tree').treeview('disableNode', [ nodeId, { silent: true } ]); +$('#tree').treeview('enableAll', { silent: true }); +$('#tree').treeview('enableNode', [ nodeId, { silent: true } ]); +$('#tree').treeview('expandAll', { levels: 2, silent: true }); +$('#tree').treeview('expandNode', [ nodeId, { levels: 2, silent: true } ]); +$('#tree').treeview('getCollapsed', nodeId); +$('#tree').treeview('getDisabled', nodeId); +$('#tree').treeview('getEnabled', nodeId); +$('#tree').treeview('getExpanded', nodeId); +$('#tree').treeview('getExpanded', nodeId); +$('#tree').treeview('getParent', node); +$('#tree').treeview('getSelected', nodeId); +$('#tree').treeview('getSiblings', node); +$('#tree').treeview('getUnselected', nodeId); +$('#tree').treeview('remove'); +$('#tree').treeview('revealNode', [ nodeId, { silent: true } ]); +$('#tree').treeview('search', [ 'Parent', { + ignoreCase: true, // case insensitive + exactMatch: false, // like or equals + revealResults: true, // reveal matching nodes +}]); +$('#tree').treeview('selectNode', [ nodeId, { silent: true } ]); +$('#tree').treeview('toggleNodeChecked', [ nodeId, { silent: true } ]); +$('#tree').treeview('toggleNodeDisabled', [ nodeId, { silent: true } ]); +$('#tree').treeview('toggleNodeExpanded', [ nodeId, { silent: true } ]); +$('#tree').treeview('toggleNodeSelected', [ nodeId, { silent: true } ]); +$('#tree').treeview('uncheckAll', { silent: true }); +$('#tree').treeview('uncheckNode', [ nodeId, { silent: true } ]); +$('#tree').treeview('unselectNode', [ nodeId, { silent: true } ]); + +// Test events +$('#tree').treeview({ + onNodeSelected: (event: any, data: BootstrapTreeViewNodeData) => void { + // Event handler + } +}); diff --git a/types/bootstrap-treeview/index.d.ts b/types/bootstrap-treeview/index.d.ts new file mode 100644 index 0000000000..fa771a6043 --- /dev/null +++ b/types/bootstrap-treeview/index.d.ts @@ -0,0 +1,70 @@ +// Type definitions for bootstrap-treeview.js 1.20 +// Project: https://github.com/jonmiles/bootstrap-treeview +// Definitions by: Jan Böhmer +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/// + +interface BootstrapTreeViewNodeData { + text?: string; + icon?: string; + selectedIcon?: string; + color?: string; + backColor?: string; + href?: string; + selectable?: boolean; + nodeId?: number; + state?: { + checked: boolean; + disabled: boolean; + expanded: boolean; + selected: boolean; + }; + tags?: string[]; + nodes?: BootstrapTreeViewNodeData[]; +} + +interface BootstrapTreeViewOptions { + data?: BootstrapTreeViewNodeData[]; + backColor?: string; + borderColor?: string; + checkedIcon?: string; + collapseIcon?: string; + color?: string; + emptyIcon?: string; + enableLinks?: boolean; + expandIcon?: string; + highlightSearchResults?: boolean; + highlightSelected?: boolean; + levels?: number; + multiSelect?: boolean; + nodeIcon?: string; + onhoverColor?: string; + selectedIcon?: string; + searchResultBackColor?: string; + searchResultColor?: string; + selectedBackColor?: string; + selectedColor?: string; + showBorder?: boolean; + showCheckbox?: boolean; + showIcon?: boolean; + showTags?: boolean; + uncheckedIcon?: boolean; + + onNodeSelected?(event: any, node: BootstrapTreeViewNodeData): void; + onNodeChecked?(event: any, node: BootstrapTreeViewNodeData): void; + onNodeCollapsed?(event: any, node: BootstrapTreeViewNodeData): void; + onNodeDisabled?(event: any, node: BootstrapTreeViewNodeData): void; + onNodeEnabled?(event: any, node: BootstrapTreeViewNodeData): void; + onNodeExpanded?(event: any, node: BootstrapTreeViewNodeData): void; + onNodeUnchecked?(event: any, node: BootstrapTreeViewNodeData): void; + onNodeUnselected?(event: any, node: BootstrapTreeViewNodeData): void; + onSearchComplete?(event: any, node: BootstrapTreeViewNodeData): void; + onSearchCleared?(event: any, node: BootstrapTreeViewNodeData): void; +} + +interface JQuery { + treeview(options: BootstrapTreeViewOptions): JQuery; + treeview(method: string, ...args: any[]): JQuery; +} diff --git a/types/bootstrap-treeview/tsconfig.json b/types/bootstrap-treeview/tsconfig.json new file mode 100644 index 0000000000..0dce7ab41a --- /dev/null +++ b/types/bootstrap-treeview/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "bootstrap-treeview-tests.ts" + ] +} diff --git a/types/bootstrap-treeview/tslint.json b/types/bootstrap-treeview/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/bootstrap-treeview/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/bootstrap-validator/index.d.ts b/types/bootstrap-validator/index.d.ts index e9f2073d70..9a0c700fc4 100644 --- a/types/bootstrap-validator/index.d.ts +++ b/types/bootstrap-validator/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for bootstrap-validator 0.11 // Project: https://github.com/1000hz/bootstrap-validator -// Definitions by: Brady Liles +// Definitions by: Brady Liles // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/bootstrap.paginator/index.d.ts b/types/bootstrap.paginator/index.d.ts index b79e7bca0a..55ee536378 100644 --- a/types/bootstrap.paginator/index.d.ts +++ b/types/bootstrap.paginator/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for bootstrap.paginator // Project: https://github.com/lyonlai/bootstrap-paginator -// Definitions by: derikwhittaker +// Definitions by: derikwhittaker // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/bootstrap.timepicker/index.d.ts b/types/bootstrap.timepicker/index.d.ts index f0cc7f472b..49283cfde7 100644 --- a/types/bootstrap.timepicker/index.d.ts +++ b/types/bootstrap.timepicker/index.d.ts @@ -1,13 +1,13 @@ // Type definitions for bootstrap.timepicker // Project: https://github.com/jdewit/bootstrap-timepicker -// Definitions by: derikwhittaker +// Definitions by: derikwhittaker , Heather Booker // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 /// interface TimepickerOptions { - defaultTime?: string|boolean; + defaultTime?: string|boolean|Date; disableFocus?: boolean; disableMousewheel?: boolean; explicitMode?: boolean; diff --git a/types/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker-tests.ts b/types/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker-tests.ts index 9f2b780f44..fe985e229f 100644 --- a/types/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker-tests.ts +++ b/types/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker-tests.ts @@ -118,7 +118,7 @@ function test_timeZone() { function test_widgetParent() { let nullW: null = null; - let str: string = "myId"; + let str = "myId"; let jquery = $("#element"); $("#picker").datetimepicker({ diff --git a/types/bootstrap.v3.datetimepicker/index.d.ts b/types/bootstrap.v3.datetimepicker/index.d.ts index 9f2f5dda78..7b1d3877ba 100644 --- a/types/bootstrap.v3.datetimepicker/index.d.ts +++ b/types/bootstrap.v3.datetimepicker/index.d.ts @@ -589,7 +589,7 @@ export interface UpdateEvent extends JQueryEventObject { viewDate: moment.Moment; } -export type EventName = "dp.show" | "dp.hide" | "dp.error"; +export type EventName = "dp.show" | "dp.hide" | "dp.error"; declare global { interface JQuery { diff --git a/types/bootstrap.v3.datetimepicker/package.json b/types/bootstrap.v3.datetimepicker/package.json index 4c6d24a445..fce08a048d 100644 --- a/types/bootstrap.v3.datetimepicker/package.json +++ b/types/bootstrap.v3.datetimepicker/package.json @@ -1,4 +1,5 @@ { + "private": true, "dependencies": { "moment": ">=2.14.0" } diff --git a/types/bootstrap.v3.datetimepicker/tslint.json b/types/bootstrap.v3.datetimepicker/tslint.json index e6e6a68ad5..5b3c4f7877 100644 --- a/types/bootstrap.v3.datetimepicker/tslint.json +++ b/types/bootstrap.v3.datetimepicker/tslint.json @@ -1,6 +1,7 @@ { "extends": "dtslint/dt.json", "rules": { + "no-any-union": false, // TODO "quotemark": [true, "double", "avoid-escape"] } } diff --git a/types/bootstrap.v3.datetimepicker/v3/package.json b/types/bootstrap.v3.datetimepicker/v3/package.json index 4c6d24a445..fce08a048d 100644 --- a/types/bootstrap.v3.datetimepicker/v3/package.json +++ b/types/bootstrap.v3.datetimepicker/v3/package.json @@ -1,4 +1,5 @@ { + "private": true, "dependencies": { "moment": ">=2.14.0" } diff --git a/types/bootstrap/index.d.ts b/types/bootstrap/index.d.ts index cd15ad62ee..9fa10bcdbb 100644 --- a/types/bootstrap/index.d.ts +++ b/types/bootstrap/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Bootstrap 3.3.5 // Project: http://twitter.github.com/bootstrap/ -// Definitions by: Boris Yankov +// Definitions by: Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/botvs/botvs-tests.ts b/types/botvs/botvs-tests.ts new file mode 100644 index 0000000000..96c424c164 --- /dev/null +++ b/types/botvs/botvs-tests.ts @@ -0,0 +1,7 @@ +_N(0, 1); +_C(() => void 0); +Sleep(1e3); +const data: botvs.Record | undefined = void 0; +console.log(data); +TA.Alligator([]); +talib.help('XML'); diff --git a/types/botvs/index.d.ts b/types/botvs/index.d.ts new file mode 100644 index 0000000000..2eabcb98da --- /dev/null +++ b/types/botvs/index.d.ts @@ -0,0 +1,4106 @@ +// Type definitions for botvs 0.1 +// Project: https://www.botvs.com/ +// Definitions by: acrazing +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/// + +import Highstock = require('highcharts/highstock'); + +declare global { + namespace botvs { + /** + * 订单的状态 + */ + type VOrderState = object; + + /** + * 订单的类型 + */ + type VOrderType = object; + + /** + * 仓位的类型 + */ + type VPositionType = object; + + /** + * K线周期 + */ + type VPeriod = object; + + /** + * 日志类型 + */ + type VLogType = object; + + interface ChartOptions extends Highstock.Options { + __isStock?: boolean; + } + + interface RChart { + add(series?: number, data?: number, index?: number): void; + reset(): void; + } + + interface Socket { + write(data: string, timeout?: number): number; + read(size?: number): Buffer | null; + close(): void; + } + + /** + * 标准OHLC结构, 用来画K线和指标分析用的,由GetRecords函数返回此结构数组 + */ + interface Record { + /** + * 一个时间戳, 精确到毫秒,与Javascript的 new Date().getTime() 得到的结果格式一样 + */ + Time: number; + /** + * 开盘价 + */ + Open: number; + /** + * 最高价 + */ + High: number; + /** + * 最低价 + */ + Low: number; + /** + * 收盘价 + */ + Close: number; + /** + * 成交量 + */ + Volume: number; + } + + /** + * 市场深度单 + */ + interface MarketOrder { + /** + * 价格 + */ + Price: number; + /** + * 数量 + */ + Amount: number; + } + + /** + * 市场行情 + */ + interface Ticker { + /** + * 最高价 + */ + High: number; + /** + * 最低价 + */ + Low: number; + /** + * 卖一价 + */ + Sell: number; + /** + * 买一价 + */ + Buy: number; + /** + * 最后成交价 + */ + Last: number; + /** + * 最近成交量 + */ + Volume: number; + } + + /** + * 订单结构, 由GetOrder函数返回 + */ + interface Order { + /** + * 交易单唯一标识 + */ + Id: string; + /** + * 下单价格 + */ + Price: number; + /** + * 下单数量 + */ + Amount: number; + /** + * 成交数量 + */ + DealAmount: number; + /** + * 订单状态, 参考常量里的订单状态 + */ + Status: VOrderState; + /** + * 订单类型, 参考常量里的订单类型 + */ + Type: VOrderType; + } + + /** + * 市场深度,由GetDepth函数返回 + */ + interface Depth { + /** + * 卖单数组, MarketOrder数组, 按价格从低向高排序 + */ + Asks: MarketOrder[]; + /** + * 买单数组, MarketOrder数组, 按价格从高向低排序 + */ + Bids: MarketOrder[]; + } + + /** + * 获取所有交易历史(非自己),由GetTrades函数返回 + */ + interface Trade { + /** + * Id(交易所返回的此Trade的唯一Id) + */ + Id: string; + /** + * 时间(Unix timestamp 毫秒) + */ + Time: number; + /** + * 价格 + */ + Price: number; + /** + * 数量 + */ + Amount: number; + /** + * 订单类型, 参考常量里的订单类型 + */ + Type: VOrderType; + } + + /** + * 手续费结构, 由GetFee函数返回(如国外平台bitfinex买入卖出手续费跟账户交易量相关) + */ + interface Fee { + /** + * 卖出手续费, 为一个浮点数, 如0.2表示0.2%的手续费 + */ + Sell: number; + /** + * 买入手续费, 格式同上 + */ + Buy: number; + } + + /** + * 账户信息, 由GetAccount函数返回 + */ + interface Account { + /** + * 余额(人民币或者美元, 在Poloniex交易所里BTC_ETC这样的品种, Balance就指的是BTC的数量, + * Stocks指的是ETC数量, BTC38的ETC_BTC相当于Poloniex的BTC_ETC, 指的是以BTC计价) + */ + Balance: number; + /** + * 冻结的余额 + */ + FrozenBalance: number; + /** + * BTC/LTC数量, 现货为当前可操作币的余额(去掉冻结的币), + * 期货的话为合约当前可用保证金(传统期货为此属性) + */ + Stocks: number; + /** + * 冻结的BTC/LTC数量(传统期货无此属性) + */ + FrozenStocks: number; + } + + /** + * 期货交易中的持有仓位信息, 由GetPosition()函数返回此结构数组 + */ + interface Position { + /** + * 杆杠大小, 796期货有可能为5, 10, 20三个参数, OKCoin为10或者20, + * BitVC期货和OK期货的全仓模式返回为固定的10, 因为原生API不支持 + */ + MarginLevel: number; + /** + * 持仓量, 796期货表示持币的数量, BitVC指持仓的总金额(100的倍数), + * OKCoin表示合约的份数(整数且大于1) + */ + Amount: number; + /** + * 可平量, 只有股票有此选项, 表示可以平仓的数量(股票为T+1)今日仓不能平 + */ + CanCover: number; + /** + * 仓位冻结量 + */ + FrozenAmount: number; + /** + * 持仓均价 + */ + Price: number; + /** + * 持仓浮动盈亏(数据货币单位:BTC/LTC, 传统期货单位:RMB, 股票不支持此字段, + * 注: OKCoin期货全仓情况下指实现盈余, 并非持仓盈亏, 逐仓下指持仓盈亏) + */ + Profit: number; + /** + * PD_LONG为多头仓位(CTP中用closebuy_today平仓), PD_SHORT为空头仓位(CTP用closesell_today)平仓, + * (CTP期货中)PD_LONG_YD为咋日多头仓位(用closebuy平), PD_SHORT_YD为咋日空头仓位(用closesell平) + */ + Type: VPositionType; + /** + * 商品期货为合约代码, 股票为'交易所代码_股票代码', 具体参数SetContractType的传入类型 + */ + ContractType: string; + } + + interface AsyncJob { + wait(timeout?: number): T | null | undefined; + } + + interface Exchange { + /** + * 返回交易所名称(string) + * + * @return {string} + */ + GetName(): string; + + /** + * 返回交易所自定义的标签(string) + * + * @return {string} + */ + GetLabel(): string; + + /** + * 返回交易所使用的美元的汇率, OKCoin期货返回官方提供的汇率, 该值不受SetRate影响 + * + * @return {number} + */ + GetUSDCNY(): number; + + /** + * 返回交易所使用的流通货币与人民币的汇率, 返回1表示禁用汇率转换 + * + * 汇率接口调用雅虎提供的接口, 5分钟更新一次 + * 所有函数自动经过汇率转换,如果为1指禁用汇率转换 + * + * @return {number} + */ + GetRate(): number; + + /** + * 设置交易所的流通货币的汇率, 返回设置前的汇率, 设置为1指禁用汇率转换 + * + * 比如796期货设置SetRate(6.13), 就是设定USD/EUR对CNY的汇率为6.13, 程序所有价格会自动用这个汇率计算 + * SetRate(), 如果不加参数,则恢复系统内置汇率 + * SetRate(1), 就是禁用汇率转换 + * + * @param {number} rate + */ + SetRate(rate?: number): void; + + /** + * 设置价格与品种下单量的小数位精度, 设置后会自动截断 + * + * exchange.SetPrecision(2, 3); // 设置价格小数位精度为2位, 品种下单量小数位精度为3位 + * + * @param {number} PricePrecision + * @param {number} AmountPrecision + */ + SetPrecision(PricePrecision: number, AmountPrecision: number): void; + + /** + * 返回交易所操作的货币名称(string), 传统期货CTP返回的固定为STOCK + * + * @return {string} + */ + GetCurrency(): string; + + /** + * 返回交易所操作的基础货币名称(string), BTC_CNY就返回CNY, ETH_BTC就返回BTC + * + * @return {string} + */ + GetBaseCurrency(): string; + + /** + * 返回一个Ticker结构 + * + * @return {botvs.Ticker} + */ + GetTicker(): Ticker; + + /** + * 返回一个Depth结构 + * + * @return {botvs.Depth} + */ + GetDepth(): Depth; + + /** + * 返回一个Trade数组, 按时间从低到高的顺序, 只支持数字货币(BTC/LTC) + * + * @return {botvs.Trade[]} + */ + GetTrades(): Trade[]; + + /** + * 返回一个K线历史, K线周期在创建机器人时指定, Record数组结构 + * + * 不加参数, 默认返回添加机器人时时指量的K线周期, 但也可以自定义K线周期 + * 支持: PERIOD_M1 指1分钟, PERIOD_M5 指5分钟, PERIOD_M15 指15分钟, + * PERIOD_M30 指30分钟, PERIOD_H1 指1小时, PERIOD_D1 指一天 + * + * @param {number} Period + * @return {botvs.Record[]} + */ + GetRecords(Period?: VPeriod): Record[]; + + /** + * 返回一个Account结构, 如exchange.GetAccount(), 将返回主交易所账户信息 + * + * @return {botvs.Account} + */ + GetAccount(): Account; + + /** + * 下买单, Price为买单价格,Amount为数量, 返回一个订单ID + * + * 可以跟多余的参数做为附加消息显示到日志, 如exchange.Buy(1000,0.1, "OK", 123) + * 支持现货(火币/BitVC/OKCoin/OKCoin国际/OKCoin期货/BTCChina/BitYes)市价单, 市价单价格指定为-1 + * exchange.Buy(1000), 指买市价1000元的币, BTCChina例外exchange.Buy(0.3)指市价买0.3个币 + * + * @param {number} Price + * @param {number} Amount + * @param {*[]} args + * @return {string} - 订单ID + */ + Buy(Price: number, Amount: number, ...args: any[]): string; + + /** + * 跟Buy函数一样的调用方法和场景 {@see Exchange#Buy} + * + * @param {number} Price + * @param {number} Amount + * @return {string} + */ + Sell(Price: number, Amount: number): string; + + /** + * 获取所有未完成的订单, 返回一个Order数组结构 + * + * @return {botvs.Order[]} + */ + GetOrders(): Order[]; + + /** + * 根据订单号获取订单详情, 返回一个Order结构 + * + * @param {string} orderId + * @return {botvs.Order} + */ + GetOrder(orderId: string): Order; + + /** + * 根据订单号取消一个订单, 返回true或者false + * + * @param {string} orderId + * @return {boolean} + */ + CancelOrder(orderId: string): boolean; + + /** + * 不下单, 只记录交易信息, logType可为LOG_TYPE_BUY/LOG_TYPE_SELL/LOG_TYPE_CANCEL + * + * @param {VLogType} logType + * @param {string} orderId + * @param {number} price + * @param {number} amount + */ + Log(logType: VLogType, orderId: string, price: number, amount: number): void; + + /** + * 返回币最小交易数量 + * + * @return {number} + */ + GetMinStock(): number; + + /** + * 返回一笔订单要求的最小金额(价格*数量) + * + * Bitstamp要求5美元(程序会根据汇率自动转换为人民币), 其它没有限制 + * + * @return {number} + */ + GetMinPrice(): number; + + /** + * 返回一个Fee结构 + * + * @return {botvs.Fee} + */ + GetFee(): Fee; + + /** + * 返回最后一次REST API请求返回的原始内容(字符串), 用户可以用来自己解析扩展信息 + * + * 注: 模拟测试的话,会一直返回一个空字符串, 只在真实环境下有效 + * exchange.GetAccount(); + * var obj = JSON.parse(exchange.GetRawJSON()); + * + * 传统商品期货API获取更多信息 + * exchange.GetAccount(); + * Log(exchange.GetRawJSON());//在GetAccount成功后调用, 获取更详细的账户信息, 可以用JSON.parse解析 + * 也支持GetTicker, GetDepth后的exchange.GetRawJSON(), 以及GetPosition与GetOrders,GetOrder这三个调用后的详细反馈数据 + * + * @return {string} + */ + GetRawJSON(): string; + + /** + * 多线程异步支持函数, 可以把所有支持的函数的操作变成异步并发的.(只支持数字货币交易平台) + * + * Support: GetTicker, GetDepth, GetTrades, GetRecords, GetAccount, GetOrders, GetOrder, CancelOrder, Buy, + * Sell, GetPosition var a = exchange.Go("GetTicker"); // GetTicker 异步多线程执行 var b = + * exchange.Go("GetDepth"); var c = exchange.Go("Buy", 1000, 0.1); var d = exchange.Go("GetRecords", + * PERIOD_H1); + * + * // 上面四种操作是并发多线程异步执行, 不会耗时, 立即返回的 + * + * var ticker = a.wait(); // 调用wait方法等待返回异步获取ticker结果 + * var depth = b.wait(); // 返回深度, 如果获取失败也是有可能返回null的 + * var orderId = c.wait(1000); // 返回订单号, 限定1秒超时, 超时返回undefined, 此对像可以继续调用wait等待如果上次wait超时 + * // 注意: 判断undefiend要用typeof(xx) === "undefined", 因为null==undefined在JavaScript里是成立的 + * + * var records = d.wait(); // 等待K线结果 + * var ret = d.wait(); // 这里wait了一个已经wait过且结束的异步操作, 会返回null, 并记录出错信息. + * // Python与Javascript的区别, Python的wait返回两个参数, 第一个是异步的api返回的结果, 第二个表示是异步调用是否完成 + * ret, ok = d.wait() // ok是一定返回True的, 除非策略被停止 + * ret, ok = d.wait(100) // ok返回False, 如果等待超时, 或者wait了一个已经结束的实例 + * + * @param {keyof botvs.Exchange} Method + * @param Args + * @return {botvs.AsyncJob} + */ + Go(Method: keyof Exchange, ...Args: any[]): AsyncJob; + + /** + * 调用交易所其它功能接口 + * + * 支持所有数字货币交易所 + * exchange.IO("api", "cancel_borrow", "symbol=cny&borrow_id=123"); // no need api & sign + * Detail: {@link https://www.botvs.com/bbs-topic/146} + * + * // 只支持Websocket模式(huobi, okcoin.cn, BTCC支持)与商品期货CTP协议 + * + * exchange.IO("websocket"); // 切换行情通信协议到websocket(默认为rest), Ticker, + * Depth会切换为websocket协议来更新, 商品期货CTP无需切换 + * + * + * // 切换GetTicker, GetDepth数据更新模式 + * + * exchange.IO("mode", 0); // 立即返回模式, 如果当前还没有接收到交易所最新的行情数据推送, 就立即返回旧的行情数据, + * 如果有新的数据就返回新的数据 + * + * exchange.IO("mode", 1); // 缓存模式(默认模式), + * 如果当前还没有收到交易所最新的行情数据(同上一次api获取的数据比较), 就等待接收然后再返回, 如果调用该函数之前收到了最新的行情数据, + * 就立即返回最新的数据 + * + * exchange.IO("mode", 2); // 强制更新模式, 进入等待一直到接收到交易所下一次的最新推送数据后返回 + * + * + * + * // 如果想第一时间获取最新的行情可以切换到websocket后不Sleep的立即检测数据, GetTicker, GetDepth用缓存模式进行工作 + * + * exchange.IO("websocket"); + * + * while (true) { + * Log(exchange.GetTicker()); + * } + * + * 传统商品期货扩展的IO功能 + * exchange.IO("status"); // 返回true证明与CTP服务器行情与数据的两台服务器都连接正常 + * exchange.IO("instruments"); // 返回交易所所有的合约列表{合约名: 详情}字典形式, 只支持实盘 + * exchange.IO("products"); // 返回交易所所有的产品列表{产品名: 详情}字典形式, 只支持实盘 + * exchange.IO("subscribed"); // 返回已订阅行情的合约, 格式同上, 只支持实盘 + * exchange.IO("settlement"); // 结算单查询, 不加第二个参数默认返回之前一个交易日的, + * 加参数如"20170317"指返回20170317的结算单, 只支持实盘 + * exchange.IO("wait"); // 有任何品种更新行情信息时才返回, 可带第二个参数(毫秒数)指定超时, + * 超时返回-1, 正常返回事件接收的时间(nano级), 只支持实盘 + * exchange.IO("wait_instrument"); // 有任何品种更新行情信息时才返回, 可带第二个参数(毫秒数) + * 指定超时, 超时返回空字符串, 正常返回触发事件的品种名称, 只支持实盘 + * + * @param {"api" | "usd" | "cny" | "currency" | string} Api + * @param {string} ApiName + * @param {string} Args + * @return {T} + */ + IO(Api: 'api' | 'usd' | 'cny' | 'currency' | string, ApiName?: string, Args?: string): T; + + /** + * 获取当前持仓信息 + * + * 返回一个Position数组, (BitVC和OKCoin)可以传入一个参数, 指定要获取的合约类型 + * + * @return {botvs.Position[]} + */ + GetPosition(): Position[]; + + /** + * 设置杆杠大小 + * + * 设置Buy(多单)或者Sell(空单)的杆杠大小, MarginLevel有5, 10, 20 三个可选参数 + * 796支持5,10,20,50三个选项, BitVC的LTC不支持20倍杠杆, OKCoin支持10倍和20倍 + * 如: exchange.SetMarginLevel(5) + * + * @param {number} MarginLevel + */ + SetMarginLevel(MarginLevel: number): void; + + /** + * 设置Buy或者Sell下单类型 + * + * Direction可以取buy, closebuy, sell, closesell四个参数, 传统期货多出closebuy_today,与closesell_today, 指平今仓, + * 默认为closebuy/closesell为平咋仓 对于CTP传统期货, 可以设置第二个参数"1"或者"2"或者"3", 分别指"投机", "套利", "套保", + * 不设置默认为投机 股票只支持buy与closebuy, + * 因为股票只能买跟平仓 exchange.SetMarginLevel(5); exchange.SetDirection("buy"); exchange.Buy(1000, 2); + * exchange.SetMarginLevel(5); exchange.SetDirection("closebuy"); exchange.Sell(1000, 2); + * + * 期货交易中Buy, Sell, CancelOrder和现货交易的区别 + * Buy或Sell之前需要调用SetMarginLevel和SetDirection明确操作类型 + * 数字货币796的CancelOrder之前需要调用SetDirection明确订单类型 + * 如: + * exchange.SetDirection("sell"); + * exchange.Sell(1000, 2); + * 如: + * exchange.SetDirection("buy"); + * exchange.CancelOrder(123); + * + * 数字货币BitVC期货交易中Buy, Sell, GetOrder, SetMarginLevel与796的区别 + * GetOrder里面的Amount为订单总金额, DealAmount为订单完成的金额, 不是币的个数 + * 数字货币796的CancelOrder之前需要调用SetDirection明确订单类型 + * Buy或Sell第二个参数不是币的数量而是订单的总金额(100的倍数) + * SetMarginLevel LTC不支持20倍杠杆 + * 如: + * exchange.SetContractType("week"); exchange.SetDirection("sell"); + * exchange.Sell(1000, 100), 就是以1000元一个币的价格开100元的空头 + * + * 数字货币OKCoin期货交易中Buy, Sell, GetOrder, SetMarginLevel与796的区别 + * GetOrder里面的Amount为合约数(一份合约为10$), DealAmount为订单完成的合约数, 不是币的个数 + * Buy或Sell第二个参数不是币的数量而是合约的份数(整数且大于0) + * SetMarginLevel 只支持10倍和20倍的杠杆 + * 如: 以1000元一个币的价格做空一份合约(10$的LTC或者100$的BTC): + * exchange.SetContractType("this_week"); + * exchange.SetDirection("sell"); + * exchange.Sell(1000, 1); + * + * @param {"buy" | "closebuy" | "sell" | "closesell" | "closebuy_today" | "closesell_today"} Direction + * @constructor + */ + SetDirection(Direction: 'buy' | 'closebuy' | 'sell' | 'closesell' | 'closebuy_today' | 'closesell_today'): void; + + /** + * 设置合约类型 + * + * 传统的CTP期货的ContractType就是指的合约ID, 如SetContractType("au1506") 返回合约的详细信息, 如最少一次买多少, 手续费, + * 交割时间等, + * 主力连续合约为代码为000如MA000, 只支持回测, 不支持实盘 股票合约格式为 股票代码.(SH/SZ), SH指上交所, SZ指深交所, + * 如000001.SZ就是指深交所的平安银行 商品期货与股票取消订阅合约, + * 在合约名前加上"-"前缀重新调用即可, 如SetContractType("-au1506"); 成功返回true 数字货币796支持: "week", "weekcny", + * 默认为子账户A, 要指定子账户是A还是B, + * 在合约后加"@A"或"@B", 如: "day@A" 为日合约A子账户 BitVC有week和quarter和next_week三个可选参数, OKCoin期货有this_week, + * next_week, quarter三个参数 exchange.SetContractType("week"); + * + * @param {string} ContractType + */ + SetContractType(ContractType: string): void; + } + } + + namespace TA { + /** + * 指数平滑异同平均线 + * + * MACD(数据, 快周期, 慢周期, 信号周期), 默认参数为(12, 26, 9), 返回二维数组, 分别是[DIF, DEA, MACD] + * + * @param {botvs.Record[]} Records + * @param {number} LongPeriod + * @param {number} ShortPeriod + * @param {number} SignalPeriod + * @return {[number[] , number[] , number[]]} + */ + function MACD( + Records: botvs.Record[], + LongPeriod?: number, + ShortPeriod?: number, + SignalPeriod?: number, + ): [number[], number[], number[]]; + + /** + * 随机指标 + * + * KDJ(数据, 周期1, 周期2, 周期3), 默认参数为(9, 3, 3), 返回二维数组, 分别是[K, D, J] + * + * @param {botvs.Record[]} Records + * @param {number} FirstPeriod + * @param {number} SecondPeriod + * @param {number} ThirdPeriod + * @return {[number[] , number[] , number[]]} + */ + function KDJ( + Records: botvs.Record[], + FirstPeriod?: number, + SecondPeriod?: number, + ThirdPeriod?: number, + ): [number[], number[], number[]]; + + /** + * 强弱指标 + * + * RSI(数据, 周期), 默认参数为14, 返回一个一维数组 + * + * @param {botvs.Record[]} Records + * @param {number} Period + * @return {number[]} + */ + function RSI(Records: botvs.Record[], Period?: number): number[]; + + /** + * 平均真实波幅 + * + * ATR(数据, 周期), 默认参数为14, 返回一个一维数组 + * + * @param {botvs.Record[]} Records + * @param {number} Period + * @return {number[]} + */ + function ATR(Records: botvs.Record[], Period?: number): number[]; + + /** + * 能量潮 + * + * OBV(数据), 返回一个一维数组 + * + * @param {botvs.Record[]} Records + * @return {[number[] , number[]]} + */ + function OBV(Records: botvs.Record[]): [number[], number[]]; + + /** + * 移动平均线 + * + * MA(数据, 周期), 默认参数为9, 返回一个一维数组 + * + * @param {botvs.Record[]} Records + * @param {number} Period + * @return {number[]} + */ + function MA(Records: botvs.Record[], Period?: number): number[]; + + /** + * 指数平均数指标 + * EMA(数据, 周期), 默认参数为9, 返回一个一维数组 + * + * @param {botvs.Record[]} Records + * @param {number} Period + * @return {number[]} + */ + function EMA(Records: botvs.Record[], Period?: number): number[]; + + /** + * Alligator Indicator + * + * Alligator(数据, 下颚周期,牙齿周期,上唇周期), 鳄鱼线指标, 默认参数为(13,8,5) 返回一个二维数组[下颚,牙齿,上唇] + * + * @param {botvs.Record[]} Records + * @param {number} JawPeriod + * @param {number} TeethPeriod + * @param {number} LibsPeriod + * @return {[number[] , number[] , number[]]} + */ + function Alligator( + Records: botvs.Record[], + JawPeriod?: number, + TeethPeriod?: number, + LibsPeriod?: number, + ): [number[], number[], number[]]; + + /** + * Chaikin Money Flow + * + * CMF(数据, 周期), 默认周期参数为20, 返回一个一维数组 + * + * @param {botvs.Record[]} Records + * @param {number} Period + * @return {number[]} + */ + function CMF(Records: botvs.Record[], Period?: number): number[]; + + /** + * 周期最高价 + * + * Highest(数据, 周期, 属性), 返回最近周期内的最大值(不包含当前Bar), + * 如TA.Highest(records, 30, 'High'), 如果周期为0指所有, 如属性不指定则视数据为普通数组 + * + * @param {botvs.Record[]} Records + * @param {number} Period + * @param {keyof botvs.Record} Property + * @return {number} + * @constructor + */ + function Highest(Records: botvs.Record[], Period?: number, Property?: keyof botvs.Record): number; + + /** + * 周期最低价 + * + * Lowest(数据, 周期, 属性), 同上, 求最小值 + * + * @param {botvs.Record[]} Records + * @param {number} Period + * @param {keyof botvs.Record} Property + * @return {number} + */ + function Lowest(Records: botvs.Record[], Period?: number, Property?: keyof botvs.Record): number; + } + + namespace talib { + /** + * 查询指标调用格式 + * + * Log(talib.help('MACD')); // 在回测环境下调用 + * + * @param {string} Func + * @return {string} + */ + function help(Func: string): string; + + /** + * Vector Trigonometric ACos (反余弦函数) + * + * ACOS(Records[Close]) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function ACOS(Records: botvs.Record[] | number[]): number[]; + + /** + * Chaikin A/D Line (线随机指标) + * + * AD(Records[High,Low,Close,Volume]) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function AD(Records: botvs.Record[]): number[]; + /** + * Chaikin A/D Line (线随机指标) + * + * AD(Records[High,Low,Close,Volume]) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number[]} Volume + * @return {number[]} + */ + function AD(High: number[], Low: number[], Close: number[], Volume: number[]): number[]; + + /** + * Chaikin A/D Oscillator (佳庆指标) + * + * ADOSC(Records[High,Low,Close,Volume],Fast Period = 3,Slow Period = 10) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @param {number=3} FastPeriod + * @param {number=10} SlowPeriod + * @return {number[]} + */ + function ADOSC(Records: botvs.Record[], FastPeriod: number, SlowPeriod: number): number[]; + /** + * Chaikin A/D Oscillator (佳庆指标) + * + * ADOSC(Records[High,Low,Close,Volume],Fast Period = 3,Slow Period = 10) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number[]} Volume + * @param {number=3} FastPeriod + * @param {number=10} SlowPeriod + * @return {number[]} + */ + function ADOSC( + High: number[], + Low: number[], + Close: number[], + Volume: number[], + FastPeriod: number, + SlowPeriod: number, + ): number[]; + + /** + * Average Directional Movement Index (平均趋向指数) + * + * ADX(Records[High,Low,Close],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function ADX(Records: botvs.Record[], TimePeriod: number): number[]; + /** + * Average Directional Movement Index (平均趋向指数) + * + * ADX(Records[High,Low,Close],Time Period = 14) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=14} TimePeriod + * @return {number[]} + */ + function ADX(High: number[], Low: number[], Close: number[], TimePeriod: number): number[]; + + /** + * Average Directional Movement Index Rating (评估指数) + * + * ADXR(Records[High,Low,Close],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function ADXR(Records: botvs.Record[], TimePeriod: number): number[]; + /** + * Average Directional Movement Index Rating (评估指数) + * + * ADXR(Records[High,Low,Close],Time Period = 14) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=14} TimePeriod + * @return {number[]} + */ + function ADXR(High: number[], Low: number[], Close: number[], TimePeriod: number): number[]; + + /** + * Absolute Price Oscillator (绝对价格振荡指数) + * + * APO(Records[Close],Fast Period = 12,Slow Period = 26,MA Type = 0) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=12} FastPeriod + * @param {number=26} SlowPeriod + * @param {number=0} MAType + * @return {number[]} + */ + function APO( + Records: botvs.Record[] | number[], + FastPeriod: number, + SlowPeriod: number, + MAType: number, + ): number[]; + + /** + * Aroon (阿隆指标) + * + * AROON(Records[High,Low],Time Period = 14) = [Array(outAroonDown),Array(outAroonUp)] + * + * @param {botvs.Record[]} Records + * @param {number=14} TimePeriod + * @return {[number[], number[]]} + */ + function AROON(Records: botvs.Record[], TimePeriod: number): [number[], number[]]; + /** + * Aroon (阿隆指标) + * + * AROON(Records[High,Low],Time Period = 14) = [Array(outAroonDown),Array(outAroonUp)] + * + * @param {number[]} High + * @param {number[]} Low + * @param {number=14} TimePeriod + * @return {[number[], number[]]} + */ + function AROON(High: number[], Low: number[], TimePeriod: number): [number[], number[]]; + + /** + * Aroon Oscillator (阿隆震荡线) + * + * AROONOSC(Records[High,Low],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function AROONOSC(Records: botvs.Record[], TimePeriod: number): number[]; + /** + * Aroon Oscillator (阿隆震荡线) + * + * AROONOSC(Records[High,Low],Time Period = 14) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number=14} TimePeriod + * @return {number[]} + */ + function AROONOSC(High: number[], Low: number[], TimePeriod: number): number[]; + + /** + * Vector Trigonometric ASin (反正弦函数) + * + * ASIN(Records[Close]) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function ASIN(Records: botvs.Record[] | number[]): number[]; + + /** + * Vector Trigonometric ATan (反正切函数) + * + * ATAN(Records[Close]) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function ATAN(Records: botvs.Record[] | number[]): number[]; + + /** + * Average True Range (平均真实波幅) + * + * ATR(Records[High,Low,Close],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function ATR(Records: botvs.Record[], TimePeriod: number): number[]; + /** + * Average True Range (平均真实波幅) + * + * ATR(Records[High,Low,Close],Time Period = 14) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=14} TimePeriod + * @return {number[]} + */ + function ATR(High: number[], Low: number[], Close: number[], TimePeriod: number): number[]; + + /** + * Average Price (平均价格) + * + * AVGPRICE(Records[Open,High,Low,Close]) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function AVGPRICE(Records: botvs.Record[]): number[]; + /** + * Average Price (平均价格) + * + * AVGPRICE(Records[Open,High,Low,Close]) = Array(outReal) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function AVGPRICE(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Bollinger Bands (布林带) + * + * BBANDS(Records[Close],Time Period = 5,Deviations up = 2,Deviations down = 2,MA Type = 0) = + * [Array(outRealUpperBand),Array(outRealMiddleBand),Array(outRealLowerBand)] + * + * @param {botvs.Record[]|number[]} Records + * @param {number=5} TimePeriod + * @param {number=2} Deviationsup + * @param {number=2} Deviationsdown + * @param {number=0} MAType + * @return {[number[], number[], number[]]} + */ + function BBANDS( + Records: botvs.Record[] | number[], + TimePeriod: number, + Deviationsup: number, + Deviationsdown: number, + MAType: number, + ): [number[], number[], number[]]; + + /** + * Balance Of Power (均势指标) + * + * BOP(Records[Open,High,Low,Close]) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function BOP(Records: botvs.Record[]): number[]; + /** + * Balance Of Power (均势指标) + * + * BOP(Records[Open,High,Low,Close]) = Array(outReal) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function BOP(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Commodity Channel Index (顺势指标) + * + * CCI(Records[High,Low,Close],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function CCI(Records: botvs.Record[], TimePeriod: number): number[]; + /** + * Commodity Channel Index (顺势指标) + * + * CCI(Records[High,Low,Close],Time Period = 14) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=14} TimePeriod + * @return {number[]} + */ + function CCI(High: number[], Low: number[], Close: number[], TimePeriod: number): number[]; + + /** + * Two Crows (K线图--两只乌鸦) + * + * CDL2CROWS(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDL2CROWS(Records: botvs.Record[]): number[]; + /** + * Two Crows (K线图--两只乌鸦) + * + * CDL2CROWS(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDL2CROWS(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Three Black Crows (K线图--3只黑乌鸦) + * + * CDL3BLACKCROWS(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDL3BLACKCROWS(Records: botvs.Record[]): number[]; + /** + * Three Black Crows (K线图--3只黑乌鸦) + * + * CDL3BLACKCROWS(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDL3BLACKCROWS(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Three Inside Up/Down (K线图:3内上下震荡) + * + * CDL3INSIDE(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDL3INSIDE(Records: botvs.Record[]): number[]; + /** + * Three Inside Up/Down (K线图:3内上下震荡) + * + * CDL3INSIDE(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDL3INSIDE(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Three-Line Strike (K线图:3线震荡) + * + * CDL3LINESTRIKE(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDL3LINESTRIKE(Records: botvs.Record[]): number[]; + /** + * Three-Line Strike (K线图:3线震荡) + * + * CDL3LINESTRIKE(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDL3LINESTRIKE(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Three Outside Up/Down (K线图:3外下震荡) + * + * CDL3OUTSIDE(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDL3OUTSIDE(Records: botvs.Record[]): number[]; + /** + * Three Outside Up/Down (K线图:3外下震荡) + * + * CDL3OUTSIDE(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDL3OUTSIDE(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Three Stars In The South (K线图:南方三星) + * + * CDL3STARSINSOUTH(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDL3STARSINSOUTH(Records: botvs.Record[]): number[]; + /** + * Three Stars In The South (K线图:南方三星) + * + * CDL3STARSINSOUTH(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDL3STARSINSOUTH(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Three Advancing White Soldiers (K线图:三白兵) + * + * CDL3WHITESOLDIERS(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDL3WHITESOLDIERS(Records: botvs.Record[]): number[]; + /** + * Three Advancing White Soldiers (K线图:三白兵) + * + * CDL3WHITESOLDIERS(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDL3WHITESOLDIERS(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Abandoned Baby (K线图:弃婴) + * + * CDLABANDONEDBABY(Records[Open,High,Low,Close],Penetration = 0.3) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @param {number=0.3} Penetration + * @return {number[]} + */ + function CDLABANDONEDBABY(Records: botvs.Record[], Penetration: number): number[]; + /** + * Abandoned Baby (K线图:弃婴) + * + * CDLABANDONEDBABY(Records[Open,High,Low,Close],Penetration = 0.3) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=0.3} Penetration + * @return {number[]} + */ + function CDLABANDONEDBABY( + Open: number[], + High: number[], + Low: number[], + Close: number[], + Penetration: number, + ): number[]; + + /** + * Advance Block (K线图:推进) + * + * CDLADVANCEBLOCK(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLADVANCEBLOCK(Records: botvs.Record[]): number[]; + /** + * Advance Block (K线图:推进) + * + * CDLADVANCEBLOCK(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLADVANCEBLOCK(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Belt-hold (K线图:带住) + * + * CDLBELTHOLD(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLBELTHOLD(Records: botvs.Record[]): number[]; + /** + * Belt-hold (K线图:带住) + * + * CDLBELTHOLD(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLBELTHOLD(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Breakaway (K线图:分离) + * + * CDLBREAKAWAY(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLBREAKAWAY(Records: botvs.Record[]): number[]; + /** + * Breakaway (K线图:分离) + * + * CDLBREAKAWAY(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLBREAKAWAY(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Closing Marubozu (K线图:收盘光头光脚) + * + * CDLCLOSINGMARUBOZU(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLCLOSINGMARUBOZU(Records: botvs.Record[]): number[]; + /** + * Closing Marubozu (K线图:收盘光头光脚) + * + * CDLCLOSINGMARUBOZU(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLCLOSINGMARUBOZU(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Concealing Baby Swallow (K线图:藏婴吞没形态) + * + * CDLCONCEALBABYSWALL(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLCONCEALBABYSWALL(Records: botvs.Record[]): number[]; + /** + * Concealing Baby Swallow (K线图:藏婴吞没形态) + * + * CDLCONCEALBABYSWALL(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLCONCEALBABYSWALL(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Counterattack (K线图:反击) + * + * CDLCOUNTERATTACK(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLCOUNTERATTACK(Records: botvs.Record[]): number[]; + /** + * Counterattack (K线图:反击) + * + * CDLCOUNTERATTACK(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLCOUNTERATTACK(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Dark Cloud Cover (K线图:乌云盖) + * + * CDLDARKCLOUDCOVER(Records[Open,High,Low,Close],Penetration = 0.5) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @param {number=0.5} Penetration + * @return {number[]} + */ + function CDLDARKCLOUDCOVER(Records: botvs.Record[], Penetration: number): number[]; + /** + * Dark Cloud Cover (K线图:乌云盖) + * + * CDLDARKCLOUDCOVER(Records[Open,High,Low,Close],Penetration = 0.5) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=0.5} Penetration + * @return {number[]} + */ + function CDLDARKCLOUDCOVER( + Open: number[], + High: number[], + Low: number[], + Close: number[], + Penetration: number, + ): number[]; + + /** + * Doji (K线图:十字星 ) + * + * CDLDOJI(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLDOJI(Records: botvs.Record[]): number[]; + /** + * Doji (K线图:十字星 ) + * + * CDLDOJI(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLDOJI(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Doji Star (K线图:十字星) + * + * CDLDOJISTAR(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLDOJISTAR(Records: botvs.Record[]): number[]; + /** + * Doji Star (K线图:十字星) + * + * CDLDOJISTAR(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLDOJISTAR(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Dragonfly Doji (K线图:蜻蜓十字星) + * + * CDLDRAGONFLYDOJI(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLDRAGONFLYDOJI(Records: botvs.Record[]): number[]; + /** + * Dragonfly Doji (K线图:蜻蜓十字星) + * + * CDLDRAGONFLYDOJI(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLDRAGONFLYDOJI(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Engulfing Pattern (K线图:吞没) + * + * CDLENGULFING(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLENGULFING(Records: botvs.Record[]): number[]; + /** + * Engulfing Pattern (K线图:吞没) + * + * CDLENGULFING(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLENGULFING(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Evening Doji Star (K线图:黄昏十字星) + * + * CDLEVENINGDOJISTAR(Records[Open,High,Low,Close],Penetration = 0.3) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @param {number=0.3} Penetration + * @return {number[]} + */ + function CDLEVENINGDOJISTAR(Records: botvs.Record[], Penetration: number): number[]; + /** + * Evening Doji Star (K线图:黄昏十字星) + * + * CDLEVENINGDOJISTAR(Records[Open,High,Low,Close],Penetration = 0.3) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=0.3} Penetration + * @return {number[]} + */ + function CDLEVENINGDOJISTAR( + Open: number[], + High: number[], + Low: number[], + Close: number[], + Penetration: number, + ): number[]; + + /** + * Evening Star (K线图:黄昏之星) + * + * CDLEVENINGSTAR(Records[Open,High,Low,Close],Penetration = 0.3) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @param {number=0.3} Penetration + * @return {number[]} + */ + function CDLEVENINGSTAR(Records: botvs.Record[], Penetration: number): number[]; + /** + * Evening Star (K线图:黄昏之星) + * + * CDLEVENINGSTAR(Records[Open,High,Low,Close],Penetration = 0.3) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=0.3} Penetration + * @return {number[]} + */ + function CDLEVENINGSTAR( + Open: number[], + High: number[], + Low: number[], + Close: number[], + Penetration: number, + ): number[]; + + /** + * Up/Down-gap side-by-side white lines (K线图:上/下间隙并排的白色线条) + * + * CDLGAPSIDESIDEWHITE(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLGAPSIDESIDEWHITE(Records: botvs.Record[]): number[]; + /** + * Up/Down-gap side-by-side white lines (K线图:上/下间隙并排的白色线条) + * + * CDLGAPSIDESIDEWHITE(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLGAPSIDESIDEWHITE(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Gravestone Doji (K线图:墓碑十字线) + * + * CDLGRAVESTONEDOJI(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLGRAVESTONEDOJI(Records: botvs.Record[]): number[]; + /** + * Gravestone Doji (K线图:墓碑十字线) + * + * CDLGRAVESTONEDOJI(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLGRAVESTONEDOJI(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Hammer (K线图:锤) + * + * CDLHAMMER(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLHAMMER(Records: botvs.Record[]): number[]; + /** + * Hammer (K线图:锤) + * + * CDLHAMMER(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLHAMMER(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Hanging Man (K线图:吊人) + * + * CDLHANGINGMAN(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLHANGINGMAN(Records: botvs.Record[]): number[]; + /** + * Hanging Man (K线图:吊人) + * + * CDLHANGINGMAN(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLHANGINGMAN(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Harami Pattern (K线图:阴阳线) + * + * CDLHARAMI(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLHARAMI(Records: botvs.Record[]): number[]; + /** + * Harami Pattern (K线图:阴阳线) + * + * CDLHARAMI(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLHARAMI(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Harami Cross Pattern (K线图:交叉阴阳线) + * + * CDLHARAMICROSS(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLHARAMICROSS(Records: botvs.Record[]): number[]; + /** + * Harami Cross Pattern (K线图:交叉阴阳线) + * + * CDLHARAMICROSS(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLHARAMICROSS(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * High-Wave Candle (K线图:长脚十字线 ) + * + * CDLHIGHWAVE(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLHIGHWAVE(Records: botvs.Record[]): number[]; + /** + * High-Wave Candle (K线图:长脚十字线 ) + * + * CDLHIGHWAVE(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLHIGHWAVE(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Hikkake Pattern (K线图:陷阱) + * + * CDLHIKKAKE(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLHIKKAKE(Records: botvs.Record[]): number[]; + /** + * Hikkake Pattern (K线图:陷阱) + * + * CDLHIKKAKE(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLHIKKAKE(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Modified Hikkake Pattern (K线图:改良的陷阱) + * + * CDLHIKKAKEMOD(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLHIKKAKEMOD(Records: botvs.Record[]): number[]; + /** + * Modified Hikkake Pattern (K线图:改良的陷阱) + * + * CDLHIKKAKEMOD(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLHIKKAKEMOD(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Homing Pigeon (K线图:信鸽) + * + * CDLHOMINGPIGEON(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLHOMINGPIGEON(Records: botvs.Record[]): number[]; + /** + * Homing Pigeon (K线图:信鸽) + * + * CDLHOMINGPIGEON(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLHOMINGPIGEON(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Identical Three Crows (K线图:相同的三只乌鸦) + * + * CDLIDENTICAL3CROWS(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLIDENTICAL3CROWS(Records: botvs.Record[]): number[]; + /** + * Identical Three Crows (K线图:相同的三只乌鸦) + * + * CDLIDENTICAL3CROWS(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLIDENTICAL3CROWS(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * In-Neck Pattern (K线图:颈纹) + * + * CDLINNECK(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLINNECK(Records: botvs.Record[]): number[]; + /** + * In-Neck Pattern (K线图:颈纹) + * + * CDLINNECK(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLINNECK(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Inverted Hammer (K线图:倒锤) + * + * CDLINVERTEDHAMMER(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLINVERTEDHAMMER(Records: botvs.Record[]): number[]; + /** + * Inverted Hammer (K线图:倒锤) + * + * CDLINVERTEDHAMMER(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLINVERTEDHAMMER(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Kicking (K线图:踢) + * + * CDLKICKING(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLKICKING(Records: botvs.Record[]): number[]; + /** + * Kicking (K线图:踢) + * + * CDLKICKING(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLKICKING(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Kicking - bull/bear determined by the longer marubozu (K线图:踢牛/踢熊) + * + * CDLKICKINGBYLENGTH(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLKICKINGBYLENGTH(Records: botvs.Record[]): number[]; + /** + * Kicking - bull/bear determined by the longer marubozu (K线图:踢牛/踢熊) + * + * CDLKICKINGBYLENGTH(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLKICKINGBYLENGTH(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Ladder Bottom (K线图:梯底) + * + * CDLLADDERBOTTOM(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLLADDERBOTTOM(Records: botvs.Record[]): number[]; + /** + * Ladder Bottom (K线图:梯底) + * + * CDLLADDERBOTTOM(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLLADDERBOTTOM(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Long Legged Doji (K线图:长腿十字线) + * + * CDLLONGLEGGEDDOJI(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLLONGLEGGEDDOJI(Records: botvs.Record[]): number[]; + /** + * Long Legged Doji (K线图:长腿十字线) + * + * CDLLONGLEGGEDDOJI(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLLONGLEGGEDDOJI(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Long Line Candle (K线图:长线) + * + * CDLLONGLINE(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLLONGLINE(Records: botvs.Record[]): number[]; + /** + * Long Line Candle (K线图:长线) + * + * CDLLONGLINE(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLLONGLINE(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Marubozu (K线图:光头光脚 ) + * + * CDLMARUBOZU(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLMARUBOZU(Records: botvs.Record[]): number[]; + /** + * Marubozu (K线图:光头光脚 ) + * + * CDLMARUBOZU(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLMARUBOZU(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Matching Low (K线图:匹配低) + * + * CDLMATCHINGLOW(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLMATCHINGLOW(Records: botvs.Record[]): number[]; + /** + * Matching Low (K线图:匹配低) + * + * CDLMATCHINGLOW(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLMATCHINGLOW(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Mat Hold (K线图:垫住) + * + * CDLMATHOLD(Records[Open,High,Low,Close],Penetration = 0.5) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @param {number=0.5} Penetration + * @return {number[]} + */ + function CDLMATHOLD(Records: botvs.Record[], Penetration: number): number[]; + /** + * Mat Hold (K线图:垫住) + * + * CDLMATHOLD(Records[Open,High,Low,Close],Penetration = 0.5) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=0.5} Penetration + * @return {number[]} + */ + function CDLMATHOLD( + Open: number[], + High: number[], + Low: number[], + Close: number[], + Penetration: number, + ): number[]; + + /** + * Morning Doji Star (K线图:早晨十字星) + * + * CDLMORNINGDOJISTAR(Records[Open,High,Low,Close],Penetration = 0.3) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @param {number=0.3} Penetration + * @return {number[]} + */ + function CDLMORNINGDOJISTAR(Records: botvs.Record[], Penetration: number): number[]; + /** + * Morning Doji Star (K线图:早晨十字星) + * + * CDLMORNINGDOJISTAR(Records[Open,High,Low,Close],Penetration = 0.3) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=0.3} Penetration + * @return {number[]} + */ + function CDLMORNINGDOJISTAR( + Open: number[], + High: number[], + Low: number[], + Close: number[], + Penetration: number, + ): number[]; + + /** + * Morning Star (K线图:晨星) + * + * CDLMORNINGSTAR(Records[Open,High,Low,Close],Penetration = 0.3) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @param {number=0.3} Penetration + * @return {number[]} + */ + function CDLMORNINGSTAR(Records: botvs.Record[], Penetration: number): number[]; + /** + * Morning Star (K线图:晨星) + * + * CDLMORNINGSTAR(Records[Open,High,Low,Close],Penetration = 0.3) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=0.3} Penetration + * @return {number[]} + */ + function CDLMORNINGSTAR( + Open: number[], + High: number[], + Low: number[], + Close: number[], + Penetration: number, + ): number[]; + + /** + * On-Neck Pattern (K线图:颈型) + * + * CDLONNECK(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLONNECK(Records: botvs.Record[]): number[]; + /** + * On-Neck Pattern (K线图:颈型) + * + * CDLONNECK(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLONNECK(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Piercing Pattern (K线图:穿孔模式) + * + * CDLPIERCING(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLPIERCING(Records: botvs.Record[]): number[]; + /** + * Piercing Pattern (K线图:穿孔模式) + * + * CDLPIERCING(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLPIERCING(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Rickshaw Man (K线图:车夫) + * + * CDLRICKSHAWMAN(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLRICKSHAWMAN(Records: botvs.Record[]): number[]; + /** + * Rickshaw Man (K线图:车夫) + * + * CDLRICKSHAWMAN(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLRICKSHAWMAN(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Rising/Falling Three Methods (K线图:上升/下降三法) + * + * CDLRISEFALL3METHODS(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLRISEFALL3METHODS(Records: botvs.Record[]): number[]; + /** + * Rising/Falling Three Methods (K线图:上升/下降三法) + * + * CDLRISEFALL3METHODS(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLRISEFALL3METHODS(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Separating Lines (K线图:分割线) + * + * CDLSEPARATINGLINES(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLSEPARATINGLINES(Records: botvs.Record[]): number[]; + /** + * Separating Lines (K线图:分割线) + * + * CDLSEPARATINGLINES(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLSEPARATINGLINES(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Shooting Star (K线图:流星) + * + * CDLSHOOTINGSTAR(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLSHOOTINGSTAR(Records: botvs.Record[]): number[]; + /** + * Shooting Star (K线图:流星) + * + * CDLSHOOTINGSTAR(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLSHOOTINGSTAR(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Short Line Candle (K线图:短线) + * + * CDLSHORTLINE(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLSHORTLINE(Records: botvs.Record[]): number[]; + /** + * Short Line Candle (K线图:短线) + * + * CDLSHORTLINE(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLSHORTLINE(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Spinning Top (K线图:陀螺) + * + * CDLSPINNINGTOP(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLSPINNINGTOP(Records: botvs.Record[]): number[]; + /** + * Spinning Top (K线图:陀螺) + * + * CDLSPINNINGTOP(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLSPINNINGTOP(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Stalled Pattern (K线图:停滞模式) + * + * CDLSTALLEDPATTERN(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLSTALLEDPATTERN(Records: botvs.Record[]): number[]; + /** + * Stalled Pattern (K线图:停滞模式) + * + * CDLSTALLEDPATTERN(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLSTALLEDPATTERN(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Stick Sandwich (K线图:棍子三明治) + * + * CDLSTICKSANDWICH(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLSTICKSANDWICH(Records: botvs.Record[]): number[]; + /** + * Stick Sandwich (K线图:棍子三明治) + * + * CDLSTICKSANDWICH(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLSTICKSANDWICH(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Takuri (Dragonfly Doji with very long lower shadow) (K线图:托里) + * + * CDLTAKURI(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLTAKURI(Records: botvs.Record[]): number[]; + /** + * Takuri (Dragonfly Doji with very long lower shadow) (K线图:托里) + * + * CDLTAKURI(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLTAKURI(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Tasuki Gap (K线图:翼隙) + * + * CDLTASUKIGAP(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLTASUKIGAP(Records: botvs.Record[]): number[]; + /** + * Tasuki Gap (K线图:翼隙) + * + * CDLTASUKIGAP(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLTASUKIGAP(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Thrusting Pattern (K线图:推模式) + * + * CDLTHRUSTING(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLTHRUSTING(Records: botvs.Record[]): number[]; + /** + * Thrusting Pattern (K线图:推模式) + * + * CDLTHRUSTING(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLTHRUSTING(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Tristar Pattern (K线图:三星模式) + * + * CDLTRISTAR(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLTRISTAR(Records: botvs.Record[]): number[]; + /** + * Tristar Pattern (K线图:三星模式) + * + * CDLTRISTAR(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLTRISTAR(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Unique 3 River (K线图:独特的3河) + * + * CDLUNIQUE3RIVER(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLUNIQUE3RIVER(Records: botvs.Record[]): number[]; + /** + * Unique 3 River (K线图:独特的3河) + * + * CDLUNIQUE3RIVER(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLUNIQUE3RIVER(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Upside Gap Two Crows (K线图:双飞乌鸦) + * + * CDLUPSIDEGAP2CROWS(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLUPSIDEGAP2CROWS(Records: botvs.Record[]): number[]; + /** + * Upside Gap Two Crows (K线图:双飞乌鸦) + * + * CDLUPSIDEGAP2CROWS(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLUPSIDEGAP2CROWS(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Upside/Downside Gap Three Methods (K线图:上行/下行缺口三方法) + * + * CDLXSIDEGAP3METHODS(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLXSIDEGAP3METHODS(Records: botvs.Record[]): number[]; + /** + * Upside/Downside Gap Three Methods (K线图:上行/下行缺口三方法) + * + * CDLXSIDEGAP3METHODS(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLXSIDEGAP3METHODS(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Vector Ceil (取整函数) + * + * CEIL(Records[Close]) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function CEIL(Records: botvs.Record[] | number[]): number[]; + + /** + * Chande Momentum Oscillator (钱德动量摆动指标) + * + * CMO(Records[Close],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function CMO(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Vector Trigonometric Cos (余弦函数) + * + * COS(Records[Close]) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function COS(Records: botvs.Record[] | number[]): number[]; + + /** + * Vector Trigonometric Cosh (双曲余弦值) + * + * COSH(Records[Close]) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function COSH(Records: botvs.Record[] | number[]): number[]; + + /** + * Double Exponential Moving Average (双指数移动平均线) + * + * DEMA(Records[Close],Time Period = 30) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=30} TimePeriod + * @return {number[]} + */ + function DEMA(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Directional Movement Index (动向指数) + * + * DX(Records[High,Low,Close],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function DX(Records: botvs.Record[], TimePeriod: number): number[]; + /** + * Directional Movement Index (动向指数) + * + * DX(Records[High,Low,Close],Time Period = 14) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=14} TimePeriod + * @return {number[]} + */ + function DX(High: number[], Low: number[], Close: number[], TimePeriod: number): number[]; + + /** + * Exponential Moving Average (指数移动平均线) + * + * EMA(Records[Close],Time Period = 30) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=30} TimePeriod + * @return {number[]} + */ + function EMA(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Vector Arithmetic Exp (指数函数) + * + * EXP(Records[Close]) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function EXP(Records: botvs.Record[] | number[]): number[]; + + /** + * Vector Floor (向下取整) + * + * FLOOR(Records[Close]) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function FLOOR(Records: botvs.Record[] | number[]): number[]; + + /** + * Hilbert Transform - Dominant Cycle Period (希尔伯特变换, 主周期) + * + * HT_DCPERIOD(Records[Close]) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function HT_DCPERIOD(Records: botvs.Record[] | number[]): number[]; + + /** + * Hilbert Transform - Dominant Cycle Phase (希尔伯特变换,主阶段) + * + * HT_DCPHASE(Records[Close]) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function HT_DCPHASE(Records: botvs.Record[] | number[]): number[]; + + /** + * Hilbert Transform - Phasor Components (希尔伯特变换,相成分) + * + * HT_PHASOR(Records[Close]) = [Array(outInPhase),Array(outQuadrature)] + * + * @param {botvs.Record[]|number[]} Records + * @return {[number[], number[]]} + */ + function HT_PHASOR(Records: botvs.Record[] | number[]): [number[], number[]]; + + /** + * Hilbert Transform - SineWave (希尔伯特变换,正弦波) + * + * HT_SINE(Records[Close]) = [Array(outSine),Array(outLeadSine)] + * + * @param {botvs.Record[]|number[]} Records + * @return {[number[], number[]]} + */ + function HT_SINE(Records: botvs.Record[] | number[]): [number[], number[]]; + + /** + * Hilbert Transform - Instantaneous Trendline (希尔伯特变换,瞬时趋势) + * + * HT_TRENDLINE(Records[Close]) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function HT_TRENDLINE(Records: botvs.Record[] | number[]): number[]; + + /** + * Hilbert Transform - Trend vs Cycle Mode (希尔伯特变换-趋势与周期模式) + * + * HT_TRENDMODE(Records[Close]) = Array(outInteger) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function HT_TRENDMODE(Records: botvs.Record[] | number[]): number[]; + + /** + * Kaufman Adaptive Moving Average (适应性移动平均线) + * + * KAMA(Records[Close],Time Period = 30) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=30} TimePeriod + * @return {number[]} + */ + function KAMA(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Linear Regression (线性回归) + * + * LINEARREG(Records[Close],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function LINEARREG(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Linear Regression Angle (线性回归的角度) + * + * LINEARREG_ANGLE(Records[Close],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function LINEARREG_ANGLE(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Linear Regression Intercept (线性回归截距) + * + * LINEARREG_INTERCEPT(Records[Close],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function LINEARREG_INTERCEPT(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Linear Regression Slope (线性回归斜率) + * + * LINEARREG_SLOPE(Records[Close],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function LINEARREG_SLOPE(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Vector Log Natural (自然对数) + * + * LN(Records[Close]) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function LN(Records: botvs.Record[] | number[]): number[]; + + /** + * Vector Log10 (对数函数) + * + * LOG10(Records[Close]) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function LOG10(Records: botvs.Record[] | number[]): number[]; + + /** + * Moving average (移动平均线) + * + * MA(Records[Close],Time Period = 30,MA Type = 0) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=30} TimePeriod + * @param {number=0} MAType + * @return {number[]} + */ + function MA(Records: botvs.Record[] | number[], TimePeriod: number, MAType: number): number[]; + + /** + * Moving Average Convergence/Divergence (指数平滑移动平均线) + * + * MACD(Records[Close],Fast Period = 12,Slow Period = 26,Signal Period = 9) = + * [Array(outMACD),Array(outMACDSignal),Array(outMACDHist)] + * + * @param {botvs.Record[]|number[]} Records + * @param {number=12} FastPeriod + * @param {number=26} SlowPeriod + * @param {number=9} SignalPeriod + * @return {[number[], number[], number[]]} + */ + function MACD( + Records: botvs.Record[] | number[], + FastPeriod: number, + SlowPeriod: number, + SignalPeriod: number, + ): [number[], number[], number[]]; + + /** + * MACD with controllable MA type (MA型可控 MACD) + * + * MACDEXT(Records[Close],Fast Period = 12,Fast MA = 0,Slow Period = 26,Slow MA = 0,Signal Period = 9,Signal MA + * = + * 0) = [Array(outMACD),Array(outMACDSignal),Array(outMACDHist)] + * + * @param {botvs.Record[]|number[]} Records + * @param {number=12} FastPeriod + * @param {number=0} FastMA + * @param {number=26} SlowPeriod + * @param {number=0} SlowMA + * @param {number=9} SignalPeriod + * @param {number=0} SignalMA + * @return {[number[], number[], number[]]} + */ + function MACDEXT( + Records: botvs.Record[] | number[], + FastPeriod: number, + FastMA: number, + SlowPeriod: number, + SlowMA: number, + SignalPeriod: number, + SignalMA: number, + ): [number[], number[], number[]]; + + /** + * Moving Average Convergence/Divergence Fix 12/26 (移动平均收敛/发散修复12/26) + * + * MACDFIX(Records[Close],Signal Period = 9) = [Array(outMACD),Array(outMACDSignal),Array(outMACDHist)] + * + * @param {botvs.Record[]|number[]} Records + * @param {number=9} SignalPeriod + * @return {[number[], number[], number[]]} + */ + function MACDFIX(Records: botvs.Record[] | number[], SignalPeriod: number): [number[], number[], number[]]; + + /** + * MESA Adaptive Moving Average (MESA 移动平均线) + * + * MAMA(Records[Close],Fast Limit = 0.5,Slow Limit = 0.05) = [Array(outMAMA),Array(outFAMA)] + * + * @param {botvs.Record[]|number[]} Records + * @param {number=0.5} FastLimit + * @param {number=0.05} SlowLimit + * @return {[number[], number[]]} + */ + function MAMA(Records: botvs.Record[] | number[], FastLimit: number, SlowLimit: number): [number[], number[]]; + + /** + * Highest value over a specified period (最大值) + * + * MAX(Records[Close],Time Period = 30) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=30} TimePeriod + * @return {number[]} + */ + function MAX(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Index of highest value over a specified period (最大值索引) + * + * MAXINDEX(Records[Close],Time Period = 30) = Array(outInteger) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=30} TimePeriod + * @return {number[]} + */ + function MAXINDEX(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Median Price (中位数价格) + * + * MEDPRICE(Records[High,Low]) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function MEDPRICE(Records: botvs.Record[]): number[]; + /** + * Median Price (中位数价格) + * + * MEDPRICE(Records[High,Low]) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @return {number[]} + */ + function MEDPRICE(High: number[], Low: number[]): number[]; + + /** + * Money Flow Index (货币流量指数) + * + * MFI(Records[High,Low,Close,Volume],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function MFI(Records: botvs.Record[], TimePeriod: number): number[]; + /** + * Money Flow Index (货币流量指数) + * + * MFI(Records[High,Low,Close,Volume],Time Period = 14) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number[]} Volume + * @param {number=14} TimePeriod + * @return {number[]} + */ + function MFI(High: number[], Low: number[], Close: number[], Volume: number[], TimePeriod: number): number[]; + + /** + * MidPoint over period (中点) + * + * MIDPOINT(Records[Close],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function MIDPOINT(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Midpoint Price over period (中点价格) + * + * MIDPRICE(Records[High,Low],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function MIDPRICE(Records: botvs.Record[], TimePeriod: number): number[]; + /** + * Midpoint Price over period (中点价格) + * + * MIDPRICE(Records[High,Low],Time Period = 14) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number=14} TimePeriod + * @return {number[]} + */ + function MIDPRICE(High: number[], Low: number[], TimePeriod: number): number[]; + + /** + * Lowest value over a specified period (最小值) + * + * MIN(Records[Close],Time Period = 30) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=30} TimePeriod + * @return {number[]} + */ + function MIN(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Index of lowest value over a specified period (最小值索引) + * + * MININDEX(Records[Close],Time Period = 30) = Array(outInteger) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=30} TimePeriod + * @return {number[]} + */ + function MININDEX(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Lowest and highest values over a specified period (最小最大值) + * + * MINMAX(Records[Close],Time Period = 30) = [Array(outMin),Array(outMax)] + * + * @param {botvs.Record[]|number[]} Records + * @param {number=30} TimePeriod + * @return {[number[], number[]]} + */ + function MINMAX(Records: botvs.Record[] | number[], TimePeriod: number): [number[], number[]]; + + /** + * Indexes of lowest and highest values over a specified period (最小最大值索引) + * + * MINMAXINDEX(Records[Close],Time Period = 30) = [Array(outMinIdx),Array(outMaxIdx)] + * + * @param {botvs.Record[]|number[]} Records + * @param {number=30} TimePeriod + * @return {[number[], number[]]} + */ + function MINMAXINDEX(Records: botvs.Record[] | number[], TimePeriod: number): [number[], number[]]; + + /** + * Minus Directional Indicator (负向指标) + * + * MINUS_DI(Records[High,Low,Close],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function MINUS_DI(Records: botvs.Record[], TimePeriod: number): number[]; + /** + * Minus Directional Indicator (负向指标) + * + * MINUS_DI(Records[High,Low,Close],Time Period = 14) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=14} TimePeriod + * @return {number[]} + */ + function MINUS_DI(High: number[], Low: number[], Close: number[], TimePeriod: number): number[]; + + /** + * Minus Directional Movement (负向运动) + * + * MINUS_DM(Records[High,Low],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function MINUS_DM(Records: botvs.Record[], TimePeriod: number): number[]; + /** + * Minus Directional Movement (负向运动) + * + * MINUS_DM(Records[High,Low],Time Period = 14) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number=14} TimePeriod + * @return {number[]} + */ + function MINUS_DM(High: number[], Low: number[], TimePeriod: number): number[]; + + /** + * Momentum (动量) + * + * MOM(Records[Close],Time Period = 10) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=10} TimePeriod + * @return {number[]} + */ + function MOM(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Normalized Average True Range (归一化平均值范围) + * + * NATR(Records[High,Low,Close],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function NATR(Records: botvs.Record[], TimePeriod: number): number[]; + /** + * Normalized Average True Range (归一化平均值范围) + * + * NATR(Records[High,Low,Close],Time Period = 14) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=14} TimePeriod + * @return {number[]} + */ + function NATR(High: number[], Low: number[], Close: number[], TimePeriod: number): number[]; + + /** + * On Balance Volume (能量潮) + * + * OBV(Records[Close],Records[Volume]) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function OBV(Records: botvs.Record[]): number[]; + + /** + * On Balance Volume (能量潮) + * + * OBV(Records[Close],Records[Volume]) = Array(outReal) + * + * @param {number[]} Close + * @param {number[]} Volume + * @return {number[]} + */ + function OBV(Close: number[], Volume: number[]): number[]; + + /** + * Plus Directional Indicator (更向指示器) + * + * PLUS_DI(Records[High,Low,Close],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function PLUS_DI(Records: botvs.Record[], TimePeriod: number): number[]; + /** + * Plus Directional Indicator (更向指示器) + * + * PLUS_DI(Records[High,Low,Close],Time Period = 14) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=14} TimePeriod + * @return {number[]} + */ + function PLUS_DI(High: number[], Low: number[], Close: number[], TimePeriod: number): number[]; + + /** + * Plus Directional Movement (定向运动) + * + * PLUS_DM(Records[High,Low],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function PLUS_DM(Records: botvs.Record[], TimePeriod: number): number[]; + /** + * Plus Directional Movement (定向运动) + * + * PLUS_DM(Records[High,Low],Time Period = 14) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number=14} TimePeriod + * @return {number[]} + */ + function PLUS_DM(High: number[], Low: number[], TimePeriod: number): number[]; + + /** + * Percentage Price Oscillator (价格振荡百分比) + * + * PPO(Records[Close],Fast Period = 12,Slow Period = 26,MA Type = 0) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=12} FastPeriod + * @param {number=26} SlowPeriod + * @param {number=0} MAType + * @return {number[]} + */ + function PPO( + Records: botvs.Record[] | number[], + FastPeriod: number, + SlowPeriod: number, + MAType: number, + ): number[]; + + /** + * Rate of change : ((price/prevPrice)-1)*100 (变动率指标) + * + * ROC(Records[Close],Time Period = 10) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=10} TimePeriod + * @return {number[]} + */ + function ROC(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Rate of change Percentage: (price-prevPrice)/prevPrice (价格变化率) + * + * ROCP(Records[Close],Time Period = 10) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=10} TimePeriod + * @return {number[]} + */ + function ROCP(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Rate of change ratio: (price/prevPrice) (价格变化率) + * + * ROCR(Records[Close],Time Period = 10) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=10} TimePeriod + * @return {number[]} + */ + function ROCR(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Rate of change ratio 100 scale: (price/prevPrice)*100 (价格变化率) + * + * ROCR100(Records[Close],Time Period = 10) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=10} TimePeriod + * @return {number[]} + */ + function ROCR100(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Relative Strength Index (相对强弱指标) + * + * RSI(Records[Close],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function RSI(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Parabolic SAR (抛物线转向) + * + * SAR(Records[High,Low],Acceleration Factor = 0.02,AF Maximum = 0.2) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @param {number=0.02} AccelerationFactor + * @param {number=0.2} AFMaximum + * @return {number[]} + */ + function SAR(Records: botvs.Record[], AccelerationFactor: number, AFMaximum: number): number[]; + /** + * Parabolic SAR (抛物线转向) + * + * SAR(Records[High,Low],Acceleration Factor = 0.02,AF Maximum = 0.2) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number=0.02} AccelerationFactor + * @param {number=0.2} AFMaximum + * @return {number[]} + */ + function SAR(High: number[], Low: number[], AccelerationFactor: number, AFMaximum: number): number[]; + + /** + * Parabolic SAR - Extended (增强型抛物线转向) + * + * SAREXT(Records[High,Low],Start Value = 0,Offset on Reverse = 0,AF Init Long = 0.02,AF Long = 0.02,AF Max + * Long = + * 0.2,AF Init Short = 0.02,AF Short = 0.02,AF Max Short = 0.2) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @param {number=0} StartValue + * @param {number=0} OffsetonReverse + * @param {number=0.02} AFInitLong + * @param {number=0.02} AFLong + * @param {number=0.2} AFMaxLong + * @param {number=0.02} AFInitShort + * @param {number=0.02} AFShort + * @param {number=0.2} AFMaxShort + * @return {number[]} + */ + function SAREXT( + Records: botvs.Record[], + StartValue: number, + OffsetonReverse: number, + AFInitLong: number, + AFLong: number, + AFMaxLong: number, + AFInitShort: number, + AFShort: number, + AFMaxShort: number, + ): number[]; + /** + * Parabolic SAR - Extended (增强型抛物线转向) + * + * SAREXT(Records[High,Low],Start Value = 0,Offset on Reverse = 0,AF Init Long = 0.02,AF Long = 0.02,AF Max + * Long = + * 0.2,AF Init Short = 0.02,AF Short = 0.02,AF Max Short = 0.2) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number=0} StartValue + * @param {number=0} OffsetonReverse + * @param {number=0.02} AFInitLong + * @param {number=0.02} AFLong + * @param {number=0.2} AFMaxLong + * @param {number=0.02} AFInitShort + * @param {number=0.02} AFShort + * @param {number=0.2} AFMaxShort + * @return {number[]} + */ + function SAREXT( + High: number[], + Low: number[], + StartValue: number, + OffsetonReverse: number, + AFInitLong: number, + AFLong: number, + AFMaxLong: number, + AFInitShort: number, + AFShort: number, + AFMaxShort: number, + ): number[]; + + /** + * Vector Trigonometric Sin (正弦值) + * + * SIN(Records[Close]) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function SIN(Records: botvs.Record[] | number[]): number[]; + + /** + * Vector Trigonometric Sinh (双曲正弦函数) + * + * SINH(Records[Close]) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function SINH(Records: botvs.Record[] | number[]): number[]; + + /** + * Simple Moving Average (简单移动平均) + * + * SMA(Records[Close],Time Period = 30) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=30} TimePeriod + * @return {number[]} + */ + function SMA(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Vector Square Root (平方根) + * + * SQRT(Records[Close]) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function SQRT(Records: botvs.Record[] | number[]): number[]; + + /** + * Standard Deviation (标准偏差) + * + * STDDEV(Records[Close],Time Period = 5,Deviations = 1) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=5} TimePeriod + * @param {number=1} Deviations + * @return {number[]} + */ + function STDDEV(Records: botvs.Record[] | number[], TimePeriod: number, Deviations: number): number[]; + + /** + * Stochastic (STOCH指标) + * + * STOCH(Records[High,Low,Close],Fast-K Period = 5,Slow-K Period = 3,Slow-K MA = 0,Slow-D Period = 3,Slow-D MA + * = 0) + * = [Array(outSlowK),Array(outSlowD)] + * + * @param {botvs.Record[]} Records + * @param {number=5} Fast_KPeriod + * @param {number=3} Slow_KPeriod + * @param {number=0} Slow_KMA + * @param {number=3} Slow_DPeriod + * @param {number=0} Slow_DMA + * @return {[number[], number[]]} + */ + function STOCH( + Records: botvs.Record[], + Fast_KPeriod: number, + Slow_KPeriod: number, + Slow_KMA: number, + Slow_DPeriod: number, + Slow_DMA: number, + ): [number[], number[]]; + /** + * Stochastic (STOCH指标) + * + * STOCH(Records[High,Low,Close],Fast-K Period = 5,Slow-K Period = 3,Slow-K MA = 0,Slow-D Period = 3,Slow-D MA + * = 0) + * = [Array(outSlowK),Array(outSlowD)] + * + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=5} Fast_KPeriod + * @param {number=3} Slow_KPeriod + * @param {number=0} Slow_KMA + * @param {number=3} Slow_DPeriod + * @param {number=0} Slow_DMA + * @return {[number[], number[]]} + */ + function STOCH( + High: number[], + Low: number[], + Close: number[], + Fast_KPeriod: number, + Slow_KPeriod: number, + Slow_KMA: number, + Slow_DPeriod: number, + Slow_DMA: number, + ): [number[], number[]]; + + /** + * Stochastic Fast (快速STOCH指标) + * + * STOCHF(Records[High,Low,Close],Fast-K Period = 5,Fast-D Period = 3,Fast-D MA = 0) = + * [Array(outFastK),Array(outFastD)] + * + * @param {botvs.Record[]} Records + * @param {number=5} Fast_KPeriod + * @param {number=3} Fast_DPeriod + * @param {number=0} Fast_DMA + * @return {[number[], number[]]} + */ + function STOCHF( + Records: botvs.Record[], + Fast_KPeriod: number, + Fast_DPeriod: number, + Fast_DMA: number, + ): [number[], number[]]; + /** + * Stochastic Fast (快速STOCH指标) + * + * STOCHF(Records[High,Low,Close],Fast-K Period = 5,Fast-D Period = 3,Fast-D MA = 0) = + * [Array(outFastK),Array(outFastD)] + * + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=5} Fast_KPeriod + * @param {number=3} Fast_DPeriod + * @param {number=0} Fast_DMA + * @return {[number[], number[]]} + */ + function STOCHF( + High: number[], + Low: number[], + Close: number[], + Fast_KPeriod: number, + Fast_DPeriod: number, + Fast_DMA: number, + ): [number[], number[]]; + + /** + * Stochastic Relative Strength Index (随机强弱指数) + * + * STOCHRSI(Records[Close],Time Period = 14,Fast-K Period = 5,Fast-D Period = 3,Fast-D MA = 0) = + * [Array(outFastK),Array(outFastD)] + * + * @param {botvs.Record[]|number[]} Records + * @param {number=14} TimePeriod + * @param {number=5} Fast_KPeriod + * @param {number=3} Fast_DPeriod + * @param {number=0} Fast_DMA + * @return {[number[], number[]]} + */ + function STOCHRSI( + Records: botvs.Record[] | number[], + TimePeriod: number, + Fast_KPeriod: number, + Fast_DPeriod: number, + Fast_DMA: number, + ): [number[], number[]]; + + /** + * Summation (求和) + * + * SUM(Records[Close],Time Period = 30) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=30} TimePeriod + * @return {number[]} + */ + function SUM(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Triple Exponential Moving Average (T3) (三指数移动平均) + * + * T3(Records[Close],Time Period = 5,Volume Factor = 0.7) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=5} TimePeriod + * @param {number=0.7} VolumeFactor + * @return {number[]} + */ + function T3(Records: botvs.Record[] | number[], TimePeriod: number, VolumeFactor: number): number[]; + + /** + * Vector Trigonometric Tan (正切) + * + * TAN(Records[Close]) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function TAN(Records: botvs.Record[] | number[]): number[]; + + /** + * Vector Trigonometric Tanh (双曲正切函数) + * + * TANH(Records[Close]) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function TANH(Records: botvs.Record[] | number[]): number[]; + + /** + * Triple Exponential Moving Average (三指数移动平均) + * + * TEMA(Records[Close],Time Period = 30) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=30} TimePeriod + * @return {number[]} + */ + function TEMA(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * True Range (真实范围) + * + * TRANGE(Records[High,Low,Close]) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function TRANGE(Records: botvs.Record[]): number[]; + /** + * True Range (真实范围) + * + * TRANGE(Records[High,Low,Close]) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function TRANGE(High: number[], Low: number[], Close: number[]): number[]; + + /** + * Triangular Moving Average (三指数移动平均) + * + * TRIMA(Records[Close],Time Period = 30) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=30} TimePeriod + * @return {number[]} + */ + function TRIMA(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * 1-day Rate-Of-Change (ROC) of a Triple Smooth EMA (三重指数平滑平均线) + * + * TRIX(Records[Close],Time Period = 30) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=30} TimePeriod + * @return {number[]} + */ + function TRIX(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Time Series Forecast (时间序列预测) + * + * TSF(Records[Close],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function TSF(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Typical Price (典型价格) + * + * TYPPRICE(Records[High,Low,Close]) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function TYPPRICE(Records: botvs.Record[]): number[]; + /** + * Typical Price (典型价格) + * + * TYPPRICE(Records[High,Low,Close]) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function TYPPRICE(High: number[], Low: number[], Close: number[]): number[]; + + /** + * Ultimate Oscillator (极限振子) + * + * ULTOSC(Records[High,Low,Close],First Period = 7,Second Period = 14,Third Period = 28) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @param {number=7} FirstPeriod + * @param {number=14} SecondPeriod + * @param {number=28} ThirdPeriod + * @return {number[]} + */ + function ULTOSC( + Records: botvs.Record[], + FirstPeriod: number, + SecondPeriod: number, + ThirdPeriod: number, + ): number[]; + /** + * Ultimate Oscillator (极限振子) + * + * ULTOSC(Records[High,Low,Close],First Period = 7,Second Period = 14,Third Period = 28) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=7} FirstPeriod + * @param {number=14} SecondPeriod + * @param {number=28} ThirdPeriod + * @return {number[]} + */ + function ULTOSC( + High: number[], + Low: number[], + Close: number[], + FirstPeriod: number, + SecondPeriod: number, + ThirdPeriod: number, + ): number[]; + + /** + * Variance (变量定义) + * + * VAR(Records[Close],Time Period = 5,Deviations = 1) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=5} TimePeriod + * @param {number=1} Deviations + * @return {number[]} + */ + function VAR(Records: botvs.Record[] | number[], TimePeriod: number, Deviations: number): number[]; + + /** + * Weighted Close Price (加权收盘价) + * + * WCLPRICE(Records[High,Low,Close]) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function WCLPRICE(Records: botvs.Record[]): number[]; + /** + * Weighted Close Price (加权收盘价) + * + * WCLPRICE(Records[High,Low,Close]) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function WCLPRICE(High: number[], Low: number[], Close: number[]): number[]; + + /** + * Williams' %R (威廉指标) + * + * WILLR(Records[High,Low,Close],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function WILLR(Records: botvs.Record[], TimePeriod: number): number[]; + /** + * Williams' %R (威廉指标) + * + * WILLR(Records[High,Low,Close],Time Period = 14) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=14} TimePeriod + * @return {number[]} + */ + function WILLR(High: number[], Low: number[], Close: number[], TimePeriod: number): number[]; + + /** + * Weighted Moving Average (加权移动平均) + * + * WMA(Records[Close],Time Period = 30) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=30} TimePeriod + * @return {number[]} + */ + function WMA(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + } + + /** + * 订单的状态: 未完成 + */ + const ORDER_STATE_PENDING: botvs.VOrderState; + + /** + * 订单的状态: 已关闭 + */ + const ORDER_STATE_CLOSED: botvs.VOrderState; + + /** + * 订单的状态: 已取消 + */ + const ORDER_STATE_CANCELED: botvs.VOrderState; + + /** + * 订单的类型: 买单 + */ + const ORDER_TYPE_BUY: botvs.VOrderType; + + /** + * 订单的类型: 卖单 + */ + const ORDER_TYPE_SELL: botvs.VOrderType; + + /** + * 多头仓位(CTP中用closebuy_today平仓) + */ + const PD_LONG: botvs.VPositionType; + + /** + * 空头仓位(CTP用closesell_today)平仓 + */ + const PD_SHORT: botvs.VPositionType; + + /** + * (CTP期货中)PD_LONG_YD为咋日多头仓位(用closebuy平 + */ + const PD_LONG_YD: botvs.VPositionType; + + /** + * 咋日空头仓位(用closesell平) + */ + const PD_SHORT_YD: botvs.VPositionType; + + /** + * 1分钟 + */ + const PERIOD_M1: botvs.VPeriod; + + /** + * 5分钟 + */ + const PERIOD_M5: botvs.VPeriod; + + /** + * 15分钟 + */ + const PERIOD_M15: botvs.VPeriod; + + /** + * 30分钟 + */ + const PERIOD_M30: botvs.VPeriod; + + /** + * 1小时 + */ + const PERIOD_H1: botvs.VPeriod; + + /** + * 1天 + */ + const PERIOD_D1: botvs.VPeriod; + + /** + * 买单日志 + */ + const LOG_TYPE_BUY: botvs.VLogType; + + /** + * 卖单日志 + */ + const LOG_TYPE_SELL: botvs.VLogType; + + /** + * 取消日志 + */ + const LOG_TYPE_CANCEL: botvs.VLogType; + + /** + * 默认主交易所对像, 添加交易平台时排列第一的交易所 + */ + const exchange: botvs.Exchange; + + /** + * 交易所数组, 如果添加多个交易所, 可以访问此变量获取交易所对像 + */ + const exchanges: botvs.Exchange[]; + + /** + * 保存一条信息到日志列表 + * + * 如果在字符串后面加上@字符则消息会进入推送队列, 推送到使用绑定的微信账号上(账户安全里绑定)(50条/小时, 1条/5秒 限制) + * 如: Log("微信你好 !@"); 或Log("微信你好, #ff0000@"); + * Log支持打印base64编码后的图片, 以"`"开头, 以"`"结尾, 如Log("`data:image/png;base64,AAAA`") + * Log支持直接打印Python的matplotlib.pyplot对象, 只要对象包含savefig方法就可以直接Log打印, 如: + * import matplotlib.pyplot as plt + * def main(): + * plt.plot([3,6,2,4,7,1]) + * Log(plt) + * + * @param {string} arg + */ + function Log(arg: string): void; + + /** + * 休眠函数 + * + * 参数为毫秒数,如Sleep(1000)为休眠一秒 + * + * @param {number} Millisecond + */ + function Sleep(Millisecond: number): void; + + /** + * 判断是否是模拟回测 + * + * 模拟回测状态返回true,实盘返回false + * + * @return {boolean} + */ + function IsVirtual(): boolean; + + /** + * 记录盈利值,这个为总盈利的值,参数类型为浮点数 + * + * @param {number} Profit + */ + function LogProfit(Profit: number): void; + + /** + * 清空所有收益日志, 可以带一个数字参数, 指定保留的条数 + * + * @param {number} reserve + */ + function LogProfitReset(reserve?: number): void; + + /** + * 清空所有日志, 可以带一个数字参数, 指定保留的条数 + * + * @param {number} reserve + */ + function LogReset(reserve?: number): void; + + /** + * 此信息不保存到日志列表里, 只更新当前机器人的状态信息, 在日志上方显示, 可多次调用, 更新状态 + * + * * LogStatus('这是一个普通的状态提示'); + * LogStatus('这是一个红色字体的状态提示 #ff0000'); + * LogStatus('这是一个多行的状态信息\n我是第二行'); + * LogStatus支持打印base64编码后的图片, 以"`"开头, 以"`"结尾, 如LogStatus("`data:image/png;base64,AAAA`") + * LogStatus支持直接传入Python的matplotlib.pyplot对象, 只要对象包含savefig方法就可以传入LogStatus, 如: + * import matplotlib.pyplot as plt + * def main(): + * plt.plot([3,6,2,4,7,1]) + * LogStatus(plt) + * var table = {type: 'table', title: '持仓信息', cols: ['列1', '列2'], rows: [ ['abc', 'def'], ['ABC', 'support color + * #ff0000']]}; LogStatus('`' + JSON.stringify(table)+'`'); // JSON序列化后两边加上`字符, 视为一个复杂消息格式(当前支持表格) + * LogStatus('第一行消息\n`' + JSON.stringify(table)+'`\n第三行消息'); + * // 表格信息也可以在多行中出现 LogStatus('`' + JSON.stringify([table, + * table])+'`'); // 支持多个表格同时显示, 将以TAB显示到一组里 + * // 也可以构造一个按钮在表格中, 策略用GetCommand接收cmd属性的内容 + * var table = { + * type: 'table', + * title: '持仓操作', + * cols: ['列1', '列2', 'Action'], + * rows: [ + * ['abc', 'def', {'type':'button', 'cmd': 'coverAll', 'name': '平仓'}], + * ] + * }; + * LogStatus('`' + JSON.stringify(table) + '`') + * // 或者构造一单独的按钮 + * LogStatus('`' + JSON.stringify({'type':'button', 'cmd': 'coverAll', 'name': '平仓'}) + '`') + * // 可以自定义按钮风格(bootstrap的按钮属性) + * LogStatus('`' + JSON.stringify({'type':'button', 'class': 'btn btn-xs btn-danger', 'cmd': 'coverAll', 'name': + * '平仓'}) + '`') + * + * @param {string} Msg + */ + function LogStatus(Msg: string): void; + + /** + * 打开或者关闭定单和出错信息的日志记录 + * + * @param {boolean} IsEnable + */ + function EnableLog(IsEnable: boolean): void; + + /** + * 图表绘图函数 + * + * 参数为可以JSON序列化的HighStocks的Highcharts.StockChart参数, 比原生的参数增加一个 + * __isStock属性, 如果指定__isStock: false, 则显示为普通图表 + * 返回对像可以调用add([series索引(如0), 数据])向指定索引的series添加数据, 调用reset() + * 清空图表数据, reset可以带一个数字参数, 指定保留的条数 + * 可以调用add([series索引(如0), 数据, 此数据在series中的索引])来更改数据 + * 可以为负数, -1指最后一个, -2是倒数第二个, 如: + * chart.add([0, 13.5, -1]), 更改series[0].data的倒数第一个点的数据 + * 支持显示多个图表, 配置时只需传入数组参数即可如: var chart = Chart([{...}, {...}, {...}]), + * 比如图表一有两个series, 图表二有一个series, 图表三有一个series, + * 那么add时指定0与1序列ID代表更新图表1的两个序列的数据, add时指定序列ID为2指图表2的第一个 + * series的数据, 指定序列3指的是图表3的第一个series的数据 HighStocks: + * http://api.highcharts.com/highstock + * + * @param {botvs.ChartOptions} options + * @return {botvs.RChart} + */ + function Chart(...options: botvs.ChartOptions[]): botvs.RChart; + + /** + * 发送邮件函数 + * + * Mail(smtpServer, smtpUsername, smtpPassword, mailTo, title, body); ret true or false + * Mail("smtp.163.com", "asdf@163.com", "password", "111@163.com", "title", "body") + * + * @param {string} smtpServer + * @param {string} smtpUsername + * @param {string} smtpPassword + * @param {string} mailTo + * @param {string} title + * @param {string} body + * @return {boolean} + */ + function Mail( + smtpServer: string, + smtpUsername: string, + smtpPassword: string, + mailTo: string, + title: string, + body: string, + ): boolean; + + /** + * 错误信息过滤 + * + * 被此正则表达式匹配的错误将不上传到日志系统, 可多次调用设置多个 + * SetErrorFilter("502:|503:|tcp|character|unexpected|network|timeout|WSARecv|Connect|GetAddr|no + * such|reset|http|received|EOF|reused"); + * + * @param {string} RegEx + */ + function SetErrorFilter(RegEx: string): void; + + /** + * 返回机器人进程ID + * + * @return {number} + */ + function GetPid(): number; + + /** + * 获取最近一次出错信息,一般无需使用,因为程序会把出错信息自动上传到日志系统 + * + * @return {string} + */ + function GetLastError(): string; + + /** + * 可保存的全局字典表 + * + * KV表, 永久保存在本地文件, 每个机器人单独一个数据库, 重启或者托管者退出后一直存在 + * K必须为数字或者字符串, 不区分大小写, V可以为任何可以JSON序列化的内容 + * _G("num", 1); // 设置一个全局变量num, 值为1 + * _G("num", "ok"); // 更改一个全局变量num, 值为字符串ok + * _G("num", null); // 删除全局变量 num + * _G("num"); // 返回全局变量num的值 + * _G(); // 返回当前机器人的ID + * _G(null); // 删除所有全局变量 + * + * @param {string} K + * @param {T} V + */ + function _G(K: string, V: T): void; + + /** + * 获取交互命令(utf-8) + * + * 获取策略交互界面发来的命令并清空, 没有命令则返回null, 返回的命令格式为 "按钮名称:参数", 如果没有参数, 则命令就是按钮名称 + * while (true) { + * var cmd = GetCommand(); + * if (cmd) { + * Log(cmd); + * } + * Sleep(1000); + * } + * + * @return {string} + */ + function GetCommand(): string | null; + + /** + * 原始的Socket访问, 支持tcp, udp, tls, unix 协议 + * + * @example + * + * ``` + * var client = Dial("tls://www.baidu.com:443"); // Dial支持tcp://, udp://, tls://, unix:// 协议, 可加一个参数指定超时的秒数 + * if (client) { + * client.write("GET / HTTP/1.1\nConnection: Closed\n\n"); // write可再跟一个数字参数指定超时, write返回成功发送的字节数 + * while (true) { + * var buf = client.read();// read可再跟一个数字参数指定超时, 返回null指出错或者超时或者socket已经关闭 + * if (!buf) { + * break; + * } + * Log(buf); + * } + * client.close(); + * } + * ``` + * + * @param {string} Address + * @param {number} Timeout + * @return {botvs.Socket} + */ + function Dial(Address: string, Timeout?: number): botvs.Socket | void; + + /** + * 网络URL访问 + * + * HttpQuery(Url, PostData, Cookies, Headers, IsReturnHeader) + * 获取一个Url的返回内容, 如果第二个参数PostData为字符串就以POST方式提交 + * 第二个参数PostData可以自定义方法比如HttpQuery('http://www.abc.com', {method:'PUT', data:'xx'}) + * 传递Cookie字符串需要第三个参数, 但不需要POST请将第二个参数置为null + * 模拟测试的时候因为无法模拟访问URL, 函数就返回固定字符串 Dummy Data + * 可以用此接口发送短信, 或者与其它API进行交互 + * HttpQuery("http://www.baidu.com/"); // Get + * HttpQuery("http://www.163.com", "xxx"); // Post + * HttpQuery("http://www.baidu.com/", null, "a=10; b=20", "User-Agent: Mobile\nContent-Type: text/html", true); + * // will return {Header: HTTP Header, Body: HTML} + * + * @param {string} Url + * @param {string | null | {method: string; data?: string}} PostData + * @param {string} Cookies + * @param {string} Headers + * @return {string} + */ + function HttpQuery( + Url: string, + PostData: string | null | { method: string, data?: string }, + Cookies: string, + Headers: string, + ): string; + function HttpQuery( + Url: string, + PostData: string | null | { method: string, data?: string }, + Cookies: string, + Headers: string, + IsReturnHeader: true, + ): { Header: string, Body: string }; + + /** + * 支持 md5/sha256/sha512/sha1 的哈希计算, 只支持实盘 + * + * 第二个参数可设置为raw/hex/base64, 分别指输出加密后的 原始内容/hex编码过的/base64编码过的 + * Log(Hash('md5', 'hex', 'hello')); + * Log(Hash('sha512', 'base64', 'hello')); + * + * @param {"md5" | "sha256" | "sha512" | "sha1"} Algo + * @param {"hex" | "base64"} OutputAlgo + * @param {string} Data + * @return {string} + */ + function Hash( + Algo: 'md5' | 'sha256' | 'sha512' | 'sha1', + OutputAlgo: 'hex' | 'base64' | 'raw', + Data: string, + ): string; + + /** + * 支持 md5/sha256/sha512/sha1 的HMAC加密计算, 只支持实盘 + * + * 第二个参数可设置为raw/hex/base64, 分别指输出加密后的 原始内容/hex编码过的/base64编码过的 + * Log(HMAC('md5', 'hex', 'hello', 'pass')); + * Log(HMAC('sha512', 'base64', 'hello', 'pass')); + * + * @param {"md5" | "sha256" | "sha512" | "sha1"} Algo + * @param {"hex" | "base64" | "raw"} OutputAlgo + * @param {string} Data + * @param {string} password + * @return {string} + */ + function HMAC( + Algo: 'md5' | 'sha256' | 'sha512' | 'sha1', + OutputAlgo: 'hex' | 'base64' | 'raw', + Data: string, + password: string, + ): string; + + /** + * 返回指定时间戳(ms)字符串, 不传任何参数就返回当前时间, + * 如_D(),或者_D(1478570053241), 默认格式为yyyy-MM-dd hh:mm:ss + * + * @param {string} timestamp + * @param {string} format + * @return {string} + */ + function _D(timestamp: string, format: string): string; + + /** + * 格式化一个浮点函数 + * + * @param {number} num + * @param {number=4} precision + * @return {string} + */ + function _N(num: number, precision?: number): string; + + /** + * 重试函数, 会一直调用指定函数到成功返回(函数返回null或者false会重试), + * 比如_C(exchange.GetTicker), 默认重试间隔为3秒, 可以调用_CDelay函数来控制重试间隔 + * 比如_CDelay(1000), 指改变_C函数重试间隔为1秒 + * + * @param {(...args: any[]) => T} func + * @param args + * @return {T} + */ + function _C(func: (...args: any[]) => T, ...args: any[]): T; + + /** + * 比如_CDelay(1000), 指改变_C函数重试间隔为1秒, 默认为3秒 + * + * @param {number} delay + */ + function _CDelay(delay: number): void; +} diff --git a/types/botvs/tsconfig.json b/types/botvs/tsconfig.json new file mode 100644 index 0000000000..a20db9c8e9 --- /dev/null +++ b/types/botvs/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "botvs-tests.ts" + ] +} diff --git a/types/botvs/tslint.json b/types/botvs/tslint.json new file mode 100644 index 0000000000..71ee04c4e1 --- /dev/null +++ b/types/botvs/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/bounce.js/index.d.ts b/types/bounce.js/index.d.ts index 0db872fb30..c90f709a97 100644 --- a/types/bounce.js/index.d.ts +++ b/types/bounce.js/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Bounce.js v0.8.2 -// Project: http://github.com/tictail/bounce.js -// Definitions by: Cherry +// Project: https://github.com/tictail/bounce.js +// Definitions by: Cherry // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/box2d/README.md b/types/box2d/README.md index 9a775a1962..e16b327ee1 100644 --- a/types/box2d/README.md +++ b/types/box2d/README.md @@ -73,7 +73,7 @@ Change Log License ======= -Box2DWeb-2.1.d.ts Copyright (c) 2012 Josh Baldwin http://github.com/jbaldwin/box2dweb.d.ts +Box2DWeb-2.1.d.ts Copyright (c) 2012 Josh Baldwin https://github.com/jbaldwin/box2dweb.d.ts There are a few competing javascript Box2D ports. This definitions file is for Box2dWeb.js -> http://code.google.com/p/box2dweb/ diff --git a/types/box2d/index.d.ts b/types/box2d/index.d.ts index 26411b2198..77a132592e 100644 --- a/types/box2d/index.d.ts +++ b/types/box2d/index.d.ts @@ -1,10 +1,10 @@ // Type definitions for bootstrap.timepicker // Project: http://code.google.com/p/box2dweb/ -// Definitions by: jbaldwin +// Definitions by: jbaldwin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /** -* Box2DWeb-2.1.d.ts Copyright (c) 2012-2013 Josh Baldwin http://github.com/jbaldwin/box2dweb.d.ts +* Box2DWeb-2.1.d.ts Copyright (c) 2012-2013 Josh Baldwin https://github.com/jbaldwin/box2dweb.d.ts * There are a few competing javascript Box2D ports. * This definitions file is for Box2dWeb.js -> * http://code.google.com/p/box2dweb/ diff --git a/types/brace-expansion/brace-expansion-tests.ts b/types/brace-expansion/brace-expansion-tests.ts new file mode 100644 index 0000000000..a9b0955cd7 --- /dev/null +++ b/types/brace-expansion/brace-expansion-tests.ts @@ -0,0 +1,13 @@ +import expand = require('brace-expansion'); + +// $ExpectType string[] +expand('file-{a,b,c}.jpg'); +expand('-v{,,}'); +expand('file{0..2}.jpg'); +expand('file-{a..c}.jpg'); +expand('file{2..0}.jpg'); +expand('file{0..4..2}.jpg'); +expand('file-{a..e..2}.jpg'); +expand('file{00..10..5}.jpg'); +expand('{{A..C},{a..c}}'); +expand('ppp{,config,oe{,conf}}'); diff --git a/types/brace-expansion/index.d.ts b/types/brace-expansion/index.d.ts new file mode 100644 index 0000000000..0c1894fd8c --- /dev/null +++ b/types/brace-expansion/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for brace-expansion 1.1 +// Project: https://github.com/juliangruber/brace-expansion +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = expand; + +declare function expand(input: string): string[]; diff --git a/types/brace-expansion/tsconfig.json b/types/brace-expansion/tsconfig.json new file mode 100644 index 0000000000..ef79d3729f --- /dev/null +++ b/types/brace-expansion/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "brace-expansion-tests.ts" + ] +} diff --git a/types/brace-expansion/tslint.json b/types/brace-expansion/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/brace-expansion/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/breeze/index.d.ts b/types/breeze/index.d.ts index bfd3479d3c..3094f3452d 100644 --- a/types/breeze/index.d.ts +++ b/types/breeze/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Breeze 1.6.3 // Project: http://www.breezejs.com/ -// Definitions by: Boris Yankov , IdeaBlade +// Definitions by: Boris Yankov , IdeaBlade // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Updated Jan 14 2011 - Jay Traband ( www.ideablade.com). diff --git a/types/browser-bunyan/browser-bunyan-tests.ts b/types/browser-bunyan/browser-bunyan-tests.ts index 47f439a07e..6cf1bf926b 100644 --- a/types/browser-bunyan/browser-bunyan-tests.ts +++ b/types/browser-bunyan/browser-bunyan-tests.ts @@ -1,8 +1,25 @@ import * as bunyan from "browser-bunyan"; const log = bunyan.createLogger({ - name: 'play', - serializers: bunyan.stdSerializers + name: 'myLogger', + streams: [ + { + level: 'info', + stream: new bunyan.ConsoleFormattedStream() + } + ], + serializers: bunyan.stdSerializers, + src: true }); -log.debug({foo: 'bar'}, 'hi at debug'); -log.trace('hi at trace'); + +log.info('hi on info'); + +const log2 = bunyan.createLogger({ + name: 'myLogger', + stream: new bunyan.ConsoleRawStream() +}); + +const myObject = { x: 1, y: 2 }; +log.info({ obj: myObject }, 'This is my object:'); + +new bunyan.ConsoleFormattedStream({ logByLevel: true }); diff --git a/types/browser-bunyan/index.d.ts b/types/browser-bunyan/index.d.ts index bb243e4324..7edabdca26 100644 --- a/types/browser-bunyan/index.d.ts +++ b/types/browser-bunyan/index.d.ts @@ -1,12 +1,31 @@ // Type definitions for browser-bunyan 0.4 // Project: https://github.com/philmander/browser-bunyan // Definitions by: Paul Lockwood +// Michael Strobel // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import bunyan = require("bunyan"); +/// -declare module "bunyan" { - function ConsoleFormattedStream(): void; +import * as bunyan from 'bunyan'; + +declare namespace BrowserBunyan { + interface ConsoleFormattedStreamOptions { + logByLevel?: boolean; + } + + interface ConsoleFormattedStream { + new(options?: ConsoleFormattedStreamOptions): NodeJS.WritableStream; + } + + interface ConsoleRawStream { + new(options?: ConsoleFormattedStreamOptions): NodeJS.WritableStream; + } } -export = bunyan; +type BrowserBunyan = typeof bunyan & { + ConsoleFormattedStream: BrowserBunyan.ConsoleFormattedStream + ConsoleRawStream: BrowserBunyan.ConsoleRawStream +}; + +declare const browserBunyan: BrowserBunyan; +export = browserBunyan; diff --git a/types/browser-resolve/index.d.ts b/types/browser-resolve/index.d.ts index 30f3875541..22b45dd8d2 100644 --- a/types/browser-resolve/index.d.ts +++ b/types/browser-resolve/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for browser-resolve // Project: https://github.com/defunctzombie/node-browser-resolve -// Definitions by: Mario Nebl +// Definitions by: Mario Nebl // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// diff --git a/types/browser-sync/index.d.ts b/types/browser-sync/index.d.ts index 449063192d..ade12d3cb6 100644 --- a/types/browser-sync/index.d.ts +++ b/types/browser-sync/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for browser-sync // Project: http://www.browsersync.io/ -// Definitions by: Asana , Joe Skeen +// Definitions by: Asana , Joe Skeen // Thomas "Thasmo" Deinhamer // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/browserify/index.d.ts b/types/browserify/index.d.ts index 8b51a34dd5..e419fa2ceb 100644 --- a/types/browserify/index.d.ts +++ b/types/browserify/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Browserify 12.0 // Project: http://browserify.org/ -// Definitions by: Andrew Gaspar , John Vilk , Leonard Thieu +// Definitions by: Andrew Gaspar , John Vilk , Leonard Thieu // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// diff --git a/types/bson/index.d.ts b/types/bson/index.d.ts index 67df319bf6..2b6a636e89 100644 --- a/types/bson/index.d.ts +++ b/types/bson/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for bson 1.0.4 // Project: https://github.com/mongodb/js-bson -// Definitions by: Hiroki Horiuchi +// Definitions by: Hiroki Horiuchi // Federico Caselli // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/buffers/index.d.ts b/types/buffers/index.d.ts index ec8be5a493..3f83813146 100644 --- a/types/buffers/index.d.ts +++ b/types/buffers/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for buffers 0.1.1 // Project: https://github.com/substack/node-buffers -// Definitions by: Robert Hencke +// Definitions by: Robert Hencke // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// diff --git a/types/bufferstream/postbuffer.d.ts b/types/bufferstream/postbuffer.d.ts index bd348b84db..1ca73b3064 100644 --- a/types/bufferstream/postbuffer.d.ts +++ b/types/bufferstream/postbuffer.d.ts @@ -7,6 +7,4 @@ declare class PostBuffer extends BufferStream { constructor(req: http.IncomingMessage); /** set a callback to get all post data from a http server request */ onEnd(callback: (data: any) => void): void; - /** pumps data into another stream to allow incoming streams given options will be passed to Stream.pipe */ - pipe(stream: NodeJS.WritableStream, options?: { end?: boolean }): NodeJS.ReadableStream; } diff --git a/types/bunnymq/tslint.json b/types/bunnymq/tslint.json index f93cf8562a..71ee04c4e1 100644 --- a/types/bunnymq/tslint.json +++ b/types/bunnymq/tslint.json @@ -1,3 +1,6 @@ { - "extends": "dtslint/dt.json" + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } } diff --git a/types/bunyan-config/index.d.ts b/types/bunyan-config/index.d.ts index 0ff84fd9d2..ebcddcd50d 100644 --- a/types/bunyan-config/index.d.ts +++ b/types/bunyan-config/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/LSEducation/bunyan-config // Definitions by: Cyril Schumacher // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/types/bunyan-logentries/index.d.ts b/types/bunyan-logentries/index.d.ts index 9a2a5c3fb9..33057d768b 100644 --- a/types/bunyan-logentries/index.d.ts +++ b/types/bunyan-logentries/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/nemtsov/node-bunyan-logentries // Definitions by: Aymeric Beaumet // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/types/bunyan-prettystream/index.d.ts b/types/bunyan-prettystream/index.d.ts index c82d444f76..f4c5efb948 100644 --- a/types/bunyan-prettystream/index.d.ts +++ b/types/bunyan-prettystream/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for bunyan-prettystream 0.1.3 // Project: https://www.npmjs.com/package/bunyan-prettystream -// Definitions by: Jason Swearingen , Vadim Macagon +// Definitions by: Jason Swearingen , Vadim Macagon // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// diff --git a/types/bunyan/bunyan-tests.ts b/types/bunyan/bunyan-tests.ts index 657a59c3a8..3c093c0270 100644 --- a/types/bunyan/bunyan-tests.ts +++ b/types/bunyan/bunyan-tests.ts @@ -1,13 +1,10 @@ import Logger = require('bunyan'); -let ringBufferOptions: Logger.RingBufferOptions = { +const ringBufferOptions: Logger.RingBufferOptions = { limit: 100 }; -let ringBuffer: Logger.RingBuffer = new Logger.RingBuffer(ringBufferOptions); +const ringBuffer: Logger.RingBuffer = new Logger.RingBuffer(ringBufferOptions); ringBuffer.write("hello"); -ringBuffer.end(); -ringBuffer.destroy(); -ringBuffer.destroySoon(); let level: number; level = Logger.resolveLevel("trace"); @@ -23,13 +20,14 @@ level = Logger.resolveLevel(Logger.WARN); level = Logger.resolveLevel(Logger.ERROR); level = Logger.resolveLevel(Logger.FATAL); -let options: Logger.LoggerOptions = { +const options: Logger.LoggerOptions = { name: 'test-logger', serializers: Logger.stdSerializers, streams: [{ type: 'stream', stream: process.stdout, - level: Logger.TRACE + level: Logger.TRACE, + name: 'foo' }, { type: 'file', path: '/tmp/test.log', @@ -45,7 +43,7 @@ let options: Logger.LoggerOptions = { }, { type: 'raw', stream: process.stderr, - level: Logger.WARN + level: Logger.FATAL + 1, // disabled, as stderr explodes when given raw streams }, { type: 'raw', stream: ringBuffer, @@ -53,9 +51,9 @@ let options: Logger.LoggerOptions = { }] }; -let log = Logger.createLogger(options); +const log = Logger.createLogger(options); -let customSerializer = (anything: any) => { +const customSerializer = (anything: any) => { return { obj: anything }; }; @@ -69,19 +67,17 @@ log.addSerializers( } ); -let child = log.child({ name: 'child' }); -child.reopenFileStreams(); -log.addStream({ path: '/dev/null' }); -child.level(Logger.DEBUG); -child.level('debug'); -child.levels(0, Logger.ERROR); -child.levels(0, 'error'); -child.levels('stream1', Logger.FATAL); -child.levels('stream1', 'fatal'); +const levels: number[] = log.levels(); +level = log.levels(0); +log.levels('foo'); -let buffer = new Buffer(0); -let error = new Error(''); -let object = { +log.levels(0, Logger.INFO); +log.levels(0, 'info'); +log.levels('foo', Logger.WARN); + +const buffer = new Buffer(0); +const error = new Error(''); +const object = { test: 123 }; @@ -116,7 +112,7 @@ log.fatal(error); log.fatal(object); log.fatal('Hello, %s', 'world!'); -let recursive: any = { +const recursive: any = { hello: 'world', whats: {} }; @@ -129,3 +125,22 @@ class MyLogger extends Logger { super(options); } } + +const child = log.child({ widget_type: 'wuzzle' }); +child.reopenFileStreams(); +log.addStream({ path: '/dev/null' }); +child.level(Logger.DEBUG); +child.level('debug'); +child.levels(0, Logger.ERROR); +child.levels(0, 'error'); +child.levels('foo', Logger.FATAL); +child.levels('foo', 'fatal'); + +ringBuffer.end(); +ringBuffer.destroy(); +ringBuffer.destroySoon(); + +const logLevelString: Logger.LogLevelString = 'warn'; +const nameLevel: number = Logger.levelFromName[logLevelString]; +const nameLevel2: number = Logger.levelFromName['warn']; +const levelName: string = Logger.nameFromLevel[10]; diff --git a/types/bunyan/index.d.ts b/types/bunyan/index.d.ts index bc1dca298d..055c64deb8 100644 --- a/types/bunyan/index.d.ts +++ b/types/bunyan/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/trentm/node-bunyan // Definitions by: Alex Mikhalev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// @@ -210,7 +211,11 @@ declare namespace Logger { const ERROR: number; const FATAL: number; - type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal' | number; + type LogLevelString = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal'; + type LogLevel = LogLevelString | number; + + const levelFromName: { [name in LogLevelString]: number }; + const nameFromLevel: { [level: number]: string }; const stdSerializers: StdSerializers; @@ -228,6 +233,7 @@ declare namespace Logger { closeOnExit?: boolean; period?: string; count?: number; + name?: string; } interface LoggerOptions { diff --git a/types/business-rules-engine/package.json b/types/business-rules-engine/package.json index d33ff913ce..fce08a048d 100644 --- a/types/business-rules-engine/package.json +++ b/types/business-rules-engine/package.json @@ -1,5 +1,6 @@ { + "private": true, "dependencies": { "moment": ">=2.14.0" } -} +} \ No newline at end of file diff --git a/types/bwip-js/index.d.ts b/types/bwip-js/index.d.ts index 04732ef703..401cc9dbc8 100644 --- a/types/bwip-js/index.d.ts +++ b/types/bwip-js/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for bwip-js 1.1.1 // Project: https://github.com/metafloor/bwip-js -// Definitions by: TANAKA Koichi +// Definitions by: TANAKA Koichi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// diff --git a/types/bytebuffer/index.d.ts b/types/bytebuffer/index.d.ts index 1cf7142592..8456f28182 100644 --- a/types/bytebuffer/index.d.ts +++ b/types/bytebuffer/index.d.ts @@ -1,8 +1,8 @@ // Type definitions for bytebuffer.js 5.0.0 // Project: https://github.com/dcodeIO/bytebuffer.js -// Definitions by: Denis Cappellin +// Definitions by: Denis Cappellin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// Definitions by: SINTEF-9012 +// Definitions by: SINTEF-9012 import Long = require("long"); diff --git a/types/bytes/index.d.ts b/types/bytes/index.d.ts index ae9e8f2d87..0f438052e3 100644 --- a/types/bytes/index.d.ts +++ b/types/bytes/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for bytes v2.5.0 // Project: https://github.com/visionmedia/bytes.js -// Definitions by: Zhiyuan Wang +// Definitions by: Zhiyuan Wang // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped interface BytesOptions { diff --git a/types/c3/c3-tests.ts b/types/c3/c3-tests.ts index 029946c710..509678636b 100644 --- a/types/c3/c3-tests.ts +++ b/types/c3/c3-tests.ts @@ -3,7 +3,7 @@ ////////////////// function chart_examples() { - let chart = c3.generate({ + const chart = c3.generate({ data: {}, bindto: "#myContainer", size: { @@ -30,19 +30,19 @@ function chart_examples() { onresized: () => { /* code*/ } }); - let chart2 = c3.generate({ + const chart2 = c3.generate({ bindto: document.getElementById("myContainer"), data: {} }); - let chart3 = c3.generate({ + const chart3 = c3.generate({ bindto: d3.select("#myContainer"), data: {} }); } function data_examples() { - let chart = c3.generate({ + const chart = c3.generate({ data: { url: "/data/c3_test.csv", json: [ @@ -126,7 +126,7 @@ function data_examples() { } }); - let chart2 = c3.generate({ + const chart2 = c3.generate({ data: { labels: { format: (v, id, i, j) => { /* code */ } }, hide: ["data1"] @@ -135,7 +135,7 @@ function data_examples() { } function axis_examples() { - let chart = c3.generate({ + const chart = c3.generate({ data: {}, axis: { rotated: true, @@ -207,7 +207,7 @@ function axis_examples() { } }); - let chart2 = c3.generate({ + const chart2 = c3.generate({ data: {}, axis: { x: { @@ -241,7 +241,7 @@ function axis_examples() { } function grid_examples() { - let chart = c3.generate({ + const chart = c3.generate({ data: {}, grid: { x: { @@ -265,7 +265,7 @@ function grid_examples() { } function region_examples() { - let chart = c3.generate({ + const chart = c3.generate({ data: {}, regions: [ { axis: "x", start: 1, end: 4, class: "region-1-4" }, @@ -274,7 +274,7 @@ function region_examples() { } function legend_examples() { - let chart = c3.generate({ + const chart = c3.generate({ data: {}, legend: { show: true, @@ -294,7 +294,7 @@ function legend_examples() { } }); - let chart2 = c3.generate({ + const chart2 = c3.generate({ data: {}, legend: { hide: "data1", @@ -307,7 +307,7 @@ function legend_examples() { } }); - let chart3 = c3.generate({ + const chart3 = c3.generate({ data: {}, legend: { hide: ["data1", "data2"] @@ -316,7 +316,7 @@ function legend_examples() { } function subchart_examples() { - let chart = c3.generate({ + const chart = c3.generate({ data: {}, subchart: { show: true, @@ -329,7 +329,7 @@ function subchart_examples() { } function zoom_examples() { - let chart = c3.generate({ + const chart = c3.generate({ data: {}, zoom: { enabled: false, @@ -343,7 +343,7 @@ function zoom_examples() { } function point_examples() { - let chart = c3.generate({ + const chart = c3.generate({ data: {}, point: { show: false, @@ -362,7 +362,7 @@ function point_examples() { } function line_examples() { - let chart = c3.generate({ + const chart = c3.generate({ data: {}, line: { connectNull: true, @@ -374,7 +374,7 @@ function line_examples() { } function area_examples() { - let chart = c3.generate({ + const chart = c3.generate({ data: {}, area: { zerobased: false @@ -383,7 +383,7 @@ function area_examples() { } function bar_examples() { - let chart = c3.generate({ + const chart = c3.generate({ data: {}, bar: { width: 10, @@ -391,7 +391,7 @@ function bar_examples() { } }); - let chart2 = c3.generate({ + const chart2 = c3.generate({ data: {}, bar: { width: { @@ -403,7 +403,7 @@ function bar_examples() { } function pie_examples() { - let chart = c3.generate({ + const chart = c3.generate({ data: {}, pie: { label: { @@ -419,7 +419,7 @@ function pie_examples() { } function donut_examples() { - let chart = c3.generate({ + const chart = c3.generate({ data: {}, donut: { label: { @@ -437,7 +437,7 @@ function donut_examples() { } function gauge_examples() { - let chart = c3.generate({ + const chart = c3.generate({ data: {}, gauge: { label: { @@ -460,7 +460,7 @@ function gauge_examples() { ///////////////// function simple_multiple() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 30, 200, 100, 400, 150, 250], @@ -481,7 +481,7 @@ function simple_multiple() { } function timeseries() { - let chart = c3.generate({ + const chart = c3.generate({ data: { x: "x", xFormat: "%Y%m%d", // 'xFormat' can be used as custom format of 'x' @@ -503,7 +503,7 @@ function timeseries() { } function chart_spline() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 30, 200, 100, 400, 150, 250], @@ -515,7 +515,7 @@ function chart_spline() { } function simple_xy() { - let chart = c3.generate({ + const chart = c3.generate({ data: { x: "x", columns: [ @@ -528,7 +528,7 @@ function simple_xy() { } function simple_xy_multiple() { - let chart = c3.generate({ + const chart = c3.generate({ data: { xs: { data1: "x1", @@ -545,7 +545,7 @@ function simple_xy_multiple() { } function simple_regions() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 30, 200, 100, 400, 150, 250], @@ -560,7 +560,7 @@ function simple_regions() { } function chart_step() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 300, 350, 300, 0, 0, 100], @@ -575,7 +575,7 @@ function chart_step() { } function area_chart() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 300, 350, 300, 0, 0, 0], @@ -590,7 +590,7 @@ function area_chart() { } function chart_area_stacked() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 300, 350, 300, 0, 0, 120], @@ -607,7 +607,7 @@ function chart_area_stacked() { } function chart_bar() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 30, 200, 100, 400, 150, 250], @@ -627,7 +627,7 @@ function chart_bar() { } function chart_bar_stacked() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", -30, 200, 200, 400, -150, 250], @@ -648,7 +648,7 @@ function chart_bar_stacked() { } function chart_scatter() { - let chart = c3.generate({ + const chart = c3.generate({ data: { xs: { setosa: "setosa_x", @@ -682,7 +682,7 @@ function chart_scatter() { } function chart_pie() { - let chart = c3.generate({ + const chart = c3.generate({ data: { // iris data from R columns: [ @@ -698,7 +698,7 @@ function chart_pie() { } function chart_donut() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 30], @@ -716,7 +716,7 @@ function chart_donut() { } function gauge_chart() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data", 91.4] @@ -753,7 +753,7 @@ function gauge_chart() { } function chart_combination() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 30, 20, 50, 40, 60, 50], @@ -781,7 +781,7 @@ function chart_combination() { //////////////////// function categorized() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 30, 200, 100, 400, 150, 250, 50, 100, 250] @@ -797,7 +797,7 @@ function categorized() { } function axes_rotated() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 30, 200, 100, 400, 150, 250], @@ -814,7 +814,7 @@ function axes_rotated() { } function axes_y2() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 30, 200, 100, 400, 150, 250], @@ -834,7 +834,7 @@ function axes_y2() { } function axes_x_tick_format() { - let chart = c3.generate({ + const chart = c3.generate({ data: { x: "x", columns: [ @@ -855,7 +855,7 @@ function axes_x_tick_format() { } function axes_x_tick_count() { - let chart = c3.generate({ + const chart = c3.generate({ data: { x: "x", columns: [ @@ -876,7 +876,7 @@ function axes_x_tick_count() { } function axes_x_tick_values() { - let chart = c3.generate({ + const chart = c3.generate({ data: { x: "x", columns: [ @@ -897,7 +897,7 @@ function axes_x_tick_values() { } function axes_x_tick_culling() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["sample", 30, 200, 100, 400, 150, 250, 30, 200, 100, 400, 150, 250, 30, 200, 100, 400, 150, 250, 200, 100, 400, 150, 250] @@ -919,7 +919,7 @@ function axes_x_tick_culling() { } function axes_x_tick_fit() { - let chart = c3.generate({ + const chart = c3.generate({ data: { x: "x", columns: [ @@ -940,7 +940,7 @@ function axes_x_tick_fit() { } function axes_x_localtime() { - let chart = c3.generate({ + const chart = c3.generate({ data: { x: "x", xFormat: "%Y", @@ -966,7 +966,7 @@ function axes_x_localtime() { } function axes_x_tick_rotate() { - let chart = c3.generate({ + const chart = c3.generate({ data: { x: "x", columns: [ @@ -990,7 +990,7 @@ function axes_x_tick_rotate() { } function axes_y_tick_format() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["sample", 30, 200, 100, 400, 150, 2500] @@ -1008,7 +1008,7 @@ function axes_y_tick_format() { } function axes_y_padding() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 30, 200, 100, 400, 150, 250], @@ -1032,7 +1032,7 @@ function axes_y_padding() { } function axes_y_range() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["sample", 30, 200, 100, 400, 150, 250] @@ -1050,7 +1050,7 @@ function axes_y_range() { } function axes_label() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["sample", 30, 200, 100, 400, 150, 250], @@ -1076,7 +1076,7 @@ function axes_label() { } function axes_label_position() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["sample1", 30, 200, 100, 400, 150, 250], @@ -1134,7 +1134,7 @@ function axes_label_position() { /////////////////// function data_columned() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 30, 20, 50, 40, 60, 50], @@ -1146,7 +1146,7 @@ function data_columned() { } function data_rowed() { - let chart = c3.generate({ + const chart = c3.generate({ data: { rows: [ ["data1", "data2", "data3"], @@ -1210,7 +1210,7 @@ function data_json() { } function data_url() { - let chart = c3.generate({ + const chart = c3.generate({ data: { url: "/data/c3_test.csv" } @@ -1227,7 +1227,7 @@ function data_url() { } function data_stringx() { - let chart = c3.generate({ + const chart = c3.generate({ data: { x: "x", columns: [ @@ -1294,7 +1294,7 @@ function data_stringx() { } function data_load() { - let chart = c3.generate({ + const chart = c3.generate({ data: { url: "/data/c3_test.csv", type: "line" @@ -1397,7 +1397,7 @@ function data_load() { } function data_name() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 30, 200, 100, 400, 150, 250], @@ -1412,7 +1412,7 @@ function data_name() { } function data_color() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 30, 20, 50, 40, 60, 50], @@ -1434,7 +1434,7 @@ function data_color() { } function data_order() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 130, 200, 320, 400, 530, 750], @@ -1478,7 +1478,7 @@ function data_order() { } function data_label() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 30, -200, -100, 400, 150, 250], @@ -1500,7 +1500,7 @@ function data_label() { } function data_label_format() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 30, -200, -100, 400, 150, 250], @@ -1532,7 +1532,7 @@ function data_label_format() { /////////////////// function options_gridline() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["sample", 30, 200, 100, 400, 150, 250, 120, 200] @@ -1550,7 +1550,7 @@ function options_gridline() { } function grid_x_lines() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["sample", 30, 200, 100, 400, 150, 250] @@ -1569,7 +1569,7 @@ function grid_x_lines() { } function grid_y_lines() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["sample", 30, 200, 100, 400, 150, 250], @@ -1601,7 +1601,7 @@ function grid_y_lines() { /////////////////// function region() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 30, 200, 100, 400, 150, 250, 400], @@ -1631,7 +1631,7 @@ function region() { } function region_timeseries() { - let chart = c3.generate({ + const chart = c3.generate({ data: { x: "date", columns: [ @@ -1657,7 +1657,7 @@ function region_timeseries() { ///////////////////// function options_subchart() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["sample", 30, 200, 100, 400, 150, 250] @@ -1670,7 +1670,7 @@ function options_subchart() { } function interaction_zoom() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["sample", 30, 200, 100, 400, 150, 250, 150, 200, 170, 240, 350, 150, 100, 400, 150, 250, 150, 200, 170, 240, 100, 150, 250, 150, 200, 170, 240, 30, 200, 100, 400, 150, 250, 150, @@ -1688,7 +1688,7 @@ function interaction_zoom() { ///////////////////// function options_legend() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["sample", 30, 200, 100, 400, 150, 250] @@ -1701,7 +1701,7 @@ function options_legend() { } function legend_position() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 30, 200, 100, 400, 150, 250], @@ -1737,7 +1737,7 @@ function legend_position() { } function legend_custom() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 100], @@ -1781,7 +1781,7 @@ function legend_custom() { ///////////////////// function tooltip_show() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 30, 200, 100, 400, 150, 250], @@ -1795,7 +1795,7 @@ function tooltip_show() { } function tooltip_grouped() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 30, 200, 100, 400, 150, 250], @@ -1810,7 +1810,7 @@ function tooltip_grouped() { } function tooltip_format() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 30000, 20000, 10000, 40000, 15000, 250000], @@ -1837,7 +1837,7 @@ function tooltip_format() { format: { title: (d: any) => "Data " + d, value: (value: any, ratio: any, id: any) => { - let format = id === "data1" ? d3.format(",") : d3.format("$"); + const format = id === "data1" ? d3.format(",") : d3.format("$"); return format(value); } // value: d3.format(",") // apply this format to both y and y2 @@ -1851,7 +1851,7 @@ function tooltip_format() { //////////////////////// function options_size() { - let chart = c3.generate({ + const chart = c3.generate({ size: { height: 240, width: 480 @@ -1865,7 +1865,7 @@ function options_size() { } function options_padding() { - let chart = c3.generate({ + const chart = c3.generate({ padding: { top: 40, right: 100, @@ -1881,7 +1881,7 @@ function options_padding() { } function options_color() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 30, 200, 100, 400, 150, 250], @@ -1900,7 +1900,7 @@ function options_color() { } function transition_duration() { - let chart = c3.generate({ + const chart = c3.generate({ data: { url: "/data/c3_test.csv" }, @@ -1953,7 +1953,7 @@ function transition_duration() { ///////////////////////////// function point_show() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 30, 200, 100, 400, 150, 250], @@ -1971,7 +1971,7 @@ function point_show() { //////////////////////////// function pie_label_format() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 30], @@ -1994,7 +1994,7 @@ function pie_label_format() { ///////////////////// function api_flow() { - let chart = c3.generate({ + const chart = c3.generate({ data: { x: "x", columns: [ @@ -2064,7 +2064,7 @@ function api_flow() { } function api_data_name() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 30, 200, 100, 400, 150, 250], @@ -2087,7 +2087,7 @@ function api_data_name() { } function api_data_color() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 30, 20, 50, 40, 60, 50], @@ -2122,7 +2122,7 @@ function api_data_color() { } function api_axis_label() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 30, 200, 100, 400, 150, 250], @@ -2154,7 +2154,7 @@ function api_axis_label() { } function api_axis_range() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 30, 200, 100, 400, 150, 250], @@ -2210,7 +2210,7 @@ function api_axis_range() { } function api_resize() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 30, 200, 100, 400, 150, 250], @@ -2233,7 +2233,7 @@ function api_resize() { } function api_grid_x() { - let chart = c3.generate({ + const chart = c3.generate({ bindto: "#chart", data: { columns: [ @@ -2276,7 +2276,7 @@ function api_grid_x() { ///////////////////// function transform_line() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 30, 200, 100, 400, 150, 250], @@ -2304,7 +2304,7 @@ function transform_line() { } function transform_spline() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 30, 200, 100, 400, 150, 250], @@ -2332,7 +2332,7 @@ function transform_spline() { } function transform_bar() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 30, 200, 100, 400, 150, 250], @@ -2360,7 +2360,7 @@ function transform_bar() { } function transform_area() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 30, 200, 100, 400, 150, 250], @@ -2388,7 +2388,7 @@ function transform_area() { } function transform_areaspline() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 30, 200, 100, 400, 150, 250], @@ -2416,7 +2416,7 @@ function transform_areaspline() { } function transform_scatter() { - let chart = c3.generate({ + const chart = c3.generate({ data: { xs: { setosa: "setosa_x", @@ -2462,7 +2462,7 @@ function transform_scatter() { } function transform_pie() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 30, 200, 100, 400, 150, 250], @@ -2485,7 +2485,7 @@ function transform_pie() { } function transform_donut() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 30, 200, 100, 400, 150, 250], @@ -2516,7 +2516,7 @@ function transform_donut() { ///////////////////// function style_region() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["sample", 30, 200, 100, 400, 150, 250] @@ -2530,7 +2530,7 @@ function style_region() { } function style_grid() { - let chart = c3.generate({ + const chart = c3.generate({ data: { columns: [ ["data1", 100, 200, 1000, 900, 500] diff --git a/types/cache-manager/index.d.ts b/types/cache-manager/index.d.ts index 37af0b8374..40d644b546 100644 --- a/types/cache-manager/index.d.ts +++ b/types/cache-manager/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for cache-manager v1.2.0 // Project: https://github.com/BryanDonovan/node-cache-manager -// Definitions by: Simon Gausmann +// Definitions by: Simon Gausmann // Definitions: https://github.com/borisyankov/DefinitelyTyped interface CachingConfig { diff --git a/types/cal-heatmap/index.d.ts b/types/cal-heatmap/index.d.ts index f4b9f4df4f..affde185e2 100644 --- a/types/cal-heatmap/index.d.ts +++ b/types/cal-heatmap/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for cal-heatmap v3.5.4 // Project: https://github.com/wa0x6e/cal-heatmap -// Definitions by: Chris Baker +// Definitions by: Chris Baker // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/callsites/callsites-tests.ts b/types/callsites/callsites-tests.ts new file mode 100644 index 0000000000..abe174537d --- /dev/null +++ b/types/callsites/callsites-tests.ts @@ -0,0 +1,20 @@ +import callsites = require('callsites'); + +function unicorn() { + callsites(); // $ExpectType CallSite[] + callsites()[0].getThis(); // $ExpectType object | undefined + callsites()[0].getTypeName(); // $ExpectType string + callsites()[0].getFunction(); // $ExpectType Function | undefined + callsites()[0].getFunctionName(); // $ExpectType string + callsites()[0].getMethodName(); // $ExpectType string | null + callsites()[0].getFileName(); // $ExpectType string | undefined + callsites()[0].getLineNumber(); // $ExpectType number + callsites()[0].getColumnNumber(); // $ExpectType number + callsites()[0].getEvalOrigin(); // $ExpectType string | CallSite + callsites()[0].isToplevel(); // $ExpectType boolean + callsites()[0].isEval(); // $ExpectType boolean + callsites()[0].isNative(); // $ExpectType boolean + callsites()[0].isConstructor(); // $ExpectType boolean +} + +unicorn(); diff --git a/types/callsites/index.d.ts b/types/callsites/index.d.ts new file mode 100644 index 0000000000..aea96c767f --- /dev/null +++ b/types/callsites/index.d.ts @@ -0,0 +1,27 @@ +// Type definitions for callsites 2.0 +// Project: https://github.com/sindresorhus/callsites#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +export = callsites; + +declare function callsites(): callsites.CallSite[]; + +declare namespace callsites { + interface CallSite { + getThis(): object | undefined; + getTypeName(): string; + getFunction(): Function | undefined; // tslint:disable-line ban-types + getFunctionName(): string; + getMethodName(): string | null; + getFileName(): string | undefined; + getLineNumber(): number; + getColumnNumber(): number; + getEvalOrigin(): CallSite | string; + isToplevel(): boolean; + isEval(): boolean; + isNative(): boolean; + isConstructor(): boolean; + } +} diff --git a/types/callsites/tsconfig.json b/types/callsites/tsconfig.json new file mode 100644 index 0000000000..68aca90ea3 --- /dev/null +++ b/types/callsites/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "callsites-tests.ts" + ] +} diff --git a/types/callsites/tslint.json b/types/callsites/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/callsites/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/camelcase/camelcase-tests.ts b/types/camelcase/camelcase-tests.ts index aacb29481a..871ec5c3b2 100644 --- a/types/camelcase/camelcase-tests.ts +++ b/types/camelcase/camelcase-tests.ts @@ -1,4 +1,3 @@ - import camelCase = require('camelcase'); camelCase('foo-bar'); diff --git a/types/camelcase/index.d.ts b/types/camelcase/index.d.ts index 79705dd423..83abf5a8a5 100644 --- a/types/camelcase/index.d.ts +++ b/types/camelcase/index.d.ts @@ -1,9 +1,9 @@ -// Type definitions for camelcase +// Type definitions for camelcase 4.1 // Project: https://github.com/sindresorhus/camelcase // Definitions by: Sam Verschueren // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +export = camelcase; declare function camelcase(...args: string[]): string; -declare namespace camelcase { } -export = camelcase; +declare namespace camelcase {} diff --git a/types/camelcase/tsconfig.json b/types/camelcase/tsconfig.json index 872bd51e96..a3fc596eb6 100644 --- a/types/camelcase/tsconfig.json +++ b/types/camelcase/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -19,4 +19,4 @@ "index.d.ts", "camelcase-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/camelcase/tslint.json b/types/camelcase/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/camelcase/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/canvasjs/canvasjs-tests.ts b/types/canvasjs/canvasjs-tests.ts index e9120ec9c3..281cea0e51 100644 --- a/types/canvasjs/canvasjs-tests.ts +++ b/types/canvasjs/canvasjs-tests.ts @@ -1,248 +1,243 @@ +import * as CanvasJS from "canvasjs"; - -namespace CanvasJS.Tests { - // Column Chart - var columnChart = new CanvasJS.Chart("chartContainer", - { - title: { - text: "Top Oil Reserves", - }, - axisY: { - title: "Reserves(MMbbl)" - }, - legend: { - verticalAlign: "bottom", - horizontalAlign: "center" - }, - theme: "theme2", - data: [ - { - type: "column", - showInLegend: true, - legendMarkerColor: "grey", - legendText: "MMbbl = one million barrels", - dataPoints: [ - { y: 297571, label: "Venezuela" }, - { y: 267017, label: "Saudi" }, - { y: 175200, label: "Canada" }, - { y: 154580, label: "Iran" }, - { y: 116000, label: "Russia" }, - { y: 97800, label: "UAE" }, - { y: 20682, label: "US" }, - { y: 20350, label: "China" } - ] - } - ] - }); - columnChart.render(); - - // Line Chart - var lineChart = new CanvasJS.Chart("chartContainer", - { - theme: "theme2", - title: { - text: "Earthquakes - per month" - }, - axisX: { - valueFormatString: "MMM", - interval: 1, - intervalType: "month" - - }, - axisY: { - includeZero: false - - }, - data: [ - { - type: "line", - //lineThickness: 3, - dataPoints: [ - { x: new Date(2012, 0, 1), y: 450 }, - { x: new Date(2012, 1, 1), y: 414 }, - { x: new Date(2012, 2, 1), y: 520, indexLabel: "highest", markerColor: "red", markerType: "triangle" }, - { x: new Date(2012, 3, 1), y: 460 }, - { x: new Date(2012, 4, 1), y: 450 }, - { x: new Date(2012, 5, 1), y: 500 }, - { x: new Date(2012, 6, 1), y: 480 }, - { x: new Date(2012, 7, 1), y: 480 }, - { x: new Date(2012, 8, 1), y: 410, indexLabel: "lowest", markerColor: "DarkSlateGrey", markerType: "cross" }, - { x: new Date(2012, 9, 1), y: 500 }, - { x: new Date(2012, 10, 1), y: 480 }, - { x: new Date(2012, 11, 1), y: 510 } - - ] - } - - - ] - }); - lineChart.render(); - - // Spline Chart - var splineChart = new CanvasJS.Chart("chartContainer", - { - theme: "theme2", - title: { - text: "Game of Thrones, Viewers of the first airing on HBO" - }, - axisY: { - includeZero: false, - // suffix: " k", - valueFormatString: "#,,.", - suffix: " mn" - }, - toolTip: { - shared: true - }, - data: [ - { - type: "spline", - showInLegend: true, - name: "Season 2", - // markerSize: 0, - // color: "rgba(54,158,173,.6)", - dataPoints: [ - { label: "Ep. 1", y: 3858000 }, - { label: "Ep. 2", y: 3759000 }, - { label: "Ep. 3", y: 3766000 }, - { label: "Ep. 4", y: 3654000 }, - { label: "Ep. 5", y: 3903000 }, - { label: "Ep. 6", y: 3879000 }, - { label: "Ep. 7", y: 3694000 }, - { label: "Ep. 8", y: 3864000 }, - { label: "Ep. 9", y: 3384000 }, - { label: "Ep. 10", y: 4200000 } - - ] - }, - { - type: "spline", - showInLegend: true, - // markerSize: 0, - name: "Season 1", - dataPoints: [ - { label: "Ep. 1", y: 2220000 }, - { label: "Ep. 2", y: 2200000 }, - { label: "Ep. 3", y: 2440000 }, - { label: "Ep. 4", y: 2450000 }, - { label: "Ep. 5", y: 2580000 }, - { label: "Ep. 6", y: 2440000 }, - { label: "Ep. 7", y: 2400000 }, - { label: "Ep. 8", y: 2720000 }, - { label: "Ep. 9", y: 2660000 }, - { label: "Ep. 10", y: 3040000 } - - ] - } - ], - legend: { - cursor: "pointer", - itemclick: function (e) { - if (typeof (e.dataSeries.visible) === "undefined" || e.dataSeries.visible) { - e.dataSeries.visible = false; - } - else { - e.dataSeries.visible = true; - } - splineChart.render(); - } - - }, - }); - splineChart.render(); - - // Bar Chart - var barChart = new CanvasJS.Chart("chartContainer", { - +// Column Chart +const columnChart = new CanvasJS.Chart("chartContainer", + { title: { - text: "Fortune Global 500 Companies by Country" - }, - axisX: { - interval: 1, - gridThickness: 0, - labelFontSize: 10, - labelFontStyle: "normal", - labelFontWeight: "normal", - labelFontFamily: "Lucida Sans Unicode" + text: "Top Oil Reserves", }, axisY: { - interlacedColor: "rgba(1,77,101,.2)", - gridColor: "rgba(1,77,101,.1)" + title: "Reserves(MMbbl)" }, + legend: { + verticalAlign: "bottom", + horizontalAlign: "center" + }, + theme: "theme2", data: [ { - type: "bar", - name: "companies", - axisYType: "secondary", - color: "#014D65", + type: "column", + lineDashType: "longDash", + showInLegend: true, + legendMarkerColor: "grey", + legendText: "MMbbl = one million barrels", dataPoints: [ - { y: 5, label: "Sweden" }, - { y: 6, label: "Taiwan" }, - { y: 7, label: "Russia" }, - { y: 8, label: "Spain" }, - { y: 8, label: "Brazil" }, - { y: 8, label: "India" }, - { y: 9, label: "Italy" }, - { y: 9, label: "Australia" }, - { y: 12, label: "Canada" }, - { y: 13, label: "South Korea" }, - { y: 13, label: "Netherlands" }, - { y: 15, label: "Switzerland" }, - { y: 28, label: "Britain" }, - { y: 32, label: "Germany" }, - { y: 32, label: "France" }, - { y: 68, label: "Japan" }, - { y: 73, label: "China" }, - { y: 132, label: "US" } + { y: 297571, label: "Venezuela" }, + { y: 267017, label: "Saudi" }, + { y: 175200, label: "Canada" }, + { y: 154580, label: "Iran" }, + { y: 116000, label: "Russia" }, + { y: 97800, label: "UAE" }, + { y: 20682, label: "US" }, + { y: 20350, label: "China" } ] } ] }); - barChart.render(); +columnChart.render(); +const option = columnChart.get("title"); +columnChart.print(); +columnChart.exportChart({ format: "jpg" }); +columnChart.destroy(); +columnChart.axisX[0].convertPixelToValue(20); +columnChart.toolTip.get("text"); - // Pie Chart - var pieChart = new CanvasJS.Chart("chartContainer", - { - title: { - text: "Desktop Search Engine Market Share, Dec-2012" - }, - legend: { - verticalAlign: "center", - horizontalAlign: "left", - fontSize: 20, - fontFamily: "Helvetica" - }, - theme: "theme2", - data: [ - { - type: "pie", - indexLabelFontFamily: "Garamond", - indexLabelFontSize: 20, - indexLabel: "{label} {y}%", - startAngle: -20, - showInLegend: true, - toolTipContent: "{legendText} {y}%", - dataPoints: [ - { y: 83.24, legendText: "Google", label: "Google" }, - { y: 8.16, legendText: "Yahoo!", label: "Yahoo!" }, - { y: 4.67, legendText: "Bing", label: "Bing" }, - { y: 1.67, legendText: "Baidu", label: "Baidu" }, - { y: 0.98, legendText: "Others", label: "Others" } - ] - } - ] - }); - pieChart.render(); - - addColorSet("MyColorSet", [ - "123456", - "blue", - "red", - "orange" - ]); - - addCultureInfo("js", { - days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] +// Line Chart +const lineChart = new CanvasJS.Chart("chartContainer", + { + theme: "theme2", + title: { + text: "Earthquakes - per month" + }, + axisX: { + valueFormatString: "MMM", + interval: 1, + intervalType: "month" + }, + axisY: { + includeZero: false + }, + data: [ + { + type: "line", + // lineThickness: 3, + dataPoints: [ + { x: new Date(2012, 0, 1), y: 450 }, + { x: new Date(2012, 1, 1), y: 414 }, + { x: new Date(2012, 2, 1), y: 520, indexLabel: "highest", markerColor: "red", markerType: "triangle" }, + { x: new Date(2012, 3, 1), y: 460 }, + { x: new Date(2012, 4, 1), y: 450 }, + { x: new Date(2012, 5, 1), y: 500 }, + { x: new Date(2012, 6, 1), y: 480 }, + { x: new Date(2012, 7, 1), y: 480 }, + { x: new Date(2012, 8, 1), y: 410, indexLabel: "lowest", markerColor: "DarkSlateGrey", markerType: "cross" }, + { x: new Date(2012, 9, 1), y: 500 }, + { x: new Date(2012, 10, 1), y: 480 }, + { x: new Date(2012, 11, 1), y: 510 } + ] + } + ] }); -} +lineChart.render(); + +// Spline Chart +const splineChart = new CanvasJS.Chart("chartContainer", + { + theme: "theme2", + title: { + text: "Game of Thrones, Viewers of the first airing on HBO" + }, + axisY: { + includeZero: false, + // suffix: " k", + valueFormatString: "#,,.", + suffix: " mn" + }, + toolTip: { + shared: true + }, + data: [ + { + type: "spline", + showInLegend: true, + name: "Season 2", + // markerSize: 0, + // color: "rgba(54,158,173,.6)", + dataPoints: [ + { label: "Ep. 1", y: 3858000 }, + { label: "Ep. 2", y: 3759000 }, + { label: "Ep. 3", y: 3766000 }, + { label: "Ep. 4", y: 3654000 }, + { label: "Ep. 5", y: 3903000 }, + { label: "Ep. 6", y: 3879000 }, + { label: "Ep. 7", y: 3694000 }, + { label: "Ep. 8", y: 3864000 }, + { label: "Ep. 9", y: 3384000 }, + { label: "Ep. 10", y: 4200000 } + ] + }, + { + type: "spline", + showInLegend: true, + // markerSize: 0, + name: "Season 1", + dataPoints: [ + { label: "Ep. 1", y: 2220000 }, + { label: "Ep. 2", y: 2200000 }, + { label: "Ep. 3", y: 2440000 }, + { label: "Ep. 4", y: 2450000 }, + { label: "Ep. 5", y: 2580000 }, + { label: "Ep. 6", y: 2440000 }, + { label: "Ep. 7", y: 2400000 }, + { label: "Ep. 8", y: 2720000 }, + { label: "Ep. 9", y: 2660000 }, + { label: "Ep. 10", y: 3040000 } + ] + } + ], + legend: { + cursor: "pointer", + itemclick: (e) => { + e.dataSeries.visible = !(typeof (e.dataSeries.visible) === "undefined" || e.dataSeries.visible); + splineChart.render(); + } + }, + }); +splineChart.render(); + +// Bar Chart +const barChart = new CanvasJS.Chart("chartContainer", { + title: { + text: "Fortune Global 500 Companies by Country" + }, + axisX: { + interval: 1, + gridThickness: 0, + labelFontSize: 10, + labelFontStyle: "normal", + labelFontWeight: "normal", + labelFontFamily: "Lucida Sans Unicode" + }, + axisY: { + interlacedColor: "rgba(1,77,101,.2)", + gridColor: "rgba(1,77,101,.1)" + }, + data: [ + { + type: "bar", + name: "companies", + axisYType: "secondary", + color: "#014D65", + dataPoints: [ + { y: 5, label: "Sweden" }, + { y: 6, label: "Taiwan" }, + { y: 7, label: "Russia" }, + { y: 8, label: "Spain" }, + { y: 8, label: "Brazil" }, + { y: 8, label: "India" }, + { y: 9, label: "Italy" }, + { y: 9, label: "Australia" }, + { y: 12, label: "Canada" }, + { y: 13, label: "South Korea" }, + { y: 13, label: "Netherlands" }, + { y: 15, label: "Switzerland" }, + { y: 28, label: "Britain" }, + { y: 32, label: "Germany" }, + { y: 32, label: "France" }, + { y: 68, label: "Japan" }, + { y: 73, label: "China" }, + { y: 132, label: "US" } + ] + } + ] +}); +barChart.render(); + +// Pie Chart +const pieChart = new CanvasJS.Chart("chartContainer", + { + title: { + text: "Desktop Search Engine Market Share, Dec-2012" + }, + legend: { + verticalAlign: "center", + horizontalAlign: "left", + fontSize: 20, + fontFamily: "Helvetica" + }, + theme: "theme2", + data: [ + { + type: "pie", + indexLabelFontFamily: "Garamond", + indexLabelFontSize: 20, + indexLabel: "{label} {y}%", + startAngle: -20, + showInLegend: true, + toolTipContent: "{legendText} {y}%", + dataPoints: [ + { y: 83.24, legendText: "Google", label: "Google" }, + { y: 8.16, legendText: "Yahoo!", label: "Yahoo!" }, + { y: 4.67, legendText: "Bing", label: "Bing" }, + { y: 1.67, legendText: "Baidu", label: "Baidu" }, + { y: 0.98, legendText: "Others", label: "Others" } + ] + } + ] + }); +pieChart.render(); + +CanvasJS.addColorSet("MyColorSet", [ + "123456", + "blue", + "red", + "orange" +]); + +CanvasJS.addCultureInfo("js", { + days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] +}); + +CanvasJS.formatNumber(20); + +CanvasJS.formatDate(new Date()); diff --git a/types/canvasjs/index.d.ts b/types/canvasjs/index.d.ts index 79a168f2d0..e1b74a7606 100644 --- a/types/canvasjs/index.d.ts +++ b/types/canvasjs/index.d.ts @@ -1,992 +1,1673 @@ -// Type definitions for CanvasJS v1.5.1 +// Type definitions for CanvasJS 1.9 // Project: http://canvasjs.com/ -// Definitions by: Mark Overholt +// Definitions by: ShuYin Zhang // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +type DashType = "solid" | "shortDash" | "shortDot" | "shortDashDot" | "shortDashDotDot" | "dot" | "dash" | "dashDot" | "longDash" | "longDashDot" | "longDashDotDot"; + declare namespace CanvasJS { class Chart { - /** - * The current options of the chart. - */ + * The current options of the chart. + */ options: ChartOptions; - /** - * Initializes a new instance of CanvasJS Chart. - * @param containerId the DOM ID of the location where the chart is to be rendered - * @param options the options used to render the chart - */ + * All Title options become available as properties after Chart Render. You can access them either via get method or dot notation. But you can change / set those values only via set method. + */ + readonly title: ChartTitle; + /** + * The subtitles of the chart. + * You can access them either via get method or dot notation. But you can change / set those values only via set method. + */ + readonly subtitles: ChartTitle[]; + /** + * The toolTip of the chart. + */ + readonly toolTip: ChartToolTip; + readonly axisX: ChartAxisX[]; + readonly axisX2: ChartAxisX[]; + readonly axisY: ChartAxisY[]; + readonly axisY2: ChartAxisY[]; + readonly stripLines: ChartStrip[]; + readonly data: ChartDataSeries[]; + /** + * Initializes a new instance of CanvasJS Chart. + * @param containerId the DOM ID of the location where the chart is to be rendered + * @param options the options used to render the chart + */ constructor(containerId: string, options?: ChartOptions); /** - * Renders the chart. - * @param options an optional set of options that will override the constructed values. - */ - render(options?: ChartOptions): void; + * Renders the chart. + */ + render(): void; + /** + * Returns the specified property of Chart. + * @param propertyName Name of the property. + */ + get(propertyName: string): any; + /** + * Sets the specified property of Chart. + * Notes: + * 1. Chart should be rendered before you can use this method. + * 2. Because the chart updates each time set is called by default, + * it is recommended to disable auto update (set updateChart to false) till the last step if you have to set multiple properties. + * Otherwise it can affect performance because of repeated chart rendering. You can see an example below. + * @param propertyName Name of the property. + * @param value value to be set on property. + * @param updateChart When true, Updates the chart automatically after setting the value. Defaults to true. + */ + set(propertyName: string, value: ChartOptions, updateChart?: boolean): void; + /** + * Adds a new element of given type to the specified array. For example, it can be used to add new Axis to axisY array. + * Notes: + * 1. Chart should be rendered before you can use this method. + * 2. Chart renders automatically after addTo() operation. + * @param propertyName Name of the property + * @param options Option for the new element + * @param index Index of the array where the new element is to be added. Defaults to the length (end) of array. + * @param updateChart When true, Updates the chart automatically after setting the value. Defaults to true. + */ + addTo(propertyName: string, options: ChartAxisXOptions | ChartAxisYOptions | ChartDataSeriesOptions, index?: number, updateChart?: boolean): void; + /** + * Export the chart as image (jpg / png). + * @param options Setting when export + */ + exportChart(options: { format: "jpg" | "png", toDataURL?: boolean, fileName?: string }): void; + /** + * Prints the Chart. + * Chart should be rendered before you can use this method. + */ + print(): void; + /** + * Removes the chart references internally, thus making the chart eligible for garbage collection, in turn clearing up the memory. + * Notes: + * 1. On calling chart.destroy(), chart won’t be responsive unless new chart is created. + * 2. chart.destroy() should be called before using the same variable to hold a newly allocated object/chart to prevent memory leaks. + */ + destroy(): void; } /** - * Adds a new chart color set - * @param the name of the color set - * @param an array of colors. - */ + * Adds a new chart color set + * @param colorSetName name of the color set + * @param colorSetArray array of colors. + */ function addColorSet(colorSetName: string, colorSetArray: string[]): void; - /** - * Adds a new culture info for your chart - * @param culture the name of the culture - * @param the information used by this culture - */ + * Adds a new culture info for your chart + * @param culture the name of the culture + * @param info information used by this culture + */ function addCultureInfo(culture: string, info: CultureInfo): void; + /** + * Formats number according to the given formatString(optional) & culture(optional). + * @param number Number to format. + * @param formatString Default formatString is “#,##0.##” . + * @param culture Default culture is “en” + */ + function formatNumber(number: number, formatString?: string, culture?: string): string; + /** + * Formats date/timestamp according to the given formatString(optional) & culture(optional). + * @param date Date type or timestamp number. + * @param formatString Default formatString is “DD MMM YYYY”. + * @param culture Default culture is “en”. + */ + function formatDate(date: Date | number, formatString?: string, culture?: string): void; interface CultureInfo { /** - * Character used to separate fractional part from the whole number. - */ + * Character used to separate fractional part from the whole number. + * Default: "." + * Example: “.“ ”,” + */ decimalSeparator?: string; /** - * Also referred to as Thousand Separator - */ + * Also referred to as Thousand Separator. + * Default: “,” + * Example: “,”, “.” + */ digitGroupSeparator?: string; /** - * Text is shown inside the Button till v1.4 - * v1.5 onwards Text is shown as tooltip. - */ + * Text is shown inside the Button till v1.4 + * v1.5 onwards Text is shown as tooltip. + * Default: "Zoom" + * Example: “zoom”, etc + */ zoomText?: string; /** - * Text is shown inside the Button till v1.4 - * v1.5 onwards Text is shown as tooltip. - */ + * Text is shown inside the Button till v1.4 + * v1.5 onwards Text is shown as tooltip. + * Default: “Pan” + * Example: “pan”, etc + */ panText?: string; /** - * Text is shown inside the Button till v1.4 - * v1.5 onwards Text is shown as tooltip. - */ + * Text is shown inside the Button till v1.4 + * v1.5 onwards Text is shown as tooltip. + * Default: “Reset” + * Example: “reset”, etc + */ resetText?: string; /** - * Set text is shown instead of Save as PNG. - */ + * Set text is shown instead of Save as PNG. + * Default: “Save as PNG” + * Example: “save as png”, etc + */ savePNGText?: string; /** - * Set text is shown instead of Save as JPG. - */ + * Set text is shown instead of Save as JPG. + * Default: “Save as JPG” + * Example: “save as jpg”, etc + */ saveJPGText?: string; /** - * Tool Tip for Menu Button. - */ + * Tool Tip for Menu Button. + * Default: “More Options” + * Example: “More Options”, etc + */ menuText?: string; /** - * Day names starting from Sunday. Should be exactly 7 in total. - */ + * Day names starting from Sunday. Should be exactly 7 in total. + * Default: [“Sunday”, “Monday”, “Tuesday”, “Wednesday”, “Thursday”, “Friday”, “Saturday”] + * Example: [“domingo”, “lunes”, “martes”, “miércoles”, “jueves”, “viernes”, “sábado”] + */ days?: string[]; /** - * Short Day names starting from Sunday. Should be exactly 7 in total. - */ + * Short Day names starting from Sunday. Should be exactly 7 in total. + * Default: [“Sun”, “Mon”, “Tue”, “Wed”, “Thu”, “Fri”, “Sat”] + * Example: [“Sun”, “Mon”, “Tue”, “Wed”, “Thu”, “Fri”, “Sat”] + */ shortDays?: string[]; /** - * Month Names starting from January - */ + * Month Names starting from January. + * Default: [“January”, “February”, “March”, “April”, “May”, “June”, “July”, “August”, “September”, “October”, “November”, “December”] + * Example: [“January”, “February”, “March”, “April”, “May”, “June”, “July”, “August”, “September”, “October”, “November”, “December”] + */ months?: string[]; /** - * Short Month Names starting from January - */ + * Short Month Names starting from January. + * Default: [“Jan”, “Feb”, “Mar”, “Apr”, “May”, “Jun”, “Jul”, “Aug”, “Sep”, “Oct”, “Nov”, “Dec”] + * Example: [“Jan”, “Feb”, “Mar”, “Apr”, “May”, “Jun”, “Jul”, “Aug”, “Sep”, “Oct”, “Nov”, “Dec”] + */ shortMonths?: string[]; } interface ChartOptions { /** - * Enables / Disables Chart interactivity like toolTip, mouse and touch events - * Default: true - * Example: false, true - */ + * Enables / Disables Chart interactivity like toolTip, mouse and touch events. + * Default: true + * Example: false, true + */ interactivityEnabled?: boolean; /** - * Enables Animation while rendering the Chart. - * Default: true - * Example: false, true - */ + * Sets the duration of animation in milliseconds. + * Default: 1200 + * Example: 1000, 500 etc. + */ + animationDuration?: number; + /** + * Enables Animation while rendering the Chart. + * Default: true + * Example: false, true + */ animationEnabled?: boolean; /** - * While exporting any chart, "Chart" is used as the default fine name with corresponding extension "jpg" or "png". You can override this name using exportFileName property. - * Default: Chart - */ + * While exporting any chart, "Chart" is used as the default fine name with corresponding extension "jpg" or "png". You can override this name using exportFileName property. + * Default: Chart + */ exportFileName?: string; /** - * Setting exportEnabled to true enables the export feature. As of now JPG & PNG formats are supported. Export feature is available in all Chart Types. - * Default: false - * Options: true, false - */ + * Setting exportEnabled to true enables the export feature. As of now JPG & PNG formats are supported. Export feature is available in all Chart Types. + * Default: false + * Options: true, false + */ exportEnabled?: boolean; /** - * Setting zoomEnabled to true enables zooming and panning feature of Chart. This way you can zoom into an area of interest when there is a large amount of data. This will also allow you to pan through the chart. If not set, the property is automatically enabled for large number of dataPoints. You can switch between zooming & panning using the toolbar that appears on the chart. After Zooming in, you can reset the chart by clicking the reset button. - * Default: false - * Options: true, false - */ + * Setting zoomEnabled to true enables zooming and panning feature of Chart. + * This way you can zoom into an area of interest when there is a large amount of data. + * This will also allow you to pan through the chart. + * If not set, the property is automatically enabled for large number of dataPoints. You can switch between zooming & panning using the toolbar that appears on the chart. + * After Zooming in, you can reset the chart by clicking the reset button. + * Default: false + * Options: true, false + */ zoomEnabled?: boolean; /** - * Sets the theme of the Chart. Various predefined themes are bundled along with the library. User can easily switch these themes by changing theme property to the below mentioned options. - * Default: "theme1" - * Options: "theme1","theme2", "theme3" - */ + * Sets the theme of the Chart. Various predefined themes are bundled along with the library. User can easily switch these themes by changing theme property to the below mentioned options. + * Default: "theme1" + * Options: "theme1","theme2", "theme3" + */ theme?: string; /** - * Sets the background color of entire Chart Area. Values can be "HTML Color Name", "hex code" or "rgba values" - * Default: "white" - * Example: "yellow", "#F5DEB3".. - */ + * Sets the background color of entire Chart Area. Values can be "HTML Color Name", "hex code" or "rgba values" + * Default: "white" + * Example: "yellow", "#F5DEB3".. + */ backgroundColor?: string; /** - * Sets the colorSet of the Chart. Color Set is an array of colors that are used to render data. Various predefined Color Sets are bundled along with the library. You can either choose from the pre-defined Color Sets or define your own Color Set. - * Default: "colorset1" or as defined in the selected theme - * Example: "colorSet1", "colorSet2", "colorSet3" - */ + * Sets the colorSet of the Chart. Color Set is an array of colors that are used to render data. Various predefined Color Sets are bundled along with the library. + * You can either choose from the pre-defined Color Sets or define your own Color Set. + * Default: "colorset1" or as defined in the selected theme + * Example: "colorSet1", "colorSet2", "colorSet3" + */ colorSet?: string; /** - * CanvasJS allows you to localize various culture / language / country specific elements in the Chart like number formatting style – where you can choose which character to use as a decimal separator and as a digit group separator (also referred to as a thousand separator). By default CanvasJS is set to Neutral English Culture – "en". - * Default: "en" - */ + * CanvasJS allows you to localize various culture / language / country specific elements in the Chart like number formatting style – where you can choose + * which character to use as a decimal separator and as a digit group separator (also referred to as a thousand separator). + * By default CanvasJS is set to Neutral English Culture – "en". + * Default: "en" + */ culture?: string; /** - * Sets the width of the Chart. - * Default: Takes chart container’s width by default. If the width is not set for the chart container, defaults to 500. - * Example: 380, 500, 720 - */ + * Sets the width of the Chart. + * Default: Takes chart container’s width by default. If the width is not set for the chart container, defaults to 500. + * Example: 380, 500, 720 + */ width?: number; /** - * Sets the width of the Chart - * Default: Takes chart container’s height by default. If the height is not set for the chart container, defaults to 400. - * Example: 260, 300, 400 - */ + * Sets the width of the Chart + * Default: Takes chart container’s height by default. If the height is not set for the chart container, defaults to 400. + * Example: 260, 300, 400 + */ height?: number; /** - * Title allows you to set content, appearance and position of Chart’s Title. - */ + * dataPointMaxWidth sets the maximum width of dataPoints in column / bar, ohlc and candlestick, charts. + * This allows you to limit the width of dataPoints when there are very few of them in the chart. + * At the same time, when the number of dataPoints increase, chart reduces their width so that they don’t overlap. + * Default : Automatically calculated based on the chart size. + * Example : 10, 20, 30, etc. + */ + dataPointMaxWidth?: number; + /** + * Title allows you to set content, appearance and position of Chart’s Title. + */ title: ChartTitleOptions; /** - * Whenever the chart contains multiple dataSeries, it is recommended to represent each dataSeries in a legend. This way it becomes easier for the user to know what exactly is represented by each of the dataSeries. In case of Pie and Doughnut charts, an entry is created for each dataPoint and in rest of the chart types entries are created for each dataSeries. - * You can selectively show or hide a dataSeries in the Legend using showInLegend property of dataSeries. - */ + * Whenever the chart contains multiple dataSeries, it is recommended to represent each dataSeries in a legend. + * This way it becomes easier for the user to know what exactly is represented by each of the dataSeries. + * In case of Pie and Doughnut charts, an entry is created for each dataPoint and in rest of the chart types entries are created for each dataSeries. + * You can selectively show or hide a dataSeries in the Legend using showInLegend property of dataSeries. + */ legend?: ChartLegendOptions; /** - * axisX object lets you set various parameters of X Axis like interval, grid lines, etc. It is mostly horizontal, except when we are working with Bar Charts, where axisX is vertical. - */ - axisX?: ChartAxisXOptions; + * axisX object lets you set various parameters of X Axis like interval, grid lines, etc. It is mostly horizontal, except when we are working with Bar Charts, where axisX is vertical. + */ + axisX?: ChartAxisXOptions | ChartAxisXOptions[]; /** - * axisY object lets you set various parameters of Y Axis like interval, grid lines, etc. It is mostly vertical, except when we are working with Bar Charts, where axisY is horizontal. - */ - axisY?: ChartAxisYOptions; + * axisX2 is the secondary axis which renders on the opposite of primary axis (axisX). + * It is mostly horizontal on top, except when we are working with Bar Charts, where axisX2 is vertical on right. + */ + axisX2?: ChartAxisXOptions | ChartAxisXOptions[]; /** - * toolTip object lets user set behaviour of toolTip at global level like enabling/disabling animation, setting Border Color, sharing toolTip between multiple dataSeries, etc. You can also disable the toolTip by setting enabled property to false. - */ + * axisY object lets you set various parameters of Y Axis like interval, grid lines, etc. It is mostly vertical, except when we are working with Bar Charts, where axisY is horizontal. + */ + axisY?: ChartAxisYOptions | ChartAxisYOptions[]; + /** + * axisY2 is the secondary axis which renders on the opposite of primary axis (axisY). It is mostly vertical, except when we are working with Bar Charts, where axisY2 is horizontal. + */ + axisY2?: ChartAxisYOptions | ChartAxisYOptions[]; + /** + * toolTip object lets user set behaviour of toolTip at global level like enabling/disabling animation, setting Border Color, sharing toolTip between multiple dataSeries, etc. + * You can also disable the toolTip by setting enabled property to false. + */ toolTip?: ChartToolTipOptions; /** - * data is an array of dataSeries Objects. - */ - data: ChartDataOptions[]; + * data is an array of dataSeries Objects. + */ + data: ChartDataSeriesOptions[]; + /** + * subtitles is a collection of subtitle elements. This allows you to have as many subtitles as you want in a chart. + * subtitle allows you to set content, appearance and position of Chart’s subtitle. subtitle is very much like title except that its font size is lesser than title by default. + */ + subtitles?: ChartTitleOptions[]; } interface ChartTitleOptions { /** - * Sets the Title’s text. - * Default: null - * Example: "Chart title" - */ + * Sets the Title’s text. + * Default: null + * Example: "Chart title" + */ text?: string; /** - * This property lets you align the Chart Title vertically. - * Default: "top" - * Options: "top", "center", "bottom" - */ + * This property lets you align the Chart Title vertically. + * Default: "top" + * Options: "top", "center", "bottom" + */ verticalAlign?: string; /** - * This property lets you align the Chart Title horizontally. - * Default: "center" - * Options: "left", "right", "center" - */ + * This property lets you align the Chart Title horizontally. + * Default: "center" + * Options: "left", "right", "center" + */ horizontalAlign?: string; /** - * Sets the font Size of Chart Title in pixels. - * Default: Automatically Calculated based on Chart Size - * Example: 16,18,22 .. - */ + * Sets the font Size of Chart Title in pixels. + * Default: 20 + * Example: 16,18,22 .. + */ fontSize?: number; /** - * Sets the Font Family of Chart Title. - * Default: "Calibri, Optima, Candara, Verdana, Geneva, sans-serif" - * Example: "arial" , "tahoma", "verdana" .. - */ + * Sets the Font Family of Chart Title. + * Default: "calibri, Optima, Candara, verdana, Geneva, sans-serif" + * Example: "arial" , "tahoma", "verdana" .. + */ fontFamily?: string; /** - * Sets the Font Weight used in the Chart Title. - * Default: "bold" - * Options: "lighter", "normal", "bold" , "bolder" - */ + * Sets the Font Weight used in the Chart Title. + * Default: "normal" + * Options: "lighter", "normal", "bold" , "bolder" + */ fontWeight?: string; /** - * Sets the font color of Chart Title. The value of fontColor can be a "HTML Color Name" or "hex" code . - * Default: "#3A3A3A" - * Example: "red", "#FAC003" .. - */ + * Sets the font color of Chart Title. The value of fontColor can be a "HTML Color Name" or "hex" code . + * Default: "black" + * Example: "red", "#FAC003" .. + */ fontColor?: string; /** - * Sets the fontStyle of Chart Title. fontStyle can be set to one of the below options. - * Default: "normal" - * Options: "normal", "italic" , "oblique" - */ + * Sets the fontStyle of Chart Title. fontStyle can be set to one of the below options. + * Default: "normal" + * Options: "normal", "italic" , "oblique" + */ fontStyle?: string; /** - * Sets the thickness of border around the Title in pixels. To display border around title, set the borderThickness to a number greater than zero. - * Default: 0 - * Example: 2,4 .. - */ + * Sets the thickness of border around the Title in pixels. To display border around title, set the borderThickness to a number greater than zero. + * Default: 0 + * Example: 2,4 .. + */ borderThickness?: number; /** - * To display rounded borders around the title, set the cornerRadius of title. Higher the value, more rounded are the corners. - * Default: 0 - * Options: 5,8 .. - */ + * To display rounded borders around the title, set the cornerRadius of title. Higher the value, more rounded are the corners. + * Default: 0 + * Options: 5,8 .. + */ cornerRadius?: number; /** - * Sets the color of border around Chart Title. Values of borderColor can be "HTML Color Name" or "hex" code . - * Default: "black" - * Example: "red", "#FF0000" .. - */ + * Sets the color of border around Chart Title. Values of borderColor can be "HTML Color Name" or "hex" code . + * Default: "black" + * Example: "red", "#FF0000" .. + */ borderColor?: string; /** - * Sets the background color of Chart Title. Values can be "HTML Color Name" or "hex" code. - * Default: null - * Example: "red", "#FF0000" .. - */ + * Sets the background color of Chart Title. Values can be "HTML Color Name" or "hex" code. + * Default: null + * Example: "red", "#FF0000" .. + */ backgroundColor?: string; /** - * This property lets you set margin around the Chart Title in pixels. - * Default: 10 - * Example: 4,12 .. - */ + * This property lets you set margin around the Chart Title in pixels. + * Default: 5 + * Example: 4,12 .. + */ margin?: number; /** - * This property allows you to set the padding for Chart Title - * Default: 0 - * Example: 5, 8 .. - */ + * This property allows you to set the padding for Chart Title + * Default: 0 + * Example: 5, 8 .. + */ padding?: number; + /** + * Wrap specifies whether to wrap the title once its width crosses maxWidth or not. If it is set to false, title gets clipped after reaching maxWidth. + * Default: true; + * Example : true, false + */ + wrap?: boolean; + /** + * Sets the maximum width of title after which it gets wrapped or clipped depending on whether wrap is set to true (default) or false. + * Default: Automatically calculated based on the chart size. + * Example: 200, 400 .. + */ + maxWidth?: number; + /** + * When dockInsidePlotArea is set to true, title renders inside the plot area there by giving more space to plot area. + * Default: false + * Example: false, true. + */ + dockInsidePlotArea?: boolean; + } + + interface ChartTitle extends ChartTitleOptions { + /** + * Can be accessed via get method or dot notation. + */ + readonly bounds: { + x1: number, + x2: number, + y1: number, + y2: number, + }; + /** + * Returns the specified property of title. + * @param propertyName Name of the property. + */ + get(propertyName: string): string | number | boolean; + /** + * Sets the specified property of Title. + * @param propertyName Name of the property. + * @param value value to be set on property. + * @param updateChart When true, Updates the chart automatically after setting the value. Defaults to true. + */ + set(propertyName: string, value: string | number | boolean, updateChart: boolean): void; + /** + * Removes title of the chart. + */ + remove(): void; } interface ChartLegendOptions { /** - * Sets the cursor type for legend items. - * Default: "default" - * Examples: "pointer", "crosshair" .. - */ + * Sets the cursor type for legend items. + * Default: "default" + * Examples: "pointer", "crosshair" .. + */ cursor?: string; - /** - * Sets the font Size of Legend Text in pixels. - * Default: 12 - * Example: 16,18,22 .. - */ + * Sets the font Size of Legend Text in pixels. + * Default: 20 + * Example: 16,18,22 .. + */ fontSize?: number; /** - * Sets the Font Family of Legend Text. - * Default: "calibri" - * Example: "arial" , "tahoma", "verdana" .. - */ + * Sets the Font Family of Legend Text. + * Default: "calibri" + * Example: "arial" , "tahoma", "verdana" .. + */ fontFamily?: string; /** - * Sets the font color of Legend Text . The value of fontColor can be a "HTML Color Name" or "hex" code . - * Default: "black" - * Example: "red", "#FAC003" .. - */ + * Sets the font color of Legend Text . The value of fontColor can be a "HTML Color Name" or "hex" code . + * Default: "black" + * Example: "red", "#FAC003" .. + */ fontColor?: string; /** - * Sets the Font Weight of Legend Text. - * Default: "normal" - * Example: "lighter", "normal", "bold" , "bolder" - */ + * Sets the Font Weight of Legend Text. + * Default: "normal" + * Example: "lighter", "normal", "bold" , "bolder" + */ fontWeight?: string; /** - * Sets the fontStyle of Legend Text. fontStyle can be set to one of the below options. - * Default: "normal" - * Example: "normal", "italic" , "oblique" - */ + * Sets the fontStyle of Legend Text. fontStyle can be set to one of the below options. + * Default: "normal" + * Example: "normal", "italic" , "oblique" + */ fontStyle?: string; /** - * This property lets you align the Legend Position vertically. - * Default: "bottom" - * Example: "top", "center", "bottom" - */ + * This property lets you align the Legend Position vertically. + * Default: "bottom" + * Example: "top", "center", "bottom" + */ verticalAlign?: string; /** - * This property lets you align the Legend Position horizontally. - * Default: "right" - * Example: "left", "right", "center" - */ + * This property lets you align the Legend Position horizontally. + * Default: "right" + * Example: "left", "right", "center" + */ horizontalAlign?: string; /** - * Sets the mouseover event handler for the legend, which is triggered when the user moves the mouse(input device) over a legend item. After the event is triggered, the event related data is passed as a parameter to the assigned event handler. Parameters passed to the function are shown in the Event Object section below. - * @param event a chart event - */ - itemmouseover?: (event: ChartEvent) => void; + * Sets the margin between marker and text of each item inside legend. + * Default: Automatically calculated based on the chart size. + * Example: 4,12 .. + */ + markerMargin?: number; /** - * Sets the mousemove event handler for the legend, which is triggered when the user moves the mouse(input device) within a legend item. When the event is triggered, the event related data is passed as a parameter to the assigned event handler. Parameters passed to the function are shown in the Event Object section below. - * @param event a chart event - */ - itemmousemove?: (event: ChartEvent) => void; + * Sets the mouseover event handler for the legend, which is triggered when the user moves the mouse(input device) over a legend item. + * After the event is triggered, the event related data is passed as a parameter to the assigned event handler. Parameters passed to the function are shown in the Event Object section below. + * @param event a chart event + */ + itemmouseover?(event: ChartEvent): void; /** - * Sets the mouseout event handler for the legend, which is triggered when the user moves the mouse pointer outside a legend item. After the event is triggered, the event related data is passed as a parameter to the assigned event handler. Parameters passed to the function are shown in the Event Object section below. - * @param event a chart event - */ - itemmouseout?: (event: ChartEvent) => void; + * Sets the mousemove event handler for the legend, which is triggered when the user moves the mouse(input device) within a legend item. + * When the event is triggered, the event related data is passed as a parameter to the assigned event handler. + * Parameters passed to the function are shown in the Event Object section below. + * @param event a chart event + */ + itemmousemove?(event: ChartEvent): void; /** - * Sets the click event handler for the legend, which is triggered when the user clicks on a legend item. After the event is triggered, the event related data is passed as a parameter to the assigned event handler. Parameters passed to the function are shown in the Event Object section below. - * @param event a chart event - */ - itemclick?: (event: ChartEvent) => void; + * Sets the mouseout event handler for the legend, which is triggered when the user moves the mouse pointer outside a legend item. + * After the event is triggered, the event related data is passed as a parameter to the assigned event handler. + * Parameters passed to the function are shown in the Event Object section below. + * @param event a chart event + */ + itemmouseout?(event: ChartEvent): void; + /** + * Sets the click event handler for the legend, which is triggered when the user clicks on a legend item. + * After the event is triggered, the event related data is passed as a parameter to the assigned event handler. + * Parameters passed to the function are shown in the Event Object section below. + * @param event a chart event + */ + itemclick?(event: ChartEvent): void; + /** + * Setting reversed property to true shows legend items in reverse order. + * Default: false; + * Example: true, false + */ + reversed?: boolean; + /** + * Sets the maximum width of legend. If any item is longer than the maxWidth, it gets wrapped or clipped depending on the itemWrap property. itemWrap is true by default. + * Whenever items are stacked horizontally, new items are moved to the next row once maxWidth is reached. + * Default: Automatically calculated based on the chart size. + * Example: 100, 200, 500 etc. + */ + maxWidth?: number; + /** + * Sets the maximum height of legend. Once the maximum height is reached, remaining legend items are not shown when horizontally stacked (while on top or bottom or plotArea) + * and a new column is created when items are vertically stacked (when displayed to the left or right of plotArea). + * Default: Automatically calculated based on chart size. + * Example: 100,200, 300 etc. + */ + maxHeight?: number; + /** + * Sets the maximum width of individual legend items after which they get wrapped or clipped depending on whether itemWrap is set to true (default) or false. + * itemMaxWidth can’t be greater than maxWidth of legend. + * Default: Automatically calculated based on the chart size. + * Example: 100, 150, 200 etc. + */ + itemMaxWidth?: number; + /** + * Sets the width of individual legend items after which the it gets wrapped or clipped depending on whether itemWrap is set to true (default) or false. + * itemWidth can’t be greater than itemMaxWidth and maxWidth of legend. + * Default: Automatically calculated based on chart size. + * Example: 100, 200, 300 etc. + */ + itemWidth?: number; + /** + * itemWrap specifies whether to wrap or clip legendText once its width crosses itemMaxWidth / maxWidth. + * Default: true + * Example: true, false + */ + itemWrap?: boolean; + /** + * A custom formatter function that returns text to be displayed inside individual legend items. + */ + itemTextFormatter?(e?: { chart: Chart, legend: ChartLegendOptions, dataSeries: ChartDataSeriesOptions, dataPoint: ChartDataPoint }): string; + /** + * When dockInsidePlotArea is set to true, legend renders inside the plot area there by giving more space to plot area. + * Default: false + * Example: true, false + */ + dockInsidePlotArea?: boolean; + } + + interface ChartLegend extends ChartLegendOptions { + /** + * Returns the specified property of legend. + * @param propertyName Name of the property. + */ + get(propertyName: string): number | string | boolean; + /** + * Sets the specified property of legend. + * @param propertyName Name of the property. + * @param value Name of the property. + * @param updateChart When true, Updates the chart automatically after setting the value. Defaults to true. + */ + set(propertyName: string, value: number | string | boolean, updateChart?: boolean): void; } interface ChartEvent { /** - * The x value of the item - */ + * The x value of the item + */ x: any; /** - * The y value of the item - */ + * The y value of the item + */ y: number; /** - * The chart object - */ + * The chart object + */ chart: Chart; /** - * The datapoint options - */ + * The datapoint options + */ dataPoint: ChartDataPoint; /** - * The data series options - */ - dataSeries: ChartDataOptions; + * The data series options + */ + dataSeries: ChartDataSeriesOptions; /** - * The index of the data point - */ + * The index of the data point + */ dataPointIndex: number; /** - * The index of the data series - */ + * The index of the data series + */ dataSeriesIndex: number; } interface ChartAxisOptions { /** - * Sets the Axis Title. - * Default: null - * Example: "Axis X Title" - */ + * Sets the Axis Title. + * Default: null + * Example: "Axis X Title" + */ title?: string; /** - * Sets the Font Color of Axis Title. The value of titleFontColor can be a "HTML Color Name" or "hex" code . - * Default: "#666666" - * Example: "red", "#006400" . - */ + * Sets the Font Color of Axis Title. The value of titleFontColor can be a "HTML Color Name" or "hex" code . + * Default: "#666666" + * Example: "red", "#006400" . + */ titleFontColor?: string; /** - * Sets the Font Size of Axis Title in pixels. - * Default: Automatically Calculated based on Chart Size - * Example: 16, 25 .. - */ + * Sets the Font Size of Axis Title in pixels. + * Default: 20 + * Example: 16, 25 .. + */ titleFontSize?: number; /** - * Sets the Font Family of Axis Title. - * Default: "Calibri, Optima, Candara, Verdana, Geneva, sans-serif" - * Example: "calibri", "tahoma, "verdana" .. - */ + * Sets the Font Family of Axis Title. + * Default: "arial" + * Example: "calibri", "tahoma, "verdana" .. + */ titleFontFamily?: string; /** - * Sets the Font Weight used in the Axis Title. It can be set to one of the options below. - * Default: "normal" - * Options: "lighter", "normal", "bold" , "bolder" - */ + * Sets the Font Weight used in the Axis Title. It can be set to one of the options below. + * Default: "normal" + * Options: "lighter", "normal", "bold" , "bolder" + */ titleFontWeight?: string; /** - * Sets the Font Style of Axis Title. It can be set to one of the below options. - * Default: "normal" - * Options: "normal", "italic" , "oblique" - */ + * Sets the Font Style of Axis Title. It can be set to one of the below options. + * Default: "normal" + * Options: "normal", "italic" , "oblique" + */ titleFontStyle?: string; /** - * This property lets you set margin between chart’s boundary and Axis. - * Default: 2 - * Example: 8, 10.. - */ + * This property lets you set margin between chart’s boundary and Axis. + * Default: 2 + * Example: 8, 10.. + */ margin?: number; /** - * Sets the angle for Axis Labels. - * Default: null - * Example: 20, 45, -30 .. - */ - labelAngle?: number; - /** - * Sets the Axis Label color. The value of labelFontColor can be a "HTML Color Name" or "hex" code . - * Default: "grey" - * Example: "red", "#FAC003" .. - */ - labelFontColor?: string; - /** - * Sets the Axis Label Font Size in pixels. - * Default: Automatically Calculated based on Chart Size - * Example: 16, 18, 22.. - */ - labelFontSize?: number; - /** - * Sets the Font Family of Axis labels. - * Default: "Calibri, Optima, Candara, Verdana, Geneva, sans-serif" - * Example: "calibri", "tahoma", "verdana" .. - */ - labelFontFamily?: string; - /** - * Set the font Weight used in Axis Labels. It can be set to one of the options below. - * Default: "normal" - * Options: "lighter", "normal", "bold" , "bolder" - */ - labelFontWeight?: string; - /** - * Sets the Font Style of Axis Labels. It can be set to one of the below options. - * Default: "normal" - * Options: "italic", "oblique", "normal" - */ - labelFontStyle?: string; - /** - * A string that prepends all the labels on axisX. - * Default: null - * Example: "$","cat".. - */ - prefix?: string; - /** - * A string that appends all the labels on axisX. - * Default: null - * Example: "$","cat".. - */ - suffix?: string; - /** - * Defines how values must be formatted before they appear on Axis X. You can format numbers and date time values using this property. Below you will find descriptive table explaining various specifiers with example. - */ - valueFormatString?: string; - /** - * Sets the distance between Tick Marks, Grid Lines and Interlaced Colors. - * Default: Automatically Calculated - * Example: 50, 75.. - */ - interval?: number; - /** - * intervalType is the unit of interval property. intervalType is by default set to "number" and hence you need to specify the interval type (eg "week", "month", etc) depending on the type of interval you intend to set. If required interval is 3 months, you need to provide interval as 3 and intervalType as "month" - * Default: Automatically handled when interval property is not set. Defaults to "number" when you set the interval. - * Option: "number","millisecond" ,"second"," minute", "hour", "day", "month" ,"year" - * Example: for interval as 15 minutes, set interval as 15, and set intervalType as "minute", - */ - intervalType?: string; - /** - * Sets the length of Tick Marks that are drawn on the Axis. - * Default: 5 - * Example: 10, 14.. - */ - tickLength?: number; - /** - * Sets the color of Tick Marks drawn on the axis. The value of tickColor can be a "HTML Color Name" or "hex" code . - * Default: "#BBBBBB" - * Example: "red", "#006400". - */ - tickColor?: string; - /** - * Sets the thickness of the Tick Marks in pixels. - * Default: 2 - * Example: 3, 4.. - */ - tickThickness?: number; - /** - * Sets the color of Axis line. Axis line color can be a "HTML Color Name" or "hex" code . - * Default: "#BBBBBB" - * Example: "blue","#21AB13".. - */ + * Sets the color of Axis line. Axis line color can be a "HTML Color Name" or "hex" code . + * Default: "#BBBBBB" + * Example: "blue","#21AB13".. + */ lineColor?: string; /** - * Sets the Thickness of Axis line in pixels. - * Default: 2 - * Example: 2, 4.. - */ - lineThickness?: string; + * Sets the Thickness of Axis line in pixels. + * Default: 2 + * Example: 2, 4.. + */ + lineThickness?: number; /** - * Sets the Interlacing Color that alternates between the set interval. If the interval is not set explicitly, then the auto calculated interval is considered. The value of interlacedColor can be a "HTML Color Name" or "hex" code . - * Default: null - * Example: "#F8F1E4", "#FEFDDF" …. - */ - interlaceColor?: string; + * Sets the dash type for axisY. + * Default: "solid" + */ + lineDashType?: DashType; /** - * Sets the Thickness of Grid Lines. To display grid on Axis X, set the Grid Thickness to a number greater than zero. - * Default: 0 - * Example: 2,4 .. - */ - gridThickness?: number; - /** - * Sets the Color of Grid Lines. Value of gridColor can be a "HTML Color Name" or "hex" code . - * Default: "#BBBBBB" - * Example: "red", "#FEFDDF" .. - */ - gridColor?: string; - - /** - * Sets the Interlacing Color that alternates between the set interval. - * If the interval is not set explicitly, then the auto calculated interval is considered. - * The value of interlacedColor can be an "HTML Color Name" or "hex" code. - * Default: null - * Example: "#F8F1E4", "#FEFDDF" - */ - interlacedColor?: string; - - /** - * Strip Lines are vertical or horizontal lines used to highlight/mark a certain region on the plot area. You can choose whether to draw a line at a specific position or shade a region on the plot area. Strip Lines are sometimes referred to as trend lines. - * If you want to just mark a certain position on the axis, you can set the value attribute and it’ll draw a line at that position with the set thickness. If you want to shade a region instead, you need to set startValue and endValue attributes. This will fill the area within the specified range. - * In the case you set startValue and endValue attributes, value and thickness attributes are ignored (as either a single thread of line can exist, or a shaded region between two given points). - * Strip Lines can be displayed using AxisX or AxisY’s stripLines array. This allows you to have one or more strip lines on both x & y axis. - */ - stripLines?: ChartStripLines; - } - - interface ChartStripLines { - /** - * Sets the point where the stripLine has to be plotted or drawn along the axis X. - * Default: null - * Example: 20,30,100,50 - */ - value?: number; - /** - * Sets the point where the stripLine’s shaded region begins on the x-axis. - * Default: null - * Example: 20,30,100,50 - */ - startValue?: number; - /** - * Sets the point where the stripLine’s shaded region ends on the x-axis. - * Default: null - * Example: 50,60,200,300 - */ - endValue?: number; - /** - * Sets the thickness of the stripLine in pixels. - * Default: 2 - * Example: 2,4,5,6 - */ - thickness?: number; - /** - * Sets the color of the stripLine. - * Default: "orange" - * Example: "green", "#23EA23" - */ - color?: string; - /** - * Sets the label of the stripLine. These are shown on top of axis labels. - * Default: "" (empty string) - * Example: "Threshold", "Deaths in 1920" - */ - label?: string; - /** - * Sets the background color of stripLine’s label. - * Default: "#eeeeee" - * Example: "red","#fabd76" - */ - labelBackgroundColor?: string; - /** - * Sets the font-family of stripLine’s label. If the first font is not found in the system from the specified font-family list, it tries to use the next font in the list. - * Default: "arial" - * Example: "Arial, Trebuchet MS, Tahoma, sans-serif" - */ - labelFontFamily?: string; - /** - * Sets the font color of label. - * Default: "orange" - * Example: "blue","#4135e9" - */ - labelFontColor?: string; - /** - * Sets the font size of the label in pixels. - * Default: 12 - * Example: 18,19,20,22 - */ - labelFontSize?: number; - /** - * Sets the font weight of stripLine’s label. - * Default: "normal" - * Example: "lighter","normal","bold","bolder" - */ - labelFontWeight?: string; - /** - * Sets the font style of stripLine’s label. - * Default: "normal" - * Example: "normal","italic","oblique" - */ - labelFontStyle?: string; - } - - interface ChartAxisXOptions extends ChartAxisOptions { - /** - * Sets the minimum value of Axis. Values smaller than minimum are clipped. - * Default: Automatically Calculated based on the data - * Example: 100, 350.. - */ - minimum?: number | Date; - /** - * Sets the maximum value permitted on Axis. Values greater than maximum are clipped. - * Default: Automatically Calculated based on the data - * Example: 100, 350.. - */ - maximum?: number | Date; - } - - interface ChartAxisYOptions extends ChartAxisOptions { - /** - * When includeZero is set to true, axisY sets the range in such a way that Zero is a part of it. It is set to true by default. But, whenever y values are very big and difference among dataPoints are hard to judge, setting includeZero to false makes axisY to set a range that makes the differences prominently visible. - * Default: true - * Example: true, false - */ - includeZero?: boolean; - - /** - * Sets the minimum value of Axis. Values smaller than minimum are clipped. - * Default: Automatically Calculated based on the data - * Example: 100, 350.. - */ + * Sets the minimum value of Axis. Values smaller than minimum are clipped. minimum also sets the lower limit while panning chart. + * Default: Automatically Calculated based on the data. + * Example: 100, 350.. + */ minimum?: number; /** - * Sets the maximum value permitted on Axis. Values greater than maximum are clipped. - * Default: Automatically Calculated based on the data - * Example: 100, 350.. - */ + * Sets the maximum value permitted on Axis. Values greater than maximum are clipped. maximum also set the upper limit while panning chart. + * Default: Automatically Calculated based on the data. + * Example: 100, 350.. + */ maximum?: number; + /** + * Viewport is the visible range of the axis and viewportMinimum allows you to set its minimum value. + * This can be used in combination with viewportMaximum in order to zoom into a certain region programmatically. + * Default: Automatically Calculated based on the data. + * Example: -100, 350.. + */ + viewportMinimum?: number; + /** + * Viewport is the visible range of the axis and viewportMinimum allows you to set its minimum value. + * This can be used in combination with viewportMaximum in order to zoom into a certain region programmatically. + * Default: Automatically Calculated based on the data. + * Example: -100, 350.. + */ + viewportMaximum?: number; + } + + interface ChartStripLinesOptions { + /** + * Sets the point where the stripLine has to be plotted or drawn along the axis X. + * Default: null + * Example: 20,30,100,50 + */ + value?: number; + /** + * Sets the point where the stripLine’s shaded region begins on the x-axis. + * Default: null + * Example: 20,30,100,50 + */ + startValue?: number; + /** + * Sets the point where the stripLine’s shaded region ends on the x-axis. + * Default: null + * Example: 50,60,200,300 + */ + endValue?: number; + /** + * Sets the thickness of the stripLine in pixels. + * Default: 2 + * Example: 2,4,5,6 + */ + thickness?: number; + /** + * Sets the color of the stripLine. + * Default: "orange" + * Example: "green", "#23EA23" + */ + color?: string; + /** + * Sets the label of the stripLine. These are shown on top of axis labels. + * Default: "" (empty string) + * Example: "Threshold", "Deaths in 1920" + */ + label?: string; + /** + * labelPlacement allows you to place stripline’s Label either inside or outside of plotArea. + * Default: “inside” + * Options: “inside”, “outside” + */ + labelPlacement?: string; + /** + * labelAlign allows you to place the stripline’s Label far, center or near the axis. + * Default: “far” + * Options: “far”, “center”, “near” + */ + labelAlign?: string; + /** + * Setting labelWrap to true wraps the labels at labelMaxWidth. Clips the same when set to false. It overrides the labelWrap set at axis level. + * Default: true + * Example: true, false. + */ + labelWrap: boolean; + /** + * labelMaxWidth defines the maximum width of labels after which they get wrapped or clipped depending on labelWrap’s value. + * It overrides the labelMaxWidth value set at axis level. + * Default: Automatically calculated based on the length of label. + * Example: 4, 20, 100 etc. + */ + labelMaxWidth: number; + /** + * Sets the background color of stripLine’s label. + * Default: "#eeeeee" + * Example: "red","#fabd76" + */ + labelBackgroundColor?: string; + /** + * Sets the font-family of stripLine’s label. If the first font is not found in the system from the specified font-family list, it tries to use the next font in the list. + * Default: "arial" + * Example: "Arial, Trebuchet MS, Tahoma, sans-serif" + */ + labelFontFamily?: string; + /** + * Sets the font color of label. + * Default: "orange" + * Example: "blue","#4135e9" + */ + labelFontColor?: string; + /** + * Sets the font size of the label in pixels. + * Default: 12 + * Example: 18,19,20,22 + */ + labelFontSize?: number; + /** + * Sets the font weight of stripLine’s label. + * Default: "normal" + * Example: "lighter","normal","bold","bolder" + */ + labelFontWeight?: string; + /** + * Sets the font style of stripLine’s label. + * Default: "normal" + * Example: "normal","italic","oblique" + */ + labelFontStyle?: string; + /** + * stripLine is displayed on top of dataPoints when showOnTop is set to true. + * Default: false + * Example: true, false + */ + showOnTop?: boolean; + /** + * Sets the Dash Type for stripLine. + * Default: solid + */ + lineDashType?: DashType; + /** + * Sets opacity of stripLine. + * Default: null + * Example: .1, .5, 1 etc. + */ + opacity?: number; + /** + * A custom formatter function that returns stripLine’s label. + */ + labelFormatter?(e?: { chart: Chart, axis: ChartAxisYOptions, stripline: ChartStripLinesOptions }): string; + } + + interface ChartStrip extends ChartStripLinesOptions { + /** + * Returns the specified property of stripLines. + * @param propertyName Name of the property + */ + get(propertyName: string): number | string | boolean; + /** + * Sets the specified property of stripLines. + * @param propertyName Name of the property. + * @param value value to be set on property. + * @param updateChart When true, Updates the chart automatically after setting the value. Defaults to true. + */ + set(propertyName: string, value: number | string | boolean, updateChart: boolean): void; + /** + * Removes specified stripLine from stripLines Array. + */ + remove(): void; + } + + interface ChartAxisXOptions extends ChartAxisOptions { + /** + * TitleWrap specifies whether to wrap or clip axis title once its width crosses titleMaxWidth. + * Default: true + * Options: true, false + */ + titleWrap?: boolean; + /** + * Sets the maximum width of title after which it gets wrapped or clipped depending on whether titleWrap is set to true (default) or false. + * Default: Automatically calculated based on the length of axis. + * Example: 100, 200... + */ + titleMaxWidth?: number; + /** + * Sets the Axis Label background color. The value of labelBackgroundColor can be a “HTML Color Name” or “hex” code. + * Default: “transparent” + * Example: “red”,”#fabd76″ + */ + labelBackgroundColor?: string; + /** + * Sets the maximum width of label after which it gets wrapped or clipped depending on whether labelWrap is set to true (default) or false. + * Default: Automatically calculated based on the length of label. + * Example: 4, 20, 100 etc. + */ + labelMaxWidth?: number; + /** + * labelWrap specifies whether to wrap or clip label once its width crosses labelMaxWidth. + * Default: true + * Example: true, false + */ + labelWrap?: boolean; + /** + * Setting labelAutoFit to true automatically wraps and/or rotates and/or reduces font size of label when they are too long and overlaps, + * finds the best-fit and automatically manages label overlapping. + * Default: true + * Options: true, false + */ + labelAutoFit?: boolean; + /** + * Sets the angle for Axis Labels. + * Notes: + * 1.Units in degrees. + * 2.Values can be positive or negative. + * Default: null; + * Example: 20, 45, -30.. + */ + labelAngle?: number; + /** + * Sets the Font Family of Axis labels. + * Default: “calibri, optima, Candara, Verdana, Geneva, sans-serif” + * Example: “calibri”, “tahoma”, “verdana” .. + */ + labelFontFamily?: string; + /** + * Sets the Axis Label color. The value of labelFontColor can be a "HTML Color Name" or "hex" code . + * Default: "grey" + * Example: "red", "#FAC003" .. + */ + labelFontColor?: string; + /** + * Sets the Axis Label Font Size in pixels. + * Default: Automatically Calculated based on Chart Size + * Example: 16, 18, 22.. + */ + labelFontSize?: number; + /** + * Set the font Weight used in Axis Labels. It can be set to one of the options below. + * Default: "normal" + * Options: "lighter", "normal", "bold" , "bolder" + */ + labelFontWeight?: string; + /** + * Sets the Font Style of Axis Labels. It can be set to one of the below options. + * Default: "normal" + * Options: "italic", "oblique", "normal" + */ + labelFontStyle?: string; + /** + * A string that prepends all the labels on axisX. + * Default: null + * Example: "$","cat".. + */ + prefix?: string; + /** + * A string that appends all the labels on axisX. + * Default: null + * Example: "$","cat".. + */ + suffix?: string; + /** + * Defines how values must be formatted before they appear on Axis X. + * You can format numbers and date time values using this property. + * More Detail: https://canvasjs.com/docs/charts/chart-options/axisx/valueformatstring/ + */ + valueFormatString?: string; + /** + * Sets the distance between Tick Marks, Grid Lines and Interlaced Colors. + * Default: Automatically Calculated + * Example: 50, 75.. + */ + interval?: number; + /** + * intervalType is the unit of interval property. + * intervalType is by default set to "number" and hence you need to specify the interval type (eg "week", "month", etc) depending on the type of interval you intend to set. + * If required interval is 3 months, you need to provide interval as 3 and intervalType as "month" + * Default: Automatically handled when interval property is not set. Defaults to "number" when you set the interval. + * Option: "number","millisecond" ,"second"," minute", "hour", "day", "month" ,"year" + * Example: for interval as 15 minutes, set interval as 15, and set intervalType as "minute", + */ + intervalType?: string; + /** + * Setting reversed property to true shows axis in reverse order. + * Default: false + * Options: true, false + */ + reversed?: boolean; + /** + * Setting logarithmic property to true changes axis scale to logarithmic scale. Default Logarithm Base is 10 – which you can customize using logarithmBase property. + * Default: false + * Options: true, false + */ + logarithmic?: boolean; + /** + * Sets the logarithm base for Axis X. Works only when logarithm property is set to true. + * Default: 10 + * Options: 2, 16, Math.E, .. + */ + logarithmBase?: number; + /** + * Sets the length of Tick Marks that are drawn on the Axis. + * Default: 5 + * Example: 10, 14.. + */ + tickLength?: number; + /** + * Sets the color of Tick Marks drawn on the axis. The value of tickColor can be a "HTML Color Name" or "hex" code . + * Default: "#BBBBBB" + * Example: "red", "#006400". + */ + tickColor?: string; + /** + * Sets the thickness of the Tick Marks in pixels. + * Default: 2 + * Example: 3, 4.. + */ + tickThickness?: number; + /** + * Sets the Interlacing Color that alternates between the set interval. + * If the interval is not set explicitly, then the auto calculated interval is considered. The value of interlacedColor can be a “HTML Color Name” or “hex” code. + * Default: null + * Example: "#F8F1E4", "#FEFDDF"... + */ + interlacedColor?: string; + /** + * Sets the Thickness of Grid Lines. To display grid on Axis X, set the Grid Thickness to a number greater than zero. + * Default: 0 + * Example: 2,4 .. + */ + gridThickness?: number; + /** + * Sets the Color of Grid Lines. Value of gridColor can be a "HTML Color Name" or "hex" code . + * Default: "#BBBBBB" + * Example: "red", "#FEFDDF" .. + */ + gridColor?: string; + /** + * Sets the Dash Type for grid lines on axisX. + * Default: solid + */ + gridDashType?: DashType; + /** + * A custom formatter function that returns label to be displayed on axisX. + * Notes: + * 1.labelFormatter function should return a string. + * 2.You can use formatNumber and formatDate functions to format number/date values inside the formatter function. + */ + labelFormatter?(e: { chart: Chart, axis: ChartAxisYOptions, value: number, label: string }): string; + /** + * Strip Lines / Trend Lines are vertical or horizontal lines used to highlight/mark a certain region on the plot area. + * You can choose whether to draw a line at a specific position or shade a region on the plot area. Strip Lines are also referred to as Trend Lines. + */ + stripLines?: ChartStripLinesOptions | ChartStripLinesOptions[]; + } + + interface ChartAxisX extends ChartAxisXOptions { + /** + * Returns the specified property of Axis. + * @param propertyName Name of the property. + */ + get(propertyName: string): string | number | boolean; + /** + * Sets the specified property of Axis. + * @param propertyName Name of the property. + * @param value value to be set on property. + * @param updateChart When true, Updates the chart automatically after setting the value. Defaults to true. + */ + set(propertyName: string, value: string | number | boolean, updateChart: boolean): void; + /** + * Removes specified axis from axis Array. + */ + remove(): void; + /** + * Adds a new element of given type to the specified array. For example, it can be used to add new stripLine to stripLines array. + * @param propertyName Name of the property. + * @param options Option for the new element. + * @param index Index of the array where the new element is to be added. Defaults to the length (end) of array. + * @param updateChart When true, Updates the chart automatically after setting the value. Defaults to true. + */ + addTo(propertyName: string, options: ChartStripLinesOptions, index?: number, updateChart?: boolean): void; + /** + * Return the pixel coordinate of the given value over axis. + * @param value Numeric value over Axis + */ + convertValueToPixel(value: number): number; + /** + * Return the value along Axis for given pixel coordinate. + * @param pixel pixel value over Axis + */ + convertPixelToValue(pixel: number): number; + } + interface ChartAxisYOptions extends ChartAxisXOptions { + /** + * When includeZero is set to true, axisY sets the range in such a way that Zero is a part of it. It is set to true by default. + * But, whenever y values are very big and difference among dataPoints are hard to judge, + * setting includeZero to false makes axisY to set a range that makes the differences prominently visible. + * Default: true + * Example: true, false + */ + includeZero?: boolean; + } + + interface ChartAxisY extends ChartAxisYOptions { + /** + * Returns the specified property of Axis. + * @param propertyName Name of the property. + */ + get(propertyName: string): string | number | boolean; + /** + * Sets the specified property of Axis. + * @param propertyName Name of the property. + * @param value value to be set on property. + * @param updateChart When true, Updates the chart automatically after setting the value. Defaults to true. + */ + set(propertyName: string, value: string | number | boolean, updateChart: boolean): void; + /** + * Removes specified axis from axis Array. + */ + remove(): void; + /** + * Adds a new element of given type to the specified array. For example, it can be used to add new stripLine to stripLines array. + * @param propertyName Name of the property. + * @param options Option for the new element. + * @param index Index of the array where the new element is to be added. Defaults to the length (end) of array. + * @param updateChart When true, Updates the chart automatically after setting the value. Defaults to true. + */ + addTo(propertyName: string, options: ChartStripLinesOptions, index?: number, updateChart?: boolean): void; + /** + * Return the pixel coordinate of the given value over axis. + * @param value Numeric value over Axis + */ + convertValueToPixel(value: number): number; + /** + * Return the value along Axis for given pixel coordinate. + * @param pixel pixel value over Axis + */ + convertPixelToValue(pixel: number): number; } interface ChartToolTipOptions { /** - * Enables or Disables the toolTip for the chart. - * Default: True - * Example: True, False - */ - enabled?: boolean; - /** - * In a Multi-Series or a Combination Chart, it is often required to display all values common to x value in a single bubble. Setting shared to true will show in a common bubble all the values of y from each series next to their name. - * Default: True - * Example: True, False - */ - shared?: boolean; - /** - * toolTip for entire chart can be set by adding content at toolTip object. content can either be a string or a custom function that returns HTML/String to be displayed inside the toolTip. - * Default: auto - */ - content?: string; - /** - * While mouse hovers from one dataPoint to another there is a smooth transition in toolTip. This effect can be controlled by animationEnabled Property. Setting it to false, will disable the animation and toolTip will directly switch from one dataPoint to the other. - * Default: True - * Example: True, False - */ + * While mouse hovers from one dataPoint to another there is a smooth transition in toolTip. + * This effect can be controlled by animationEnabled Property. Setting it to false, will disable the animation and toolTip will directly switch from one dataPoint to the other. + * Default: True + * Example: True, False + */ animationEnabled?: boolean; /** - * Sets the border color around Tool Tip. When not set it takes the color of corresponding dataSeries or dataPoint. - * Default: dataSeries color/ dataPoint color - * Example: "red", "#808080".. - */ + * Enables or Disables the toolTip for the chart. + * Default: True + * Example: True, False + */ + enabled?: boolean; + /** + * In a Multi-Series or a Combination Chart, it is often required to display all values common to x value in a single bubble. + * Setting shared to true will show in a common bubble all the values of y from each series next to their name. + * Default: True + * Example: True, False + */ + shared?: boolean; + /** + * Sets the border color around Tool Tip. When not set it takes the color of corresponding dataSeries or dataPoint. + * Default: dataSeries color/ dataPoint color + * Example: "red", "#808080".. + */ borderColor?: string; + /** + * toolTip for entire chart can be set by adding content at toolTip object. + * content can either be a string or a custom function that returns HTML/String to be displayed inside the toolTip. + * Default: auto + */ + content?: string; + /** + * Sets the Font Color of toolTipContent. The value of fontColor can be a “HTML Color Name” or “hex” code. + * Default: “black” + * Example: “red”, “#FAC003″ .. + */ + fontColor?: string; + /** + * Sets the Font Style of ToolTip Content. It can be set to one of the below options. + * Default: “italic” + * Example: “normal”, “italic” , “oblique” + */ + fontStyle?: string; + /** + * Sets the font Size of ToolTip Content in pixels. + * Default: 14 + * Example: 16,18,22 .. + */ + fontSize?: number; + /** + * Sets the Font Family of ToolTip Content. + * Default: “Calibri, Arial, Georgia, serif” + * Example: “arial” , “tahoma”, “verdana” .. + */ + fontFamily?: string; + /** + * Set the font Weight of ToolTip Content. + * Default: “normal” + * Example: “lighter”, “normal”, “bold” , “bolder” + */ + fontWeight?: string; + /** + * Sets the thickness of border around the toolTip in pixels. To display border around toolTip, set the borderThickness to a number greater than zero. Setting it to zero removes the border. + * Default: 2 + * Example: 2,4 .. + */ + borderThickness?: number; + /** + * Setting a value higher than 0 makes the corners of toolTip rounded. Higher the value, more rounded the corners are. + * Default: 5 + * Options: 2,3,8 .. + */ + cornerRadius?: number; + /** + * Reverses the order in which items inside toolTip are shown. + * Default: false + * Example: true, false + */ + reversed?: boolean; + /** + * A custom formatter function that returns the content (text/html) to be displayed inside the toolTip. + */ + contentFormatter?(e: { chart: Chart, toolTip: ChartToolTipOptions, entries: Array<{ dataPoint: ChartDataPoint, dataSeries: ChartDataSeriesOptions }> }): string; + /** + * Sets the background color of toolTip. Values can be “HTML Color Name” or “hex” code. + * Default: white + * Example: “red”, “#FF0000” .. + */ + backgroundColor?: string; + } + + interface ChartToolTip extends ChartToolTipOptions { + /** + * Returns the specified property of legend. + * @param propertyName Name of the property. + */ + get(propertyName: string): number | string | boolean; + /** + * Sets the specified property of legend. + * @param propertyName Name of the property. + * @param value Name of the property. + * @param updateChart When true, Updates the chart automatically after setting the value. Defaults to true. + */ + set(propertyName: string, value: number | string | boolean, updateChart?: boolean): void; } interface ChartDataCommon { /** - * Sets the dataPoint Name. dataPoint name is shown in various places like toolTip & legend unless overridden. - * Default: Automatically Named ("dataPoint 1", "dataPoint 2" .. ) - * Example: "apple", "mango" .. - */ + * Sets the dataPoint Name. dataPoint name is shown in various places like toolTip & legend unless overridden. + * Default: Automatically Named ("dataPoint 1", "dataPoint 2" .. ) + * Example: "apple", "mango" .. + */ name?: string; /** - * Sets the color of dataSeries. The value of tickColor can be a "HTML Color Name" or "Hex Code". - * Default: Automatically set from Theme. - * Example: "red", "green" .. - */ + * Sets the color of dataSeries. The value of tickColor can be a "HTML Color Name" or "Hex Code". + * Default: Automatically set from Theme. + * Example: "red", "green" .. + */ color?: string; /** - * Instead of setting string values for all indexLabels, you can also use keywords like x, y, etc that will automatically show corresponding properties as indexLabel. This will allow you to define indexLabel at the series level once. While setting indexLabel you specify a keyword by enclosing it in flower brackets like {x}, {y}, {color}, etc. - * Range Charts have two indexLabels – one for each y value. This requires the use of a special keyword #index to show index label on either sides of the column/bar/area. - * eg: indexLabel: "{x}: {y[#index]}" - * Important keywords to keep in mind are. {x}, {y}, {name}, {label}. - * Default: null - * Example: "{label}", "Win", "x: {x}, y: {y} " - */ + * Enables or Disables highlighting of dataPoints on mouse hover. + * Default: true + * Example: true,false + */ + highlightEnabled?: boolean; + /** + * Instead of setting string values for all indexLabels, you can also use keywords like x, y, etc that will automatically show corresponding properties as indexLabel. + * This will allow you to define indexLabel at the series level once. While setting indexLabel you specify a keyword by enclosing it in flower brackets like {x}, {y}, {color}, etc. + * Range Charts have two indexLabels – one for each y value. This requires the use of a special keyword #index to show index label on either sides of the column/bar/area. + * eg: indexLabel: "{x}: {y[#index]}" + * Important keywords to keep in mind are. {x}, {y}, {name}, {label}. + * Default: null + * Example: "{label}", "Win", "x: {x}, y: {y} " + */ indexLabel?: string; /** - * Using this property you can define whether to render indexLabel "inside" or "outside" the dataPoint. - * Default: "outside" - * Example: "outside", "inside" - */ + * Sets the Dash Type for indexLabel’s line. It is applicable only for pie and doughnut charts when indexLabelPlacement is set to “outside”. + * For other chart-types, indexLabelLineThickness should be set greater than zero. + * Default: solid + */ + indexLabelLineDashType?: DashType; + /** + * A custom formatter function which returns the text to be displayed as indexLabel on dataPoints. + * @param e event object + */ + indexLabelFormatter?(e: { chart: Chart, dataSeries: ChartDataSeriesOptions, dataPoint: ChartDataPoint, index?: number, total?: number, pencent?: number }): string; + /** + * Using this property you can define whether to render indexLabel "inside" or "outside" the dataPoint. + * Default: "outside" + * Example: "outside", "inside" + */ indexLabelPlacement?: string; /** - * Sets the Orientation of indexLabel to "horizontal" or "vertical". - * Default: "horizontal" - * Options: "horizontal", "vertical" - */ + * Sets the Orientation of indexLabel to "horizontal" or "vertical". + * Default: "horizontal" + * Options: "horizontal", "vertical" + */ indexLabelOrientation?: string; /** - * Sets the Background color of Index Labels. The value of indexLabelBackgroundColor can be a "HTML Color Name" or "Hex Code". - * Default: null - * Example: "red", "#FAC003" .. - */ + * Sets the Background color of Index Labels. The value of indexLabelBackgroundColor can be a "HTML Color Name" or "Hex Code". + * Default: null + * Example: "red", "#FAC003" .. + */ indexLabelBackgroundColor?: string; /** - * Sets the Index Label’s Font Style. It can be set to one of the below options. - * Default: "normal" - * Options: "italic", "oblique", "normal" - */ + * Sets the Index Label’s Font Style. It can be set to one of the below options. + * Default: "normal" + * Options: "italic", "oblique", "normal" + */ indexLabelFontStyle?: string; /** - * Sets the Index Label’s Font color. The value of IndexLabelFontColor can be a "HTML Color Name" or "Hex Code". - * Default: "grey" - * Example: "red", "#FAC003" .. - */ + * Sets the Index Label’s Font color. The value of IndexLabelFontColor can be a "HTML Color Name" or "Hex Code". + * Default: "grey" + * Example: "red", "#FAC003" .. + */ indexLabelFontColor?: string; /** - * Sets the Index Label’s Font Size in pixels. - * Default: 18 - * Example: 12, 16, 22.. - */ + * Sets the Index Label’s Font Size in pixels. + * Default: 18 + * Example: 12, 16, 22.. + */ indexLabelFontSize?: number; /** - * Sets the Index Label’s Font Family. - * Default: "Calibri, Optima, Candara, Verdana, Geneva, sans-serif" - * Example: "calibri", "tahoma", "verdana".. - */ + * Sets the Index Label’s Font Family. + * Default: "Calibri, Optima, Candara, Verdana, Geneva, sans-serif" + * Example: "calibri", "tahoma", "verdana".. + */ indexLabelFontFamily?: string; /** - * Sets the Index Label’s Font Weight. It can be set to one of the below options. - * Default: "normal" - * Example: "lighter", "normal" ,"bold" , "bolder" - */ + * Sets the Index Label’s Font Weight. It can be set to one of the below options. + * Default: "normal" + * Example: "lighter", "normal" ,"bold" , "bolder" + */ indexLabelFontWeight?: string; /** - * Sets the color of line connecting index labels with their dataPoint. It is only applicable for pie and doughnut chart when indexLabelPlacment is outside. The value of indexLineColor can be a "HTML Color Name" or "Hex Code". - * Default: "lightgrey" - * Example: "red", "#FAC003" .. - */ + * Sets the color of line connecting index labels with their dataPoint. It is only applicable for pie and doughnut chart when indexLabelPlacment is outside. + * The value of indexLineColor can be a "HTML Color Name" or "Hex Code". + * Default: "lightgrey" + * Example: "red", "#FAC003" .. + */ indexLabelLineColor?: string; /** - * Sets the thickness of line connecting indexLabel with its corresponding dataPoint. It is only applicable for pie and doughnut chart when indexLabelPlacement is set to "outside". - * Default: 2 - * Example: 4, 6 - */ - indexLabelLineThickness?: string; + * Sets the thickness of line connecting indexLabel with its corresponding dataPoint. + * It is only applicable for pie and doughnut chart when indexLabelPlacement is set to "outside". + * Default: 2 + * Example: 4, 6 + */ + indexLabelLineThickness?: number; /** - * Default Tooltip can be modified at dataSeries or dataPoint level. You can add content to be displayed in toolTip using toolTipContent. toolTipContent set at dataPoint will override toolTipContent set at dataSeries level. - * Default: auto set depending on chart type. - */ + * Default Tooltip can be modified at dataSeries or dataPoint level. You can add content to be displayed in toolTip using toolTipContent. + * toolTipContent set at dataPoint will override toolTipContent set at dataSeries level. + * Default: auto set depending on chart type. + */ toolTipContent?: string; /** - * Sets marker type to be rendered at each dataPoint. While markers are helpful in highlighting individual dataPoints, they do not help much when the dataPoints are crowded. In case of large number of dataPoints it is recommended to disable markers in order to improve the appearance and performance of chart. - * Same marker type is also used in legend unless overridden by legendMarkerType property. - * Default: "circle" - * Options: "none", "circle", "square", "triangle" and "cross" - */ + * Sets marker type to be rendered at each dataPoint. While markers are helpful in highlighting individual dataPoints, they do not help much when the dataPoints are crowded. + * In case of large number of dataPoints it is recommended to disable markers in order to improve the appearance and performance of chart. + * Same marker type is also used in legend unless overridden by legendMarkerType property. + * Default: "circle" + * Options: "none", "circle", "square", "triangle" and "cross" + */ markerType?: string; /** - * Sets the color of marker that is displayed on the Chart. Legend Marker for the series uses the same Color as set here unless overridden using legendMarkerColor property. - * Default: dataSeries Color - * Example: "red", "#008000" .. - */ + * Sets the color of marker that is displayed on the Chart. Legend Marker for the series uses the same Color as set here unless overridden using legendMarkerColor property. + * Default: dataSeries Color + * Example: "red", "#008000" .. + */ markerColor?: string; /** - * Sets the Size of the marker that is drawn. To display marker in area Chart, set markerSize to a value greater than zero. For line, scatter chart, size it is automatically set unless overridden. - * Default: auto. Zero for area chart - * Example: 5, 10.. - */ + * Sets the Size of the marker that is drawn. To display marker in area Chart, set markerSize to a value greater than zero. + * For line, scatter chart, size it is automatically set unless overridden. + * Default: auto. Zero for area chart + * Example: 5, 10.. + */ markerSize?: number; /** - * Sets the border color around marker. Value of markerBorderColor can be "HTML Color Name" or "hex code". - * Default: dataSeries color. - * Example: "red", "#008000" .. - */ + * Sets the border color around marker. Value of markerBorderColor can be "HTML Color Name" or "hex code". + * Default: dataSeries color. + * Example: "red", "#008000" .. + */ markerBorderColor?: string; /** - * Sets the thickness of the Marker’s Border in pixels. - * Default: 1 - * Example: 2,4 .. - */ + * Sets the thickness of the Marker’s Border in pixels. + * Default: 1 + * Example: 2,4 .. + */ markerBorderThickness?: number; /** - * Sets the text that describes the dataSeries in legend. - * Default: "DataSeries 1", "DataSeries 2" ..etc - * Example: "2010", "2011".. - */ + * Sets the text that describes the dataSeries in legend. + * Default: "DataSeries 1", "DataSeries 2" ..etc + * Example: "2010", "2011".. + */ legendText?: string; /** - * Sets the Legend Marker to one of the options below. This property is used to override the default marker in legend, which is same as dataSeries Marker Type. - * Default: same as markerType - * Options: "circle", "square", "cross" and "triangle" - */ + * Sets the Legend Marker to one of the options below. This property is used to override the default marker in legend, which is same as dataSeries Marker Type. + * Default: same as markerType + * Options: "circle", "square", "cross" and "triangle" + */ legendMarkerType?: string; /** - * Sets the click event handler for dataSeries which is triggered when user clicks on a dataSeries. Upon event, a parameter that contains event related data is sent to the assigned event handler. Parameter includes dataPoint and dataSeries corresponding to the event. - * Default: null - */ - click?: (event: ChartEvent) => void; - /** - * Sets the color of marker that is displayed on legend. This property overrides default Marker’s Color in Legend, which is same as dataSeries Marker Color. Value of legendMarkerColor can be "HTML Color Name" or "hex code". - * Default: dataSeries marker color - * Example: "red", "#008000" .. - */ + * Sets the color of marker that is displayed on legend. This property overrides default Marker’s Color in Legend, which is same as dataSeries Marker Color. + * Value of legendMarkerColor can be "HTML Color Name" or "hex code". + * Default: dataSeries marker color + * Example: "red", "#008000" .. + */ legendMarkerColor?: string; /** - * Sets the mouseover event handler for dataSeries which is triggered when user moves Mouse Over a dataSeries. Upon event, a parameter that contains event related data is sent to the assigned event handler. Parameter includes dataPoint and dataSeries corresponding to the event. - * Default: null - */ - mouseover?: (event: ChartEvent) => void; + * Sets the border color around the legend marker. Value of legendMarkerBorderColor can be “color names” or “hex code”. + * Default: dataSeries color. + * Example: “red”, “#008000” .. + */ + legendMarkerBorderColor?: string; /** - * Sets the mousemove event handler for dataSeries which is triggered when user Moves mouse on a dataSeries. Upon event, a parameter that contains event related data is sent to the assigned event handler. Parameter includes dataPoint and dataSeries corresponding to the event. - * Default: null - */ - mousemove?: (event: ChartEvent) => void; + * Sets the thickness of the legend’s Marker Border in pixels. + * Default: 0 + * Example: 2, 4 .. + */ + legendMarkerBorderThickness?: number; /** - * Sets the mouseout event handler for dataSeries which is triggered when user moves mouse out of a dataSeries. Upon event, a parameter that contains event related data is sent to the assigned event handler. Parameter includes dataPoint and dataSeries corresponding to the event. - * Default: null - */ - mouseout?: (event: ChartEvent) => void; + * Sets the click event handler for dataSeries which is triggered when user clicks on a dataSeries. + * Upon event, a parameter that contains event related data is sent to the assigned event handler. + * Parameter includes dataPoint and dataSeries corresponding to the event. + * Default: null + */ + click?(event: ChartEvent): void; + /** + * Sets the mouseover event handler for dataSeries which is triggered when user moves Mouse Over a dataSeries. + * Upon event, a parameter that contains event related data is sent to the assigned event handler. + * Parameter includes dataPoint and dataSeries corresponding to the event. + * Default: null + */ + mouseover?(event: ChartEvent): void; + /** + * Sets the mousemove event handler for dataSeries which is triggered when user Moves mouse on a dataSeries. + * Upon event, a parameter that contains event related data is sent to the assigned event handler. + * Parameter includes dataPoint and dataSeries corresponding to the event. + * Default: null + */ + mousemove?(event: ChartEvent): void; + /** + * Sets the mouseout event handler for dataSeries which is triggered when user moves mouse out of a dataSeries. + * Upon event, a parameter that contains event related data is sent to the assigned event handler. + * Parameter includes dataPoint and dataSeries corresponding to the event. + * Default: null + */ + mouseout?(event: ChartEvent): void; } - interface ChartDataOptions extends ChartDataCommon { + interface ChartDataSeriesOptions extends ChartDataCommon { /** - * Sets the visibility of dataSeries. Data Series is visible by default and you can hide the same by setting visible property to false. - * Default: true - * Example: true, false - */ + * Sets the visibility of dataSeries. Data Series is visible by default and you can hide the same by setting visible property to false. + * Default: true + * Example: true, false + */ visible?: boolean; /** - * Sets the type of chart to be rendered for corresponding dataSeries. One can choose from the following options. - * Default: "column" - * Options: - * "line" - * "column" - * "bar" - * "area" - * "spline" - * "splineArea" - * "stepLine" - * "scatter" - * "bubble" - * "stackedColumn" - * "stackedBar" - * "stackedArea" - * "stackedColumn100" - * "stackedBar100" - * "stackedArea100" - * "pie" - * "doughnut" - */ + * Sets the type of chart to be rendered for corresponding dataSeries. One can choose from the following options. + * Default: "column" + * Options: + * "line" + * "column" + * "bar" + * "area" + * "spline" + * "splineArea" + * "stepLine" + * "scatter" + * "bubble" + * "stackedColumn" + * "stackedBar" + * "stackedArea" + * "stackedColumn100" + * "stackedBar100" + * "stackedArea100" + * "pie" + * "doughnut" + */ type?: string; /** - * Setting axisYType lets you choose between primary and secondary Y Axis for a dataSeries to plot against. By choosing "secondary" Axis you can plot the series against axisY2. - * In case of Multi-Series or Combinational Charts, one can assign primary axis to some series and secondary axis to other series. - * This is helpful when dataSeries objects use different unit of measurement or range of data. By default, all series are plotted against primary Y axis. - * Default: "primary" - * Options: "primary", "secondary" - */ + * Setting axisXType lets you choose between primary and secondary X Axis for a dataSeries to plot against. By choosing “secondary” Axis you can plot the series against axisX2. + * In case of Multi-Series or Combinational Charts, one can assign primary axis to some series and secondary axis to other series. + * This is helpful when dataSeries objects use different unit of measurement or range of data. By default, all series are plotted against primary X axis. + */ + axisXType?: string; + /** + * Setting axisYType lets you choose between primary and secondary Y Axis for a dataSeries to plot against. By choosing "secondary" Axis you can plot the series against axisY2. + * In case of Multi-Series or Combinational Charts, one can assign primary axis to some series and secondary axis to other series. + * This is helpful when dataSeries objects use different unit of measurement or range of data. By default, all series are plotted against primary Y axis. + * Default: "primary" + * Options: "primary", "secondary" + */ axisYType?: string; /** - * This defines the data type of x values. Data Type is normally figured out by default based on the object type that is assigned to x. But if you are providing time stamp (which is integer) values instead of Date objects, you’ll have to explicitly set the xValueType to "dateTime". - * Default: Automatically Calculated - * Options: "number", "dateTime" - */ + * Setting axisXIndex lets you choose to which X axis the dataSeries should be attached. + * In case of Multi-Series or Combinational Charts, one can assign some series to first X axis and rest to another axis. + * This is helpful when dataSeries objects use different unit of measurement or range of data. By default, all series are plotted against first axis. + */ + axisXIndex?: number; + /** + * Setting axisYIndex lets you choose to which Y axis the dataSeries should be attached to. + * In case of Multi-Series or Combinational Charts, one can assign some series to first Y axis and rest to another axis. + * This is helpful when dataSeries objects use different unit of measurement or range of data. By default, all series are plotted against first axis. + */ + axisYIndex?: number; + /** + * This defines the data type of x values. Data Type is normally figured out by default based on the object type that is assigned to x. + * But if you are providing time stamp (which is integer) values instead of Date objects, you’ll have to explicitly set the xValueType to "dateTime". + * Default: Automatically Calculated + * Options: "number", "dateTime" + */ xValueType?: string; /** - * Defines how y axis values must be formatted before they appear on the indexLabel or toolTip. You can format numbers and date time values using this property. - */ + * Defines how y axis values must be formatted before they appear on the indexLabel or toolTip. You can format numbers and date time values using this property. + */ yValueFormatString?: string; /** - * Defines how x axis values must be formatted before they appear on the indexLabel or toolTip. You can format numbers and date time values using this property. - */ + * Defines how x axis values must be formatted before they appear on the indexLabel or toolTip. You can format numbers and date time values using this property. + */ xValueFormatString?: string; /** - * Defines how z values is formatted before they appear on the indexLabel or toolTip. You can format numbers using this property. - */ + * Defines how z values is formatted before they appear on the indexLabel or toolTip. You can format numbers using this property. + */ zValueFormatString?: string; /** - * Sets the bevel property, which creates a chiselled effect at the corners of a Column Charts and Bar Charts. - * Default: "true" - * Example: "true", "false" - */ + * Defines how percent values are formatted before they appear on the indexLabel or toolTip. You can format percent values using this property. + */ + percentFormatString?: string; + /** + * Sets the bevel property, which creates a chiselled effect at the corners of a Column Charts and Bar Charts. + * Default: "true" + * Example: "true", "false" + */ bevelEnabled?: boolean; /** - * Sets opacity of the filled color. - * Default: .7 for Area Charts and 1 for all other chart types. - */ + * Sets opacity of the filled color. + * Default: .7 for Area Charts and 1 for all other chart types. + */ fillOpacity?: number; /** - * Sets the starting Angle of the Pie or Doughnut Chart in degrees. - * Default: 0 - * Example: 30, 240, -100.. - */ + * Sets the starting Angle of the Pie or Doughnut Chart in degrees. + * Default: 0 + * Example: 30, 240, -100.. + */ startAngle?: number; /** - * Sets the thickness of line in line charts and area charts. - * Default: 2 - * Example: 3,4.. - */ + * innerRadius property allows you to set a Doughnut chart’s inner radius. + * Value can either be in pixels (number – ex: 100) or percent (string – ex: “80%”). Percent values are relative to the outer radius of doughnut chart. + * Default: “70%” + * Example: 200, 150, “90%”, “75%” + */ + innerRadius?: number | string; + /** + * radius property allows you to set the Pie/Doughnut chart’s (outer) radius. + * Value can either be in pixels (number – ex: 100) or percent (string – ex: “80%”). Percent values are relative to the plot area’s size. + * By default, a pie/doughnut chart’s size(radius) changes in order to best fit the indexLabels. This can lead to charts of different sizes in the same page. + * In order to override this behavior and set equal sizes to all pie/doughnut charts in a page, you can use radius property. + * Default: Automatically calculate in order to best fit the indexLabels. + * Example: 200, 150, “90%”, “75%” + */ + radius?: number | string; + /** + * Sets the thickness of line in line charts and area charts. + * Default: 2 + * Example: 3,4.. + */ lineThickness?: number; /** - * Setting this property to true makes the dataSeries to appear in legend. In case of pie/ doughnut chart, dataPoints of the single series chart appear in legend. - * Default: false - * Options: false, true - */ + * Setting this property to true makes the dataSeries to appear in legend. In case of pie/ doughnut chart, dataPoints of the single series chart appear in legend. + * Default: false + * Options: false, true + */ showInLegend?: boolean; /** - * In candle Stick chart, when Closing Price is greater than Opening price, the body is filled with white by default and it can be overridden by risingColor property. - * Default: "white" - * Options: "red", "#DD7E86", etc. - */ + * Enables or disables exploding of Pie/Doughnut segment on click. + * Default: true + * Options: false, true + */ + explodeOnClick?: boolean; + /** + * In candle Stick chart, when Closing Price is greater than Opening price, the body is filled with white by default and it can be overridden by risingColor property. + * Default: "white" + * Options: "red", "#DD7E86", etc. + */ risingColor?: string; /** - * It represents collection dataPoint inside dataSeries . - */ + * It represents collection dataPoint inside dataSeries. + */ dataPoints: ChartDataPoint[]; + /** + * By default, a line breaks wherever a null dataPoint (y = null) is present. + * You can change this behaviour to draw a line between adjacent non-null dataPoints by setting connectNullData to true. + * Default: false + * Example: true, false + */ + connectNullData?: boolean; + /** + * Sets the Line Dash Type for all Line and Area Charts. + * Default: solid + */ + lineDashType?: DashType; + /** + * Sets the Line Dash Type of line wherever null data is present. + * Note: + * 1.Will effect only if connectNullData is set to true. + * 2.Supported with all Line and Area Charts. + * 3.Not Supported on IE8. + * Default: "dash" + */ + nullDataLineDashType?: DashType; + } + + interface ChartDataSeries extends ChartDataSeriesOptions { + /** + * Returns the specified property of dataSeries + * @param propertyName Name of the property. + */ + get(propertyName: string): boolean | string | number | ChartDataPoint; + /** + * Sets the specified property of dataSeries. + * @param propertyName Name of the property. + * @param value value to be set on property. + * @param updateChart When true, Updates the chart automatically after setting the value. Defaults to true. + */ + set(propertyName: string, value: boolean | string | number | ChartDataPoint, updateChart: boolean): void; + /** + * Adds a new element of given type to the specified array. For example, it can be used to add new dataPoint to datPoints array. + * @param propertyName Name of the property + * @param options Option for the new element + * @param index Index of the array where the new element is to be added. Defaults to the length (end) of array. + * @param updateChart When true, Updates the chart automatically after setting the value. Defaults to true. + */ + addTo(propertyName: string, options: ChartDataPoint, index?: number, updateChart?: boolean): void; + /** + * Removes specified dataSeries from data Array. + */ + remove(): void; } interface ChartDataPoint extends ChartDataCommon { /** - * Sets the x value. It determines the position of the dataPoint on X Axis. It can be numeric or a dateTime value. Values can be positive or Negative. - * Default: null - * Example: 10, 20, 30 .. - * new Date(2011, 08, 01) - */ - x?: any; + * Sets the x value. It determines the position of the dataPoint on X Axis. It can be numeric or a dateTime value. Values can be positive or Negative. + * If no x value is provided, they are automatically set sequentially starting from zero + * Default: null + * Example: 10, 20, 30 .. + * new Date(2011, 08, 01) + */ + x?: number | Date; /** - * Sets the y value of dataPoint. It determines the position of dataPoint on Y Axis. Values can be positive or Negative - * Default: null - * Example: 5, 20, -30 .. - */ - y?: number; + * Sets the y value of dataPoint. It determines the position of dataPoint on Y Axis. Values can be positive or Negative + * Default: null + * Example: 5, 20, -30 .. + */ + y?: number | null; /** - * Sets the z value of dataPoint. It is only applicable in case of Bubble chart. This value determines the size of the bubble. - * Default: 1 - * Example: 10, 20, 35.. - */ + * Sets the z value of dataPoint. It is only applicable in case of Bubble chart. This value determines the size of the bubble. + * Default: 1 + * Example: 10, 20, 35.. + */ z?: number; /** - * Sets label value of a dataPoint. The value appears next to the dataPoint on axisX Line. If not provided, it takes x value for label. - * Default: x value - * Example: "label1", "label2".. - */ + * Sets label value of a dataPoint. The value appears next to the dataPoint on axisX Line. If not provided, it takes x value for label. + * Default: x value + * Example: "label1", "label2".. + */ label?: string; /** - * Sets the exploded value of dataPoint. It is applicable only in case of Pie and Doughnut Charts. This property causes the Pie/Doughnut slice to separate out. - * Default: true - * Example: true, false - */ + * Sets the exploded value of dataPoint. It is applicable only in case of Pie and Doughnut Charts. This property causes the Pie/Doughnut slice to separate out. + * Default: true + * Example: true, false + */ exploded?: boolean; - /** - * Sets the color of marker that is displayed on legend. This property works only with Pie and Doughnut charts. Value of legendMarkerColor can be "HTML Color Name" or "hex" code. - * Default: dataSeries marker color - * Example: "red", "#008000".. - */ - legendMarkerColor?: string; } } +declare function CanvasJS(): void; +export = CanvasJS; +export as namespace CanvasJS; diff --git a/types/canvasjs/tsconfig.json b/types/canvasjs/tsconfig.json index 218036fa08..459ca95138 100644 --- a/types/canvasjs/tsconfig.json +++ b/types/canvasjs/tsconfig.json @@ -19,4 +19,4 @@ "index.d.ts", "canvasjs-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/canvasjs/tslint.json b/types/canvasjs/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/canvasjs/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/capitalize/index.d.ts b/types/capitalize/index.d.ts index b844784757..660592cfa6 100644 --- a/types/capitalize/index.d.ts +++ b/types/capitalize/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for capitalize 1.0 // Project: https://github.com/grncdr/js-capitalize -// Definitions by: Frederick Fogerty +// Definitions by: Frederick Fogerty // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 diff --git a/types/capitalize/tslint.json b/types/capitalize/tslint.json index 2750cc0197..939faba9c2 100644 --- a/types/capitalize/tslint.json +++ b/types/capitalize/tslint.json @@ -1 +1,7 @@ -{ "extends": "dtslint/dt.json" } \ No newline at end of file +{ + "extends": "dtslint/dt.json", + "rules": { + // TODO + "no-duplicate-imports": false + } +} \ No newline at end of file diff --git a/types/cassandra-driver/index.d.ts b/types/cassandra-driver/index.d.ts index 1f7f2fe33d..4b9d6a7d9d 100644 --- a/types/cassandra-driver/index.d.ts +++ b/types/cassandra-driver/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for nodejs-driver v0.8.2 // Project: https://github.com/datastax/nodejs-driver -// Definitions by: Marc Fisher +// Definitions by: Marc Fisher // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -508,6 +508,7 @@ export interface Client extends events.EventEmitter { batch(queries: Array | Array<{ query: string, params?: any }>, options: QueryOptions, callback: ResultCallback): void; connect(callback: Callback): void; eachRow(query: string, params?: any, options?: QueryOptions, rowCallback?: Callback, callback?: Callback): void; + execute(query: string, params?: any, callback?: ResultCallback): void; execute(query: string, params?: any, options?: QueryOptions, callback?: ResultCallback): void; getReplicas(keyspace: string, token: Buffer): Array; // TODO: Should this be a more explicit return? shutdown(callback?: Callback): void; diff --git a/types/catbox/index.d.ts b/types/catbox/index.d.ts index e34059d618..7bc691abdc 100644 --- a/types/catbox/index.d.ts +++ b/types/catbox/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for catbox 7.1 // Project: https://github.com/hapijs/catbox -// Definitions by: Jason Swearingen , AJP +// Definitions by: Jason Swearingen , AJP // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/chai-arrays/chai-arrays-tests.ts b/types/chai-arrays/chai-arrays-tests.ts index 7fabaacbca..1562272240 100644 --- a/types/chai-arrays/chai-arrays-tests.ts +++ b/types/chai-arrays/chai-arrays-tests.ts @@ -1,14 +1,11 @@ -import { expect } from 'chai'; -import { assert } from 'chai'; - -import chai = require('chai'); +import { assert, expect, use, should } from 'chai'; import ChaiArrays = require('chai-arrays'); -chai.use(ChaiArrays); -chai.should(); +use(ChaiArrays); +should(); const arr: any[] = [1, 2, 3]; -const str: string = 'abcdef'; +const str = 'abcdef'; const otherArr: number[] = [1, 2, 3]; const anotherArr: number[] = [2, 4]; diff --git a/types/chai-arrays/index.d.ts b/types/chai-arrays/index.d.ts index d50be4f101..1e61eec3ae 100644 --- a/types/chai-arrays/index.d.ts +++ b/types/chai-arrays/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for chai-arrays 1.0 // Project: https://github.com/GaneshSPatil/chai-arrays -// Definitions by: Clément Prévot +// Definitions by: Clément Prévot // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// diff --git a/types/chai-as-promised/chai-as-promised-tests.ts b/types/chai-as-promised/chai-as-promised-tests.ts index 7e422521aa..2157f0cc3c 100644 --- a/types/chai-as-promised/chai-as-promised-tests.ts +++ b/types/chai-as-promised/chai-as-promised-tests.ts @@ -26,6 +26,7 @@ thenableNum = chai.expect(thenableNum).to.notify(() => console.log('done')); // BDD API (should) thenableNum = thenableNum.should.be.fulfilled; thenableNum = thenableNum.should.eventually.deep.equal(3); +thenableNum = thenableNum.should.eventually.become(3); thenableNum = thenableNum.should.become(3); thenableNum = thenableNum.should.be.rejected; thenableNum = thenableNum.should.be.rejectedWith(Error); diff --git a/types/chai-as-promised/index.d.ts b/types/chai-as-promised/index.d.ts index 0dde8837dd..459758aa55 100644 --- a/types/chai-as-promised/index.d.ts +++ b/types/chai-as-promised/index.d.ts @@ -1,6 +1,10 @@ -// Type definitions for chai-as-promised +// Type definitions for chai-as-promised 7.1.0 // Project: https://github.com/domenic/chai-as-promised/ -// Definitions by: jt000 , Yuki Kokubun , Leonard Thieu +// Definitions by: jt000 , +// Yuki Kokubun , +// Leonard Thieu , +// Mike Lazer-Walker , +// Matt Bishop // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -25,22 +29,25 @@ declare namespace Chai { become(expected: any): PromisedAssertion; fulfilled: PromisedAssertion; rejected: PromisedAssertion; - rejectedWith(expected: any, message?: string | RegExp): PromisedAssertion; + rejectedWith: PromisedThrow; notify(fn: Function): PromisedAssertion; } // Eventually does not have .then(), but PromisedAssertion have. interface Eventually extends PromisedLanguageChains, PromisedNumericComparison, PromisedTypeComparison { // From chai-as-promised - become(expected: PromiseLike): PromisedAssertion; + become(expected: any): PromisedAssertion; fulfilled: PromisedAssertion; rejected: PromisedAssertion; - rejectedWith(expected: any, message?: string | RegExp): PromisedAssertion; + rejectedWith: PromisedThrow; notify(fn: Function): PromisedAssertion; // From chai not: PromisedAssertion; deep: PromisedDeep; + ordered: PromisedOrdered; + nested: PromisedNested; + any: PromisedKeyFilter; all: PromisedKeyFilter; a: PromisedTypeComparison; an: PromisedTypeComparison; @@ -51,6 +58,7 @@ declare namespace Chai { false: PromisedAssertion; null: PromisedAssertion; undefined: PromisedAssertion; + NaN: PromisedAssertion; exist: PromisedAssertion; empty: PromisedAssertion; arguments: PromisedAssertion; @@ -63,20 +71,36 @@ declare namespace Chai { property: PromisedProperty; ownProperty: PromisedOwnProperty; haveOwnProperty: PromisedOwnProperty; + ownPropertyDescriptor: PromisedOwnPropertyDescriptor; + haveOwnPropertyDescriptor: PromisedOwnPropertyDescriptor; length: PromisedLength; lengthOf: PromisedLength; - match(regexp: RegExp | string, message?: string): PromisedAssertion; + match: PromisedMatch; + matches: PromisedMatch; string(string: string, message?: string): PromisedAssertion; keys: PromisedKeys; key(string: string): PromisedAssertion; throw: PromisedThrow; throws: PromisedThrow; Throw: PromisedThrow; - respondTo(method: string, message?: string): PromisedAssertion; + respondTo: PromisedRespondTo; + respondsTo: PromisedRespondTo; itself: PromisedAssertion; - satisfy(matcher: Function, message?: string): PromisedAssertion; - closeTo(expected: number, delta: number, message?: string): PromisedAssertion; + satisfy: PromisedSatisfy; + satisfies: PromisedSatisfy; + closeTo: PromisedCloseTo; + approximately: PromisedCloseTo; members: PromisedMembers; + increase: PromisedPropertyChange; + increases: PromisedPropertyChange; + decrease: PromisedPropertyChange; + decreases: PromisedPropertyChange; + change: PromisedPropertyChange; + changes: PromisedPropertyChange; + extensible: PromisedAssertion; + sealed: PromisedAssertion; + frozen: PromisedAssertion; + oneOf(list: any[], message?: string): PromisedAssertion; } interface PromisedAssertion extends Eventually, PromiseLike { @@ -99,6 +123,8 @@ declare namespace Chai { at: PromisedAssertion; of: PromisedAssertion; same: PromisedAssertion; + but: PromisedAssertion; + does: PromisedAssertion; } interface PromisedNumericComparison { @@ -129,10 +155,28 @@ declare namespace Chai { (constructor: Object, message?: string): PromisedAssertion; } - interface PromisedDeep { - equal: PromisedEqual; + interface PromisedCloseTo { + (expected: number, delta: number, message?: string): PromisedAssertion; + } + + interface PromisedNested { include: PromisedInclude; property: PromisedProperty; + members: PromisedMembers; + } + + interface PromisedDeep { + equal: PromisedEqual; + equals: PromisedEqual; + eq: PromisedEqual; + include: PromisedInclude; + property: PromisedProperty; + members: PromisedMembers; + ordered: PromisedOrdered + } + + interface PromisedOrdered { + members: PromisedMembers; } interface PromisedKeyFilter { @@ -151,6 +195,11 @@ declare namespace Chai { (name: string, message?: string): PromisedAssertion; } + interface PromisedOwnPropertyDescriptor { + (name: string, descriptor: PropertyDescriptor, message?: string): PromisedAssertion; + (name: string, message?: string): PromisedAssertion; + } + interface PromisedLength extends PromisedLanguageChains, PromisedNumericComparison { (length: number, message?: string): PromisedAssertion; } @@ -160,13 +209,21 @@ declare namespace Chai { (value: string, message?: string): PromisedAssertion; (value: number, message?: string): PromisedAssertion; keys: PromisedKeys; + deep: PromisedDeep; + ordered: PromisedOrdered; members: PromisedMembers; + any: PromisedKeyFilter; all: PromisedKeyFilter; } + interface PromisedMatch { + (regexp: RegExp | string, message?: string): PromisedAssertion; + } + interface PromisedKeys { (...keys: string[]): PromisedAssertion; (keys: any[]): PromisedAssertion; + (keys: Object): PromisedAssertion; } interface PromisedThrow { @@ -179,10 +236,22 @@ declare namespace Chai { (constructor: Function, expected?: RegExp, message?: string): PromisedAssertion; } + interface PromisedRespondTo { + (method: string, message?: string): PromisedAssertion; + } + + interface PromisedSatisfy { + (matcher: Function, message?: string): PromisedAssertion; + } + interface PromisedMembers { (set: any[], message?: string): PromisedAssertion; } + interface PromisedPropertyChange { + (object: Object, property: string, message?: string): PromisedAssertion; + } + // For Assert API interface Assert { eventually: PromisedAssert; @@ -198,7 +267,9 @@ declare namespace Chai { export interface PromisedAssert { fail(actual?: any, expected?: any, msg?: string, operator?: string): PromiseLike; + isOk(val: any, msg?: string): PromiseLike; ok(val: any, msg?: string): PromiseLike; + isNotOk(val: any, msg?: string): PromiseLike; notOk(val: any, msg?: string): PromiseLike; equal(act: any, exp: any, msg?: string): PromiseLike; @@ -210,12 +281,26 @@ declare namespace Chai { deepEqual(act: any, exp: any, msg?: string): PromiseLike; notDeepEqual(act: any, exp: any, msg?: string): PromiseLike; + isAbove(val: number, above: number, msg?: string): PromiseLike; + isAtLeast(val: number, atLeast: number, msg?: string): PromiseLike; + isAtBelow(val: number, below: number, msg?: string): PromiseLike; + isAtMost(val: number, atMost: number, msg?: string): PromiseLike; + isTrue(val: any, msg?: string): PromiseLike; isFalse(val: any, msg?: string): PromiseLike; + isNotTrue(val: any, msg?: string): PromiseLike; + isNotFalse(val: any, msg?: string): PromiseLike; + isNull(val: any, msg?: string): PromiseLike; isNotNull(val: any, msg?: string): PromiseLike; + isNaN(val: any, msg?: string): PromiseLike; + isNotNaN(val: any, msg?: string): PromiseLike; + + exists(val: any, msg?: string): PromiseLike; + notExists(val: any, msg?: string): PromiseLike; + isUndefined(val: any, msg?: string): PromiseLike; isDefined(val: any, msg?: string): PromiseLike; @@ -287,10 +372,46 @@ declare namespace Chai { operator(val: any, operator: string, val2: any, msg?: string): PromiseLike; closeTo(act: number, exp: number, delta: number, msg?: string): PromiseLike; + approximately(act: number, exp: number, delta: number, msg?: string): PromiseLike; sameMembers(set1: any[], set2: any[], msg?: string): PromiseLike; + sameDeepMembers(set1: any[], set2: any[], msg?: string): PromiseLike; + sameOrderedMembers(set1: any[], set2: any[], msg?: string): PromiseLike; + notSameOrderedMembers(set1: any[], set2: any[], msg?: string): PromiseLike; + sameDeepOrderedMembers(set1: any[], set2: any[], msg?: string): PromiseLike; + notSameDeepOrderedMembers(set1: any[], set2: any[], msg?: string): PromiseLike; + includeOrderedMembers(set1: any[], set2: any[], msg?: string): PromiseLike; + notIncludeOrderedMembers(set1: any[], set2: any[], msg?: string): PromiseLike; + includeDeepOrderedMembers(set1: any[], set2: any[], msg?: string): PromiseLike; + notIncludeDeepOrderedMembers(set1: any[], set2: any[], msg?: string): PromiseLike; includeMembers(set1: any[], set2: any[], msg?: string): PromiseLike; + includeDeepMembers(set1: any[], set2: any[], msg?: string): PromiseLike; + + oneOf(val: any, list: any[], msg?: string): PromiseLike; + + changes(modifier: Function, obj: Object, property: string, msg?: string): PromiseLike; + doesNotChange(modifier: Function, obj: Object, property: string, msg?: string): PromiseLike; + increases(modifier: Function, obj: Object, property: string, msg?: string): PromiseLike; + doesNotIncrease(modifier: Function, obj: Object, property: string, msg?: string): PromiseLike; + decreases(modifier: Function, obj: Object, property: string, msg?: string): PromiseLike; + doesNotDecrease(modifier: Function, obj: Object, property: string, msg?: string): PromiseLike; ifError(val: any, msg?: string): PromiseLike; + + isExtensible(obj: Object, msg?: string): PromiseLike; + isNotExtensible(obj: Object, msg?: string): PromiseLike; + + isSealed(obj: Object, msg?: string): PromiseLike; + sealed(obj: Object, msg?: string): PromiseLike; + isNotSealed(obj: Object, msg?: string): PromiseLike; + notSealed(obj: Object, msg?: string): PromiseLike; + + isFrozen(obj: Object, msg?: string): PromiseLike; + frozen(obj: Object, msg?: string): PromiseLike; + isNotFrozen(obj: Object, msg?: string): PromiseLike; + notFrozen(obj: Object, msg?: string): PromiseLike; + + isEmpty(val: any, msg?: string): PromiseLike; + isNotEmpty(val: any, msg?: string): PromiseLike; } } diff --git a/types/chai-datetime/index.d.ts b/types/chai-datetime/index.d.ts index c008586cfe..176d112dc0 100644 --- a/types/chai-datetime/index.d.ts +++ b/types/chai-datetime/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for chai-datetime // Project: https://github.com/gaslight/chai-datetime.git -// Definitions by: Cliff Burger +// Definitions by: Cliff Burger // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// diff --git a/types/chai-enzyme/chai-enzyme-tests.tsx b/types/chai-enzyme/chai-enzyme-tests.tsx index 77ad5a0169..4b88d077aa 100644 --- a/types/chai-enzyme/chai-enzyme-tests.tsx +++ b/types/chai-enzyme/chai-enzyme-tests.tsx @@ -30,6 +30,7 @@ expect(wrapper).to.have.ref("test"); expect(wrapper).to.be.selected(); expect(wrapper).to.have.tagName("div"); expect(wrapper).to.have.text(""); +expect(wrapper).to.contain.text(""); expect(wrapper).to.have.type(Test); expect(wrapper).to.have.value("test"); expect(wrapper).to.have.attr("test", "test"); diff --git a/types/chai-enzyme/index.d.ts b/types/chai-enzyme/index.d.ts index 86b6f6f7b3..f1283994f6 100644 --- a/types/chai-enzyme/index.d.ts +++ b/types/chai-enzyme/index.d.ts @@ -26,6 +26,12 @@ declare namespace Chai { * @param code */ (selector: EnzymeSelector): Assertion; + + /** + * Assert that the given wrapper has the supplied text: + * @param str + */ + text(str?: string): Assertion; } interface Assertion { /** diff --git a/types/chai-http/chai-http-tests.ts b/types/chai-http/chai-http-tests.ts index 83e434f9e1..f4f65cae7b 100644 --- a/types/chai-http/chai-http-tests.ts +++ b/types/chai-http/chai-http-tests.ts @@ -13,7 +13,7 @@ if (!global.Promise) { chai.request.addPromises(when.promise); } -let app: http.Server; +declare const app: http.Server; chai.request(app).get('/'); chai.request('http://localhost:8080').get('/'); @@ -39,7 +39,17 @@ chai.request(app) chai.request(app) .get('/search') - .query({name: 'foo', limit: 10}); + .query({ name: 'foo', limit: 10 }); + +chai.request(app) + .get('/download') + .buffer() + .parse((res, cb) => { + let data = ''; + res.setEncoding('binary'); + res.on('data', (chunk: any) => { data += chunk; }); + res.on('end', () => { cb(undefined, new Buffer(data, 'binary')); }); + }); chai.request(app) .put('/user/me') @@ -55,7 +65,7 @@ chai.request(app) .then((res: ChaiHttp.Response) => chai.expect(res).to.have.status(200)) .catch((err: any) => { throw err; }); -let agent = chai.request.agent(app); +const agent = chai.request.agent(app); agent .post('/session') @@ -69,7 +79,7 @@ agent }); function test1() { - let req = chai.request(app).get('/'); + const req = chai.request(app).get('/'); req.then((res: ChaiHttp.Response) => { chai.expect(res).to.have.status(200); chai.expect(res).to.have.header('content-type', 'text/plain'); @@ -98,3 +108,9 @@ function test1() { } when(chai.request(app).get('/')).done(() => console.log('success'), () => console.log('failure')); + +Promise.resolve(1) + .then(val => chai.request(app).get(`/user/${val}`)) + .then(res => { + chai.expect(res).to.have.status(200); + }); diff --git a/types/chai-http/index.d.ts b/types/chai-http/index.d.ts index 88ab7f8b84..6a9404c9da 100644 --- a/types/chai-http/index.d.ts +++ b/types/chai-http/index.d.ts @@ -1,8 +1,10 @@ // Type definitions for chai-http 3.0 // Project: https://github.com/chaijs/chai-http // Definitions by: Wim Looman -// Liam Jones +// Liam Jones +// Federico Caselli // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 /// /// @@ -47,6 +49,8 @@ declare global { type: string; status: number; text: string; + setEncoding(encoding: string): void; + on(event: string, fn: (...args: any[]) => void): void; } interface Request extends FinishedRequest { @@ -57,12 +61,13 @@ declare global { auth(user: string, name: string): Request; field(name: string, val: string): Request; buffer(): Request; + parse(fn: (res: Response, cb: (e?: Error, r?: any) => void) => void): Request; end(callback?: (err: any, res: Response) => void): FinishedRequest; } - interface FinishedRequest { - then(success?: (res: Response) => void, failure?: (err: any) => void): FinishedRequest; - catch(failure?: (err: any) => void): FinishedRequest; + interface FinishedRequest { + then(success?: (res: T) => TR1 | PromiseLike, failure?: (err: any) => TR2 | PromiseLike): FinishedRequest; + catch(failure?: (err: any) => void): FinishedRequest; } interface Agent { diff --git a/types/chai-jest-snapshot/chai-jest-snapshot-tests.ts b/types/chai-jest-snapshot/chai-jest-snapshot-tests.ts new file mode 100644 index 0000000000..05cf190765 --- /dev/null +++ b/types/chai-jest-snapshot/chai-jest-snapshot-tests.ts @@ -0,0 +1,23 @@ +import chaiJestSnapshot from 'chai-jest-snapshot'; +import { expect } from 'chai'; + +chai.use(chaiJestSnapshot); + +expect({}).to.matchSnapshot(); +expect({}).to.matchSnapshot(true); +expect({}).to.matchSnapshot("filename"); +expect({}).to.matchSnapshot("filename", "snapshotname"); +expect({}).to.matchSnapshot("filename", "snapshotname", false); + +const mockContext: Mocha.IBeforeAndAfterContext = { + currentTest: { + file: 'testfile', + fullTitle: () => 'fullTitle' + } +}; + +chaiJestSnapshot.setFileName("filename"); +chaiJestSnapshot.setTestName("testname"); +chaiJestSnapshot.configureUsingMochaContext(mockContext); +chaiJestSnapshot.resetSnapshotRegistry(); +chaiJestSnapshot.addSerializer({}); diff --git a/types/chai-jest-snapshot/index.d.ts b/types/chai-jest-snapshot/index.d.ts new file mode 100644 index 0000000000..f19158e282 --- /dev/null +++ b/types/chai-jest-snapshot/index.d.ts @@ -0,0 +1,63 @@ +// Type definitions for chai-jest-snapshot 1.3 +// Project: https://github.com/suchipi/chai-jest-snapshot#readme +// Definitions by: Matt Perry +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +/// + +declare global { + namespace Chai { + interface Assertion { + /** + * Assert that the object matches the snapshot + * @param snapshotFilename + * @param snapshotName + * @param update + */ + matchSnapshot(snapshotFilename?: string, snapshotName?: string, update?: boolean): Assertion; + matchSnapshot(update: boolean): Assertion; + } + } +} + +interface ChaiJestSnapshot { + /** + * Chai bootstrapper + * @param chai + * @param utils + */ + (chai: any, utils: any): void; + + /** + * Set snapshot file name + * @param filename + */ + setFileName(filename: string): void; + + /** + * Set snapshot test name + * @param testname + */ + setTestName(testname: string): void; + + /** + * Configure snapshot name using mocha context + * @param context + */ + configureUsingMochaContext(context: Mocha.IBeforeAndAfterContext): void; + + /** + * Reset snapshot registry + */ + resetSnapshotRegistry(): void; + + /** + * Add a serializer plugin + * @param serializer + */ + addSerializer(serializer: any): void; +} + +declare var ChaiJestSnapshot: ChaiJestSnapshot; +export default ChaiJestSnapshot; diff --git a/types/chai-jest-snapshot/tsconfig.json b/types/chai-jest-snapshot/tsconfig.json new file mode 100644 index 0000000000..32dea54632 --- /dev/null +++ b/types/chai-jest-snapshot/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "chai-jest-snapshot-tests.ts" + ] +} diff --git a/types/chai-jest-snapshot/tslint.json b/types/chai-jest-snapshot/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/chai-jest-snapshot/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/chai-jquery/index.d.ts b/types/chai-jquery/index.d.ts index 453336b08b..e1628f1743 100644 --- a/types/chai-jquery/index.d.ts +++ b/types/chai-jquery/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for chai-jquery 1.1.1 // Project: https://github.com/chaijs/chai-jquery -// Definitions by: Kazi Manzur Rashid +// Definitions by: Kazi Manzur Rashid // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/chai-json-schema/chai-json-schema-tests.ts b/types/chai-json-schema/chai-json-schema-tests.ts index 7273ac60cc..ee57572ae1 100644 --- a/types/chai-json-schema/chai-json-schema-tests.ts +++ b/types/chai-json-schema/chai-json-schema-tests.ts @@ -1,11 +1,8 @@ -import { expect } from 'chai'; -import { assert } from 'chai'; - -import chai = require('chai'); +import { assert, expect, use, should, tv4 } from 'chai'; import ChaiJsonSchema = require('chai-json-schema'); -chai.use(ChaiJsonSchema); -chai.should(); +use(ChaiJsonSchema); +should(); const goodApple = { skin: 'thin', @@ -63,5 +60,5 @@ const schema = { const data1 = [true, false]; const data2 = [true, 123]; -expect(chai.tv4.validate(data1, schema)).to.be.true; -expect(chai.tv4.validate(data2, schema)).to.be.false; +expect(tv4.validate(data1, schema)).to.be.true; +expect(tv4.validate(data2, schema)).to.be.false; diff --git a/types/chai-string/index.d.ts b/types/chai-string/index.d.ts index 1c880dc87e..fad380cf07 100644 --- a/types/chai-string/index.d.ts +++ b/types/chai-string/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for chai-string 1.1.4 // Project: https://github.com/onechiporenko/chai-string -// Definitions by: Nick Malaguti +// Definitions by: Nick Malaguti // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// diff --git a/types/chai-subset/index.d.ts b/types/chai-subset/index.d.ts index 3e0818aa2b..615f9f52e4 100644 --- a/types/chai-subset/index.d.ts +++ b/types/chai-subset/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for chai-subset 1.3 // Project: https://github.com/e-conomic/chai-subset -// Definitions by: Sam Noedel , Andrew Brown +// Definitions by: Sam Noedel , Andrew Brown // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// diff --git a/types/chai-xml/chai-xml-tests.ts b/types/chai-xml/chai-xml-tests.ts index c217662316..afc867387e 100644 --- a/types/chai-xml/chai-xml-tests.ts +++ b/types/chai-xml/chai-xml-tests.ts @@ -9,7 +9,7 @@ function test_chaiXml() { expect('nope').xml.not.to.be.valid(); expect(testXml).xml.to.be.valid(); expect(testXml).xml.to.equal('\ntest\n'); - expect(testXml).xml.to.not.equal('' ); + expect(testXml).xml.to.not.equal(''); } test_chaiXml(); diff --git a/types/chai/index.d.ts b/types/chai/index.d.ts index 20f3c2b7df..bb730fe598 100644 --- a/types/chai/index.d.ts +++ b/types/chai/index.d.ts @@ -1,11 +1,12 @@ // Type definitions for chai 4.0.0 // Project: http://chaijs.com/ -// Definitions by: Jed Mao , +// Definitions by: Jed Mao , // Bart van der Schoor , // Andrew Brown , // Olivier Chevet , // Matt Wistrand , // Josh Goldberg +// Shaun Luttin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // @@ -487,6 +488,24 @@ declare namespace Chai { */ isNotNaN(value: T, message?: string): void; + /** + * Asserts that the target is neither null nor undefined. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + exists(value: T, message?: string): void; + + /** + * Asserts that the target is either null or undefined. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + notExists(value: T, message?: string): void; + /** * Asserts that value is undefined. * @@ -1318,6 +1337,29 @@ declare namespace Chai { * @param message Message to display on error. */ notFrozen(object: T, message?: string): void; + + /** + * Asserts that the target does not contain any values. For arrays and + * strings, it checks the length property. For Map and Set instances, it + * checks the size property. For non-function objects, it gets the count + * of own enumerable string keys. + * + * @type T Type of object + * @param object Actual value. + * @param message Message to display on error. + */ + isEmpty(object: T, message?: string): void; + + /** + * Asserts that the target contains values. For arrays and strings, it checks + * the length property. For Map and Set instances, it checks the size property. + * For non-function objects, it gets the count of own enumerable string keys. + * + * @type T Type of object. + * @param object Object to test. + * @param message Message to display on error. + */ + isNotEmpty(object: T, message?: string): void; } export interface Config { diff --git a/types/chance/chance-tests.ts b/types/chance/chance-tests.ts index a426142d7f..dfb942f5c5 100644 --- a/types/chance/chance-tests.ts +++ b/types/chance/chance-tests.ts @@ -37,3 +37,4 @@ var timeString: string = chance.time(); var chanceConstructedWithSeed100 = new Chance(100); var chanceCalledWithSeed100 = Chance() +var chanceConstructedWithStringSeed = new Chance("test") diff --git a/types/chance/index.d.ts b/types/chance/index.d.ts index fc5347e859..3b477c4bce 100644 --- a/types/chance/index.d.ts +++ b/types/chance/index.d.ts @@ -1,23 +1,24 @@ // Type definitions for Chance 0.7.3 // Project: http://chancejs.com -// Definitions by: Chris Bowdon +// Definitions by: Chris Bowdon // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace Chance { + type Seed = number | string; interface Seeded { - seed: number; + seed: Seed; } type SeededChance = Chance & Seeded; interface ChanceStatic { (): Chance - (seed: number): SeededChance + (seed: Seed): SeededChance (generator: () => any): Chance new(): Chance; - new(seed: number): SeededChance; + new(seed: Seed): SeededChance; new(generator: () => any): Chance; } @@ -156,7 +157,7 @@ declare namespace Chance { // "Hidden" cc_types(): CreditCardType[]; - mersenne_twister(seed?: number): any; // API return type not defined in docs + mersenne_twister(seed?: Seed): any; // API return type not defined in docs months(): Month[]; name_prefixes(): Name[]; provinces(): Name[]; diff --git a/types/charm/index.d.ts b/types/charm/index.d.ts index 2ce1b9e13a..63b8c3daa3 100644 --- a/types/charm/index.d.ts +++ b/types/charm/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Charm 1.0 // Project: https://github.com/substack/node-charm/ -// Definitions by: Jad Sarout +// Definitions by: Jad Sarout // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// diff --git a/types/chart.js/chart.js-tests.ts b/types/chart.js/chart.js-tests.ts index 5c2dab60f9..a4cccb0bae 100644 --- a/types/chart.js/chart.js-tests.ts +++ b/types/chart.js/chart.js-tests.ts @@ -4,9 +4,9 @@ import { Chart, ChartData } from 'chart.js'; // import chartjs = require('chart.js'); // => chartjs.Chart -let chart: Chart = new Chart(new CanvasRenderingContext2D(), { +const chart: Chart = new Chart(new CanvasRenderingContext2D(), { type: 'bar', - data: { + data: { labels: ['group 1'], datasets: [ { diff --git a/types/chart.js/index.d.ts b/types/chart.js/index.d.ts index a465806797..607f6924f8 100644 --- a/types/chart.js/index.d.ts +++ b/types/chart.js/index.d.ts @@ -2,16 +2,16 @@ // Project: https://github.com/nnnick/Chart.js // Definitions by: Alberto Nuti // Fabien Lavocat -// KentarouTakeda +// KentarouTakeda +// Larry Bahr +// Daniel Luz // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -/// - declare class Chart { static readonly Chart: typeof Chart; constructor( - context: string | JQuery | CanvasRenderingContext2D | HTMLCanvasElement | string[] | CanvasRenderingContext2D[] | HTMLCanvasElement[], + context: string | CanvasRenderingContext2D | HTMLCanvasElement | ArrayLike, options: Chart.ChartConfiguration ); config: Chart.ChartConfiguration; @@ -82,6 +82,8 @@ declare namespace Chart { type ScaleType = 'category' | 'linear' | 'logarithmic' | 'time' | 'radialLinear'; + type PointStyle = 'circle' | 'cross' | 'crossRot' | 'dash' | 'line' | 'rect' | 'rectRounded' | 'rectRot' | 'star' | 'triangle'; + type PositionType = 'left' | 'right' | 'top' | 'bottom'; interface ChartArea { @@ -158,6 +160,8 @@ declare namespace Chart { animation?: ChartAnimationOptions; elements?: ChartElementsOptions; scales?: ChartScales; + showLines?: boolean; + spanGaps?: boolean; cutoutPercentage?: number; circumference?: number; rotation?: number; @@ -172,7 +176,7 @@ declare namespace Chart { interface ChartTitleOptions { display?: boolean; - position?: string; + position?: PositionType; fullWdith?: boolean; fontSize?: number; fontFamily?: string; @@ -184,10 +188,12 @@ declare namespace Chart { interface ChartLegendOptions { display?: boolean; - position?: string; + position?: PositionType; fullWidth?: boolean; - onClick?(event: any, legendItem: any): void; + onClick?(event: MouseEvent, legendItem: ChartLegendItem): void; + onHover?(event: MouseEvent, legendItem: ChartLegendItem): void; labels?: ChartLegendLabelOptions; + reverse?: boolean; } interface ChartLegendLabelOptions { @@ -290,7 +296,7 @@ declare namespace Chart { interface ChartPointOptions { radius?: number; - pointStyle?: string; + pointStyle?: PointStyle; backgroundColor?: ChartColor; borderWidth?: number; borderColor?: ChartColor; @@ -329,6 +335,7 @@ declare namespace Chart { interface TickOptions { autoSkip?: boolean; + autoSkipPadding?: boolean; callback?(value: any, index: any, values: any): string|number; display?: boolean; fontColor?: ChartColor; @@ -383,7 +390,7 @@ declare namespace Chart { type ChartColor = string | CanvasGradient | CanvasPattern | string[]; interface ChartDataSets { - cubicInterpolationMode?: string; + cubicInterpolationMode?: 'default' | 'monotone'; backgroundColor?: ChartColor | ChartColor[]; borderWidth?: number; borderColor?: ChartColor; @@ -391,10 +398,15 @@ declare namespace Chart { borderDash?: number[]; borderDashOffset?: number; borderJoinStyle?: string; + borderSkipped?: PositionType; data?: number[] | ChartPoint[]; - fill?: boolean; + fill?: boolean | number | string; + hoverBackgroundColor?: string | string[]; + hoverBorderColor?: string | string[]; + hoverBorderWidth?: number | number[]; label?: string; lineTension?: number; + steppedLine?: 'before' | 'after' | boolean; pointBorderColor?: ChartColor | ChartColor[]; pointBackgroundColor?: ChartColor | ChartColor[]; pointBorderWidth?: number | number[]; @@ -404,14 +416,15 @@ declare namespace Chart { pointHoverBackgroundColor?: ChartColor | ChartColor[]; pointHoverBorderColor?: ChartColor | ChartColor[]; pointHoverBorderWidth?: number | number[]; - pointStyle?: string | string[] | HTMLImageElement | HTMLImageElement[]; + pointStyle?: PointStyle | HTMLImageElement | Array; xAxisID?: string; yAxisID?: string; type?: string; hidden?: boolean; hideInLegendAndTooltip?: boolean; + showLine?: boolean; stack?: string; - spanGaps?: string; + spanGaps?: boolean; } interface ChartScales { diff --git a/types/chayns/chayns-tests.ts b/types/chayns/chayns-tests.ts new file mode 100644 index 0000000000..8e8912430a --- /dev/null +++ b/types/chayns/chayns-tests.ts @@ -0,0 +1,14 @@ +// Test file for chayns typings + +chayns.register({ + strictMode: false, + appName: 'chayns-typings-test' +}); + +chayns.ready.then(data => { + return data; +}).catch(err => { + return err; +}); + +chayns.dialog.alert('chayns-typings', 'Test chayns-typings!'); diff --git a/types/chayns/index.d.ts b/types/chayns/index.d.ts new file mode 100644 index 0000000000..a1989a1c51 --- /dev/null +++ b/types/chayns/index.d.ts @@ -0,0 +1,938 @@ +// Type definitions for chayns 3.1 +// Project: https://github.com/TobitSoftware/chayns-js +// Definitions by: Henning Kuehl +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +/** + * Definition file for chayns v3.1 + */ +declare namespace chayns { + /** + * Getting Started + * chayns + * + */ + let ready: Promise; + + function register(config: RegisterConfig): void; + + /** + * Basic Functions + * chayns + */ + function login(parameters?: string[]): Promise; + + function getUser(config: GetUserConfig): Promise; + + function getUacGroups(siteId: number, updateCache?: boolean): Promise; + + function startInteractionIdentification(config: InteractionIdentificationConfig): Promise; + + function stopInteractionIdentification(): Promise; + + function allowRefreshScroll(): Promise; + + function disallowRefreshScroll(): Promise; + + function showTitleImage(): Promise; + + function hideTitleImage(): Promise; + + function setOnActivateCallback(callback: (tappEvent: number) => any): Promise; + + function setNetworkChangeCallback(callback: (result: NetworkChangeResult) => any, ongoing: boolean): Promise; + + function setNfcCallback(callback: (rfid: string) => any): Promise; + + function removeNfcCallback(): Promise; + + function startNfcDetection(callback: (result: NfcDetectionResult) => any, interval: number, vibrate: boolean): Promise; + + function stopNfcDetection(): Promise; + + function scanQRCode(cameryType?: number, timeout?: number): Promise; // TODO interface for promise result + + function createQRCode(text: string): Promise; + + function showFinetradingQRCode(): Promise; + + function selectTapp(tapp: SelectTappConfig, parameter?: string[]): Promise; + + function openUrl(config: OpenUrlConfig): void; + + function closeUrl(): void; + + function openUrlInBrowser(url: string): void; + + function getGeoLocation(): Promise; + + function getLocationBeacons(forceReload: boolean): Promise; + + function getBeaconHistory(subNumber?: number): Promise; + + function getBaseColor(color?: string, colorMode?: number): string; + + function share(config: ShareConfig): Promise; // TODO interface for promise result + + function getAvailableSharingServices(): Promise; + + function navigateBack(): Promise; + + function updateNavigation(tappId?: number, config?: UpdateNavigationConfig): Promise; + + function enableDisplayTimeout(): Promise; + + function disableDisplayTimeout(): Promise; + + function setSpeechToText(callback: (result: SpeechToTextResult) => any, title?: string): Promise; + + function createTappShortcut(name: string, imageUrl: string): Promise; + + function setSubTapp(config: SubTappConfig): void; + + function removeSubTapp(config: RemoveSubTappConfig): void; + + function vibrate(ms: number[]): Promise; + + function setHeight(config: SetHeightConfig): Promise; + + function scrollToY(position: number): Promise; + + function addToWallet(passbook: string): Promise; // TODO check passbock parameter + + function addScrollListener(callback: (data: any) => any, throttle?: number): Promise; // TODO interface for callback data + + function setScreenOrientation(orientation: number): Promise; + + function findSite(name: string, skip?: number, take?: number): Promise; + + /** + * UI Functions + * Waitcursor + * chayns + */ + function showWaitCursor(text?: string, timeout?: number): Promise; + + function hideWaitCursor(): Promise; + + /** + * UI Functions + * Floating Button + * chayns + */ + function showFloatingButton(config: FloatingConfig, callback: () => any): void; + + function hideFloatingButton(): void; + + /** + * Media Functions + * Image + * chayns + */ + function openImage(urls: string[], start?: number): Promise; + + function uploadImage(): Promise; + + /** + * Media Functions + * Miscellaneous + * chayns + */ + function openVideo(url: string): Promise; + + function saveAppointment(config: SaveAppointmentConfig): Promise; + + function playSound(url: string, playOnMute?: boolean): Promise; + + function addErrorListener(logFn: (error: any) => Promise<{}>, appName: string): void; + + function getGlobalData(): GlobalData; + + /** + * chayns.smartShop + */ + let smartShop: any; + + /** + * Basic Functions + * chayns.intercom + */ + namespace intercom { + function sendMessageToUser(userId: number, config: IntercomConfig): Promise; // TODO set interface for promise result + + function sendMessageToGroup(groupId: number, config: IntercomConfig): Promise; // TODO set interface for promise result + + function sendMessageToPage(config: IntercomConfig): Promise; // TODO set interface for promise result + } + + /** + * Basic Functions + * chayns.passKit + */ + namespace passKit { + function getInstalled(): Promise; // TODO interface for promise result + + function isInstalled(identifier: string): Promise; // TODO interface for promise result + } + + /** + * Environmental Variables + * chayns.env + */ + namespace env { + let _parameters: any; + + let parameters: any; + + let isBrowser: boolean; + + let isChaynsWeb: boolean; + + let isChaynsWebDesktop: boolean; + + let isChaynsWebMobile: boolean; + + let isDesktop: boolean; + + let isMobile: boolean; + + let isApp: boolean; + + let isIOS: boolean; + + let isAndroid: boolean; + + let isTablet: boolean; + + let isWP: boolean; + + let appVersion: number; + + let os: string; + + let apiVersion: number; + + let debugMode: boolean; + + let isChaynsParent: boolean; + + let isChaynsWebLight: boolean; + + let isInFacebookFrame: boolean; + + let isInFrame: boolean; + + let isWidget: boolean; + + let language: string; + + /** + * Environmental Variables + * chayns.env.user + */ + namespace user { + let tobitAccessToken: string; + + let facebookAccessToken: string; + + let facebookId: string; + + let id: number; + + let name: string; + + let personId: string; + + let isAuthenticated: boolean; + + let language: string; + + let groups: UserGroup[]; + } + + /** + * Environmental Variables + * chayns.env.site + */ + namespace site { + let color: string; + + let colorMode: number; + + let colorScheme: number; + + let domain: string; + + let facebookAppId: string; + + let facebookPageId: string; + + let id: string; + + let isAdEnabled: boolean; + + let isArEnabled: boolean; + + let language: string; + + let locationId: number; + + let locationPersonId: string; + + let tapps: SiteTapp[]; + + let title: string; + + let url: string; + + let version: string; + + /** + * Environmental Variables + * chayns.env.site.tapp + */ + namespace tapp { + let customUrl: string; + + let id: number; + + let internalName: string; + + let isExclusiveView: boolean; + + let isKioskMode: boolean; + + let isSubTapp: boolean; + + let showName: string; + + let sortId: number; + + let userGroupIds: number[]; + } + } + + /** + * Environmental Variables + * chayns.env.app + */ + namespace app { + let flavor: string; + + let languageId: string; + + let model: string; + + let name: string; + + let uid: string; + + let version: string; + } + + /** + * Environmental Variables + * chayns.env.device + */ + namespace device { + let fontScale: any; + + let imei: string; + + let languageId: string; + + let model: string; + + let systemName: string; + + let systemVersion: number; + + let uid: string; + } + + /** + * Environmental Variables + * chayns.env.browser + */ + namespace browser { + let name: string; + + let version: string; + } + } + + /** + * UI Functions + * chayns.dialog + */ + namespace dialog { + enum buttonType { + CANCEL = -1, + NEGATIVE = 0, + POSITIVE = 1 + } + + enum buttonText { + CANCEL = 'Abbrechen', + NO = 'Nein', + OK = 'OK', + YES = 'Ja' + } + + enum dateType { + DATE, + TIME, + DATE_TIME + } + + enum inputType { + DEFAULT = 0, + PASSWORD = 1 + } + + function alert(title: string, message?: string): Promise; + + function confirm(title: string, message?: string, buttons?: DialogButton[]): Promise; + + function date(config: DialogDateConfig): Promise; + + function select(config: DialogSelectConfig): Promise; + + function input(config: DialogInputConfig): Promise; + + function facebook(options: DialogFacebookOptions): Promise; + } + + /** + * chayns.ui + */ + namespace ui { + /** + * UI Functions + * chayns.ui.modeSwitch + */ + namespace modeSwitch { + function init(config: ModeSwitchConfig): void; + + function addItem(item: ModeSwitchItem, index?: number): void; + + function changeMode(item: number | ModeSwitchItem): void; + + function remove(): void; + + function add(): void; + } + + /** + * Media Functions + * chayns.ui.gallery + */ + namespace gallery { + function create(id: string, urls: string[]): void; + + function setUrls(id: string, urls: string[]): void; + + function getUrls(id: string): string[]; + + function addUrl(id: string, url: string): void; + + function removeUrl(id: string, url: string): void; + } + + /** + * chayns.ui.tooltip + */ + namespace tooltip { + function init(config: UiTooltipInitConfig, rootElement: any): Promise; + } + + /** + * chayns.ui.slider + */ + namespace slider { + function refreshTrack(): void; + } + } + + /** + * Utility Functions + * chayns.utils + */ + namespace utils { + /** + * Utility Functions + * Check Types + * chayns.utils + */ + function isHex(parameter: any, shorthand: boolean): boolean; + + function isArray(parameter: any): boolean; + + function isBLEAdress(parameter: any): boolean; + + function isBlank(parameter: any): boolean; + + function isDate(parameter: any): boolean; + + function isDefined(parameter: any): boolean; + + function isFormData(parameter: any): boolean; + + function isFunction(parameter: any): boolean; + + function isGUID(parameter: any): boolean; + + function isMacAdress(parameter: any): boolean; + + function isNumber(parameter: any): boolean; + + function isObject(parameter: any): boolean; + + function isPromise(parameter: any): boolean; + + function isString(parameter: any): boolean; + + function isUUID(parameter: any): boolean; + + function isUndefined(parameter: any): boolean; + + function isDeferred(parameter: any): boolean; + + function isJwt(parameter: any): boolean; + + function isUrl(parameter: any): boolean; + + /** + * Utility Functions + * Miscellaneous + * chayns.utils + */ + function getJwtPayload(token: string): JwtPaylod; + + function mod(number: number, modulo: number): number; + + function trim(test: string): string; + + function replacePlaceholder(text: string, parameters: any[]): string; // TODO set interface for parameters + + function mixColor(color1: string, color2: string, saturation: number): string; + + function isPresent(parameter: any): boolean; + + function setLevel(level: number): void; + + /** + * Utility Functions + * Local Storage + * chayns.utils.ls + */ + namespace ls { + function set(key: string, value: string): void; + + function get(key: string): string; + + function remove(key: string): void; + + function removeAll(): void; + } + + namespace lang { + function init(config: any): void; + + function renderTextStrings(): void; + + function get(textString: string): string; + + function translateDomStrings(): void; + } + } + + /** + * chayns.storage + */ + namespace storage { + enum accessMode { + PUBLIC, + PROTECTED, + PRIVATE + } + + function set(key: string, value: any, accessMode?: accessMode, tappIds?: number[]): Promise; + + function get(key: string, accessMode?: accessMode): any; + + function remove(key: string, accessMode?: accessMode): Promise; + } +} + +/** + * Getting Started + * chayns + * interfaces + */ +// chayns.register() +interface RegisterConfig { + strictMode?: boolean; + appName?: string; + cssPrefix?: string; + callbackPrefix?: string; + initialHeight?: number; + autoResize?: boolean; +} + +/** + * Basic Functions + * chayns + * interfaces + */ +// chayns.getUser() +interface GetUserConfig { + accessToken?: string; + userId?: number; + fbId?: string; + personId?: string; +} + +interface User { + FacebookID: string; + FirstName: string; + LastName: string; + PersonID: string; + UserFullName: string; + UserID: number; +} + +// chayns.getUacGroups() +interface UacGroup { + id: number; + name: string; + showName: string; +} + +// chayns.startInteractionIdentification() +interface InteractionIdentificationConfig { + duration: number; + delay?: number; + callback: any; + resetOnInteraction?: boolean; + foregroundColor: string; + backgroundColor?: string; +} + +// chayns.setNetworkChangeCallback() +interface NetworkChangeResult { + isConnected: boolean; + type: number; +} + +// chayns.startNfcDetection() +interface NfcDetectionResult { + connected: boolean; + rfid: string; +} + +// chayns.selectTapp() +interface SelectTappConfig { + id?: number; + internalName?: string; + showName?: string; + position?: number; +} + +// chayns.openUrl() +interface OpenUrlConfig { + url: string; + title?: string; + exclusiveView?: boolean; + darkenBackground?: boolean; + fullSize?: boolean; + width?: number; +} + +// chayns.getGeoLocation() +interface GeoLocationResult { + longitude: number; + latitude: number; +} + +// chayns.getLocationBeacons() +interface LocationBeacon { + id: number; + pushMessage: string; + latitude: number; + longitude: number; +} + +// chayns.getBeaconHistory() +interface BeaconHistory { + id: number; + timestamp: number; +} + +// chayns.share() +interface ShareConfig { + title?: string; + text: string; + imageUrl?: string; + sharingApp: number; + sharingAndroidApp?: string; +} + +// chayns.updateNavigation() +interface UpdateNavigationConfig { + stateOnly?: boolean; + updateTapp?: boolean; +} + +// chayns.setSpeecToText() +interface SpeechToTextResult { + languageCode: string; + text: string[]; +} + +// chayns.setSubTapp() +interface SubTappConfig { + tappID: number; + name: string; + color: string; + colorText?: string; + sortID: number; + icon: string; + callbackURL?(result: any): any; + url: string; + buttonName: string; + isExclusiveView?: boolean; + replaceParent?: boolean; + boldText?: boolean; +} + +// chayns.removeSubTapp() +interface RemoveSubTappConfig { + tappID: number; + close: boolean; + remove: boolean; +} + +// chayns.setHeight() +interface SetHeightConfig { + height: number; + growOnly?: boolean; + full?: boolean; + fullViewport?: boolean; +} + +// chayns.findSite() +interface Site { + appstoreName: string; + facebookId: string; + siteId: string; + locationId: number; +} + +/** + * Basic Functions + * chayns.intercom + * interfaces + */ +interface IntercomConfig { + text: string; +} + +/** + * UI Functions + * chayns.dialog + * interfaces + */ +// chayns.dialog.confirm() +interface DialogButton { + text: string; + buttonType: chayns.dialog.buttonType; +} + +// chayns.dialog.date() +interface DialogDateConfig { + dateType: chayns.dialog.dateType; + preSelect?: Date; + minDate?: Date; + maxDate?: Date; +} + +interface DialogDateResult { + timestamp: number; + buttonType: chayns.dialog.buttonType; +} + +// chayns.dialog.select() +interface DialogSelectConfig { + title: string; + message?: string; + quickfind?: boolean; + multiselect?: boolean; + buttons?: any[]; // TODO interface for buttons + list: DialogSelectConfigItem[]; +} + +interface DialogSelectConfigItem { + name: string; + value?: string; + image?: string; + isSelected?: boolean; +} + +interface DialogSelectResult { + buttonType: chayns.dialog.buttonType; + selection: DialogSelectResultItem[]; +} + +interface DialogSelectResultItem { + name: string; + value?: string; +} + +// chayns.dialog.input() +interface DialogInputConfig { + title: string; + message?: string; + placeholderText?: string; + text?: string; + buttons?: DialogButton[]; +} + +interface DialogInputResult { + buttonType: chayns.dialog.buttonType; + text: string; +} + +/** + * UI Functions + * chayns.ui.modeswitch + * interfaces + */ +// chayns.ui.modeswitch.init() +interface ModeSwitchConfig { + items: ModeSwitchItem[]; + callback(result: ModeSwitchItem): void; + headline?: string; + preventclose?: boolean; +} + +interface ModeSwitchItem { + name: string; + value: number; + default?: boolean; +} + +/** + * UI Functions + * Floating Button + * chayns + * interfaces + */ +// chayns.showFloatingButton() +interface FloatingConfig { + text?: string; + color?: string; + colorText?: string; + icon?: string; +} + +/** + * Media Functions + * Miscellaneous + * chayns + * interfaces + */ +// chayns.saveAppointment() +interface SaveAppointmentConfig { + name: string; + location: string; + description: string; + start: Date; + end: Date; +} + +/** + * Utility Functions + * Miscellaneous + * chayns.utils + * interfaces + */ +// chayns.utils.getJwtPayload() +interface JwtPaylod { + FacebookUserID: string; + FirstName: string; + LastName: string; + PersonID: string; + LocationID: number; + TobitUserID: number; + LoginType: number; + isAdmin: boolean; +} + +/** + * Enviroment Variables + * User + * interfaces + */ +// chayns.env.user.groups +interface UserGroup { + id: number; + isActive?: boolean; + isSystemGroup?: boolean; + name: string; + showName?: string; +} + +/** + * Enviroment Variables + * Site + * interfaces + */ +interface SiteTapp { + customUrl: string; + id: number; + internalName: string; + isExclusiveView: boolean; + isKioskMode: boolean; + isSubTapp: boolean; + showName: string; + sortId: number; + userGroupIds: number[]; +} + +interface GlobalData { + _result: any; +} + +interface DialogFacebookOptions { + title: string; + message?: string; + quickfind?: number; + multiselect?: number; + button?: DialogFacebookButton[]; + preSelected: number[]; // TODO: Verify type +} + +interface DialogFacebookButton { + text: string; + value: number; // TODO: Verify type +} + +interface DialogFacebookResult { + buttonType: number; + selection: DialogFacebookResultSelection[]; +} + +interface DialogFacebookResultSelection { + first_name: string; + last_name: string; + id: string; + gender: string; + name: string; +} + +interface UiTooltipInitConfig { + tooltipClass: string; + preventAnimation: boolean; +} diff --git a/types/chayns/tsconfig.json b/types/chayns/tsconfig.json new file mode 100644 index 0000000000..99d0599998 --- /dev/null +++ b/types/chayns/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "chayns-tests.ts" + ] +} diff --git a/types/chayns/tslint.json b/types/chayns/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/chayns/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/check-sum/check-sum-tests.ts b/types/check-sum/check-sum-tests.ts new file mode 100644 index 0000000000..e1f310e74d --- /dev/null +++ b/types/check-sum/check-sum-tests.ts @@ -0,0 +1,18 @@ +import checksum = require('check-sum'); +import * as fs from 'fs'; + +const stream = fs.createReadStream('package.json'); + +checksum(stream, { + md5: 'asdfasdfasdf', + sha1: 'asdfasdfasdf' +}, err => { + err; // $ExpectType any +}); + +checksum('package.json', { + md5: 'asdfasdfasdf', + sha1: 'asdfasdfasdf' +}, err => { + err; // $ExpectType Error | ChecksumError | undefined +}); diff --git a/types/check-sum/index.d.ts b/types/check-sum/index.d.ts new file mode 100644 index 0000000000..d1e4b7eb02 --- /dev/null +++ b/types/check-sum/index.d.ts @@ -0,0 +1,24 @@ +// Type definitions for check-sum 0.1 +// Project: https://github.com/stream-utils/check-sum +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +import { Readable } from 'stream'; + +export = checksum; + +declare function checksum(stream: Readable, hashes: checksum.Hashes, callback: (error: checksum.ChecksumError | any) => void): (fn: () => void) => void; +declare function checksum(path: string, hashes: checksum.Hashes, callback: (error: checksum.ChecksumError | Error | undefined) => void): (fn: () => void) => void; + +declare namespace checksum { + interface ChecksumError { + algorithm: string; + expected: string; + actual: string; + } + + interface Hashes { + [algorithm: string]: string | Buffer; + } +} diff --git a/types/check-sum/tsconfig.json b/types/check-sum/tsconfig.json new file mode 100644 index 0000000000..2143ca3bd6 --- /dev/null +++ b/types/check-sum/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "check-sum-tests.ts" + ] +} diff --git a/types/check-sum/tslint.json b/types/check-sum/tslint.json new file mode 100644 index 0000000000..d9d49e375e --- /dev/null +++ b/types/check-sum/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "no-any-union": false + } +} diff --git a/types/chmodr/chmodr-tests.ts b/types/chmodr/chmodr-tests.ts new file mode 100644 index 0000000000..886dc9e3db --- /dev/null +++ b/types/chmodr/chmodr-tests.ts @@ -0,0 +1,14 @@ +import chmodr = require('chmodr'); +import { URL } from 'url'; + +chmodr('', '', err => { + err; // $ExpectType ErrnoException +}); +chmodr(new Buffer(''), '', () => {}); +chmodr(new URL(''), '', () => {}); +chmodr(new URL(''), 1, () => {}); + +chmodr.sync('', ''); +chmodr.sync(new Buffer(''), ''); +chmodr.sync(new URL(''), ''); +chmodr.sync(new URL(''), 1); diff --git a/types/chmodr/index.d.ts b/types/chmodr/index.d.ts new file mode 100644 index 0000000000..16eeaf7cbd --- /dev/null +++ b/types/chmodr/index.d.ts @@ -0,0 +1,17 @@ +// Type definitions for chmodr 1.0 +// Project: https://github.com/isaacs/chmodr#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +import { URL } from 'url'; + +export = chmodr; + +declare function chmodr(path: chmodr.PathLike, mode: string | number, callback: (err: NodeJS.ErrnoException) => void): void; + +declare namespace chmodr { + function sync(path: PathLike, mode: string | number): void; + + type PathLike = string | Buffer | URL; +} diff --git a/types/chmodr/tsconfig.json b/types/chmodr/tsconfig.json new file mode 100644 index 0000000000..5aa0c9aac2 --- /dev/null +++ b/types/chmodr/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "chmodr-tests.ts" + ] +} diff --git a/types/chmodr/tslint.json b/types/chmodr/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/chmodr/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/chocolatechipjs/chocolatechipjs-tests.ts b/types/chocolatechipjs/chocolatechipjs-tests.ts index bbb6ae72e3..a723d1b8f9 100644 --- a/types/chocolatechipjs/chocolatechipjs-tests.ts +++ b/types/chocolatechipjs/chocolatechipjs-tests.ts @@ -1,5 +1,5 @@ // ChocolateChipStatic -- DOM creation, etc. -$(function() { +$(() => { alert('Ready to do stuff!'); }); const docRoot = $(); @@ -20,10 +20,10 @@ const moreEls = $.html('

      Stuff

      '); const oldTag = $('#oldTag'); const newTag = $('#newTag'); $.replace(oldTag, newTag); -$.require('./scripts/myscript.js', function() { +$.require('./scripts/myscript.js', () => { $.noop; }); -$.defer(function() { +$.defer(() => { console.log("This comes after Squawk!"); }); const concatenation = $.concat('This', ' ', 'is', ' ', 'a', ' ', 'string', '.'); @@ -41,7 +41,7 @@ $.isInteger(123); $.isInteger(123.123); // should return false $.isFloat(123.123); // should return true const newUuid = $.makeUuid(); -$.each(['a', 'b', 'c'], function(ctx: string, idx: number) { +$.each(['a', 'b', 'c'], (ctx: string, idx: number) => { console.log(ctx); console.log(idx); }); @@ -55,7 +55,7 @@ $.fn.extend({ }); // ChocolateChipElementArray extensions: -$('li').each(function(ctx, idx) { +$('li').each((ctx, idx) => { console.log(ctx.nodeName); }); const uniqueElements = $('li').unique(); @@ -63,19 +63,19 @@ const secondElement = $('li').eq(1); const lastElement = $('li').eq(-1); const whichIndex = $('li').index($('.selected')); const whichListItemIndex = $('li').eq(3).index(); -$('.elems').is('div').each(function(ctx) { +$('.elems').is('div').each(ctx => { console.log('This element is a div.'); }); -$('.elems').isnt('p').each(function() { +$('.elems').isnt('p').each(() => { console.log('This element is not a paragraph tag.'); }); -$('li').has('p').each(function(ctx) { +$('li').has('p').each(ctx => { console.log('This list item has a paragraph tag.'); }); -$('li').hasnt('p').each(function(ctx) { +$('li').hasnt('p').each(ctx => { console.log('This list item does not have a paragraph tag.'); }); -$('ul').find('li').each(function(ctx) { +$('ul').find('li').each(ctx => { console.log(ctx); }); $('li').css('color'); @@ -124,14 +124,14 @@ $('ul').hide(); $('ul').hide('slow'); $('ul').hide('fast'); $('ul').hide(1000); -$('ul').hide('fast', function() { +$('ul').hide('fast', () => { console.log('Finished hiding these.'); }); $('ul').show(); $('ul').show('slow'); $('ul').show('fast'); $('ul').show(1000); -$('ul').show('fast', function() { +$('ul').show('fast', () => { console.log('Finished hiding these.'); }); $('#list').prev().css('display', 'none'); @@ -198,22 +198,22 @@ const isSafari = $.isSafari; const isNativeAndroid = $.isNativeAndroid; // Events: -$('li').bind('click', function() { +$('li').bind('click', () => { $.noop; }, false); -$('li').unbind('click', function() { +$('li').unbind('click', () => { $.noop; }, false); -$('ul').delegate('click', 'li', function() { +$('ul').delegate('click', 'li', () => { $.noop; }, false); -$('ul').undelegate('click', 'li', function() { +$('ul').undelegate('click', 'li', () => { $.noop; }, false); -$('li').on('click', function() { +$('li').on('click', () => { $.noop; }); -$('ul').on('click', 'li', function() { +$('ul').on('click', 'li', () => { console.log($(this).text()); }); $('li').off('click'); @@ -224,22 +224,22 @@ $('.selected').data('selection', 'This is awesome!'); // set the value of data v $('.selected').data('selection'); // return the data value of "selection" on ".selected" // Promises: -let myPromise = new Promise(function(resolve, reject) { +let myPromise = new Promise((resolve, reject) => { $.noop; }); -myPromise = new Promise(function(resolve, reject) { +myPromise = new Promise((resolve, reject) => { // Resolve the promise: resolve('Success!'); // or reject it: // reject('Lost in Space!'); }); -myPromise.then(function(value) { +myPromise.then(value => { // Success: console.log(value); }, // Opps! There was a problem: - function(reason) { + reason => { console.log(reason); }); @@ -256,10 +256,10 @@ interface WineInterface { } fetch('../data/wines.json') .then($.json) -.then(function(obj: any): any { +.then((obj: any) => { $('#message_ajax').empty(); - obj.data.forEach(function(wine: any) { - $('#message_ajax').append('
    • ' + wine.name + '
    • '); + obj.data.forEach((wine: any) => { + $('#message_ajax').append(`
    • ${wine.name}
    • `); }); }); @@ -278,12 +278,12 @@ fetch('../controllers/php-post.php', { body: formData }) .then($.json) -.then(function(data: any): any { +.then((data: any) => { if (data.email_check === "valid") { - $("#message_ajax").html("
      " + data.email + " is a valid e-mail address. Thank you, " + data.name + ".
      "); - $("#message_ajax").append('

      ' + data.msg + '

      '); + $("#message_ajax").html(`
      ${data.email} is a valid e-mail address. Thank you, ${data.name}.
      `); + $("#message_ajax").append(`

      ${data.msg}

      `); } else { - $("#message_ajax").html("
      Sorry " + data.name + ", " + data.email + " is NOT a valid e-mail address. Try again.
      "); + $("#message_ajax").html(`
      Sorry ${data.name}, ${data.email} is NOT a valid e-mail address. Try again.
      `); } }); // PUT: @@ -301,12 +301,12 @@ fetch('../controllers/php-put.php', { body: putData }) .then($.json) -.then(function(data: any): any { +.then((data: any) => { console.dir(data.base); - $("#message_ajax").append('

      ' + data.result + '

      '); - $("#message_ajax").append('

      The file name is: ' + data.fileName + '

      '); + $("#message_ajax").append(`

      ${data.result}

      `); + $("#message_ajax").append(`

      The file name is: ${data.fileName}

      `); }) -.catch(function(error: Error) { +.catch((error: Error) => { console.log(error); $("#message_ajax").html("
      Sorry, put was not successful.
      "); }); @@ -324,15 +324,15 @@ fetch('../controllers/php-delete.php', { body: file }) .then($.json) -.then(function(data: any): any { +.then((data: any) => { $("#message_ajax").html("
      DELETE was sent to the server successfully.
      "); - $("#message_ajax").append('

      ' + data.result + '

      '); + $("#message_ajax").append(`

      ${data.result}

      `); }, -function(data: any) { +(data: any) => { console.log('PROBLEM'); console.log(data); }) -.catch(function(error: any) { +.catch((error: any) => { $("#message_ajax").html("
      Sorry, 'DELETE' was not successful.
      "); error.reject(); }); @@ -349,30 +349,30 @@ fetch('../controllers/php-post.php', { timeout: 10000 }) .then($.json) - .then(function (data: any): any { + .then((data: any) => { if (data.email_check === "valid") { - $("#message_ajax").html("
      " + data.email + " is a valid e-mail address. Thank you, " + data.name + ".
      "); - $("#message_ajax").append('

      ' + data.msg + '

      '); + $("#message_ajax").html(`
      ${data.email} is a valid e-mail address. Thank you, ${data.name}.
      `); + $("#message_ajax").append(`

      ${data.msg}

      `); } else { - $("#message_ajax").html("
      Sorry " + data.name + ", " + data.email + " is NOT a valid e-mail address. Try again.
      "); + $("#message_ajax").html(`
      Sorry ${data.name}, ${data.email} is NOT a valid e-mail address. Try again.
      `); } }) // Catch timeout: - .catch(function(error) { + .catch(error => { console.log(error); }); // $.jsonp: $.jsonp('https://api.github.com/users/rbiggs/repos?name=chipper', {timeout: 10000}) .then($.json) -.then(function(obj: any): any { +.then((obj: any) => { console.log(obj); - obj.data.forEach(function(repo: any): any { - $('#message_ajax').append("
    • " + repo.name + "
    • "); + obj.data.forEach((repo: any) => { + $('#message_ajax').append(`
    • ${repo.name}
    • `); }); }) -.catch(function(error: any): any { - $('#message_ajax').append("
    • " + error.message + "
    • "); +.catch((error: any) => { + $('#message_ajax').append(`
    • ${error.message}
    • `); }); // Templates: @@ -411,10 +411,9 @@ $.template.data['myRepeater'] = [{ name: "Joe" }, { name: "Sally" }, {name: "Tom $.template.repeater(); // Pub/Sub: -const arraySubscriber = function(topic: string, data: any): any { - $('.list').append('
    • ' + topic + '

      ' + data + '

    • '); -}; -const newsSubscription = $.subscribe('news/update', arraySubscriber); +const newsSubscription = $.subscribe('news/update', (topic: string, data: any) => { + $('.list').append(`
    • ${topic}

      ${data}

    • `); +}); $.publish('news/update', 'The New York Stock Exchange rose an unprecedented 1000 points in just three minutes. Analysts and investors are confused and uncertain how to respond.'); $.unsubscribe('news/update'); // Due to being unsubscribed above, this does nothing: diff --git a/types/chocolatechipjs/tslint.json b/types/chocolatechipjs/tslint.json index e502fddef8..ce367ade18 100644 --- a/types/chocolatechipjs/tslint.json +++ b/types/chocolatechipjs/tslint.json @@ -4,7 +4,9 @@ // TODOs "adjacent-overload-signatures": false, "ban-types": false, - "only-arrow-functions": false, - "unified-signatures": false + "dt-header": false, + "no-any-union": false, + "unified-signatures": false, + "no-unnecessary-generics": false } } diff --git a/types/chokidar/index.d.ts b/types/chokidar/index.d.ts index b60a4a5655..683214fe35 100644 --- a/types/chokidar/index.d.ts +++ b/types/chokidar/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for chokidar 1.7.0 // Project: https://github.com/paulmillr/chokidar -// Definitions by: Stefan Steinhart , Felix Becker +// Definitions by: Stefan Steinhart , Felix Becker // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// diff --git a/types/chosen-js/index.d.ts b/types/chosen-js/index.d.ts index 221eefb3d3..c9a5556c26 100644 --- a/types/chosen-js/index.d.ts +++ b/types/chosen-js/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Chosen.JQuery 1.6.1 // Project: http://harvesthq.github.com/chosen/ -// Definitions by: Boris Yankov , denis +// Definitions by: Boris Yankov , denis // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/chownr/chownr-tests.ts b/types/chownr/chownr-tests.ts new file mode 100644 index 0000000000..b544ce288e --- /dev/null +++ b/types/chownr/chownr-tests.ts @@ -0,0 +1,14 @@ +import chownr = require('chownr'); +import { URL } from 'url'; + +chownr('', 1, 1, err => { + err; // $ExpectType ErrnoException +}); +chownr(new Buffer(''), 1, 1, () => {}); +chownr(new URL(''), 1, 1, () => {}); +chownr(new URL(''), 1, 1, () => {}); + +chownr.sync('', 1, 1); +chownr.sync(new Buffer(''), 1, 1); +chownr.sync(new URL(''), 1, 1); +chownr.sync(new URL(''), 1, 1); diff --git a/types/chownr/index.d.ts b/types/chownr/index.d.ts new file mode 100644 index 0000000000..8ca1404bf9 --- /dev/null +++ b/types/chownr/index.d.ts @@ -0,0 +1,17 @@ +// Type definitions for chownr 1.0 +// Project: https://github.com/isaacs/chownr#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +import { URL } from 'url'; + +export = chownr; + +declare function chownr(path: chownr.PathLike, uid: number, gid: number, callback: (err: NodeJS.ErrnoException) => void): void; + +declare namespace chownr { + function sync(path: PathLike, uid: number, gid: number): void; + + type PathLike = string | Buffer | URL; +} diff --git a/types/chownr/tsconfig.json b/types/chownr/tsconfig.json new file mode 100644 index 0000000000..587c9ef8f8 --- /dev/null +++ b/types/chownr/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "chownr-tests.ts" + ] +} diff --git a/types/chownr/tslint.json b/types/chownr/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/chownr/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/chroma-js/chroma-js-tests.ts b/types/chroma-js/chroma-js-tests.ts index 53a3e912b8..82cfb7274d 100644 --- a/types/chroma-js/chroma-js-tests.ts +++ b/types/chroma-js/chroma-js-tests.ts @@ -182,3 +182,8 @@ function test_scale() { chroma.scale('RdYlBu'); chroma.scale('RdYlBu').padding(0.15); } + +function test_types() { + const color: chroma.Color = chroma('orange'); + const scale: chroma.Scale = chroma.scale('RdYlBu'); +} diff --git a/types/chroma-js/index.d.ts b/types/chroma-js/index.d.ts index 1b679b816a..41f7a36785 100644 --- a/types/chroma-js/index.d.ts +++ b/types/chroma-js/index.d.ts @@ -7,7 +7,7 @@ /** * Chroma.js is a tiny library for all kinds of color conversions and color scales. */ -declare namespace Chroma { +declare namespace chroma { interface ColorSpaces { rgb: [number, number, number]; rgba: [number, number, number, number]; @@ -353,7 +353,7 @@ declare namespace Chroma { } } -declare var chroma: Chroma.ChromaStatic; +declare var chroma: chroma.ChromaStatic; export = chroma; export as namespace chroma; diff --git a/types/chrome/index.d.ts b/types/chrome/index.d.ts index ee61cf5575..42ba4c1804 100644 --- a/types/chrome/index.d.ts +++ b/types/chrome/index.d.ts @@ -7366,7 +7366,7 @@ declare namespace chrome.webRequest { interface WebRedirectionResponseEvent extends _WebResponseHeadersEvent {} interface WebAuthenticationChallengeEvent extends chrome.events.Event<(details: WebAuthenticationChallengeDetails, callback?: (response: BlockingResponse) => void) => void> { - addListener(callback: (details: WebAuthenticationChallengeDetails) => void, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void; + addListener(callback: (details: WebAuthenticationChallengeDetails, callback?: (response: BlockingResponse) => void) => void, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void; } interface WebResponseErrorEvent extends _WebResponseHeadersEvent {} diff --git a/types/chunked-dc/index.d.ts b/types/chunked-dc/index.d.ts index d200c07899..5e57953621 100644 --- a/types/chunked-dc/index.d.ts +++ b/types/chunked-dc/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for chunked-dc 0.1 // Project: https://github.com/saltyrtc/chunked-dc-js -// Definitions by: Danilo Bargen +// Definitions by: Danilo Bargen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Interfaces diff --git a/types/circular-json/index.d.ts b/types/circular-json/index.d.ts index b724f92577..1b4e5c1d2b 100644 --- a/types/circular-json/index.d.ts +++ b/types/circular-json/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for circular-json v0.1.6 // Project: https://github.com/WebReflection/circular-json -// Definitions by: Jonathan Pevarnek +// Definitions by: Jonathan Pevarnek // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/ckeditor/ckeditor-tests.ts b/types/ckeditor/ckeditor-tests.ts index 289e97168a..b6471ddab6 100644 --- a/types/ckeditor/ckeditor-tests.ts +++ b/types/ckeditor/ckeditor-tests.ts @@ -407,3 +407,85 @@ function test_sharedSpace() { function test_specifying_editor_path() { window.CKEDITOR_BASEPATH = '/ckeditor/'; } + +function test_editor_instance_event() { + var textarea = document.createElement('textarea'); + var instance = CKEDITOR.replace(textarea, { + on: { + activeEnterModeChange: function() {}, + activeFilterChange: function() {}, + afterCommandExec: function() {}, + afterInsertHtml: function() {}, + afterPaste: function() {}, + afterPasteFromWord: function() {}, + afterSetData: function() {}, + afterUndoImage: function() {}, + ariaEditorHelpLabel: function() {}, + ariaWidget: function() {}, + autogrow: function() {}, + beforeCommandExec: function() {}, + beforeDestroy: function() {}, + beforeModeUnload: function() {}, + beforeSetMode: function() {}, + beforeUndoImage: function() {}, + blur: function() {}, + change: function() {}, + configLoaded: function() {}, + contentDirChanged: function() {}, + contentDom: function() {}, + contentDomInvalidated: function() {}, + contentDomUnload: function() {}, + customConfigLoaded: function() {}, + dataFiltered: function() {}, + dataReady: function() {}, + destroy: function() {}, + dialogHide: function() {}, + dialogShow: function() {}, + dirChanged: function() {}, + doubleclick: function() {}, + dragend: function() {}, + dragstart: function() {}, + drop: function() {}, + elementsPathUpdate: function() {}, + fileUploadRequest: function() {}, + fileUploadResponse: function() {}, + floatingSpaceLayout: function() {}, + focus: function() {}, + getData: function() {}, + getSnapshot: function() {}, + insertElement: function() {}, + insertHtml: function() {}, + insertText: function() {}, + instanceReady: function() {}, + key: function() {}, + langLoaded: function() {}, + loadSnapshot: function() {}, + loaded: function() {}, + lockSnapshot: function() {}, + maximize: function() {}, + menuShow: function() {}, + mode: function() {}, + notificationHide: function() {}, + notificationShow: function() {}, + notificationUpdate: function() {}, + paste: function() {}, + pasteFromWord: function() {}, + pluginsLoaded: function() {}, + readOnly: function() {}, + removeFormatCleanup: function() {}, + required: function() {}, + resize: function() {}, + save: function() {}, + saveSnapshot: function() {}, + selectionChange: function() {}, + setData: function() {}, + stylesSet: function() {}, + template: function() {}, + toDataFormat: function() {}, + toHtml: function() {}, + unlockSnapshot: function() {}, + updateSnapshot: function() {}, + widgetDefinition: function() {} + } + }); +} diff --git a/types/ckeditor/index.d.ts b/types/ckeditor/index.d.ts index 71a9202557..24ff341b38 100644 --- a/types/ckeditor/index.d.ts +++ b/types/ckeditor/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for CKEditor // Project: http://ckeditor.com/ -// Definitions by: Ondrej Sevcik +// Definitions by: Ondrej Sevcik // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // WORK-IN-PROGRESS: Any contribution support welcomed. @@ -1163,6 +1163,7 @@ declare namespace CKEDITOR { afterCommandExec?: (evt: CKEDITOR.eventInfo) => void; afterInsertHtml?: (evt: CKEDITOR.eventInfo) => void; afterPaste?: (evt: CKEDITOR.eventInfo) => void; + afterPasteFromWord?: (evt: CKEDITOR.eventInfo) => void; afterSetData?: (evt: CKEDITOR.eventInfo) => void; afterUndoImage?: (evt: CKEDITOR.eventInfo) => void; ariaEditorHelpLabel?: (evt: CKEDITOR.eventInfo) => void; @@ -1170,9 +1171,11 @@ declare namespace CKEDITOR { autogrow?: (evt: CKEDITOR.eventInfo) => void; beforeCommandExec?: (evt: CKEDITOR.eventInfo) => void; + beforeDestroy?: (evt: CKEDITOR.eventInfo) => void; beforeGetData?: (evt: CKEDITOR.eventInfo) => void; - beforeModuleUnload?: (evt: CKEDITOR.eventInfo) => void; + beforeModeUnload?: (evt: CKEDITOR.eventInfo) => void; beforeSetMode?: (evt: CKEDITOR.eventInfo) => void; + beforeUndoImage?: (evt: CKEDITOR.eventInfo) => void; blur?: (evt: CKEDITOR.eventInfo) => void; change?: (evt: CKEDITOR.eventInfo) => void; @@ -1189,7 +1192,7 @@ declare namespace CKEDITOR { dialogHide?: (evt: CKEDITOR.eventInfo) => void; dialogShow?: (evt: CKEDITOR.eventInfo) => void; dirChanged?: (evt: CKEDITOR.eventInfo) => void; - doubleckick?: (evt: CKEDITOR.eventInfo) => void; + doubleclick?: (evt: CKEDITOR.eventInfo) => void; dragend?: (evt: CKEDITOR.eventInfo) => void; dragstart?: (evt: CKEDITOR.eventInfo) => void; drop?: (evt: CKEDITOR.eventInfo) => void; @@ -1207,7 +1210,7 @@ declare namespace CKEDITOR { insertElement?: (evt: CKEDITOR.eventInfo) => void; insertHtml?: (evt: CKEDITOR.eventInfo) => void; insertText?: (evt: CKEDITOR.eventInfo) => void; - insanceReady?: (evt: CKEDITOR.eventInfo) => void; + instanceReady?: (evt: CKEDITOR.eventInfo) => void; key?: (evt: CKEDITOR.eventInfo) => void; @@ -1224,6 +1227,7 @@ declare namespace CKEDITOR { notificationUpdate?: (evt: CKEDITOR.eventInfo) => void; paste?: (evt: CKEDITOR.eventInfo) => void; + pasteFromWord?: (evt: CKEDITOR.eventInfo) => void; pluginsLoaded?: (evt: CKEDITOR.eventInfo) => void; readOnly?: (evt: CKEDITOR.eventInfo) => void; @@ -1851,4 +1855,3 @@ declare namespace CKEDITOR { function detect(defaultLanguage: string, probeLanguage: string): string; } } - diff --git a/types/clamp-js/index.d.ts b/types/clamp-js/index.d.ts index 2fa557bac6..b905e16e8f 100644 --- a/types/clamp-js/index.d.ts +++ b/types/clamp-js/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for clamp-js 0.7 // Project: https://github.com/xavi160/Clamp.js -// Definitions by: Sebastiaan de Rooij +// Definitions by: Sebastiaan de Rooij // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace clamp { diff --git a/types/classnames/bind.d.ts b/types/classnames/bind.d.ts new file mode 100644 index 0000000000..4af94d1835 --- /dev/null +++ b/types/classnames/bind.d.ts @@ -0,0 +1,3 @@ +import * as cn from "./index"; + +export function bind(styles: Record): typeof cn; diff --git a/types/classnames/classnames-tests.ts b/types/classnames/classnames-tests.ts index 1938acb4f9..b2b8c9eba4 100644 --- a/types/classnames/classnames-tests.ts +++ b/types/classnames/classnames-tests.ts @@ -1,5 +1,6 @@ import classNames = require('classnames'); import * as classNames2 from 'classnames'; +import * as cn from 'classnames/bind'; classNames2('foo', 'bar'); // => 'foo bar' @@ -23,3 +24,17 @@ classNames(null, 'bar', undefined, 0, 1, { baz: null }, ''); // => 'bar 1' // Supporting booleans is tricky since we should only support passing in false, which is ignored // classNames(false, 'bar', 0, 1, { baz: null }, ''); // => 'bar 1' + +// Support for CSS-Modules. Example from README: +// https://github.com/JedWatson/classnames/blob/master/README.md#alternate-bind-version-for-css-modules +const styles = { + foo: 'abc', + bar: 'def', + baz: 'xyz' +}; + +const cx = cn.bind(styles); +const className = cx('foo', ['bar'], { baz: true }); // => "abc def xyz" + +// falsey values are just ignored +cx(null, 'bar', undefined, 0, 1, { baz: null }, ''); // => 'bar 1' diff --git a/types/classnames/index.d.ts b/types/classnames/index.d.ts index 42352fc9b8..ce2abb5ee3 100644 --- a/types/classnames/index.d.ts +++ b/types/classnames/index.d.ts @@ -3,9 +3,11 @@ // Definitions by: Dave Keen // Adi Dahiya // Jason Killian -// Sean Kelley +// Sean Kelley // Michal Adamczyk +// Marvin Hagemeister // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 type ClassValue = string | number | ClassDictionary | ClassArray | undefined | null | false; diff --git a/types/classnames/tsconfig.json b/types/classnames/tsconfig.json index 8eeaf9b1ca..bb39a9d874 100644 --- a/types/classnames/tsconfig.json +++ b/types/classnames/tsconfig.json @@ -17,6 +17,7 @@ }, "files": [ "index.d.ts", + "bind.d.ts", "classnames-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/classnames/tslint.json b/types/classnames/tslint.json index 3db14f85ea..946c3b6691 100644 --- a/types/classnames/tslint.json +++ b/types/classnames/tslint.json @@ -1 +1,7 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + // TODO + "dt-header": false + } +} diff --git a/types/cldrjs/index.d.ts b/types/cldrjs/index.d.ts index 70a7c1c753..1837e9c88d 100644 --- a/types/cldrjs/index.d.ts +++ b/types/cldrjs/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Cldr.js 0.4.4 // Project: https://github.com/rxaviers/cldrjs -// Definitions by: Raman But-Husaim , Grégoire Castre +// Definitions by: Raman But-Husaim , Grégoire Castre // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export = self; diff --git a/types/clean-stack/clean-stack-tests.ts b/types/clean-stack/clean-stack-tests.ts new file mode 100644 index 0000000000..72bef3f6b3 --- /dev/null +++ b/types/clean-stack/clean-stack-tests.ts @@ -0,0 +1,8 @@ +import cleanStack = require('clean-stack'); + +const error = new Error('Missing unicorn'); + +if (error.stack) { + cleanStack(error.stack); // $ExpectType string + cleanStack(error.stack, {pretty: true}); // $ExpectType string +} diff --git a/types/clean-stack/index.d.ts b/types/clean-stack/index.d.ts new file mode 100644 index 0000000000..59af64e31b --- /dev/null +++ b/types/clean-stack/index.d.ts @@ -0,0 +1,14 @@ +// Type definitions for clean-stack 1.3 +// Project: https://github.com/sindresorhus/clean-stack#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = cleanStack; + +declare function cleanStack(stack: string, options?: cleanStack.Options): string; + +declare namespace cleanStack { + interface Options { + pretty?: boolean; + } +} diff --git a/types/clean-stack/tsconfig.json b/types/clean-stack/tsconfig.json new file mode 100644 index 0000000000..79e1474200 --- /dev/null +++ b/types/clean-stack/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "clean-stack-tests.ts" + ] +} diff --git a/types/clean-stack/tslint.json b/types/clean-stack/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/clean-stack/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/cli-table2/index.d.ts b/types/cli-table2/index.d.ts index 46d4619162..b216b23832 100644 --- a/types/cli-table2/index.d.ts +++ b/types/cli-table2/index.d.ts @@ -70,7 +70,7 @@ declare namespace CliTable2 { } interface GenericTable extends Array { - options: CliTable2.TableInstanceOptions; + options: TableInstanceOptions; readonly width: number; } diff --git a/types/client-sessions/client-sessions-tests.ts b/types/client-sessions/client-sessions-tests.ts new file mode 100644 index 0000000000..7498aac12d --- /dev/null +++ b/types/client-sessions/client-sessions-tests.ts @@ -0,0 +1,25 @@ +import express = require("express"); +import session = require("client-sessions"); + +const secret = "yolo"; +const app = express(); +const options = { secret }; + +let middleware = session(options); +middleware = session({ secret, cookieName: "_s" }); +middleware = session({ secret, duration: 600000 }); +middleware = session({ secret, activeDuration: 42 }); +middleware = session({ + secret, + cookie: { + httpOnly: false, + } +}); + +app.use(middleware); +app.use((req: any, res: any) => { + req.session = { test: true }; +}); + +const encoded = session.util.encode(options, { test: true }); +session.util.decode(options, encoded); diff --git a/types/client-sessions/index.d.ts b/types/client-sessions/index.d.ts new file mode 100644 index 0000000000..6a4b3b2b2f --- /dev/null +++ b/types/client-sessions/index.d.ts @@ -0,0 +1,74 @@ +// Type definitions for client-sessions 0.8 +// Project: https://github.com/mozilla/node-client-sessions +// Definitions by: Aditya +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/// + +import * as cookies from "cookies"; + +declare namespace client_sessions { + type NextFunction = (err?: Error) => void; + type RequestHandler = (req: any, res: any, next: NextFunction) => any; + + interface SessionOptions { + /** + * encryption secret for the session. + * required + */ + secret: string; + + /** + * session cookie name. + * Default: 'session_state' + */ + cookieName?: string; + + /** + * how long the session will stay valid in ms. + * Default: 24 hours + */ + duration?: number; + + /** + * if expiresIn < activeDuration, the session will be extended by activeDuration milliseconds. + * Default: 5 minutes + */ + activeDuration?: number; + + /** + * session accessor on the request object. + * Default: 'session' + */ + requestKey?: string; + + cookie?: cookies.IOptions; + } + + interface DecodeResult { + content: any; + createdAt: number; + duration: number; + } + + interface ComputeHmacOptions { + signatureAlgorithm: string; + signatureKey: Buffer; + } + + interface Util { + computeHmac(options: any, iv: string, ciphertext: string, duration: number, createdAt: number): Buffer; + encode(options: SessionOptions, content: any, duration?: number, createdAt?: number): string; + decode(options: SessionOptions, encoded: string): DecodeResult; + } + + interface Sessions { + (options: SessionOptions): RequestHandler; + util: Util; + } +} + +declare var client_sessions: client_sessions.Sessions; +export = client_sessions; +export as namespace client_sessions; diff --git a/types/client-sessions/tsconfig.json b/types/client-sessions/tsconfig.json new file mode 100644 index 0000000000..151ca87623 --- /dev/null +++ b/types/client-sessions/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "client-sessions-tests.ts" + ] +} diff --git a/types/client-sessions/tslint.json b/types/client-sessions/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/client-sessions/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/clipboardy/clipboardy-tests.ts b/types/clipboardy/clipboardy-tests.ts new file mode 100644 index 0000000000..33ae8ac9a8 --- /dev/null +++ b/types/clipboardy/clipboardy-tests.ts @@ -0,0 +1,10 @@ +import clipboardy = require('clipboardy'); + +clipboardy.writeSync('🦄'); +clipboardy.write('🦄').then(() => {}); + +let str: string; +str = clipboardy.readSync(); +clipboardy.read().then(toPaste => { + str = toPaste; +}); diff --git a/types/clipboardy/index.d.ts b/types/clipboardy/index.d.ts new file mode 100644 index 0000000000..12e2c3b85a --- /dev/null +++ b/types/clipboardy/index.d.ts @@ -0,0 +1,9 @@ +// Type definitions for clipboardy 1.1 +// Project: https://github.com/sindresorhus/clipboardy#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export function write(input: string): Promise; +export function writeSync(input: string): void; +export function read(): Promise; +export function readSync(): string; diff --git a/types/clipboardy/tsconfig.json b/types/clipboardy/tsconfig.json new file mode 100644 index 0000000000..455154a1d2 --- /dev/null +++ b/types/clipboardy/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "clipboardy-tests.ts" + ] +} diff --git a/types/clipboardy/tslint.json b/types/clipboardy/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/clipboardy/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/clndr/package.json b/types/clndr/package.json index 21243d59df..770614d9be 100644 --- a/types/clndr/package.json +++ b/types/clndr/package.json @@ -1,4 +1,5 @@ { + "private": true, "dependencies": { "moment": ">=2.8.3" } diff --git a/types/co-views/index.d.ts b/types/co-views/index.d.ts index 3eda7191b1..db37de3611 100644 --- a/types/co-views/index.d.ts +++ b/types/co-views/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for co-views 2.1 // Project: https://github.com/tj/co-views/ -// Definitions by: devlee , Joshua DeVinney +// Definitions by: devlee , Joshua DeVinney // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace CoViews { diff --git a/types/codemirror/codemirror-runmode.d.ts b/types/codemirror/codemirror-runmode.d.ts index 2252eb9649..e08be74ee0 100644 --- a/types/codemirror/codemirror-runmode.d.ts +++ b/types/codemirror/codemirror-runmode.d.ts @@ -20,5 +20,5 @@ declare module "codemirror" { * tokens will be converted to span elements as in an editor, * and inserted into the node (through innerHTML). */ - function runMode(text: string, modespec: any, callback: (HTMLElement | ((text: string, style: string) => void)), options? : { tabSize?: number; state?: any; }): void; + function runMode(text: string, modespec: any, callback: (HTMLElement | ((text: string, style: string | null) => void)), options? : { tabSize?: number; state?: any; }): void; } diff --git a/types/codemirror/index.d.ts b/types/codemirror/index.d.ts index b42ebabae3..fb755fae4b 100644 --- a/types/codemirror/index.d.ts +++ b/types/codemirror/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for CodeMirror // Project: https://github.com/marijnh/CodeMirror // Definitions by: mihailik +// nrbernard // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export = CodeMirror; @@ -102,6 +103,21 @@ declare namespace CodeMirror { To fire your own events, use CodeMirror.signal(target, name, args...), where target is a non-DOM-node object. */ function signal(target: any, name: string, ...args: any[]): void; + type DOMEvent = 'mousedown' | 'dblclick' | 'touchstart' | 'contextmenu' | 'keydown' | 'keypress' | 'keyup' | 'cut' | 'copy' | 'paste' | 'dragstart' | 'dragenter' | 'dragover' | 'dragleave' | 'drop'; + + interface Token { + /** The character(on the given line) at which the token starts. */ + start: number; + /** The character at which the token ends. */ + end: number; + /** The token's string. */ + string: string; + /** The token type the mode assigned to the token, such as "keyword" or "comment" (may also be null). */ + type: string | null; + /** The mode's state at the end of this token. */ + state: any; + } + interface Editor { /** Tells you whether the editor currently has focus. */ @@ -163,7 +179,7 @@ declare namespace CodeMirror { /** Sets the gutter marker for the given gutter (identified by its CSS class, see the gutters option) to the given value. Value can be either null, to clear the marker, or a DOM element, to set it. The DOM element will be shown in the specified gutter next to the specified line. */ - setGutterMarker(line: any, gutterID: string, value: HTMLElement): CodeMirror.LineHandle; + setGutterMarker(line: any, gutterID: string, value: HTMLElement | null): CodeMirror.LineHandle; /** Remove all gutter markers in the gutter with the given ID. */ clearGutter(gutterID: string): void; @@ -228,7 +244,7 @@ declare namespace CodeMirror { setSize(width: any, height: any): void; /** Scroll the editor to a given(pixel) position.Both arguments may be left as null or undefined to have no effect. */ - scrollTo(x: number, y: number): void; + scrollTo(x?: number | null, y?: number | null): void; /** Get an { left , top , width , height , clientWidth , clientHeight } object that represents the current scroll position, the size of the scrollable area, and the size of the visible area(minus scrollbars). */ @@ -236,7 +252,7 @@ declare namespace CodeMirror { /** Scrolls the given element into view. pos is a { line , ch } position, referring to a given character, null, to refer to the cursor. The margin parameter is optional. When given, it indicates the amount of pixels around the given area that should be made visible as well. */ - scrollIntoView(pos: CodeMirror.Position, margin?: number): void; + scrollIntoView(pos: CodeMirror.Position | null, margin?: number): void; /** Scrolls the given element into view. pos is a { left , top , right , bottom } object, in editor-local coordinates. The margin parameter is optional. When given, it indicates the amount of pixels around the given area that should be made visible as well. */ @@ -287,20 +303,11 @@ declare namespace CodeMirror { you should probably follow up by calling this method to ensure CodeMirror is still looking as intended. */ refresh(): void; - /** Retrieves information about the token the current mode found before the given position (a {line, ch} object). */ - getTokenAt(pos: CodeMirror.Position): { - /** The character(on the given line) at which the token starts. */ - start: number; - /** The character at which the token ends. */ - end: number; - /** The token's string. */ - string: string; - /** The token type the mode assigned to the token, such as "keyword" or "comment" (may also be null). */ - type: string; - /** The mode's state at the end of this token. */ - state: any; - }; + getTokenAt(pos: CodeMirror.Position): Token; + + /** This is similar to getTokenAt, but collects all tokens for a given line into an array. */ + getLineTokens(line: number, precise?: boolean): Token[]; /** Returns the mode's parser state, if any, at the end of the given line number. If no line number is given, the state at the end of the document is returned. @@ -405,6 +412,10 @@ declare namespace CodeMirror { on(eventName: 'renderLine', handler: (instance: CodeMirror.Editor, line: CodeMirror.LineHandle, element: HTMLElement) => void ): void; off(eventName: 'renderLine', handler: (instance: CodeMirror.Editor, line: CodeMirror.LineHandle, element: HTMLElement) => void ): void; + /** Fires when one of the DOM events fires. */ + on(eventName: DOMEvent, handler: (instance: CodeMirror.Editor, event: Event) => void ): void; + off(eventName: DOMEvent, handler: (instance: CodeMirror.Editor, event: Event) => void ): void; + /** Expose the state object, so that the Editor.state.completionActive property is reachable*/ state: any; } @@ -464,7 +475,7 @@ declare namespace CodeMirror { getLineHandle(num: number): CodeMirror.LineHandle; /** Given a line handle, returns the current position of that line (or null when it is no longer in the document). */ - getLineNumber(handle: CodeMirror.LineHandle): number; + getLineNumber(handle: CodeMirror.LineHandle): number | null; /** Iterate over the whole document, and call f for each line, passing the line handle. This is a faster way to visit a range of line handlers than calling getLineHandle for each of them. @@ -487,6 +498,9 @@ declare namespace CodeMirror { /** Get the currently selected code. */ getSelection(): string; + + /** Returns an array containing a string for each selection, representing the content of the selections. */ + getSelections(lineSep?: string): Array; /** Replace the selection with the given string. By default, the new selection will span the inserted text. The optional collapse argument can be used to change this � passing "start" or "end" will collapse the selection to the start or end of the inserted text. */ @@ -522,7 +536,7 @@ declare namespace CodeMirror { /** Retrieve the editor associated with a document. May return null. */ - getEditor(): CodeMirror.Editor; + getEditor(): CodeMirror.Editor | null; /** Create an identical copy of the given doc. When copyHistory is true , the history will also be copied.Can not be called directly on an editor. */ @@ -935,12 +949,12 @@ declare namespace CodeMirror { /** * Returns the next character in the stream without advancing it. Will return an null at the end of the line. */ - peek(): string; + peek(): string | null; /** * Returns the next character in the stream and advances it. Also returns null when no more characters are available. */ - next(): string; + next(): string | null; /** * match can be a character, a regular expression, or a function that takes a character and returns a boolean. @@ -1016,7 +1030,7 @@ declare namespace CodeMirror { * This function should read one token from the stream it is given as an argument, optionally update its state, * and return a style string, or null for tokens that do not have to be styled. Multiple styles can be returned, separated by spaces. */ - token(stream: StringStream, state: T): string; + token(stream: StringStream, state: T): string | null; /** * A function that produces a state object to be used at the start of a document. diff --git a/types/collections/tsconfig.json b/types/collections/tsconfig.json index 6b5293a242..e547d4914d 100644 --- a/types/collections/tsconfig.json +++ b/types/collections/tsconfig.json @@ -1,16 +1,22 @@ { - "files": [ - "collections-tests.ts", - "index.d.ts" - ], "compilerOptions": { - "module": "commonjs", - "target": "es6", - "lib": ["es6"], - "forceConsistentCasingInFileNames": true, - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "noEmit": true - } -} + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "collections-tests.ts" + ] +} \ No newline at end of file diff --git a/types/color-convert/color-convert-tests.ts b/types/color-convert/color-convert-tests.ts index 735c169a2f..fe45e209f3 100644 --- a/types/color-convert/color-convert-tests.ts +++ b/types/color-convert/color-convert-tests.ts @@ -1,6 +1,6 @@ import * as color from 'color-convert'; import * as conv from 'color-convert/conversions'; -let hsv: [number, number, number] = color.rgb.hsv([1, 2, 3]); -let hsv_raw: [number, number, number] = color.rgb.hsv.raw([1, 2, 3]); -let aaa: [number, number, number] = color.rgb.hsv([1, 2, 3]); +const hsv: [number, number, number] = color.rgb.hsv([1, 2, 3]); +const hsv_raw: [number, number, number] = color.rgb.hsv.raw([1, 2, 3]); +const aaa: [number, number, number] = color.rgb.hsv([1, 2, 3]); diff --git a/types/color/color-tests.ts b/types/color/color-tests.ts index 2d05e86f05..4e475a0ce0 100644 --- a/types/color/color-tests.ts +++ b/types/color/color-tests.ts @@ -1,41 +1,43 @@ -import * as Color from "color" +import Color = require('color'); -var color: Color.Color = Color("white") -var colorOther: Color.Color = Color("black") -var colorRGB: Color.Color = Color({ r : 0, g : 0, b : 0 }, "rgb") -var colorInt: Color.Color = Color(0x000000) +const color: Color = new Color("white"); +const colorOther: Color = new Color("black"); +const colorRGB: Color = new Color({ r: 0, g: 0, b: 0 }, "rgb"); +const colorInt: Color = new Color(0x000000); +const colorWithoutNew: Color = Color(0x000000); +const colorByStaticMethod: Color = Color.rgb({ r: 0, g: 0, b: 0 }); -var hex: string = color.hex() -var percent: string = color.percentString() -var keyword: string | void = color.keyword() -var alpha: number = color.alpha() -var red: number = color.red() -var green: number = color.green() -var blue: number = color.blue() -var hue: number = color.hue() -var saturationl: number = color.saturationl() -var lightness: number = color.lightness() -var saturationv: number = color.saturationv() -var value: number = color.value() -var cyan: number = color.cyan() -var magenta: number = color.magenta() -var yellow: number = color.yellow() -var black: number = color.black() -var luminosity: number = color.luminosity() -var contrast: number = color.contrast(colorOther) -var dark: boolean = color.dark() -var light: boolean = color.light() -var level: string = color.level(colorOther) +const hex: string = color.hex(); +const percent: string = color.percentString(); +const keyword: string = color.keyword(); +const alpha: number = color.alpha(); +const red: number = color.red(); +const green: number = color.green(); +const blue: number = color.blue(); +const hue: number = color.hue(); +const saturationl: number = color.saturationl(); +const lightness: number = color.lightness(); +const saturationv: number = color.saturationv(); +const value: number = color.value(); +const cyan: number = color.cyan(); +const magenta: number = color.magenta(); +const yellow: number = color.yellow(); +const black: number = color.black(); +const luminosity: number = color.luminosity(); +const contrast: number = color.contrast(colorOther); +const dark: boolean = color.dark(); +const light: boolean = color.light(); +const level: string = color.level(colorOther); -var x: number = color.x() -var y: number = color.y() -var z: number = color.z() -var l: number = color.l() -var a: number = color.a() -var b: number = color.b() -var rgbNumber: number = color.rgbNumber() +const x: number = color.x(); +const y: number = color.y(); +const z: number = color.z(); +const l: number = color.l(); +const a: number = color.a(); +const b: number = color.b(); +const rgbNumber: number = color.rgbNumber(); -var chain: Color.Color = color +const chain: Color = color .alpha(0) .red(0) .green(0) @@ -54,7 +56,7 @@ var chain: Color.Color = color .darken(0) .saturate(0) .desaturate(0) - .greyscale() + .grayscale() .whiten(0) .blacken(0) .opaquer(0) diff --git a/types/color/index.d.ts b/types/color/index.d.ts index a9fc18f29a..8290b78129 100644 --- a/types/color/index.d.ts +++ b/types/color/index.d.ts @@ -1,101 +1,135 @@ -// Type definitions for color 1.0 -// Project: https://www.npmjs.com/package/color -// Definitions by: Karol Janyst +// Type definitions for color 2.0 +// Project: https://github.com/qix-/color#readme +// Definitions by: Junyoung Clare Jang // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 -declare namespace Color { +import convert = require('color-convert'); - type ColorParam = string | { [param: string]: number } | number; +type ColorParam = Color | string | ArrayLike | number | { [key: string]: any }; - type ColorModel = "rgb" | "hsl" | "hsv" | "hwb" | "hcg" | "cmyk" | "xyz" | "lab" | "hex" | "gray" | "keyword"; +interface Color { + toString(): string; + toJSON(): Color; + string(places?: number): string; + percentString(places?: number): string; + array(): number[]; + object(): { alpha?: number } & { [key: string]: number }; + unitArray(): number[]; + unitObject(): { r: number, g: number, b: number, alpha?: number }; + round(places?: number): Color; + alpha(): number; + alpha(val: number): Color; + red(): number; + red(val: number): Color; + green(): number; + green(val: number): Color; + blue(): number; + blue(val: number): Color; + hue(): number; + hue(val: number): Color; + saturationl(): number; + saturationl(val: number): Color; + lightness(): number; + lightness(val: number): Color; + saturationv(): number; + saturationv(val: number): Color; + value(): number; + value(val: number): Color; + chroma(): number; + chroma(val: number): Color; + gray(): number; + gray(val: number): Color; + white(): number; + white(val: number): Color; + wblack(): number; + wblack(val: number): Color; + cyan(): number; + cyan(val: number): Color; + magenta(): number; + magenta(val: number): Color; + yellow(): number; + yellow(val: number): Color; + black(): number; + black(val: number): Color; + x(): number; + x(val: number): Color; + y(): number; + y(val: number): Color; + z(): number; + z(val: number): Color; + l(): number; + l(val: number): Color; + a(): number; + a(val: number): Color; + b(): number; + b(val: number): Color; + keyword(): string; + keyword(val: string): Color; + hex(): string; + hex(val: string): Color; + rgbNumber(): number; + luminosity(): number; + contrast(color2: Color): number; + level(color2: Color): 'AAA' | 'AA' | ''; + dark(): boolean; + light(): boolean; + negate(): Color; + lighten(ratio: number): Color; + darken(ratio: number): Color; + saturate(ratio: number): Color; + desaturate(ratio: number): Color; + whiten(ratio: number): Color; + blacken(ratio: number): Color; + grayscale(): Color; + fade(ratio: number): Color; + opaquer(ratio: number): Color; + rotate(degrees: number): Color; + mix(mixinColor: Color, weight?: number): Color; - interface Color { - (color: ColorParam | Color, model?: ColorModel) : Color; - toString(): string; - toJSON(): any; - string(places?: number): string; - percentString(placse?: number): string; - array(): number[]; - object(): any; - unitArray(): any[]; - unitObject(): any; - round(places?: number): Color; - alpha(alpha: number): Color; - alpha(): number; - red(red: number): Color; - red(): number; - green(green: number): Color; - green(): number; - blue(blue: number): Color; - blue(): number; - hue(hue: number): Color; - hue(): number; - saturationl(saturation: number): Color; - saturationl(): number; - lightness(lightness: number): Color; - lightness(): number; - saturationv(saturationv: number): Color; - saturationv(): number; - value(value: number): Color; - value(): number; - chroma(chroma: number): Color; - chroma(): number; - gray(value: number): Color; - gray(): number; - cyan(cyan: number): Color; - cyan(): number; - magenta(magenta: number): Color; - magenta(): number; - yellow(yellow: number): Color; - yellow(): number; - black(black: number): Color; - black(): number; - x(x: number): Color; - x(): number; - y(y: number): Color; - y(): number; - z(z: number): Color; - z(): number; - l(l: number): Color; - l(): number; - a(a: number): Color; - a(): number; - b(b: number): Color; - b(): number; - keyword(keyword: string): Color; - keyword(): string | undefined; - hex(color: string): Color; - hex(): string; - rgb(): Color; - hsl(): Color; - hsv(): Color; - hwb(): Color; - hcg(): Color; - cmyk(): Color; - xyz(): Color; - lab(): Color; - rgbNumber(): number; - luminosity(): number; - contrast(color: Color): number; - level(color: Color): string; - dark(): boolean; - light(): boolean; - negate(): Color; - lighten(value: number): Color; - darken(value: number): Color; - saturate(value: number): Color; - desaturate(value: number): Color; - whiten(value: number): Color; - blacken(value: number): Color; - greyscale(): Color; - fade(ratio: number): Color; - opaquer(value: number): Color; - rotate(value: number): Color; - mix(color: Color, value?: number): Color; - hsl(): Color; - } + rgb(...args: number[]): Color; + hsl(...args: number[]): Color; + hsv(...args: number[]): Color; + hwb(...args: number[]): Color; + cmyk(...args: number[]): Color; + xyz(...args: number[]): Color; + lab(...args: number[]): Color; + lch(...args: number[]): Color; + ansi16(...args: number[]): Color; + ansi256(...args: number[]): Color; + hcg(...args: number[]): Color; + apple(...args: number[]): Color; } -declare const Color: Color.Color; +interface ColorConstructor { + (obj?: ColorParam, model?: keyof (typeof convert)): Color; + new(obj?: ColorParam, model?: keyof (typeof convert)): Color; + rgb(...val: number[]): Color; + rgb(color: ColorParam): Color; + hsl(...val: number[]): Color; + hsl(color: ColorParam): Color; + hsv(...val: number[]): Color; + hsv(color: ColorParam): Color; + hwb(...val: number[]): Color; + hwb(color: ColorParam): Color; + cmyk(...val: number[]): Color; + cmyk(color: ColorParam): Color; + xyz(...val: number[]): Color; + xyz(color: ColorParam): Color; + lab(...val: number[]): Color; + lab(color: ColorParam): Color; + lch(...val: number[]): Color; + lch(color: ColorParam): Color; + ansi16(...val: number[]): Color; + ansi16(color: ColorParam): Color; + ansi256(...val: number[]): Color; + ansi256(color: ColorParam): Color; + hcg(...val: number[]): Color; + hcg(color: ColorParam): Color; + apple(...val: number[]): Color; + apple(color: ColorParam): Color; +} + +declare const Color: ColorConstructor; + export = Color; -export as namespace Color; diff --git a/types/color/tsconfig.json b/types/color/tsconfig.json index 3034984bd5..77175286b3 100644 --- a/types/color/tsconfig.json +++ b/types/color/tsconfig.json @@ -19,4 +19,4 @@ "index.d.ts", "color-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/color/tslint.json b/types/color/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/color/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/color/v1/color-tests.ts b/types/color/v1/color-tests.ts new file mode 100644 index 0000000000..2d05e86f05 --- /dev/null +++ b/types/color/v1/color-tests.ts @@ -0,0 +1,63 @@ +import * as Color from "color" + +var color: Color.Color = Color("white") +var colorOther: Color.Color = Color("black") +var colorRGB: Color.Color = Color({ r : 0, g : 0, b : 0 }, "rgb") +var colorInt: Color.Color = Color(0x000000) + +var hex: string = color.hex() +var percent: string = color.percentString() +var keyword: string | void = color.keyword() +var alpha: number = color.alpha() +var red: number = color.red() +var green: number = color.green() +var blue: number = color.blue() +var hue: number = color.hue() +var saturationl: number = color.saturationl() +var lightness: number = color.lightness() +var saturationv: number = color.saturationv() +var value: number = color.value() +var cyan: number = color.cyan() +var magenta: number = color.magenta() +var yellow: number = color.yellow() +var black: number = color.black() +var luminosity: number = color.luminosity() +var contrast: number = color.contrast(colorOther) +var dark: boolean = color.dark() +var light: boolean = color.light() +var level: string = color.level(colorOther) + +var x: number = color.x() +var y: number = color.y() +var z: number = color.z() +var l: number = color.l() +var a: number = color.a() +var b: number = color.b() +var rgbNumber: number = color.rgbNumber() + +var chain: Color.Color = color + .alpha(0) + .red(0) + .green(0) + .blue(0) + .hue(0) + .saturationl(0) + .lightness(0) + .saturationv(0) + .value(0) + .cyan(0) + .magenta(0) + .yellow(0) + .black(0) + .negate() + .lighten(0) + .darken(0) + .saturate(0) + .desaturate(0) + .greyscale() + .whiten(0) + .blacken(0) + .opaquer(0) + .rotate(0) + .mix(colorOther, 0) + .hsl(); diff --git a/types/color/v1/index.d.ts b/types/color/v1/index.d.ts new file mode 100644 index 0000000000..a9fc18f29a --- /dev/null +++ b/types/color/v1/index.d.ts @@ -0,0 +1,101 @@ +// Type definitions for color 1.0 +// Project: https://www.npmjs.com/package/color +// Definitions by: Karol Janyst +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace Color { + + type ColorParam = string | { [param: string]: number } | number; + + type ColorModel = "rgb" | "hsl" | "hsv" | "hwb" | "hcg" | "cmyk" | "xyz" | "lab" | "hex" | "gray" | "keyword"; + + interface Color { + (color: ColorParam | Color, model?: ColorModel) : Color; + toString(): string; + toJSON(): any; + string(places?: number): string; + percentString(placse?: number): string; + array(): number[]; + object(): any; + unitArray(): any[]; + unitObject(): any; + round(places?: number): Color; + alpha(alpha: number): Color; + alpha(): number; + red(red: number): Color; + red(): number; + green(green: number): Color; + green(): number; + blue(blue: number): Color; + blue(): number; + hue(hue: number): Color; + hue(): number; + saturationl(saturation: number): Color; + saturationl(): number; + lightness(lightness: number): Color; + lightness(): number; + saturationv(saturationv: number): Color; + saturationv(): number; + value(value: number): Color; + value(): number; + chroma(chroma: number): Color; + chroma(): number; + gray(value: number): Color; + gray(): number; + cyan(cyan: number): Color; + cyan(): number; + magenta(magenta: number): Color; + magenta(): number; + yellow(yellow: number): Color; + yellow(): number; + black(black: number): Color; + black(): number; + x(x: number): Color; + x(): number; + y(y: number): Color; + y(): number; + z(z: number): Color; + z(): number; + l(l: number): Color; + l(): number; + a(a: number): Color; + a(): number; + b(b: number): Color; + b(): number; + keyword(keyword: string): Color; + keyword(): string | undefined; + hex(color: string): Color; + hex(): string; + rgb(): Color; + hsl(): Color; + hsv(): Color; + hwb(): Color; + hcg(): Color; + cmyk(): Color; + xyz(): Color; + lab(): Color; + rgbNumber(): number; + luminosity(): number; + contrast(color: Color): number; + level(color: Color): string; + dark(): boolean; + light(): boolean; + negate(): Color; + lighten(value: number): Color; + darken(value: number): Color; + saturate(value: number): Color; + desaturate(value: number): Color; + whiten(value: number): Color; + blacken(value: number): Color; + greyscale(): Color; + fade(ratio: number): Color; + opaquer(value: number): Color; + rotate(value: number): Color; + mix(color: Color, value?: number): Color; + hsl(): Color; + } +} + +declare const Color: Color.Color; +export = Color; +export as namespace Color; diff --git a/types/color/v1/tsconfig.json b/types/color/v1/tsconfig.json new file mode 100644 index 0000000000..66541f0172 --- /dev/null +++ b/types/color/v1/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "types": [], + "paths": { + "color": [ + "color/v1" + ] + }, + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "color-tests.ts" + ] +} diff --git a/types/command-line-args/index.d.ts b/types/command-line-args/index.d.ts index 33af16bcf5..442ee5cb93 100644 --- a/types/command-line-args/index.d.ts +++ b/types/command-line-args/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for command-line-args 4.0.6 // Project: https://github.com/75lb/command-line-args -// Definitions by: CzBuCHi +// Definitions by: CzBuCHi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /** diff --git a/types/command-line-commands/index.d.ts b/types/command-line-commands/index.d.ts index cf69198dac..8cfc9c094d 100644 --- a/types/command-line-commands/index.d.ts +++ b/types/command-line-commands/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for command-line-commands 2.0.0 // Project: https://github.com/75lb/command-line-commands -// Definitions by: CzBuCHi +// Definitions by: CzBuCHi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /** diff --git a/types/commander/index.d.ts b/types/commander/index.d.ts index 017495784a..9e5feded68 100644 --- a/types/commander/index.d.ts +++ b/types/commander/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for commander 2.9 // Project: https://github.com/visionmedia/commander.js -// Definitions by: Alan Agius , Marcelo Dezem , vvakame +// Definitions by: Alan Agius , Marcelo Dezem , vvakame // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// diff --git a/types/commonmark/commonmark-tests.ts b/types/commonmark/commonmark-tests.ts index 8d3a3a5447..b85eb16ace 100644 --- a/types/commonmark/commonmark-tests.ts +++ b/types/commonmark/commonmark-tests.ts @@ -26,18 +26,18 @@ function logNode(node: commonmark.Node) { const parser = new commonmark.Parser({ smart: true, time: true }); const node = parser.parse('# a piece of _markdown_'); -let w = node.walker(); -let step = w.next(); +const w = node.walker(); +const step = w.next(); if (step.entering) { logNode(step.node); } -let xmlRenderer = new commonmark.XmlRenderer({ sourcepos: true, time: true }); -let xml = xmlRenderer.render(node); +const xmlRenderer = new commonmark.XmlRenderer({ sourcepos: true, time: true }); +const xml = xmlRenderer.render(node); console.log(xml); -let htmlRenderer = new commonmark.HtmlRenderer({ safe: true, smart: true, sourcepos: true, time: true }); -let html = htmlRenderer.render(node); +const htmlRenderer = new commonmark.HtmlRenderer({ safe: true, smart: true, sourcepos: true, time: true }); +const html = htmlRenderer.render(node); console.log(html); function basic_usage() { diff --git a/types/compare-version/index.d.ts b/types/compare-version/index.d.ts index 1807abe537..5a2639a7c8 100644 --- a/types/compare-version/index.d.ts +++ b/types/compare-version/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for compare-version v0.1.2 // Project: https://www.npmjs.com/package/compare-version -// Definitions by: Jonathan Pevarnek +// Definitions by: Jonathan Pevarnek // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/component-emitter/index.d.ts b/types/component-emitter/index.d.ts index 52f8f05655..95682f6ca4 100644 --- a/types/component-emitter/index.d.ts +++ b/types/component-emitter/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for component-emitter v1.2.1 // Project: https://www.npmjs.com/package/component-emitter -// Definitions by: Peter Snider +// Definitions by: Peter Snider // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped/emitter-component diff --git a/types/compressible/compressible-tests.ts b/types/compressible/compressible-tests.ts new file mode 100644 index 0000000000..d793f8d877 --- /dev/null +++ b/types/compressible/compressible-tests.ts @@ -0,0 +1,5 @@ +import compressible = require('compressible'); + +// $ExpectType boolean | undefined +compressible('text/html'); +compressible('image/png'); diff --git a/types/compressible/index.d.ts b/types/compressible/index.d.ts new file mode 100644 index 0000000000..fe0d27ae23 --- /dev/null +++ b/types/compressible/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for compressible 2.0 +// Project: https://github.com/jshttp/compressible#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = compressible; + +declare function compressible(type: string): boolean | undefined; diff --git a/types/compressible/tsconfig.json b/types/compressible/tsconfig.json new file mode 100644 index 0000000000..fb011bf968 --- /dev/null +++ b/types/compressible/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "compressible-tests.ts" + ] +} diff --git a/types/compressible/tslint.json b/types/compressible/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/compressible/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/compression/index.d.ts b/types/compression/index.d.ts index 5099a3fb1b..75c37d4374 100644 --- a/types/compression/index.d.ts +++ b/types/compression/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for compression // Project: https://github.com/expressjs/compression -// Definitions by: Santi Albo +// Definitions by: Santi Albo // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import * as express from 'express'; diff --git a/types/concat-stream/concat-stream-tests.ts b/types/concat-stream/concat-stream-tests.ts index 4f3bf839e0..b89cde817b 100644 --- a/types/concat-stream/concat-stream-tests.ts +++ b/types/concat-stream/concat-stream-tests.ts @@ -3,7 +3,7 @@ import concat = require("concat-stream"); import { Readable } from "stream"; class MyReadable extends Readable { - i: number = 1; + i = 1; _read() { if (this.i <= 100) { this.push(this.i.toString()); diff --git a/types/conf/conf-tests.ts b/types/conf/conf-tests.ts index 0b9f49ff79..1da0e4de2d 100644 --- a/types/conf/conf-tests.ts +++ b/types/conf/conf-tests.ts @@ -1,19 +1,41 @@ import Conf = require('conf'); -const conf = new Conf(); +const conf = new Conf(); +new Conf({ + defaults: { + foo: 'bar', + unicorn: 'rainbow' + }, + configName: '', + projectName: 'foo', + cwd: '' +}); +// $ExpectError +new Conf({ + defaults: { + foo: 'bar', + unicorn: ['rainbow'] + } +}); conf.set('foo', 'bar'); conf.set('hello', 1); conf.set('unicorn', false); -conf.set('object', { - foo: 'bar', - unicorn: ['rainbow'] -}); +conf.set('null', null); // $ExpectError -conf.get('foo'); +conf.get('foo'); // $ExpectType string | number | boolean +conf.get('foo', 'bar'); // $ExpectType string | number | boolean +conf.get('foo', null); // $ExpectError conf.delete('foo'); -conf.has('foo'); +conf.has('foo'); // $ExpectType boolean conf.clear(); -for (const value of conf) { - console.log(value[0], value[1]); +conf.store = { + foo: 'bar', + unicorn: 'rainbow' +}; +conf.path; // $ExpectType string + +for (const [key, value] of conf) { + key; // $ExpectType string + value; // $ExpectType string | number | boolean } diff --git a/types/conf/index.d.ts b/types/conf/index.d.ts index 21c136e823..9f88a88355 100644 --- a/types/conf/index.d.ts +++ b/types/conf/index.d.ts @@ -1,29 +1,30 @@ -// Type definitions for conf 0.11 +// Type definitions for conf 1.1 // Project: https://github.com/sindresorhus/conf // Definitions by: Sam Verschueren +// BendingBender // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 -interface Options { - defaults?: any; +interface Options { + defaults?: {[key: string]: T}; configName?: string; projectName?: string; cwd?: string; } -declare class Conf implements Iterable<[string, string | number | boolean | symbol | {}]> { - path: string; - store: any; - +declare class Conf implements Iterable<[string, T]> { + store: {[key: string]: T}; + readonly path: string; readonly size: number; - constructor(options?: Options); - get(key: string): any; - set(key: string, val: string | number | boolean | symbol | {}): void; - set(object: {}): void; + constructor(options?: Options); + get(key: string, defaultValue?: T): T; + set(key: string, val: T): void; + set(object: {[key: string]: T}): void; has(key: string): boolean; delete(key: string): void; clear(): void; - [Symbol.iterator](): Iterator<[string, string | number | boolean | symbol | {}]>; + [Symbol.iterator](): Iterator<[string, T]>; } export = Conf; diff --git a/types/conf/tsconfig.json b/types/conf/tsconfig.json index 8ef2367ca4..d165e88ea2 100644 --- a/types/conf/tsconfig.json +++ b/types/conf/tsconfig.json @@ -2,13 +2,12 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6", - "dom" + "es6" ], "target": "es6", "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -21,4 +20,4 @@ "index.d.ts", "conf-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/conf/v0/conf-tests.ts b/types/conf/v0/conf-tests.ts new file mode 100644 index 0000000000..1368e45c29 --- /dev/null +++ b/types/conf/v0/conf-tests.ts @@ -0,0 +1,20 @@ +import Conf = require('conf'); + +const conf = new Conf(); +conf.set('foo', 'bar'); +conf.set('hello', 1); +conf.set('unicorn', false); +conf.set('object', { + foo: 'bar', + unicorn: ['rainbow'] +}); + +conf.get('foo'); +conf.delete('foo'); +conf.has('foo'); +conf.clear(); + +for (const [key, value] of conf) { + key; // $ExpectType string + value; // $ExpectType string | number | boolean | symbol | {} +} diff --git a/types/conf/v0/index.d.ts b/types/conf/v0/index.d.ts new file mode 100644 index 0000000000..21c136e823 --- /dev/null +++ b/types/conf/v0/index.d.ts @@ -0,0 +1,29 @@ +// Type definitions for conf 0.11 +// Project: https://github.com/sindresorhus/conf +// Definitions by: Sam Verschueren +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +interface Options { + defaults?: any; + configName?: string; + projectName?: string; + cwd?: string; +} + +declare class Conf implements Iterable<[string, string | number | boolean | symbol | {}]> { + path: string; + store: any; + + readonly size: number; + + constructor(options?: Options); + get(key: string): any; + set(key: string, val: string | number | boolean | symbol | {}): void; + set(object: {}): void; + has(key: string): boolean; + delete(key: string): void; + clear(): void; + [Symbol.iterator](): Iterator<[string, string | number | boolean | symbol | {}]>; +} + +export = Conf; diff --git a/types/conf/v0/tsconfig.json b/types/conf/v0/tsconfig.json new file mode 100644 index 0000000000..6047f464f4 --- /dev/null +++ b/types/conf/v0/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "paths": { + "conf": ["conf/v0"] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "conf-tests.ts" + ] +} diff --git a/types/conf/v0/tslint.json b/types/conf/v0/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/conf/v0/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/confit/index.d.ts b/types/confit/index.d.ts index b78bd88727..14e2940ad4 100644 --- a/types/confit/index.d.ts +++ b/types/confit/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Confit 2.x // Project: https://github.com/krakenjs/confit -// Definitions by: Ethan Resnick +// Definitions by: Ethan Resnick // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module "confit" { diff --git a/types/connect-flash/connect-flash-tests.ts b/types/connect-flash/connect-flash-tests.ts index 0f22c0cdd5..2b75c4ed77 100644 --- a/types/connect-flash/connect-flash-tests.ts +++ b/types/connect-flash/connect-flash-tests.ts @@ -13,4 +13,5 @@ app.use(flash({ app.use(function(req: Express.Request, res: Express.Response, next: Function) { req.flash('Message'); req.flash('info', 'Message'); + req.flash(); }); diff --git a/types/connect-flash/index.d.ts b/types/connect-flash/index.d.ts index 1a10aae6db..cb7d460623 100644 --- a/types/connect-flash/index.d.ts +++ b/types/connect-flash/index.d.ts @@ -1,12 +1,13 @@ // Type definitions for connect-flash // Project: https://github.com/jaredhanson/connect-flash -// Definitions by: Andreas Gassmann +// Definitions by: Andreas Gassmann // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// declare namespace Express { export interface Request { + flash(): { [key: string]: string[] }; flash(message: string): any; flash(event: string, message: string): any; } diff --git a/types/connect-history-api-fallback/connect-history-api-fallback-tests.ts b/types/connect-history-api-fallback/connect-history-api-fallback-tests.ts index 382e436366..6095d2fecb 100644 --- a/types/connect-history-api-fallback/connect-history-api-fallback-tests.ts +++ b/types/connect-history-api-fallback/connect-history-api-fallback-tests.ts @@ -57,7 +57,7 @@ historyApiFallback({ { from: /^\/libs\/(.*)$/, to(context) { - return '/' + context.match[2] + '/' + context.match[3]; + return `/${context.match[2]}/${context.match[3]}`; } } ] diff --git a/types/connect-livereload/index.d.ts b/types/connect-livereload/index.d.ts index 993e610b04..b0dadcfcc8 100644 --- a/types/connect-livereload/index.d.ts +++ b/types/connect-livereload/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for connect-livereload v0.5.3 // Project: https://github.com/intesso/connect-livereload -// Definitions by: Maxime LUCE +// Definitions by: Maxime LUCE // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/connect-modrewrite/index.d.ts b/types/connect-modrewrite/index.d.ts index 00a8b4fe46..41372046d1 100644 --- a/types/connect-modrewrite/index.d.ts +++ b/types/connect-modrewrite/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for connect-modrewrite // Project: https://github.com/tinganho/connect-modrewrite -// Definitions by: Tingan Ho +// Definitions by: Tingan Ho // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/connect/index.d.ts b/types/connect/index.d.ts index 66c5b7562c..8cebd6ba78 100644 --- a/types/connect/index.d.ts +++ b/types/connect/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for connect v3.4.0 // Project: https://github.com/senchalabs/connect -// Definitions by: Maxime LUCE +// Definitions by: Maxime LUCE // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// diff --git a/types/console-stamp/index.d.ts b/types/console-stamp/index.d.ts index ff6571330d..c7b9547cc8 100644 --- a/types/console-stamp/index.d.ts +++ b/types/console-stamp/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for console-stamp 0.2.0 // Project: https://github.com/starak/node-console-stamp -// Definitions by: Eric Byers +// Definitions by: Eric Byers // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/content-type/content-type-tests.ts b/types/content-type/content-type-tests.ts index 0705d440c1..4be9519a94 100644 --- a/types/content-type/content-type-tests.ts +++ b/types/content-type/content-type-tests.ts @@ -1,18 +1,19 @@ -import contentType = require('content-type'); -import express = require('express'); +/// -let obj = contentType.parse('image/svg+xml; charset=utf-8'); +import * as contentType from 'content-type'; +import * as http from 'http'; -console.log(obj.type); // => 'image/svg+xml' -console.log(obj.parameters.charset); // => 'utf-8' +const mediaType = contentType.parse('image/svg+xml; charset=utf-8'); +mediaType; // $ExpectType ParsedMediaType +mediaType.type; // $ExpectType string +mediaType.parameters; // $ExpectType { [key: string]: string; } -let req: express.Request; -obj = contentType.parse(req); +http.createServer((req, res) => { + contentType.parse(req); + contentType.parse(res); +}); -let res: express.Response; -obj = contentType.parse(res); - -let str: string = contentType.format({type: 'image/svg+xml'}); - -let media: contentType.MediaType; -contentType.format(media); +// $ExpectType string +contentType.format({type: 'image/svg+xml'}); +contentType.format({type: 'image/svg+xml', parameters: {charset: 'utf-8'}}); +contentType.format(mediaType); diff --git a/types/content-type/index.d.ts b/types/content-type/index.d.ts index ec60de446f..5ff4ae7ff1 100644 --- a/types/content-type/index.d.ts +++ b/types/content-type/index.d.ts @@ -1,21 +1,26 @@ // Type definitions for content-type 1.1 // Project: https://www.npmjs.com/package/content-type // Definitions by: Hiroki Horiuchi +// BendingBender // Definitions: https://github.com/borisyankov/DefinitelyTyped -import * as express from 'express'; +export function parse(input: RequestLike | ResponseLike | string): ParsedMediaType; +export function format(obj: MediaType): string; -declare var ct: ct.StaticFunctions; -export = ct; +export interface ParsedMediaType { + type: string; + parameters: {[key: string]: string}; +} -declare namespace ct { - interface StaticFunctions { - parse(input: express.Request | express.Response | string): MediaType; - format(obj: MediaType): string; - } +export interface MediaType { + type: string; + parameters?: {[key: string]: string}; +} - interface MediaType { - type: string; - parameters?: any; - } +export interface RequestLike { + headers: {[header: string]: string | string[]}; +} + +export interface ResponseLike { + getHeader(name: string): number | string | string[] | undefined; } diff --git a/types/content-type/tsconfig.json b/types/content-type/tsconfig.json index 4eaa2f42f4..3361989225 100644 --- a/types/content-type/tsconfig.json +++ b/types/content-type/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -19,4 +19,4 @@ "index.d.ts", "content-type-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/continuation-local-storage/continuation-local-storage-tests.ts b/types/continuation-local-storage/continuation-local-storage-tests.ts index 3d85886d73..aee44866af 100644 --- a/types/continuation-local-storage/continuation-local-storage-tests.ts +++ b/types/continuation-local-storage/continuation-local-storage-tests.ts @@ -21,7 +21,7 @@ function test(topic: string, callback: (t: Test) => any) { test("asynchronously propagating state with local-context-domains", function (t) { t.plan(2); - var namespace = cls.createNamespace('namespace'); + const namespace = cls.createNamespace('namespace'); // t.ok(process.namespaces.namespace, "namespace has been created"); namespace.run(function () { @@ -39,7 +39,7 @@ test("minimized test case that caused #6011 patch to fail", function (t) { // when the flaw was in the patch, commenting out this line would fix things: process.nextTick(function () { console.log('!'); }); - var n = cls.createNamespace("test"); + const n = cls.createNamespace("test"); t.ok(!n.get('state'), "state should not yet be visible"); n.run(function () { @@ -59,7 +59,7 @@ test("event emitters bound to CLS context", function (t) { t.test("handler registered in context, emit out of context", function (t) { t.plan(1); - var n = cls.createNamespace('in') + const n = cls.createNamespace('in') , ee = new EventEmitter() ; @@ -78,7 +78,7 @@ test("event emitters bound to CLS context", function (t) { t.test("once handler registered in context", function (t) { t.plan(1); - var n = cls.createNamespace('inOnce') + const n = cls.createNamespace('inOnce') , ee = new EventEmitter() ; @@ -97,7 +97,7 @@ test("event emitters bound to CLS context", function (t) { t.test("handler registered out of context, emit in context", function (t) { t.plan(1); - var n = cls.createNamespace('out') + const n = cls.createNamespace('out') , ee = new EventEmitter() ; @@ -117,7 +117,7 @@ test("event emitters bound to CLS context", function (t) { t.test("once handler registered out of context", function (t) { t.plan(1); - var n = cls.createNamespace('outOnce') + const n = cls.createNamespace('outOnce') , ee = new EventEmitter() ; @@ -137,7 +137,7 @@ test("event emitters bound to CLS context", function (t) { t.test("handler registered out of context, emit out of context", function (t) { t.plan(1); - var n = cls.createNamespace('out') + const n = cls.createNamespace('out') , ee = new EventEmitter() ; @@ -155,12 +155,12 @@ test("event emitters bound to CLS context", function (t) { }); t.test("once handler registered out of context on Readable", function (t) { - var Readable = require('stream').Readable; + const Readable = require('stream').Readable; if (Readable) { t.plan(12); - var n = cls.createNamespace('outOnceReadable') + const n = cls.createNamespace('outOnceReadable') , re = new Readable() ; @@ -203,7 +203,7 @@ test("event emitters bound to CLS context", function (t) { t.test("emitter with newListener that removes handler", function (t) { t.plan(3); - var n = cls.createNamespace('newListener') + const n = cls.createNamespace('newListener') , ee = new EventEmitter() ; @@ -239,12 +239,12 @@ test("event emitters bound to CLS context", function (t) { }); t.test("handler registered in context on Readable", function (t) { - var Readable = require('stream').Readable; + const Readable = require('stream').Readable; if (Readable) { t.plan(12); - var n = cls.createNamespace('outOnReadable') + const n = cls.createNamespace('outOnReadable') , re = new Readable() ; @@ -288,7 +288,7 @@ test("event emitters bound to CLS context", function (t) { t.test("handler added but used entirely out of context", function (t) { t.plan(2); - var n = cls.createNamespace('none') + const n = cls.createNamespace('none') , ee = new EventEmitter() ; @@ -309,12 +309,12 @@ test("event emitters bound to CLS context", function (t) { t.test("handler added but no listeners registered", function (t) { t.plan(3); - var http = require('http') + const http = require('http') , n = cls.createNamespace('no_listener') ; // only fails on Node < 0.10 - var server = http.createServer(function (req: any, res: any) { + const server = http.createServer(function (req: any, res: any) { n.bindEmitter(req); t.doesNotThrow(function () { @@ -342,7 +342,7 @@ test("event emitters bound to CLS context", function (t) { t.test("listener with parameters added but not bound to context", function (t) { t.plan(2); - var ee = new EventEmitter() + const ee = new EventEmitter() , n = cls.createNamespace('param_list') ; @@ -361,7 +361,7 @@ test("event emitters bound to CLS context", function (t) { t.test("listener that throws doesn't leave removeListener wrapped", function (t) { t.plan(4); - var ee = new EventEmitter() + const ee = new EventEmitter() , n = cls.createNamespace('kaboom') ; @@ -385,7 +385,7 @@ test("event emitters bound to CLS context", function (t) { t.test("emitter bound to multiple namespaces handles them correctly", function (t) { t.plan(8); - var ee = new EventEmitter() + const ee = new EventEmitter() , ns1 = cls.createNamespace('1') , ns2 = cls.createNamespace('2') ; @@ -430,7 +430,7 @@ test("event emitters bound to CLS context", function (t) { // multiple contexts in use test("simple tracer built on contexts", function (t) { - var tracer = cls.createNamespace('tracer'); + const tracer = cls.createNamespace('tracer'); class Trace { harvester: any; @@ -438,7 +438,7 @@ test("simple tracer built on contexts", function (t) { this.harvester = harvester; } runHandler(callback: any) { - var wrapped = tracer.bind(function () { + const wrapped = tracer.bind(function () { callback(); this.harvester.emit('finished', tracer.get('transaction')); }.bind(this)); @@ -448,8 +448,8 @@ test("simple tracer built on contexts", function (t) { t.plan(6); - var harvester = new EventEmitter(); - var trace = new Trace(harvester); + const harvester = new EventEmitter(); + const trace = new Trace(harvester); harvester.on('finished', function (transaction: any) { t.ok(transaction, "transaction should have been passed in"); diff --git a/types/continuation-local-storage/tsconfig.json b/types/continuation-local-storage/tsconfig.json index 130110c3b9..0bf318d3e8 100644 --- a/types/continuation-local-storage/tsconfig.json +++ b/types/continuation-local-storage/tsconfig.json @@ -1,7 +1,6 @@ { "compilerOptions": { "module": "commonjs", - "moduleResolution": "node", "lib": [ "es6" ], diff --git a/types/continuation-local-storage/tslint.json b/types/continuation-local-storage/tslint.json index 4b7077d438..0c26acc12f 100644 --- a/types/continuation-local-storage/tslint.json +++ b/types/continuation-local-storage/tslint.json @@ -7,6 +7,7 @@ "one-variable-per-declaration": false, "space-before-function-paren": false, "no-var": false, - "interface-over-type-literal": false + "interface-over-type-literal": false, + "no-unnecessary-generics": false } } diff --git a/types/convert-hrtime/convert-hrtime-tests.ts b/types/convert-hrtime/convert-hrtime-tests.ts new file mode 100644 index 0000000000..986b427027 --- /dev/null +++ b/types/convert-hrtime/convert-hrtime-tests.ts @@ -0,0 +1,9 @@ +/// + +import convertHrtime = require('convert-hrtime'); + +const time = convertHrtime(process.hrtime(process.hrtime())); +let num: number; +num = time.seconds; +num = time.milliseconds; +num = time.nanoseconds; diff --git a/types/convert-hrtime/index.d.ts b/types/convert-hrtime/index.d.ts new file mode 100644 index 0000000000..a23d222eec --- /dev/null +++ b/types/convert-hrtime/index.d.ts @@ -0,0 +1,16 @@ +// Type definitions for convert-hrtime 2.0 +// Project: https://github.com/sindresorhus/convert-hrtime#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = convertHrtime; + +declare function convertHrtime(hrtime: [number, number]): convertHrtime.HRTime; + +declare namespace convertHrtime { + interface HRTime { + seconds: number; + milliseconds: number; + nanoseconds: number; + } +} diff --git a/types/convert-hrtime/tsconfig.json b/types/convert-hrtime/tsconfig.json new file mode 100644 index 0000000000..08efd1ab39 --- /dev/null +++ b/types/convert-hrtime/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "convert-hrtime-tests.ts" + ] +} diff --git a/types/convert-hrtime/tslint.json b/types/convert-hrtime/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/convert-hrtime/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/convert-source-map/index.d.ts b/types/convert-source-map/index.d.ts index 9576e5a08f..6b1346b61f 100644 --- a/types/convert-source-map/index.d.ts +++ b/types/convert-source-map/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for convert-source-map 1.3 +// Type definitions for convert-source-map 1.5 // Project: https://github.com/thlorenz/convert-source-map -// Definitions by: Andrew Gaspar , Melvin Groenhoff , TeamworkGuy2 +// Definitions by: Andrew Gaspar , Melvin Groenhoff , TeamworkGuy2 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /** Converts a source-map from/to different formats and allows adding/changing properties. @@ -47,17 +47,14 @@ export function fromBase64(base64: string): SourceMapConverter; /** Returns source map converter from given base64 encoded json string prefixed with //# sourceMappingURL=... */ export function fromComment(comment: string): SourceMapConverter; -/**Returns source map converter from given filename by parsing //# sourceMappingURL=filename. +/** Returns source map converter from given filename by parsing //# sourceMappingURL=filename. * filename must point to a file that is found inside the mapFileDir. Most tools store this file right next to the generated file, i.e. the one containing the source map. */ export function fromMapFileComment(comment: string, commentFileDir: string): SourceMapConverter; /** Finds last sourcemap comment in file and returns source map converter or returns null if no source map comment was found. - * If largeSource is set to true, an algorithm that does not use regex is applied to find the source map. - * This is faster and especially useful if you're running into "call stack size exceeded" errors with the default algorithm. - * However, it is less accurate and may match content that isn't a source map comment. */ -export function fromSource(content: string, largeSource?: boolean): SourceMapConverter | null; +export function fromSource(content: string): SourceMapConverter | null; /** Finds last sourcemap comment in file and returns source map converter or returns null if no source map comment was found. * The sourcemap will be read from the map file found by parsing # sourceMappingURL=file comment. For more info see fromMapFileComment. @@ -70,10 +67,10 @@ export function removeComments(src: string): string; /** Returns src with all source map comments pointing to map files removed */ export function removeMapFileComments(src: string): string; -/** Returns the regex used to find source map comments */ +/** Returns a new regex used to find source map comments */ export const commentRegex: RegExp; -/** Returns the regex used to find source map comments pointing to map files */ +/** Returns a new regex used to find source map comments pointing to map files */ export const mapFileCommentRegex: RegExp; /** Returns a comment that links to an external source map via file. diff --git a/types/convict/convict-tests.ts b/types/convict/convict-tests.ts index daa07c6875..98a107d8e8 100644 --- a/types/convict/convict-tests.ts +++ b/types/convict/convict-tests.ts @@ -35,7 +35,7 @@ convict.addFormats({ } }); -let conf = convict({ +const conf = convict({ env: { doc: 'The applicaton environment.', format: ['production', 'development', 'test'], @@ -98,9 +98,9 @@ let conf = convict({ // load environment dependent configuration -let env = conf.get('env'); -let dbip = conf.get('db.ip'); -conf.loadFile('./config/' + env + '.json'); +const env = conf.get('env'); +const dbip = conf.get('db.ip'); +conf.loadFile(`./config/${env}.json`); conf.loadFile(['./configs/always.json', './configs/sometimes.json']); // perform validation @@ -113,13 +113,13 @@ conf.validate({ allowed: 'warn' }); conf .loadFile(['./configs/always.json', './configs/sometimes.json']) - .loadFile('./config/' + env + '.json') + .loadFile(`./config/${env}.json`) .load({ jsonKey: 'jsonValue' }) .set('key', 'value') .validate({ allowed: 'warn' }) .toString(); -let port: number = conf.default('port'); +const port: number = conf.default('port'); if (conf.has('key')) { conf.set('the.awesome', true); diff --git a/types/convict/index.d.ts b/types/convict/index.d.ts index 183d91ed91..d7904ec5d6 100644 --- a/types/convict/index.d.ts +++ b/types/convict/index.d.ts @@ -28,7 +28,7 @@ declare namespace convict { } interface Schema { - [name: string]: convict.Schema | { + [name: string]: Schema | { default: any; doc?: string; /** diff --git a/types/cookie-parser/index.d.ts b/types/cookie-parser/index.d.ts index b2520080b0..9d0c6c1f0a 100644 --- a/types/cookie-parser/index.d.ts +++ b/types/cookie-parser/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for cookie-parser 1.4 // Project: https://github.com/expressjs/cookie-parser -// Definitions by: Santi Albo +// Definitions by: Santi Albo // BendingBender // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 diff --git a/types/cookie-session/index.d.ts b/types/cookie-session/index.d.ts index b0f4a1060e..29562d0320 100644 --- a/types/cookie-session/index.d.ts +++ b/types/cookie-session/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for cookie-session 2.0 // Project: https://github.com/expressjs/cookie-session -// Definitions by: Borislav Zhivkov +// Definitions by: Borislav Zhivkov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// diff --git a/types/cookies/cookies-tests.ts b/types/cookies/cookies-tests.ts index c65bcbd4aa..2f78f8ad49 100644 --- a/types/cookies/cookies-tests.ts +++ b/types/cookies/cookies-tests.ts @@ -1,26 +1,39 @@ import * as Cookies from 'cookies'; import * as http from 'http'; +import * as Keygrip from 'keygrip'; +import * as express from 'express'; +import * as connect from 'connect'; const server = http.createServer((req, res) => { const cookies = new Cookies(req, res); + new Cookies(req, res, {keys: []}); + new Cookies(req, res, {keys: new Keygrip([])}); + new Cookies(req, res, {secure: true}); + let unsigned: string; let signed: string; let tampered: string; if (req.url === "/set") { cookies - // set a regular cookie + // set a regular cookie .set("unsigned", "foo", { httpOnly: false }) - // set a signed cookie + // set a signed cookie .set("signed", "bar", { signed: true }) - // mimic a signed cookie, but with a bogus signature + // mimic a signed cookie, but with a bogus signature .set("tampered", "baz") - .set("tampered.sig", "bogus"); + .set("tampered.sig", "bogus") + + // sameSite option + .set("samesite", "same", {sameSite: 'lax'}) + .set("samesite", "same", {sameSite: 'strict'}) + .set("samesite", "same", {sameSite: false}); res.writeHead(302, { Location: "/" }); - return res.end("Now let's check."); + res.end("Now let's check."); + return; } unsigned = cookies.get("unsigned"); @@ -29,11 +42,23 @@ const server = http.createServer((req, res) => { res.writeHead(200, { "Content-Type": "text/plain" }); res.end( - "unsigned expected: foo\n\n" + - "unsigned actual: " + unsigned + "\n\n" + - "signed expected: bar\n\n" + - "signed actual: " + signed + "\n\n" + - "tampered expected: undefined\n\n" + - "tampered: " + tampered + "\n\n" - ); + `unsigned expected: foo + +unsigned actual: ${unsigned} + +signed expected: bar + +signed actual: ${signed} + +tampered expected: undefined + +tampered: ${tampered} + +`); }); + +const eApp = express(); +eApp.use(Cookies.express([])); + +const cApp = connect(); +cApp.use(Cookies.connect([])); diff --git a/types/cookies/index.d.ts b/types/cookies/index.d.ts index 55feb7ec7d..8a897cfeae 100644 --- a/types/cookies/index.d.ts +++ b/types/cookies/index.d.ts @@ -1,11 +1,15 @@ -// Type definitions for cookies 0.6 +// Type definitions for cookies 0.7 // Project: https://github.com/pillarjs/cookies -// Definitions by: Wang Zishi , jKey Lu +// Definitions by: Wang Zishi +// jKey Lu +// BendingBender // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// import { IncomingMessage, ServerResponse } from 'http'; import * as Keygrip from 'keygrip'; +import * as express from 'express'; +import * as connect from 'connect'; interface Cookies { secure: boolean; @@ -38,7 +42,7 @@ declare namespace Cookies { type IOptions = SetOption; interface Option { - keys: string[] | Keygrip; + keys?: string[] | Keygrip; secure?: boolean; } @@ -78,6 +82,11 @@ declare namespace Cookies { * and not made available to client JavaScript (true by default). */ httpOnly?: boolean; + /** + * a boolean or string indicating whether the cookie is a "same site" cookie (false by default). + * This can be set to 'strict', 'lax', or true (which maps to 'strict'). + */ + sameSite?: 'strict' | 'lax' | boolean; /** * a boolean indicating whether the cookie is to be signed (false by default). * If this is true, another cookie of the same name with the .sig suffix @@ -102,7 +111,7 @@ declare namespace Cookies { name: string; value: string; /** - * "maxage"" is deprecated, use "maxAge" instead + * "maxage" is deprecated, use "maxAge" instead */ maxage: number; maxAge: number; @@ -111,6 +120,7 @@ declare namespace Cookies { domain: string; secure: boolean; httpOnly: boolean; + sameSite: boolean; overwrite: boolean; toString(): string; @@ -146,6 +156,9 @@ interface CookiesFunction { Cookie: { new (name: string, value?: string, attrs?: Cookies.CookieAttr): Cookies.Cookie; }; + + express(keys: string[] | Keygrip): express.Handler; + connect(keys: string[] | Keygrip): connect.NextHandleFunction; } declare const Cookies: CookiesFunction; diff --git a/types/copy-text-to-clipboard/copy-text-to-clipboard-tests.ts b/types/copy-text-to-clipboard/copy-text-to-clipboard-tests.ts new file mode 100644 index 0000000000..4a1e63b28c --- /dev/null +++ b/types/copy-text-to-clipboard/copy-text-to-clipboard-tests.ts @@ -0,0 +1,8 @@ +import copy = require('copy-text-to-clipboard'); + +const button: HTMLButtonElement | null = document.getElementById('my-button'); +if (button) { + button.addEventListener('click', () => { + copy('🦄🌈'); + }); +} diff --git a/types/copy-text-to-clipboard/index.d.ts b/types/copy-text-to-clipboard/index.d.ts new file mode 100644 index 0000000000..56493778d0 --- /dev/null +++ b/types/copy-text-to-clipboard/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for copy-text-to-clipboard 1.0 +// Project: https://github.com/sindresorhus/copy-text-to-clipboard#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = copy; + +declare function copy(text: string): boolean; diff --git a/types/copy-text-to-clipboard/tsconfig.json b/types/copy-text-to-clipboard/tsconfig.json new file mode 100644 index 0000000000..71b4595292 --- /dev/null +++ b/types/copy-text-to-clipboard/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "copy-text-to-clipboard-tests.ts" + ] +} diff --git a/types/copy-text-to-clipboard/tslint.json b/types/copy-text-to-clipboard/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/copy-text-to-clipboard/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/copy-webpack-plugin/index.d.ts b/types/copy-webpack-plugin/index.d.ts index 11a3a30dd9..8bfae1e0ed 100644 --- a/types/copy-webpack-plugin/index.d.ts +++ b/types/copy-webpack-plugin/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for copy-webpack-plugin v4.0.0 // Project: https://github.com/kevlened/copy-webpack-plugin -// Definitions by: flying-sheep +// Definitions by: flying-sheep // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import { Plugin } from 'webpack' diff --git a/types/cordova-plugin-app-version/index.d.ts b/types/cordova-plugin-app-version/index.d.ts index b30beef9c6..ea727815a4 100644 --- a/types/cordova-plugin-app-version/index.d.ts +++ b/types/cordova-plugin-app-version/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for cordova-plugin-app-version v0.1.7 // Project: https://github.com/whiteoctober/cordova-plugin-app-version -// Definitions by: Markus Wagner +// Definitions by: Markus Wagner // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped interface Cordova { diff --git a/types/cordova-plugin-battery-status/tsconfig.json b/types/cordova-plugin-battery-status/tsconfig.json index cac92776c8..dc873349a3 100644 --- a/types/cordova-plugin-battery-status/tsconfig.json +++ b/types/cordova-plugin-battery-status/tsconfig.json @@ -8,6 +8,11 @@ "noImplicitAny": false, "noImplicitThis": true, "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/types/cordova-plugin-camera/tsconfig.json b/types/cordova-plugin-camera/tsconfig.json index d0afcc73be..e54cb67d89 100644 --- a/types/cordova-plugin-camera/tsconfig.json +++ b/types/cordova-plugin-camera/tsconfig.json @@ -5,9 +5,14 @@ "es6", "dom" ], - "noImplicitAny": false, + "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/types/cordova-plugin-contacts/tsconfig.json b/types/cordova-plugin-contacts/tsconfig.json index b582025b43..76ef345600 100644 --- a/types/cordova-plugin-contacts/tsconfig.json +++ b/types/cordova-plugin-contacts/tsconfig.json @@ -8,6 +8,11 @@ "noImplicitAny": false, "noImplicitThis": true, "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/types/cordova-plugin-device-motion/tsconfig.json b/types/cordova-plugin-device-motion/tsconfig.json index a7dab35ed9..7330314961 100644 --- a/types/cordova-plugin-device-motion/tsconfig.json +++ b/types/cordova-plugin-device-motion/tsconfig.json @@ -8,6 +8,11 @@ "noImplicitAny": false, "noImplicitThis": true, "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/types/cordova-plugin-device/tsconfig.json b/types/cordova-plugin-device/tsconfig.json index 1ef065998e..3265c8b5b8 100644 --- a/types/cordova-plugin-device/tsconfig.json +++ b/types/cordova-plugin-device/tsconfig.json @@ -8,6 +8,11 @@ "noImplicitAny": false, "noImplicitThis": true, "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/types/cordova-plugin-dialogs/tsconfig.json b/types/cordova-plugin-dialogs/tsconfig.json index 0e77b0519a..1f11e8d304 100644 --- a/types/cordova-plugin-dialogs/tsconfig.json +++ b/types/cordova-plugin-dialogs/tsconfig.json @@ -8,6 +8,11 @@ "noImplicitAny": false, "noImplicitThis": true, "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/types/cordova-plugin-globalization/tsconfig.json b/types/cordova-plugin-globalization/tsconfig.json index 790fa07cb9..d9317cc455 100644 --- a/types/cordova-plugin-globalization/tsconfig.json +++ b/types/cordova-plugin-globalization/tsconfig.json @@ -8,6 +8,11 @@ "noImplicitAny": false, "noImplicitThis": true, "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/types/cordova-plugin-ibeacon/index.d.ts b/types/cordova-plugin-ibeacon/index.d.ts index 3530ccb70d..eb2115448d 100644 --- a/types/cordova-plugin-ibeacon/index.d.ts +++ b/types/cordova-plugin-ibeacon/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for cordova-plugin-ibeacon v3.3.0 // Project: https://github.com/petermetz/cordova-plugin-ibeacon -// Definitions by: Markus Wagner +// Definitions by: Markus Wagner // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import * as Q from "q"; diff --git a/types/cordova-plugin-inappbrowser/cordova-plugin-inappbrowser-tests.ts b/types/cordova-plugin-inappbrowser/cordova-plugin-inappbrowser-tests.ts index 1497eec386..2506df887d 100644 --- a/types/cordova-plugin-inappbrowser/cordova-plugin-inappbrowser-tests.ts +++ b/types/cordova-plugin-inappbrowser/cordova-plugin-inappbrowser-tests.ts @@ -4,7 +4,7 @@ // signature of window.open() added by InAppBrowser plugin // is similar to native window.open signature, so the compiler can's // select proper overload, but we cast result to InAppBrowser manually. -const iab = window.open('google.com', '_self'); +const iab = window.open('google.com', '_self'); iab.addEventListener('loadstart', (ev: InAppBrowserEvent) => { console.log('Start opening ' + ev.url); }); iab.addEventListener('loadstart', (ev) => { console.log('loadstart' + ev.url); }); diff --git a/types/cordova-plugin-inappbrowser/tsconfig.json b/types/cordova-plugin-inappbrowser/tsconfig.json index 7375c17d5e..fc11c3516e 100644 --- a/types/cordova-plugin-inappbrowser/tsconfig.json +++ b/types/cordova-plugin-inappbrowser/tsconfig.json @@ -8,6 +8,11 @@ "noImplicitAny": false, "noImplicitThis": true, "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/types/cordova-plugin-inappbrowser/tslint.json b/types/cordova-plugin-inappbrowser/tslint.json index 3db14f85ea..946c3b6691 100644 --- a/types/cordova-plugin-inappbrowser/tslint.json +++ b/types/cordova-plugin-inappbrowser/tslint.json @@ -1 +1,7 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + // TODO + "dt-header": false + } +} diff --git a/types/cordova-plugin-insomnia/index.d.ts b/types/cordova-plugin-insomnia/index.d.ts index 3b5fbd9e4d..122511e519 100644 --- a/types/cordova-plugin-insomnia/index.d.ts +++ b/types/cordova-plugin-insomnia/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Insomnia-PhoneGap-Plugin v4.0.1 // Project: https://github.com/EddyVerbruggen/Insomnia-PhoneGap-Plugin/ -// Definitions by: Markus Wagner +// Definitions by: Markus Wagner // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped interface Window { diff --git a/types/cordova-plugin-keyboard/tsconfig.json b/types/cordova-plugin-keyboard/tsconfig.json index f779a05b7a..d5003a2452 100644 --- a/types/cordova-plugin-keyboard/tsconfig.json +++ b/types/cordova-plugin-keyboard/tsconfig.json @@ -8,6 +8,11 @@ "noImplicitAny": false, "noImplicitThis": true, "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/types/cordova-plugin-mapsforge/index.d.ts b/types/cordova-plugin-mapsforge/index.d.ts index e4c5d02eee..79f3ac6735 100644 --- a/types/cordova-plugin-mapsforge/index.d.ts +++ b/types/cordova-plugin-mapsforge/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for cordova-plugin-mapsforge // Project: https://github.com/afsuarez/mapsforge-cordova-plugin -// Definitions by: rafw87 +// Definitions by: rafw87 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped interface Window { diff --git a/types/cordova-plugin-media/tsconfig.json b/types/cordova-plugin-media/tsconfig.json index 31ca665ed4..75eb223a75 100644 --- a/types/cordova-plugin-media/tsconfig.json +++ b/types/cordova-plugin-media/tsconfig.json @@ -8,6 +8,11 @@ "noImplicitAny": false, "noImplicitThis": true, "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/types/cordova-plugin-qrscanner/index.d.ts b/types/cordova-plugin-qrscanner/index.d.ts index 0f2a498a9c..d61777f3a4 100644 --- a/types/cordova-plugin-qrscanner/index.d.ts +++ b/types/cordova-plugin-qrscanner/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for cordova-plugin-qrscanner v1.0.1 // Project: https://github.com/bitpay/cordova-plugin-qrscanner -// Definitions by: Jason Dreyzehner +// Definitions by: Jason Dreyzehner // Josh Bronson // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/cordova-plugin-splashscreen/tsconfig.json b/types/cordova-plugin-splashscreen/tsconfig.json index c3c3c5836a..20313323c0 100644 --- a/types/cordova-plugin-splashscreen/tsconfig.json +++ b/types/cordova-plugin-splashscreen/tsconfig.json @@ -8,6 +8,11 @@ "noImplicitAny": false, "noImplicitThis": true, "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/types/cordova-plugin-statusbar/tsconfig.json b/types/cordova-plugin-statusbar/tsconfig.json index daeea4a492..0518e44a96 100644 --- a/types/cordova-plugin-statusbar/tsconfig.json +++ b/types/cordova-plugin-statusbar/tsconfig.json @@ -8,6 +8,11 @@ "noImplicitAny": false, "noImplicitThis": true, "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/types/cordova-plugin-vibration/index.d.ts b/types/cordova-plugin-vibration/index.d.ts index 192c4781f5..317576a523 100644 --- a/types/cordova-plugin-vibration/index.d.ts +++ b/types/cordova-plugin-vibration/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Apache Cordova Vibration plugin // Project: https://github.com/apache/cordova-plugin-vibration -// Definitions by: Microsoft Open Technologies Inc , Louis Lagrange +// Definitions by: Microsoft Open Technologies Inc , Louis Lagrange // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // // Copyright (c) Microsoft Open Technologies Inc diff --git a/types/cordova-plugin-vibration/tsconfig.json b/types/cordova-plugin-vibration/tsconfig.json index d0752c4764..0ea0850540 100644 --- a/types/cordova-plugin-vibration/tsconfig.json +++ b/types/cordova-plugin-vibration/tsconfig.json @@ -8,6 +8,11 @@ "noImplicitAny": false, "noImplicitThis": true, "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/types/cordova-plugin-websql/tsconfig.json b/types/cordova-plugin-websql/tsconfig.json index 7f66d4fe25..190c2aa2fb 100644 --- a/types/cordova-plugin-websql/tsconfig.json +++ b/types/cordova-plugin-websql/tsconfig.json @@ -8,6 +8,11 @@ "noImplicitAny": false, "noImplicitThis": true, "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/types/cordova-plugin-x-socialsharing/index.d.ts b/types/cordova-plugin-x-socialsharing/index.d.ts index 4560dd3f1a..a5105c898c 100644 --- a/types/cordova-plugin-x-socialsharing/index.d.ts +++ b/types/cordova-plugin-x-socialsharing/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for SocialSharing-PhoneGap-Plugin v5.1.8 // Project: https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin -// Definitions by: Markus Wagner , Larry Bahr +// Definitions by: Markus Wagner , Larry Bahr // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped interface Window { diff --git a/types/cordova-sqlite-storage/cordova-sqlite-storage-tests.ts b/types/cordova-sqlite-storage/cordova-sqlite-storage-tests.ts index 6d2e3c3454..215be1d3de 100644 --- a/types/cordova-sqlite-storage/cordova-sqlite-storage-tests.ts +++ b/types/cordova-sqlite-storage/cordova-sqlite-storage-tests.ts @@ -104,13 +104,13 @@ function sampleWithPRAGMA() { }); tx.executeSql("INSERT INTO test_table (data, data_num) VALUES (?,?)", ["test", 100], (tx, res) => { - console.log("insertId: " + res.insertId + " -- probably 1"); - console.log("rowsAffected: " + res.rowsAffected + " -- should be 1"); + console.log(`insertId: ${res.insertId} -- probably 1`); + console.log(`rowsAffected: ${res.rowsAffected} -- should be 1`); db.transaction(tx => { tx.executeSql("select count(id) as cnt from test_table;", [], (tx, res) => { - console.log("res.rows.length: " + res.rows.length + " -- should be 1"); - console.log("res.rows.item(0).cnt: " + res.rows.item(0).cnt + " -- should be 1"); + console.log(`res.rows.length: ${res.rows.length} -- should be 1`); + console.log(`res.rows.item(0).cnt: ${res.rows.item(0).cnt} -- should be 1`); }); }); @@ -135,12 +135,12 @@ function sampleWithTransactionLevelNesting() { tx.executeSql('CREATE TABLE IF NOT EXISTS test_table (id integer primary key, data text, data_num integer)'); tx.executeSql("INSERT INTO test_table (data, data_num) VALUES (?,?)", ["test", 100], (tx, res) => { - console.log("insertId: " + res.insertId + " -- probably 1"); - console.log("rowsAffected: " + res.rowsAffected + " -- should be 1"); + console.log(`insertId: ${res.insertId} -- probably 1`); + console.log(`rowsAffected: ${res.rowsAffected} -- should be 1`); tx.executeSql("select count(id) as cnt from test_table;", [], (tx, res) => { - console.log("res.rows.length: " + res.rows.length + " -- should be 1"); - console.log("res.rows.item(0).cnt: " + res.rows.item(0).cnt + " -- should be 1"); + console.log(`res.rows.length: ${res.rows.length} -- should be 1`); + console.log(`res.rows.item(0).cnt: ${res.rows.item(0).cnt} -- should be 1`); }); }, (tx, e) => { console.log("ERROR: " + e.message); diff --git a/types/cordova-sqlite-storage/index.d.ts b/types/cordova-sqlite-storage/index.d.ts index 2f78c908ff..6ba48b08d2 100644 --- a/types/cordova-sqlite-storage/index.d.ts +++ b/types/cordova-sqlite-storage/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for cordova-sqlite-storage 1.5 // Project: https://github.com/litehelpers/Cordova-sqlite-storage -// Definitions by: rafw87 +// Definitions by: rafw87 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped interface Window { diff --git a/types/cordova.plugins.diagnostic/index.d.ts b/types/cordova.plugins.diagnostic/index.d.ts index 5952b41851..e9ad96deb2 100644 --- a/types/cordova.plugins.diagnostic/index.d.ts +++ b/types/cordova.plugins.diagnostic/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for cordova.plugins.diagnostic v3.4.x // Project: https://github.com/dpa99c/cordova-diagnostic-plugin -// Definitions by: Dave Alden +// Definitions by: Dave Alden // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// diff --git a/types/core-decorators/core-decorators-tests.ts b/types/core-decorators/core-decorators-tests.ts index ef4659e56b..c617de5fcc 100644 --- a/types/core-decorators/core-decorators-tests.ts +++ b/types/core-decorators/core-decorators-tests.ts @@ -31,7 +31,7 @@ import { readonly } from 'core-decorators'; class Meal { @readonly - entree: string = 'steak'; + entree = 'steak'; } const dinner = new Meal(); @@ -155,7 +155,7 @@ class Meal2 { entree = 'steak'; @nonenumerable - cost: number = 4.44; + cost = 4.44; } const dinner2 = new Meal2(); @@ -175,7 +175,7 @@ import { nonconfigurable } from 'core-decorators'; class Meal3 { @nonconfigurable - entree: string = 'steak'; + entree = 'steak'; } const dinner3 = new Meal3(); diff --git a/types/core-decorators/tslint.json b/types/core-decorators/tslint.json index e14af8449b..bade6d465f 100644 --- a/types/core-decorators/tslint.json +++ b/types/core-decorators/tslint.json @@ -1,7 +1,9 @@ { "extends": "dtslint/dt.json", "rules": { + // TODOs "callable-types": false, - "ban-types": false + "ban-types": false, + "no-duplicate-imports": false } } diff --git a/types/core-js/core-js-tests.ts b/types/core-js/core-js-tests.ts index 325ff56fc1..32eb2d502c 100644 --- a/types/core-js/core-js-tests.ts +++ b/types/core-js/core-js-tests.ts @@ -59,7 +59,7 @@ let dictOfAny: Dict; // es6.object.to-string, es6.function.name and es6.function.has-instance. // ############################################################################################# -point = Object.assign(point, point); +point = Object.assign(point, point); // tslint:disable-line prefer-object-spread b = Object.is(point, point); Object.setPrototypeOf(point, point); s = f.name; diff --git a/types/core-js/index.d.ts b/types/core-js/index.d.ts index 0a8f506df4..5fb9400d75 100644 --- a/types/core-js/index.d.ts +++ b/types/core-js/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for core-js 0.9 // Project: https://github.com/zloirock/core-js/ -// Definitions by: Ron Buckton , Michel Felipe +// Definitions by: Ron Buckton , Michel Felipe // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 diff --git a/types/core-js/tslint.json b/types/core-js/tslint.json index a62d0d4e68..deb0a8f9b2 100644 --- a/types/core-js/tslint.json +++ b/types/core-js/tslint.json @@ -1,6 +1,7 @@ { "extends": "dtslint/dt.json", "rules": { - "ban-types": false + "ban-types": false, + "no-unnecessary-generics": false } } diff --git a/types/cote/package.json b/types/cote/package.json index ce4365fc69..951fb5721e 100644 --- a/types/cote/package.json +++ b/types/cote/package.json @@ -1,5 +1,6 @@ { - "dependencies": { - "eventemitter2": "^4.1.0" - } -} + "private": true, + "dependencies": { + "eventemitter2": "^4.1.0" + } +} \ No newline at end of file diff --git a/types/cote/tslint.json b/types/cote/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/cote/tslint.json +++ b/types/cote/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/counterpart/counterpart-tests.ts b/types/counterpart/counterpart-tests.ts new file mode 100644 index 0000000000..db9f1cf5d6 --- /dev/null +++ b/types/counterpart/counterpart-tests.ts @@ -0,0 +1,29 @@ +import * as counterpart from 'counterpart'; + +counterpart('translation.to.be.used'); +counterpart(['translation', 'to', 'be', 'used']); + +counterpart.setSeparator('*'); + +counterpart.onTranslationNotFound((locale: string, key: string, fallback: string, scope: string) => {}); +counterpart.offTranslationNotFound((locale: string, key: string, fallback: string, scope: string) => {}); + +counterpart.setMissingEntryGenerator((value: string) => {}); + +counterpart.setLocale('es'); +counterpart.getLocale(); + +counterpart.onLocaleChange((newLocale: string, oldLocale: string) => {}); +counterpart.offLocaleChange((newLocale: string, oldLocale: string) => {}); + +counterpart.setFallbackLocale('es'); + +counterpart.registerTranslations('es', { hello: 'Hola' }); + +counterpart.registerInterpolations({ library: 'Counterpart' }); + +counterpart.setKeyTransformer((value: string, options: object) => { + return value.toUpperCase(); +}); + +counterpart.localize(new Date(), { format: 'short' }); diff --git a/types/counterpart/index.d.ts b/types/counterpart/index.d.ts new file mode 100644 index 0000000000..f09ad0708c --- /dev/null +++ b/types/counterpart/index.d.ts @@ -0,0 +1,32 @@ +// Type definitions for counterpart 0.18 +// Project: https://github.com/martinandert/counterpart +// Definitions by: santiagodoldan +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +type NotFoundHandler = (locale: string, key: string, fallback: string, scope: string) => void; +type LocaleChangeHandler = (newLocale: string, oldLocale: string) => void; + +interface Counterpart { + (key: string|string[], options?: object): string; + + setSeparator(value: string): string; + onTranslationNotFound(callback: NotFoundHandler): void; + offTranslationNotFound(callback: NotFoundHandler): void; + setMissingEntryGenerator(callback: (value: string) => void): void; + getLocale(): string; + setLocale(value: string): string; + onLocaleChange(callback: LocaleChangeHandler): void; + offLocaleChange(callback: LocaleChangeHandler): void; + setFallbackLocale(value: string|string[]): void; + registerTranslations(locale: string, data: object): void; + registerInterpolations(data: object): void; + setKeyTransformer(callback: (value: string, options: object) => string): string; + localize(date: Date, options: object): string; + Instance: Counterpart; + Translator: Counterpart; +} + +declare var counterpart: Counterpart; + +export = counterpart; diff --git a/types/counterpart/tsconfig.json b/types/counterpart/tsconfig.json new file mode 100644 index 0000000000..9f2ad836b7 --- /dev/null +++ b/types/counterpart/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "counterpart-tests.ts" + ] +} diff --git a/types/counterpart/tslint.json b/types/counterpart/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/counterpart/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/cp-file/cp-file-tests.ts b/types/cp-file/cp-file-tests.ts new file mode 100644 index 0000000000..173a650e8f --- /dev/null +++ b/types/cp-file/cp-file-tests.ts @@ -0,0 +1,19 @@ +import cpFile = require('cp-file'); + +cpFile('src/unicorn.png', 'dist/unicorn.png').then(() => {}); +cpFile('src/unicorn.png', 'dist/unicorn.png', {overwrite: false}).then(() => {}); +cpFile('src/unicorn.png', 'dist/unicorn.png') + .on('progress', data => { + let str: string; + let num: number; + + str = data.src; + str = data.dest; + num = data.size; + num = data.written; + num = data.percent; + }) + .then(() => {}); + +cpFile.sync('src/unicorn.png', 'dist/unicorn.png'); +cpFile.sync('src/unicorn.png', 'dist/unicorn.png', {overwrite: false}); diff --git a/types/cp-file/index.d.ts b/types/cp-file/index.d.ts new file mode 100644 index 0000000000..d0966f4c85 --- /dev/null +++ b/types/cp-file/index.d.ts @@ -0,0 +1,28 @@ +// Type definitions for cp-file 4.2 +// Project: https://github.com/sindresorhus/cp-file#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = cpFile; + +declare function cpFile(source: string, destination: string, options?: cpFile.Options): Promise & cpFile.ProgressEmitter; + +declare namespace cpFile { + function sync(source: string, destination: string, options?: Options): void; + + interface ProgressEmitter { + on(event: 'progress', handler: (data: ProgressData) => void): Promise; + } + + interface Options { + overwrite?: boolean; + } + + interface ProgressData { + src: string; + dest: string; + size: number; + written: number; + percent: number; + } +} diff --git a/types/cp-file/tsconfig.json b/types/cp-file/tsconfig.json new file mode 100644 index 0000000000..ab4eca94d8 --- /dev/null +++ b/types/cp-file/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "cp-file-tests.ts" + ] +} diff --git a/types/cp-file/tslint.json b/types/cp-file/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/cp-file/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/cpy/cpy-tests.ts b/types/cpy/cpy-tests.ts index 3bc0cbb32a..1800ab35bf 100644 --- a/types/cpy/cpy-tests.ts +++ b/types/cpy/cpy-tests.ts @@ -1,9 +1,18 @@ import cpy = require('cpy'); -cpy(['src/*.png', '!src/goat.png'], 'dist').then(() => { - console.log('files copied'); -}); - +cpy(['src/*.png', '!src/goat.png'], 'dist').then(() => {}); cpy('foo.js', 'destination', { - rename: basename => `prefix-${basename}` + rename: basename => `prefix-${basename}`, + cwd: '/', + parents: true, + stat: true, + overwrite: false, }); +cpy('foo.js', 'destination') + .on('progress', progress => { + let num: number; + num = progress.completedFiles; + num = progress.totalFiles; + num = progress.completedSize; + }) + .then(() => {}); diff --git a/types/cpy/index.d.ts b/types/cpy/index.d.ts index 8ef585250b..b6ca781137 100644 --- a/types/cpy/index.d.ts +++ b/types/cpy/index.d.ts @@ -1,10 +1,31 @@ -// Type definitions for cpy 5.0 +// Type definitions for cpy 5.1 // Project: https://github.com/sindresorhus/cpy#readme // Definitions by: Mohamed Hegazy +// BendingBender // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +import glob = require('glob'); +import cpFile = require('cp-file'); + export = cpy; -declare function cpy( - src: string | string[], - dest: string, - opts?: { cwd?: string, parents?: boolean, rename?(s: string): string }): Promise; +declare function cpy(files: string | string[], destination: string, opts?: cpy.Options): Promise & cpy.ProgressEmitter; + +declare namespace cpy { + interface ProgressEmitter { + on(event: 'progress', handler: (progress: ProgressData) => void): Promise; + } + + type Options = CpyOptions & glob.IOptions & cpFile.Options; + + interface CpyOptions { + cwd?: string; + parents?: boolean; + rename?: string | ((basename: string) => string); + } + + interface ProgressData { + completedFiles: number; + totalFiles: number; + completedSize: number; + } +} diff --git a/types/cpy/tsconfig.json b/types/cpy/tsconfig.json index 6cb55952aa..75f61a1e5d 100644 --- a/types/cpy/tsconfig.json +++ b/types/cpy/tsconfig.json @@ -2,8 +2,7 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6", - "dom" + "es6" ], "noImplicitAny": true, "noImplicitThis": true, @@ -20,4 +19,4 @@ "index.d.ts", "cpy-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/crypto-js/crypto-js-tests.ts b/types/crypto-js/crypto-js-tests.ts index c0c23bcc79..c36def9f90 100644 --- a/types/crypto-js/crypto-js-tests.ts +++ b/types/crypto-js/crypto-js-tests.ts @@ -1,15 +1,15 @@ import CryptoJS = require('crypto-js'); // Hashers -var str: string; -str = CryptoJS.MD5('some message'); -str = CryptoJS.MD5('some message', 'some key'); +var wordArray: CryptoJS.WordArray; +wordArray = CryptoJS.MD5('some message'); +wordArray = CryptoJS.MD5('some message', 'some key'); -str = CryptoJS.SHA1('some message'); -str = CryptoJS.SHA1('some message', 'some key', { any: true }); +wordArray = CryptoJS.SHA1('some message'); +wordArray = CryptoJS.SHA1('some message', 'some key', { any: true }); -str = CryptoJS.format.OpenSSL('some message'); -str = CryptoJS.format.OpenSSL('some message', 'some key'); +wordArray = CryptoJS.format.OpenSSL('some message'); +wordArray = CryptoJS.format.OpenSSL('some message', 'some key'); // Ciphers diff --git a/types/crypto-js/index.d.ts b/types/crypto-js/index.d.ts index 07a8d18dfc..8e80c74a07 100644 --- a/types/crypto-js/index.d.ts +++ b/types/crypto-js/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for crypto-js v3.1.4 +// Type definitions for crypto-js v3.1.8 // Project: https://github.com/evanvosberg/crypto-js -// Definitions by: Michael Zabka +// Definitions by: Michael Zabka // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export = CryptoJS; @@ -8,7 +8,7 @@ export as namespace CryptoJS; declare var CryptoJS: CryptoJS.Hashes; declare namespace CryptoJS { - type Hash = (message: string, key?: string, ...options: any[]) => string; + type Hash = (message: string, key?: string, ...options: any[]) => WordArray; interface Cipher { encrypt(message: string, secretPassphrase: string, option?: CipherOption): WordArray; decrypt(encryptedMessage: string | WordArray, secretPassphrase: string, option?: CipherOption): DecryptedMessage; @@ -30,6 +30,7 @@ declare namespace CryptoJS { salt: string; ciphertext: string; key?: string; + toString(encoder?: Encoder): string; } export type DecryptedMessage = { toString(encoder?: Encoder): string; diff --git a/types/crypto-js/test/submodule-tests.ts b/types/crypto-js/test/submodule-tests.ts index 0cfd8cd83f..423d094143 100644 --- a/types/crypto-js/test/submodule-tests.ts +++ b/types/crypto-js/test/submodule-tests.ts @@ -52,15 +52,15 @@ import PadZeroPadding = require('../pad-zeropadding'); import PadNoPadding = require('../pad-nopadding'); // Hashers -var str: string; -str = MD5('some message'); -str = MD5('some message', 'some key'); +var wordArray: CryptoJS.WordArray; +wordArray = MD5('some message'); +wordArray = MD5('some message', 'some key'); -str = SHA1('some message'); -str = SHA1('some message', 'some key', { any: true }); +wordArray = SHA1('some message'); +wordArray = SHA1('some message', 'some key', { any: true }); -str = FormatOpenSSL('some message'); -str = FormatOpenSSL('some message', 'some key'); +wordArray = FormatOpenSSL('some message'); +wordArray = FormatOpenSSL('some message', 'some key'); // Ciphers diff --git a/types/csurf/index.d.ts b/types/csurf/index.d.ts index 53b86392f1..362b4c6e8e 100644 --- a/types/csurf/index.d.ts +++ b/types/csurf/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for csurf 1.9.0 // Project: https://www.npmjs.org/package/csurf -// Definitions by: Hiroki Horiuchi +// Definitions by: Hiroki Horiuchi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// diff --git a/types/csv-stringify/csv-stringify-tests.ts b/types/csv-stringify/csv-stringify-tests.ts index e73e9abde3..803575e554 100644 --- a/types/csv-stringify/csv-stringify-tests.ts +++ b/types/csv-stringify/csv-stringify-tests.ts @@ -12,6 +12,12 @@ stringify([["1", "2", "3"], ["4", "5", "6"]], { // nothing }); +stringify([{a: "1", b: "2", c: "3"}, {c: "4", b: "5", a: "6"}], { + delimiter: "," +}, (error: Error, output: string): void => { + // nothing +}); + stringify([["1", true, new Date()], ["4", false, new Date()]], { delimiter: ",", formatters: { diff --git a/types/csv-stringify/index.d.ts b/types/csv-stringify/index.d.ts index 78c049ad3a..2e8cb32edb 100644 --- a/types/csv-stringify/index.d.ts +++ b/types/csv-stringify/index.d.ts @@ -85,7 +85,7 @@ declare function stringify(opts?: stringify.StringifyOpts): stringify.Stringifie /** * Callback version: string in --> callback with string out */ -declare function stringify(input: any[][], opts: stringify.StringifyOpts, callback: (error: Error | undefined, output: string) => void): void; -declare function stringify(input: any[][], callback: (error: Error | undefined, output: string) => void): void; +declare function stringify(input: any[][] | Array<{}>, opts: stringify.StringifyOpts, callback: (error: Error | undefined, output: string) => void): void; +declare function stringify(input: any[][] | Array<{}>, callback: (error: Error | undefined, output: string) => void): void; export = stringify; diff --git a/types/csv-stringify/tslint.json b/types/csv-stringify/tslint.json index 11584e5acd..963be749a2 100644 --- a/types/csv-stringify/tslint.json +++ b/types/csv-stringify/tslint.json @@ -1,6 +1,7 @@ { "extends": "dtslint/dt.json", "rules": { + "no-any-union": false, "prefer-method-signature": false } } diff --git a/types/csvtojson/csvtojson-tests.ts b/types/csvtojson/csvtojson-tests.ts index 5b58451fac..2d6e36c84f 100644 --- a/types/csvtojson/csvtojson-tests.ts +++ b/types/csvtojson/csvtojson-tests.ts @@ -5,7 +5,7 @@ import fs = require('fs'); ///////////////////////////// // From CSV String -const csvStr: string = `1,2,3 +const csvStr = `1,2,3 4,5,6 7,8,9`; diff --git a/types/cucumber/cucumber-tests.ts b/types/cucumber/cucumber-tests.ts index e0ecc2bed9..46531711f3 100644 --- a/types/cucumber/cucumber-tests.ts +++ b/types/cucumber/cucumber-tests.ts @@ -6,42 +6,44 @@ function StepSample() { type Table = cucumber.TableDefinition; type HookScenarioResult = cucumber.HookScenarioResult; - cucumber.defineSupportCode(function ({setWorldConstructor, defineParameterType, After, Around, Before, registerHandler, Given, When, Then}) { - setWorldConstructor(function ({attach, parameters}: any) { + cucumber.defineSupportCode(({setWorldConstructor, defineParameterType, After, Around, Before, registerHandler, Given, When, Then}) => { + setWorldConstructor(function({attach, parameters}) { this.attach = attach; this.parameters = parameters; - this.visit = function (url: string, callback: Callback) { + this.visit = (url: string, callback: Callback) => { callback(null, 'pending'); + }; + }); + + Before((scenarioResult: HookScenarioResult, callback: Callback) => { + console.log(scenarioResult.status === "failed"); + callback(); + }); + + Before({ timeout: 1000 }, (scenarioResult: HookScenarioResult, callback: Callback) => { + console.log(scenarioResult.status === "failed"); + callback(); + }); + + Around((scenarioResult: HookScenarioResult, runScenario: (error: string | null, callback?: () => void) => void) => { + if (scenarioResult.status === "failed") { + runScenario(null, () => { + console.log('finish tasks'); + }); } }); - Before(function (scenarioResult: HookScenarioResult, callback: Callback) { - console.log(scenarioResult.status === "failed"); - callback(); - }); - - Before({ timeout: 1000 }, function (scenarioResult: HookScenarioResult, callback: Callback) { - console.log(scenarioResult.status === "failed"); - callback(); - }); - - Around(function (scenarioResult: HookScenarioResult, runScenario: (error: string, callback?: Function) => void) { - scenarioResult.status === "failed" && runScenario(null, function () { - console.log('finish tasks'); - }); - }); - - After((scenarioResult: HookScenarioResult, callback?: Callback) => { + After((scenarioResult: HookScenarioResult, callback: Callback) => { console.log("After"); callback(); }); - After({ timeout: 1000 }, (scenarioResult: HookScenarioResult, callback?: Callback) => { + After({ timeout: 1000 }, (scenarioResult: HookScenarioResult, callback: Callback) => { console.log("After"); callback(); }); - registerHandler('AfterFeatures', function (event: any, callback: Function) { + registerHandler('AfterFeatures', (event: any, callback: () => void) => { callback(); }); @@ -53,15 +55,15 @@ function StepSample() { console.log(typeof x); }); - Given(/^I am on the Cucumber.js GitHub repository$/, function (callback: Callback) { + Given(/^I am on the Cucumber.js GitHub repository$/, function(callback: Callback) { this.visit('https://github.com/cucumber/cucumber-js', callback); }); - When(/^I go to the README file$/, function (title: string, callback: Callback) { + When(/^I go to the README file$/, (title: string, callback: Callback) => { callback(null, 'pending'); }); - Then(/^I should see "(.*)" as the page title$/, {timeout: 60 * 1000}, function (title: string, callback: Callback) { + Then(/^I should see "(.*)" as the page title$/, {timeout: 60 * 1000}, function(title: string, callback: Callback) { const pageTitle = this.browser.text('title'); if (title === pageTitle) { @@ -74,7 +76,7 @@ function StepSample() { // Type for data_table.js on // https://github.com/cucumber/cucumber-js/blob/a5fd8251918c278ab2e389226d165cedb44df14a/lib/cucumber/ast/data_table.js - Given(/^a table step with Table raw$/, function (table: Table) { + Given(/^a table step with Table raw$/, (table: Table) => { const expected = [ ['Cucumber', 'Cucumis sativus'], ['Burr Gherkin', 'Cucumis anguria'] @@ -83,7 +85,7 @@ function StepSample() { assert.deepEqual(actual, expected); }); - Given(/^a table step with Table rows$/, function (table: Table) { + Given(/^a table step with Table rows$/, (table: Table) => { const expected = [ ['Apricot', '5'], ['Brocolli', '2'], @@ -93,22 +95,22 @@ function StepSample() { assert.deepEqual(actual, expected); }); - Given(/^a table step with Table rowHash$/, function (table: Table) { + Given(/^a table step with Table rowHash$/, (table: Table) => { const expected = { - 'Cucumber': 'Cucumis sativus', + Cucumber: 'Cucumis sativus', 'Burr Gherkin': 'Cucumis anguria' }; - const actual: { [firstCol:string]: string } = table.rowsHash(); + const actual: { [firstCol: string]: string } = table.rowsHash(); assert.deepEqual(actual, expected); }); - Given(/^a table step$/, function (table: Table) { + Given(/^a table step$/, (table: Table) => { const expected = [ - {'Vegetable': 'Apricot', 'Rating': '5'}, - {'Vegetable': 'Brocolli', 'Rating': '2'}, - {'Vegetable': 'Cucumber', 'Rating': '10'} + {Vegetable: 'Apricot', Rating: '5'}, + {Vegetable: 'Brocolli', Rating: '2'}, + {Vegetable: 'Cucumber', Rating: '10'} ]; - const actual: { [colName:string]: string }[] = table.hashes(); + const actual: Array<{ [colName: string]: string }> = table.hashes(); assert.deepEqual(actual, expected); }); @@ -118,21 +120,19 @@ function StepSample() { typeName: 'param' }); - Given('a {param} step', function (param) { - assert.equal(param, 'PARTICULAR') + Given('a {param} step', param => { + assert.equal(param, 'PARTICULAR'); }); - }); - let fns: cucumber.SupportCodeConsumer[] = cucumber.getSupportCodeFns(); + const fns: cucumber.SupportCodeConsumer[] = cucumber.getSupportCodeFns(); cucumber.clearSupportCodeFns(); } function registerListener(): cucumber.EventListener { - let listener = Object.assign(cucumber.Listener(), { + const listener = Object.assign(cucumber.Listener(), { handleBeforeScenarioEvent: (scenario: cucumber.events.ScenarioPayload, callback: () => void) => { - // do some interesting stuff ... callback(); diff --git a/types/cucumber/index.d.ts b/types/cucumber/index.d.ts index 635a594ae5..90ed0abe4a 100644 --- a/types/cucumber/index.d.ts +++ b/types/cucumber/index.d.ts @@ -1,196 +1,124 @@ -// Type definitions for cucumber-js v2.0.0 +// Type definitions for cucumber-js 2.0 // Project: https://github.com/cucumber/cucumber-js -// Definitions by: Abraão Alves , Jan Molak , Isaiah Soung +// Definitions by: Abraão Alves +// Jan Molak +// Isaiah Soung +// BendingBender // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 -export = cucumber; +export interface CallbackStepDefinition { + pending(): PromiseLike; + (error?: any, pending?: string): void; +} -declare namespace cucumber { +export interface TableDefinition { + raw(): string[][]; + rows(): string[][]; + rowsHash(): { [firstCol: string]: string }; + hashes(): Array<{ [colName: string]: string }>; +} - export interface CallbackStepDefinition { - pending: () => PromiseLike; - (error?: any, pending?: string): void; +export type StepDefinitionParam = string | number | CallbackStepDefinition | TableDefinition; + +export type StepDefinitionCode = (this: {[key: string]: any}, ...stepArgs: StepDefinitionParam[]) => PromiseLike | any | void; + +export interface StepDefinitionOptions { + timeout?: number; +} + +export interface StepDefinitions { + Given(pattern: RegExp | string, options: StepDefinitionOptions, code: StepDefinitionCode): void; + Given(pattern: RegExp | string, code: StepDefinitionCode): void; + When(pattern: RegExp | string, options: StepDefinitionOptions, code: StepDefinitionCode): void; + When(pattern: RegExp | string, code: StepDefinitionCode): void; + Then(pattern: RegExp | string, options: StepDefinitionOptions, code: StepDefinitionCode): void; + Then(pattern: RegExp | string, code: StepDefinitionCode): void; + setDefaultTimeout(time: number): void; +} + +export interface HookScenarioResult { + duration: number; + failureException: Error; + scenario: Scenario; + status: string; + stepsResults: any; +} + +export type HookCode = (this: { [key: string]: any }, scenario: HookScenarioResult, callback?: CallbackStepDefinition) => void; + +// tslint:disable-next-line ban-types +export type AroundCode = (scenario: HookScenarioResult, runScenario?: (error: string, callback?: Function) => void) => void; + +export interface Transform { + regexp: RegExp; + transformer(arg: string): any; + typeName: string; +} + +export interface HookOptions { + timeout?: number; + tags?: any; +} + +export interface Hooks { + Before(code: HookCode): void; + Before(options: HookOptions, code: HookCode): void; + After(code: HookCode): void; + After(options: HookOptions, code: HookCode): void; + Around(code: AroundCode): void; + setDefaultTimeout(time: number): void; + // tslint:disable-next-line ban-types + setWorldConstructor(world: ((this: {[key: string]: any}, init: {attach: Function, parameters: {[key: string]: any}}) => void) | {}): void; + registerHandler(handlerOption: string, code: (event: any, callback: CallbackStepDefinition) => void): void; + registerListener(listener: EventListener): void; + defineParameterType(transform: Transform): void; +} + +export class EventListener { + hear(event: events.Event, callback: () => void): void; + hasHandlerForEvent(event: events.Event): boolean; + buildHandlerNameForEvent(event: events.Event): string; + getHandlerForEvent(event: events.Event): EventHook; + buildHandlerName(shortName: string): string; + setHandlerForEvent(shortName: string, handler: EventListener): void; +} + +export function Listener(): EventListener; + +export namespace events { + interface Event { + name: string; + data: any; } - export interface TableDefinition { - raw: () => Array>; - rows: () => Array>; - rowsHash: () => { [firstCol:string]: string }; - hashes: () => Array<{ [colName:string]: string }>; + // tslint:disable-next-line no-empty-interface + interface EventPayload { } - type StepDefinitionParam = string | number | CallbackStepDefinition | TableDefinition; - - interface StepDefinitionCode { - (...stepArgs: Array): PromiseLike | any | void; + interface FeaturesPayload extends EventPayload { + getFeatures(): any[]; // https://github.com/cucumber/cucumber-js/blob/dc698bf5bc10d591fa7adeec5fa21b2d90dc9679/lib/cucumber/runtime.js#L34 } - interface StepDefinitionOptions { - timeout?: number; - } - - export interface StepDefinitions { - Given(pattern: RegExp | string, options: StepDefinitionOptions, code: StepDefinitionCode): void; - Given(pattern: RegExp | string, code: StepDefinitionCode): void; - When(pattern: RegExp | string, options: StepDefinitionOptions, code: StepDefinitionCode): void; - When(pattern: RegExp | string, code: StepDefinitionCode): void; - Then(pattern: RegExp | string, options: StepDefinitionOptions, code: StepDefinitionCode): void; - Then(pattern: RegExp | string, code: StepDefinitionCode): void; - setDefaultTimeout(time: number): void; - } - - interface HookScenarioResult { + interface FeaturesResultPayload extends EventPayload { duration: number; - failureException: Error; - scenario: Scenario; - status: string; - stepsResults: any; + scenarioResults: any[]; + success: boolean; + stepsResults: any[]; + strict: boolean; } - interface HookCode { - (scenario: HookScenarioResult, callback?: CallbackStepDefinition): void; - } - - interface AroundCode { - (scenario: HookScenarioResult, runScenario?: (error: string, callback?: Function) => void): void; - } - - interface Transform { - regexp: RegExp; - transformer: (arg: string) => any; - typeName: string; - } - - interface HookOptions { - timeout?: number; - tags?: any; - } - - export interface Hooks { - Before(code: HookCode): void; - Before(options: HookOptions, code: HookCode): void; - After(code: HookCode): void; - After(options: HookOptions, code: HookCode): void; - Around(code: AroundCode): void; - setDefaultTimeout(time: number): void; - setWorldConstructor(world: (() => void) | ({})): void; - registerHandler(handlerOption: string, code: (event: any, callback: CallbackStepDefinition) => void): void; - registerListener(listener: EventListener): void; - defineParameterType(transform: Transform): void; - } - - export class EventListener { - hear(event: events.Event, callback: () => void): void; - hasHandlerForEvent(event: events.Event): boolean; - buildHandlerNameForEvent(event: events.Event): string; - getHandlerForEvent(event: events.Event): EventHook; - buildHandlerName(shortName: string): string; - setHandlerForEvent(shortName: string, handler: EventListener): void; - } - - export function Listener(): EventListener; - - export namespace events { - - interface Event { - name: string; - data: any; - } - - interface EventPayload { - } - - interface FeaturesPayload extends EventPayload { - getFeatures(): any[]; // https://github.com/cucumber/cucumber-js/blob/dc698bf5bc10d591fa7adeec5fa21b2d90dc9679/lib/cucumber/runtime.js#L34 - } - - interface FeaturesResultPayload extends EventPayload { - duration: number; - scenarioResults: any[]; - success: boolean; - stepsResults: any[]; - strict: boolean; - } - - interface FeaturePayload extends EventPayload { - description: string; - keyword: string; - line: number; - name: string; - tags: Tag[]; - uri: string; - scenarios: Scenario[]; - } - - interface ScenarioPayload extends EventPayload { - feature: Feature; - exception: Error; - keyword: string; - lines: number[]; - name: string; - tags: Tag[]; - uri: string; - line: number; - description: string; - steps: Step[]; - } - - interface ScenarioResultPayload extends EventPayload { - duration: any; - failureException: Error; - scenario: Scenario; - status: string; - stepResults: any[]; - } - - interface StepPayload extends EventPayload { - arguments: any; - line: number; - name: string; - scenario: Scenario; - uri: string; - isBackground: boolean; - keyword: string; - keywordType: string; - } - - interface StepResultPayload extends EventPayload { - ambiguousStepDefinitions: any; - attachments: any[]; - duration: any; - failureException: Error; - step: Step; - stepDefinition: StepDefinition; - status: string; - } - - } - - export interface StepDefinition { - code: Function; - line: number; - options: {}; - pattern: any; - uri: string; - } - - export interface Tag { - name: string; - line: number; - } - - export interface Step { - arguments: any; - line: number; - name: string; - scenario: Scenario; - uri: string; - isBackground: boolean; + interface FeaturePayload extends EventPayload { + description: string; keyword: string; - keywordType: string; + line: number; + name: string; + tags: Tag[]; + uri: string; + scenarios: Scenario[]; } - export interface Scenario { + interface ScenarioPayload extends EventPayload { feature: Feature; exception: Error; keyword: string; @@ -203,62 +131,125 @@ declare namespace cucumber { steps: Step[]; } - export interface Feature { - description: string; - keyword: string; + interface ScenarioResultPayload extends EventPayload { + duration: any; + failureException: Error; + scenario: Scenario; + status: string; + stepResults: any[]; + } + + interface StepPayload extends EventPayload { + arguments: any; line: number; name: string; - tags: Tag[]; + scenario: Scenario; uri: string; - scenarios: Scenario[]; + isBackground: boolean; + keyword: string; + keywordType: string; } - interface EventHook { - (event: events.Event, callback?: () => void): void; + interface StepResultPayload extends EventPayload { + ambiguousStepDefinitions: any; + attachments: any[]; + duration: any; + failureException: Error; + step: Step; + stepDefinition: StepDefinition; + status: string; } +} - export interface SupportCodeConsumer { - (stepDefinitions: StepDefinitions & Hooks): void; - } +export interface StepDefinition { + // tslint:disable-next-line ban-types + code: Function; + line: number; + options: {}; + pattern: any; + uri: string; +} - export function defineSupportCode(consumer: SupportCodeConsumer): void; +export interface Tag { + name: string; + line: number; +} - export function getSupportCodeFns(): SupportCodeConsumer[]; +export interface Step { + arguments: any; + line: number; + name: string; + scenario: Scenario; + uri: string; + isBackground: boolean; + keyword: string; + keywordType: string; +} - export function clearSupportCodeFns(): void; +export interface Scenario { + feature: Feature; + exception: Error; + keyword: string; + lines: number[]; + name: string; + tags: Tag[]; + uri: string; + line: number; + description: string; + steps: Step[]; +} - // https://github.com/cucumber/cucumber-js/commit/231183a8a11c985ef7ced1155b7a75f5120a34b6 - export class Formatter { - constructor(options?: any); +export interface Feature { + description: string; + keyword: string; + line: number; + name: string; + tags: Tag[]; + uri: string; + scenarios: Scenario[]; +} - log(data: any): void; - } +export type EventHook = (event: events.Event, callback?: () => void) => void; - export class SummaryFormatter extends Formatter { - indent(text: string, numberOfSpaces: number): any; - } - export class PrettyFormatter extends SummaryFormatter { - formatTags(tags: Tag[]): any; - logIndented(text: string, level: number): void; - logStepResult(stepResult: any): void; - } +export type SupportCodeConsumer = (stepDefinitions: StepDefinitions & Hooks) => void; - export class ProgressFormatter extends SummaryFormatter { - } +export function defineSupportCode(consumer: SupportCodeConsumer): void; - export class RerunFormatter extends Formatter { - } +export function getSupportCodeFns(): SupportCodeConsumer[]; - export class SnippetsFormatter extends Formatter { - } +export function clearSupportCodeFns(): void; - export class UsageFormatter extends Formatter { - } +// https://github.com/cucumber/cucumber-js/commit/231183a8a11c985ef7ced1155b7a75f5120a34b6 +export class Formatter { + constructor(options?: any); - export class UsageJsonFormatter extends Formatter { - } + log(data: any): void; +} - export class JsonFormatter extends Formatter { - } +export class SummaryFormatter extends Formatter { + indent(text: string, numberOfSpaces: number): any; +} +export class PrettyFormatter extends SummaryFormatter { + formatTags(tags: Tag[]): any; + logIndented(text: string, level: number): void; + logStepResult(stepResult: any): void; +} + +export class ProgressFormatter extends SummaryFormatter { +} + +export class RerunFormatter extends Formatter { +} + +export class SnippetsFormatter extends Formatter { +} + +export class UsageFormatter extends Formatter { +} + +export class UsageJsonFormatter extends Formatter { +} + +export class JsonFormatter extends Formatter { } diff --git a/types/cucumber/tsconfig.json b/types/cucumber/tsconfig.json index c7fe6d2258..a2bd1c7023 100644 --- a/types/cucumber/tsconfig.json +++ b/types/cucumber/tsconfig.json @@ -6,8 +6,8 @@ "dom" ], "noImplicitAny": true, - "noImplicitThis": false, - "strictNullChecks": false, + "noImplicitThis": true, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -20,4 +20,4 @@ "index.d.ts", "cucumber-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/cucumber/tslint.json b/types/cucumber/tslint.json new file mode 100644 index 0000000000..215db37b37 --- /dev/null +++ b/types/cucumber/tslint.json @@ -0,0 +1,8 @@ +{ + "extends": "dtslint/dt.json", + "no-any-union": false, + "rules": { + "no-any-union": false, + "no-unnecessary-generics": false + } +} diff --git a/types/cucumber/v1/cucumber-tests.ts b/types/cucumber/v1/cucumber-tests.ts index 347bec135b..6007df8c03 100644 --- a/types/cucumber/v1/cucumber-tests.ts +++ b/types/cucumber/v1/cucumber-tests.ts @@ -1,44 +1,46 @@ -import * as assert from "power-assert"; -import cucumber = require("cucumber"); +import * as assert from 'power-assert'; +import cucumber = require('cucumber'); -function StepSample() { +function StepSample(this: cucumber.StepDefinitions & cucumber.Hooks) { type Callback = cucumber.CallbackStepDefinition; type Table = cucumber.TableDefinition; type HookScenario = cucumber.HookScenario; - const step = this; - const hook = this; + const step = this; + const hook = this; - hook.Before(function (scenario: HookScenario, callback: Callback) { + hook.Before((scenario: HookScenario, callback: Callback) => { scenario.isFailed() && callback.pending(); }); - hook.Before({ timeout: 1000 }, function(scenario: HookScenario, callback: Callback) { + hook.Before({ timeout: 1000 }, (scenario: HookScenario, callback: Callback) => { callback(); }); - hook.After({ timeout: 1000 }, function(scenario: HookScenario, callback: Callback) { + hook.After({ timeout: 1000 }, (scenario: HookScenario, callback: Callback) => { callback(); }); - hook.Around(function (scenario: HookScenario, runScenario: (error: string, callback?: Function) => void) { - scenario.isFailed() && runScenario(null, function () { - console.log('finish tasks'); - }); + hook.Around((scenario: HookScenario, runScenario: (error: string | null, callback?: () => void) => void) => { + if (scenario.isFailed()) { + runScenario(null, () => { + console.log('finish tasks'); + }); + } }); - hook.registerHandler('AfterFeatures', function (event: any, callback: Function) { + hook.registerHandler('AfterFeatures', (event: any, callback: () => void) => { callback(); }); - step.Given(/^I am on the Cucumber.js GitHub repository$/, function (callback: Callback) { + step.Given(/^I am on the Cucumber.js GitHub repository$/, function(callback: Callback) { this.visit('https://github.com/cucumber/cucumber-js', callback); }); - step.When(/^I go to the README file$/, function (title: string, callback: Callback) { + step.When(/^I go to the README file$/, (title: string, callback: Callback) => { callback(null, 'pending'); }); - step.Then(/^I should see "(.*)" as the page title$/, {timeout: 60 * 1000}, function (title: string, callback: Callback) { + step.Then(/^I should see "(.*)" as the page title$/, {timeout: 60 * 1000}, function(title: string, callback: Callback) { const pageTitle = this.browser.text('title'); if (title === pageTitle) { @@ -51,7 +53,7 @@ function StepSample() { // Type for data_table.js on // https://github.com/cucumber/cucumber-js/blob/a5fd8251918c278ab2e389226d165cedb44df14a/lib/cucumber/ast/data_table.js - step.Given(/^a table step with Table raw$/, function (table: Table) { + step.Given(/^a table step with Table raw$/, (table: Table) => { const expected = [ ['Cucumber', 'Cucumis sativus'], ['Burr Gherkin', 'Cucumis anguria'] @@ -60,7 +62,7 @@ function StepSample() { assert.deepEqual(actual, expected); }); - step.Given(/^a table step with Table rows$/, function (table: Table) { + step.Given(/^a table step with Table rows$/, (table: Table) => { const expected = [ ['Apricot', '5'], ['Brocolli', '2'], @@ -70,31 +72,29 @@ function StepSample() { assert.deepEqual(actual, expected); }); - step.Given(/^a table step with Table rowHash$/, function (table: Table) { + step.Given(/^a table step with Table rowHash$/, (table: Table) => { const expected = { - 'Cucumber': 'Cucumis sativus', + Cucumber: 'Cucumis sativus', 'Burr Gherkin': 'Cucumis anguria' }; - const actual: { [firstCol:string]: string } = table.rowsHash(); + const actual: { [firstCol: string]: string } = table.rowsHash(); assert.deepEqual(actual, expected); }); - step.Given(/^a table step$/, function (table: Table) { + step.Given(/^a table step$/, (table: Table) => { const expected = [ - {'Vegetable': 'Apricot', 'Rating': '5'}, - {'Vegetable': 'Brocolli', 'Rating': '2'}, - {'Vegetable': 'Cucumber', 'Rating': '10'} + {Vegetable: 'Apricot', Rating: '5'}, + {Vegetable: 'Brocolli', Rating: '2'}, + {Vegetable: 'Cucumber', Rating: '10'} ]; - const actual: { [colName:string]: string }[] = table.hashes(); + const actual: Array<{ [colName: string]: string }> = table.hashes(); assert.deepEqual(actual, expected); }); - } function registerListener(): cucumber.EventListener { - let listener = Object.assign(cucumber.Listener(), { - handleBeforeScenarioEvent: (scenario: cucumber.events.ScenarioPayload, callback: () => void) => { - + const listener = Object.assign(cucumber.Listener(), { + handleBeforeScenarioEvent(scenario: cucumber.events.ScenarioPayload, callback: () => void) { // do some interesting stuff ... callback(); diff --git a/types/cucumber/v1/index.d.ts b/types/cucumber/v1/index.d.ts index 39a915f935..18c70c5ea6 100644 --- a/types/cucumber/v1/index.d.ts +++ b/types/cucumber/v1/index.d.ts @@ -1,215 +1,206 @@ -// Type definitions for cucumber-js v1.3.1 +// Type definitions for cucumber-js 1.3 // Project: https://github.com/cucumber/cucumber-js -// Definitions by: Abraão Alves , Jan Molak , Isaiah Soung +// Definitions by: Abraão Alves +// Jan Molak +// Isaiah Soung +// BendingBender // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 -export = cucumber; +export interface CallbackStepDefinition { + pending(): PromiseLike; + (error?: any, pending?: string): void; +} -declare namespace cucumber { +export interface TableDefinition { + raw(): string[][]; + rows(): string[][]; + rowsHash(): { [firstCol: string]: string }; + hashes(): Array<{ [colName: string]: string }>; +} - export interface CallbackStepDefinition { - pending: () => PromiseLike; - (error?: any, pending?: string): void; - } +export type StepDefinitionParam = string | CallbackStepDefinition | TableDefinition; - export interface TableDefinition { - raw: () => Array>; - rows: () => Array>; - rowsHash: () => { [firstCol:string]: string }; - hashes: () => Array<{ [colName:string]: string }>; - } +export type StepDefinitionCode = (this: { [key: string]: any }, ...stepArgs: StepDefinitionParam[]) => PromiseLike | any | void; - type StepDefinitionParam = string | CallbackStepDefinition | TableDefinition; +export interface StepDefinitionOptions { + timeout?: number; +} - interface StepDefinitionCode { - (...stepArgs: Array): PromiseLike | any | void; - } +export interface StepDefinitions { + Given(pattern: RegExp | string, options: StepDefinitionOptions, code: StepDefinitionCode): void; + Given(pattern: RegExp | string, code: StepDefinitionCode): void; + When(pattern: RegExp | string, options: StepDefinitionOptions, code: StepDefinitionCode): void; + When(pattern: RegExp | string, code: StepDefinitionCode): void; + Then(pattern: RegExp | string, options: StepDefinitionOptions, code: StepDefinitionCode): void; + Then(pattern: RegExp | string, code: StepDefinitionCode): void; + setDefaultTimeout(time: number): void; +} - interface StepDefinitionOptions { - timeout?: number; - } +export interface HookScenario { + getKeyword(): string; + getName(): string; + getDescription(): string; + getUri(): string; + getLine(): number; + getTags(): string[]; + getException(): Error; + getAttachments(): any[]; + attach(data: any, mimeType?: string, callback?: (err?: any) => void): void; + isSuccessful(): boolean; + isFailed(): boolean; + isPending(): boolean; + isUndefined(): boolean; + isSkipped(): boolean; +} - export interface StepDefinitions { - Given(pattern: RegExp | string, options: StepDefinitionOptions, code: StepDefinitionCode): void; - Given(pattern: RegExp | string, code: StepDefinitionCode): void; - When(pattern: RegExp | string, options: StepDefinitionOptions, code: StepDefinitionCode): void; - When(pattern: RegExp | string, code: StepDefinitionCode): void; - Then(pattern: RegExp | string, options: StepDefinitionOptions, code: StepDefinitionCode): void; - Then(pattern: RegExp | string, code: StepDefinitionCode): void; - setDefaultTimeout(time: number): void; - } +export type HookCode = (this: { [key: string]: any }, scenario: HookScenario, callback?: CallbackStepDefinition) => void; - interface HookScenario { - getKeyword(): string; +// tslint:disable-next-line ban-types +export type AroundCode = (scenario: HookScenario, runScenario?: (error: string, callback?: Function) => void) => void; + +export interface HookOptions { + timeout?: number; + tags?: any; +} + +export interface Hooks { + Before(code: HookCode): void; + Before(options: HookOptions, code: HookCode): void; + After(code: HookCode): void; + After(options: HookOptions, code: HookCode): void; + Around(code: AroundCode): void; + setDefaultTimeout(time: number): void; + registerHandler(handlerOption: string, code: (event: any, callback: CallbackStepDefinition) => void): void; + registerListener(listener: EventListener): void; +} + +export class EventListener { + hear(event: events.Event, callback: () => void): void; + hasHandlerForEvent(event: events.Event): boolean; + buildHandlerNameForEvent(event: events.Event): string; + getHandlerForEvent(event: events.Event): EventHook; + buildHandlerName(shortName: string): string; + setHandlerForEvent(shortName: string, handler: EventListener): void; +} + +export function Listener(): EventListener; + +export namespace events { + interface Event { getName(): string; - getDescription(): string; - getUri(): string; - getLine(): number; - getTags(): string[]; - getException(): Error; - getAttachments(): any[]; - attach(data: any, mimeType?: string, callback?: (err?: any) => void): void; + getPayloadItem(name: string): EventPayload; + } + + // tslint:disable-next-line no-empty-interface + interface EventPayload { + } + + interface FeaturesPayload extends EventPayload { + getFeatures(): any[]; // https://github.com/cucumber/cucumber-js/blob/dc698bf5bc10d591fa7adeec5fa21b2d90dc9679/lib/cucumber/runtime.js#L34 + } + + interface FeaturesResultPayload extends EventPayload { + getDuration(): any; + getScenarioCounts(): any; + getStepCounts(): any; isSuccessful(): boolean; - isFailed(): boolean; - isPending(): boolean; - isUndefined(): boolean; - isSkipped(): boolean; } - interface HookCode { - (scenario: HookScenario, callback?: CallbackStepDefinition): void; - } - - interface AroundCode { - (scenario: HookScenario, runScenario?: (error: string, callback?: Function) => void): void; - } - - interface HookOptions { - timeout?: number; - tags?: any; - } - - export interface Hooks { - Before(code: HookCode): void; - Before(options: HookOptions, code: HookCode): void; - After(code: HookCode): void; - After(options: HookOptions, code: HookCode): void; - Around(code: AroundCode): void; - setDefaultTimeout(time: number): void; - registerHandler(handlerOption: string, code: (event: any, callback: CallbackStepDefinition) => void): void; - registerListener(listener: EventListener): void; - } - - export class EventListener { - hear(event: events.Event, callback: () => void): void; - hasHandlerForEvent(event: events.Event): boolean; - buildHandlerNameForEvent(event: events.Event): string; - getHandlerForEvent(event: events.Event): EventHook; - buildHandlerName(shortName: string): string; - setHandlerForEvent(shortName: string, handler: EventListener): void; - } - - export function Listener(): EventListener; - - export namespace events { - - interface Event { - getName(): string; - getPayloadItem(name: string): EventPayload; - } - - interface EventPayload { - } - - interface FeaturesPayload extends EventPayload { - getFeatures(): any[]; // https://github.com/cucumber/cucumber-js/blob/dc698bf5bc10d591fa7adeec5fa21b2d90dc9679/lib/cucumber/runtime.js#L34 - } - - interface FeaturesResultPayload extends EventPayload { - getDuration(): any; - getScenarioCounts(): any; - getStepCounts(): any; - isSuccessful(): boolean; - } - - interface FeaturePayload extends EventPayload { - getStepKeywordByLines(): any; - getScenarioKeyword(): string; - getKeyword(): string; - getName(): string; - getDescription(): string; - getUri(): string; - getLine(): number; - getTags(): Tag[]; - getScenarios(): ScenarioPayload[]; - getPayloadItem(): FeaturePayload; - } - - interface ScenarioPayload extends EventPayload { - getName(): string; - getKeyword(): string; - getDescription(): string; - getFeature(): FeaturePayload; - getUri(): string; - getUris(): string[]; - getLine(): number; - getLines(): number[]; - getTags(): Tag[]; - getSteps(): any[]; - getPayloadItem(): ScenarioPayload; - } - - interface ScenarioResultPayload extends EventPayload { - getFailureException(): Error; - getScenario(): any; - getStatus(): any; - } - - interface StepPayload extends EventPayload { - isHidden(): boolean; - isOutlineStep(): boolean; - getKeyword(): string; - getName(): string; - hasUri(): boolean; - getUri(): string; - getLine(): number; - getPreviousStep(): any; - hasPreviousStep(): boolean; - getAttachment(): any; - getAttachmentContents(): any; - getDocString(): string; - getDataTable(): any; - hasAttachment(): boolean; - hasDocString(): boolean; - hasDataTable(): boolean; - ensureDataTableIsAttached(): void; - isOutcomeStep(): boolean; - isEventStep(): boolean; - hasOutcomeStepKeyword(): boolean; - hasEventStepKeyword(): boolean; - isRepeatingOutcomeStep(): boolean; - isRepeatingEventStep(): boolean; - hasRepeatStepKeyword(): boolean; - isPrecededByOutcomeStep(): boolean; - isPrecededByEventStep(): boolean; - } - - interface StepResultPayload extends EventPayload { - getAmbiguousStepDefinitions(): any[]; - getAttachments(): any[]; - getDuration(): any; - getFailureException(): Error; - getStep(): any; - getStepDefinition(): any; - getStatus(): any; - hasAttachments(): boolean; - } - - } - - interface Tag { - getName(): string; - getLine(): number; - } - - export interface Scenario { + interface FeaturePayload extends EventPayload { + getStepKeywordByLines(): any; + getScenarioKeyword(): string; getKeyword(): string; getName(): string; getDescription(): string; getUri(): string; getLine(): number; getTags(): Tag[]; - getException(): Error; - getAttachments(): any[]; - attach(data: any, mimeType?: string, callback?: (err?: any) => void): void; - isSuccessful(): boolean; - isFailed(): boolean; - isPending(): boolean; - isUndefined(): boolean; - isSkipped(): boolean; + getScenarios(): ScenarioPayload[]; + getPayloadItem(): FeaturePayload; } - interface EventHook { - (event: events.Event, callback?: () => void): void; + interface ScenarioPayload extends EventPayload { + getName(): string; + getKeyword(): string; + getDescription(): string; + getFeature(): FeaturePayload; + getUri(): string; + getUris(): string[]; + getLine(): number; + getLines(): number[]; + getTags(): Tag[]; + getSteps(): any[]; + getPayloadItem(): ScenarioPayload; + } + + interface ScenarioResultPayload extends EventPayload { + getFailureException(): Error; + getScenario(): any; + getStatus(): any; + } + + interface StepPayload extends EventPayload { + isHidden(): boolean; + isOutlineStep(): boolean; + getKeyword(): string; + getName(): string; + hasUri(): boolean; + getUri(): string; + getLine(): number; + getPreviousStep(): any; + hasPreviousStep(): boolean; + getAttachment(): any; + getAttachmentContents(): any; + getDocString(): string; + getDataTable(): any; + hasAttachment(): boolean; + hasDocString(): boolean; + hasDataTable(): boolean; + ensureDataTableIsAttached(): void; + isOutcomeStep(): boolean; + isEventStep(): boolean; + hasOutcomeStepKeyword(): boolean; + hasEventStepKeyword(): boolean; + isRepeatingOutcomeStep(): boolean; + isRepeatingEventStep(): boolean; + hasRepeatStepKeyword(): boolean; + isPrecededByOutcomeStep(): boolean; + isPrecededByEventStep(): boolean; + } + + interface StepResultPayload extends EventPayload { + getAmbiguousStepDefinitions(): any[]; + getAttachments(): any[]; + getDuration(): any; + getFailureException(): Error; + getStep(): any; + getStepDefinition(): any; + getStatus(): any; + hasAttachments(): boolean; } } + +export interface Tag { + getName(): string; + getLine(): number; +} + +export interface Scenario { + getKeyword(): string; + getName(): string; + getDescription(): string; + getUri(): string; + getLine(): number; + getTags(): Tag[]; + getException(): Error; + getAttachments(): any[]; + attach(data: any, mimeType?: string, callback?: (err?: any) => void): void; + isSuccessful(): boolean; + isFailed(): boolean; + isPending(): boolean; + isUndefined(): boolean; + isSkipped(): boolean; +} + +export type EventHook = (event: events.Event, callback?: () => void) => void; diff --git a/types/cucumber/v1/tsconfig.json b/types/cucumber/v1/tsconfig.json index b467d8c4b4..3c64799f9a 100644 --- a/types/cucumber/v1/tsconfig.json +++ b/types/cucumber/v1/tsconfig.json @@ -1,31 +1,31 @@ { - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": false, - "strictNullChecks": false, - "baseUrl": "../../", - "typeRoots": [ - "../../" - ], - "types": [], - "paths": { - "cucumber": [ - "cucumber/v1" - ], - "cucumber/*": [ - "cucumber/v1/*" - ] + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "types": [], + "paths": { + "cucumber": [ + "cucumber/v1" + ], + "cucumber/*": [ + "cucumber/v1/*" + ] + }, + "noEmit": true, + "forceConsistentCasingInFileNames": true }, - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "cucumber-tests.ts" - ] + "files": [ + "index.d.ts", + "cucumber-tests.ts" + ] } diff --git a/types/cucumber/v1/tslint.json b/types/cucumber/v1/tslint.json new file mode 100644 index 0000000000..3fe527d08f --- /dev/null +++ b/types/cucumber/v1/tslint.json @@ -0,0 +1,7 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "no-any-union": false, + "no-unnecessary-generics": false + } +} diff --git a/types/cwise-parser/tslint.json b/types/cwise-parser/tslint.json index 531fb4ef87..71ee04c4e1 100644 --- a/types/cwise-parser/tslint.json +++ b/types/cwise-parser/tslint.json @@ -1,3 +1,6 @@ { - "extends": "dtslint/dt.json" -} \ No newline at end of file + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/cwise/cwise-tests.ts b/types/cwise/cwise-tests.ts index 66843adfe2..b759fb1a0c 100644 --- a/types/cwise/cwise-tests.ts +++ b/types/cwise/cwise-tests.ts @@ -66,7 +66,7 @@ tape("binary", (t) => { const binary = cwise({ args: ["array", "array", "scalar", "shape", "index"], body(a: number, b: number, t: tape.Test, s: number[], idx: number) { - if (!(a === 0)) t.fail("idx:" + idx + ", shape:" + s + ",a:" + a); + if (!(a === 0)) t.fail(`idx:${idx}, shape:${s},a:${a}`); a = b + 1001; } }); @@ -80,7 +80,7 @@ tape("binary", (t) => { binary(P, Q, t); for (let i = 0; i < P.shape[0]; ++i) { if (!(P.get(i) === i + 1001)) { - t.fail(testName + "; encountered " + P.get(i) + " instead of " + (i + 1001) + " at " + i); + t.fail(`${testName}; encountered ${P.get(i)} instead of ${(i + 1001)} at ${i}`); return; } } @@ -128,7 +128,7 @@ tape("binary", (t) => { for (let i = 0; i < P.shape[0]; ++i) { for (let j = 0; j < P.shape[1]; ++j) { if (!(P.get(i, j) === i * 1000 + j + 1001)) { - t.fail(testName + "; encountered " + P.get(i, j) + " instead of " + (i * 1000 + j + 1001) + " at (" + i + "," + j + ")"); + t.fail(`${testName}; encountered ${P.get(i, j)} instead of ${(i * 1000 + j + 1001)} at (" + i + "," + j + ")`); return; } } @@ -163,7 +163,7 @@ function bundleCasesFrom(i: number) { if (i >= cases.length) return; const b = browserify(); b.ignore("tape"); - b.add(__dirname + "/" + cases[i] + ".js"); + b.add(`${__dirname}/${cases[i]}.js`); b.transform(path.normalize(__dirname + "/../cwise.js")); tape(cases[i], (t) => { // Without nested tests, the asynchronous nature of bundle causes issues with tape... b.bundle((err, src) => { @@ -209,7 +209,7 @@ tape("fill", (t) => { for (let i = 0; i < xlen; i++) { for (let j = 0; j < ylen; j++) { - t.equals(array.get(i, j), 0, 'fill (' + i + ',' + j + ')'); + t.equals(array.get(i, j), 0, `fill (${i},${j})`); } } @@ -219,7 +219,7 @@ tape("fill", (t) => { for (let i = 0; i < xlen; i++) { for (let j = 0; j < ylen; j++) { - t.equals(array.get(i, j), 10 * (i + j), 'fill (' + i + ',' + j + ')'); + t.equals(array.get(i, j), 10 * (i + j), `fill (${i},${j})`); } } @@ -231,7 +231,7 @@ tape("offset", (t) => { const binary = cwise({ args: ["array", "array", { offset: [1], array: 1 }, "scalar", "shape", "index"], body(a, b, c, t, s, idx) { - if (!(a === 0)) t.fail("idx:" + idx + ", shape:" + s + ",a:" + a); + if (!(a === 0)) t.fail(`idx:${idx}, shape:${s},a:${a}`); a = c + b + 1000; } }); @@ -246,7 +246,7 @@ tape("offset", (t) => { binary(P, Q.hi(Q.shape[0] - 1), t); for (let i = 0; i < P.shape[0]; ++i) { if (!(P.get(i) === 2 * i + 1001)) { - t.fail(testName + "; encountered " + P.get(i) + " instead of " + (2 * i + 1001) + " at " + i); + t.fail(`${testName}; encountered ${P.get(i)} instead of ${2 * i + 1001} at ${i}`); return; } } @@ -292,7 +292,7 @@ tape("unary", (t) => { unary(arr); for (let i = 0; i < arr.shape[0]; ++i) { if (!(arr.get(i) === i + 1)) { - t.fail(testName + "; encountered " + arr.get(i) + " instead of " + (i + 1) + " at " + i); + t.fail(`${testName}; encountered ${arr.get(i)} instead of ${i + 1} at ${i}`); return; } } @@ -336,7 +336,7 @@ tape("unary", (t) => { for (let i = 0; i < arr.shape[0]; ++i) { for (let j = 0; j < arr.shape[1]; ++j) { if (!(arr.get(i, j) === 1 + i + j * arr.shape[0])) { - t.fail(testName + "; encountered " + arr.get(i, j) + " instead of " + (1 + i + j * arr.shape[0]) + " at (" + i + "," + j + ")"); + t.fail(`${testName}; encountered ${arr.get(i, j)} instead of ${1 + i + j * arr.shape[0]} at (${i},${j})`); return; } } diff --git a/types/cwise/tslint.json b/types/cwise/tslint.json index 531fb4ef87..bee01cfc64 100644 --- a/types/cwise/tslint.json +++ b/types/cwise/tslint.json @@ -1,3 +1,6 @@ { - "extends": "dtslint/dt.json" + "extends": "dtslint/dt.json", + "rules": { + "no-any-union": false + } } \ No newline at end of file diff --git a/types/d3-array/d3-array-tests.ts b/types/d3-array/d3-array-tests.ts index b95da5774f..42bf95bcfe 100644 --- a/types/d3-array/d3-array-tests.ts +++ b/types/d3-array/d3-array-tests.ts @@ -43,9 +43,9 @@ let num: number; let date: Date; let numOrUndefined: number | undefined; -let strOrUndefined: string |  undefined; -let numericOrUndefined: NumCoercible |  undefined; -let dateOrUndefined: Date |  undefined; +let strOrUndefined: string | undefined; +let numericOrUndefined: NumCoercible | undefined; +let dateOrUndefined: Date | undefined; let numOrUndefinedExtent: [number, number] | [undefined, undefined]; let strOrUndefinedExtent: [string, string] | [undefined, undefined]; let numericOrUndefinedExtent: [NumCoercible, NumCoercible] | [undefined, undefined]; @@ -55,9 +55,10 @@ let dateOrUndefinedExtent: [Date, Date] | [undefined, undefined]; let numbersArray = [10, 20, 30, 40, 50]; const numbersOrUndefinedArray = [10, 20, undefined, null, 40, 50]; -const stringyNumbersArray = ['10', '20', '30', '40', '50']; +let stringyNumbersArray = ['10', '20', '30', '40', '50']; const numericArray = [new NumCoercible(10), new NumCoercible(20), new NumCoercible(30), new NumCoercible(40), new NumCoercible(50)]; -const dateArray = [new Date(2016, 6, 1), new Date(2016, 7, 30), new Date(2015, 3, 15)]; +let dateArray = [new Date(2016, 6, 1), new Date(2016, 7, 30), new Date(2015, 3, 15)]; + const mixedObjectArray = [ new MixedObject(10, new Date(2016, 6, 1)), new MixedObject(20, new Date(2016, 7, 30)), @@ -65,8 +66,18 @@ const mixedObjectArray = [ new MixedObject(40, new Date(2014, 3, 15)), new MixedObject(50, new Date(2017, 4, 15)) ]; + const mixedObjectOrUndefinedArray = [...mixedObjectArray, undefined]; +let typedArray = Uint8Array.from(numbersArray); +let readonlyNumbersArray = numbersArray as ReadonlyArray; +const readonlyNumbersOrUndefinedArray = numbersOrUndefinedArray as ReadonlyArray; +const readonlyStringyNumbersArray = stringyNumbersArray as ReadonlyArray; +const readonlyNumericArray = numericArray as ReadonlyArray; +const readonlyDateArray = dateArray as ReadonlyArray; +const readonlyMixedObjectArray = mixedObjectArray as ReadonlyArray; +const readonlyMixedObjectOrUndefinedArray = mixedObjectOrUndefinedArray as ReadonlyArray; + function accessorMixedObjectToNum(datum: MixedObject, index: number, array: MixedObject[]): number { return datum.num; } @@ -104,6 +115,14 @@ strOrUndefined = d3Array.max(stringyNumbersArray); numericOrUndefined = d3Array.max(numericArray); dateOrUndefined = d3Array.max(dateArray); +// ArrayLike test cases + +numOrUndefined = d3Array.max(typedArray); +numOrUndefined = d3Array.max(readonlyNumbersOrUndefinedArray); +strOrUndefined = d3Array.max(readonlyStringyNumbersArray); +numericOrUndefined = d3Array.max(readonlyNumericArray); +dateOrUndefined = d3Array.max(readonlyDateArray); + // with accessors numOrUndefined = d3Array.max(mixedObjectArray, accessorMixedObjectToNum); @@ -112,6 +131,7 @@ numericOrUndefined = d3Array.max(mixedObjectArray, accessorMixedObjectToNumeric) dateOrUndefined = d3Array.max(mixedObjectArray, accessorMixedObjectToDate); numOrUndefined = d3Array.max(mixedObjectArray, accessorMixedObjectToNumOrUndefined); strOrUndefined = d3Array.max(mixedObjectArray, accessorMixedObjectToStrOrUndefined); +numOrUndefined = d3Array.max(readonlyMixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined); // min() ----------------------------------------------------------------------- @@ -122,6 +142,14 @@ strOrUndefined = d3Array.min(stringyNumbersArray); numericOrUndefined = d3Array.min(numericArray); dateOrUndefined = d3Array.min(dateArray); +// ArrayLike test cases + +numOrUndefined = d3Array.min(typedArray); +numOrUndefined = d3Array.min(readonlyNumbersOrUndefinedArray); +strOrUndefined = d3Array.min(readonlyStringyNumbersArray); +numericOrUndefined = d3Array.min(readonlyNumericArray); +dateOrUndefined = d3Array.min(readonlyDateArray); + // with accessors numOrUndefined = d3Array.min(mixedObjectArray, accessorMixedObjectToNum); @@ -130,6 +158,7 @@ numericOrUndefined = d3Array.min(mixedObjectArray, accessorMixedObjectToNumeric) dateOrUndefined = d3Array.min(mixedObjectArray, accessorMixedObjectToDate); numOrUndefined = d3Array.min(mixedObjectArray, accessorMixedObjectToNumOrUndefined); strOrUndefined = d3Array.min(mixedObjectArray, accessorMixedObjectToStrOrUndefined); +numOrUndefined = d3Array.max(readonlyMixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined); // extent() -------------------------------------------------------------------- @@ -140,6 +169,14 @@ strOrUndefinedExtent = d3Array.extent(stringyNumbersArray); numericOrUndefinedExtent = d3Array.extent(numericArray); dateOrUndefinedExtent = d3Array.extent(dateArray); +// ArrayLike test cases + +numOrUndefinedExtent = d3Array.extent(typedArray); +numOrUndefinedExtent = d3Array.extent(readonlyNumbersOrUndefinedArray); +strOrUndefinedExtent = d3Array.extent(readonlyStringyNumbersArray); +numericOrUndefinedExtent = d3Array.extent(readonlyNumericArray); +dateOrUndefinedExtent = d3Array.extent(readonlyDateArray); + // with accessors numOrUndefinedExtent = d3Array.extent(mixedObjectArray, accessorMixedObjectToNum); @@ -148,6 +185,7 @@ mixedOrUndefinedExtent = d3Array.extent(mixedObjectArray, accessorMixedObjectToN dateMixedOrUndefined = d3Array.extent(mixedObjectArray, accessorMixedObjectToDate); numOrUndefinedExtent = d3Array.extent(mixedObjectArray, accessorMixedObjectToNumOrUndefined); strOrUndefinedExtent = d3Array.extent(mixedObjectArray, accessorMixedObjectToStrOrUndefined); +numOrUndefinedExtent = d3Array.extent(readonlyMixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined); // mean() ---------------------------------------------------------------------- @@ -155,8 +193,14 @@ numOrUndefined = d3Array.mean(numbersArray); numOrUndefined = d3Array.mean(numericArray); numOrUndefined = d3Array.mean(numbersOrUndefinedArray); +numOrUndefined = d3Array.mean(typedArray); +numOrUndefined = d3Array.mean(readonlyNumbersOrUndefinedArray); +numOrUndefined = d3Array.mean(readonlyNumericArray); +numOrUndefined = d3Array.mean(readonlyNumbersOrUndefinedArray); + numOrUndefined = d3Array.mean(mixedObjectArray, accessorMixedObjectToNum); numOrUndefined = d3Array.mean(mixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined); +numOrUndefined = d3Array.mean(readonlyMixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined); // median() -------------------------------------------------------------------- @@ -164,8 +208,14 @@ numOrUndefined = d3Array.median(numbersArray); numOrUndefined = d3Array.median(numericArray); numOrUndefined = d3Array.median(numbersOrUndefinedArray); +numOrUndefined = d3Array.median(typedArray); +numOrUndefined = d3Array.median(readonlyNumbersArray); +numOrUndefined = d3Array.median(readonlyNumericArray); +numOrUndefined = d3Array.median(readonlyNumbersOrUndefinedArray); + numOrUndefined = d3Array.median(mixedObjectArray, accessorMixedObjectToNum); numOrUndefined = d3Array.median(mixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined); +numOrUndefined = d3Array.median(readonlyMixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined); // quantile() ------------------------------------------------------------------ @@ -173,8 +223,14 @@ numOrUndefined = d3Array.quantile(numbersArray, 0.5); numOrUndefined = d3Array.quantile(numericArray, 0.5); numOrUndefined = d3Array.quantile(numbersOrUndefinedArray, 0.5); +numOrUndefined = d3Array.quantile(typedArray, 0.5); +numOrUndefined = d3Array.quantile(readonlyNumbersArray, 0.5); +numOrUndefined = d3Array.quantile(readonlyNumericArray, 0.5); +numOrUndefined = d3Array.quantile(readonlyNumbersOrUndefinedArray, 0.5); + numOrUndefined = d3Array.quantile(mixedObjectArray, 0.5, accessorMixedObjectToNum); numOrUndefined = d3Array.quantile(mixedObjectOrUndefinedArray, 0.5, accessorMixedObjectToNumOrUndefined); +numOrUndefined = d3Array.quantile(readonlyMixedObjectOrUndefinedArray, 0.5, accessorMixedObjectToNumOrUndefined); // sum() ----------------------------------------------------------------------- @@ -182,8 +238,14 @@ numOrUndefined = d3Array.sum(numbersArray); numOrUndefined = d3Array.sum(numericArray); numOrUndefined = d3Array.sum(numbersOrUndefinedArray); +numOrUndefined = d3Array.sum(typedArray); +numOrUndefined = d3Array.sum(readonlyNumbersArray); +numOrUndefined = d3Array.sum(readonlyNumericArray); +numOrUndefined = d3Array.sum(readonlyNumbersOrUndefinedArray); + numOrUndefined = d3Array.sum(mixedObjectArray, accessorMixedObjectToNum); numOrUndefined = d3Array.sum(mixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined); +numOrUndefined = d3Array.sum(readonlyMixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined); // deviation() ----------------------------------------------------------------- @@ -191,8 +253,14 @@ numOrUndefined = d3Array.deviation(numbersArray); numOrUndefined = d3Array.deviation(numericArray); numOrUndefined = d3Array.deviation(numbersOrUndefinedArray); +numOrUndefined = d3Array.deviation(typedArray); +numOrUndefined = d3Array.deviation(readonlyNumbersArray); +numOrUndefined = d3Array.deviation(readonlyNumericArray); +numOrUndefined = d3Array.deviation(readonlyNumbersOrUndefinedArray); + numOrUndefined = d3Array.deviation(mixedObjectArray, accessorMixedObjectToNum); numOrUndefined = d3Array.deviation(mixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined); +numOrUndefined = d3Array.deviation(readonlyMixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined); // variance() ------------------------------------------------------------------ @@ -200,16 +268,29 @@ numOrUndefined = d3Array.variance(numbersArray); numOrUndefined = d3Array.variance(numericArray); numOrUndefined = d3Array.variance(numbersOrUndefinedArray); +numOrUndefined = d3Array.variance(typedArray); +numOrUndefined = d3Array.variance(readonlyNumbersArray); +numOrUndefined = d3Array.variance(readonlyNumericArray); +numOrUndefined = d3Array.variance(readonlyNumbersOrUndefinedArray); + numOrUndefined = d3Array.variance(mixedObjectArray, accessorMixedObjectToNum); numOrUndefined = d3Array.variance(mixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined); +numOrUndefined = d3Array.variance(readonlyMixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined); // ----------------------------------------------------------------------------- // Test Searching Arrays // ----------------------------------------------------------------------------- +numbersArray = [0, 2, 3, 4, 7, 8]; +stringyNumbersArray = ['0', '2', '3', '4', '7', '8']; +dateArray = [new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)]; +typedArray = Uint8Array.from(numbersArray); + // scan() ---------------------------------------------------------------------- numOrUndefined = d3Array.scan(numbersArray); +numOrUndefined = d3Array.scan(typedArray); +numOrUndefined = d3Array.scan(readonlyNumbersArray); numOrUndefined = d3Array.scan(mixedObjectArray, (a, b) => { const aElem: MixedObject = a; @@ -217,53 +298,113 @@ numOrUndefined = d3Array.scan(mixedObjectArray, (a, b) => { return a.num - b.num; }); +numOrUndefined = d3Array.scan(readonlyMixedObjectArray, (a, b) => { + const aElem: MixedObject = a; + const bElem: MixedObject = b; + return a.num - b.num; +}); + numOrUndefined = d3Array.scan(mixedObjectOrUndefinedArray, (a, b) => { const aElem: MixedObject | undefined = a; const bElem: MixedObject | undefined = b; return a && b ? a.num - b.num : NaN; }); +numOrUndefined = d3Array.scan(readonlyMixedObjectOrUndefinedArray, (a, b) => { + const aElem: MixedObject | undefined = a; + const bElem: MixedObject | undefined = b; + return a && b ? a.num - b.num : NaN; +}); + // bisectLeft() ---------------------------------------------------------------- -num = d3Array.bisectLeft([0, 2, 3, 4, 7, 8], 4); -num = d3Array.bisectLeft([0, 2, 3, 4, 7, 8], 4, 1); -num = d3Array.bisectLeft([0, 2, 3, 4, 7, 8], 4, 1, 4); +num = d3Array.bisectLeft(numbersArray, 4); +num = d3Array.bisectLeft(numbersArray, 4, 1); +num = d3Array.bisectLeft(numbersArray, 4, 1, 4); -num = d3Array.bisectLeft(['0', '2', '3', '4', '7', '8'], '21'); -num = d3Array.bisectLeft(['0', '2', '3', '4', '7', '8'], '21', 1); -num = d3Array.bisectLeft(['0', '2', '3', '4', '7', '8'], '21', 1, 4); +num = d3Array.bisectLeft(stringyNumbersArray, '21'); +num = d3Array.bisectLeft(stringyNumbersArray, '21', 1); +num = d3Array.bisectLeft(stringyNumbersArray, '21', 1, 4); -num = d3Array.bisectLeft([new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)], new Date(2011, 2, 1)); -num = d3Array.bisectLeft([new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)], new Date(2011, 2, 1), 1); -num = d3Array.bisectLeft([new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)], new Date(2011, 2, 1), 1, 2); +num = d3Array.bisectLeft(dateArray, new Date(2011, 2, 1)); +num = d3Array.bisectLeft(dateArray, new Date(2011, 2, 1), 1); +num = d3Array.bisectLeft(dateArray, new Date(2011, 2, 1), 1, 2); + +num = d3Array.bisectLeft(typedArray, 4); +num = d3Array.bisectLeft(typedArray, 4, 1); +num = d3Array.bisectLeft(typedArray, 4, 1, 4); + +num = d3Array.bisectLeft(readonlyNumbersArray, 4); +num = d3Array.bisectLeft(readonlyNumbersArray, 4, 1); +num = d3Array.bisectLeft(readonlyNumbersArray, 4, 1, 4); + +num = d3Array.bisectLeft(readonlyStringyNumbersArray, '21'); +num = d3Array.bisectLeft(readonlyStringyNumbersArray, '21', 1); +num = d3Array.bisectLeft(readonlyStringyNumbersArray, '21', 1, 4); + +num = d3Array.bisectLeft(readonlyDateArray, new Date(2011, 2, 1)); +num = d3Array.bisectLeft(readonlyDateArray, new Date(2011, 2, 1), 1); +num = d3Array.bisectLeft(readonlyDateArray, new Date(2011, 2, 1), 1, 2); // bisectRight() --------------------------------------------------------------- -num = d3Array.bisectRight([0, 2, 3, 4, 7, 8], 4); -num = d3Array.bisectRight([0, 2, 3, 4, 7, 8], 4, 1); -num = d3Array.bisectRight([0, 2, 3, 4, 7, 8], 4, 1, 4); +num = d3Array.bisectRight(numbersArray, 4); +num = d3Array.bisectRight(numbersArray, 4, 1); +num = d3Array.bisectRight(numbersArray, 4, 1, 4); -num = d3Array.bisectRight(['0', '2', '3', '4', '7', '8'], '21'); -num = d3Array.bisectRight(['0', '2', '3', '4', '7', '8'], '21', 1); -num = d3Array.bisectRight(['0', '2', '3', '4', '7', '8'], '21', 1, 4); +num = d3Array.bisectRight(stringyNumbersArray, '21'); +num = d3Array.bisectRight(stringyNumbersArray, '21', 1); +num = d3Array.bisectRight(stringyNumbersArray, '21', 1, 4); -num = d3Array.bisectRight([new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)], new Date(2011, 2, 1)); -num = d3Array.bisectRight([new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)], new Date(2011, 2, 1), 1); -num = d3Array.bisectRight([new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)], new Date(2011, 2, 1), 1, 2); +num = d3Array.bisectRight(dateArray, new Date(2011, 2, 1)); +num = d3Array.bisectRight(dateArray, new Date(2011, 2, 1), 1); +num = d3Array.bisectRight(dateArray, new Date(2011, 2, 1), 1, 2); + +num = d3Array.bisectRight(typedArray, 4); +num = d3Array.bisectRight(typedArray, 4, 1); +num = d3Array.bisectRight(typedArray, 4, 1, 4); + +num = d3Array.bisectRight(readonlyNumbersArray, 4); +num = d3Array.bisectRight(readonlyNumbersArray, 4, 1); +num = d3Array.bisectRight(readonlyNumbersArray, 4, 1, 4); + +num = d3Array.bisectRight(readonlyStringyNumbersArray, '21'); +num = d3Array.bisectRight(readonlyStringyNumbersArray, '21', 1); +num = d3Array.bisectRight(readonlyStringyNumbersArray, '21', 1, 4); + +num = d3Array.bisectRight(readonlyDateArray, new Date(2011, 2, 1)); +num = d3Array.bisectRight(readonlyDateArray, new Date(2011, 2, 1), 1); +num = d3Array.bisectRight(readonlyDateArray, new Date(2011, 2, 1), 1, 2); // bisect() -------------------------------------------------------------------- -num = d3Array.bisect([0, 2, 3, 4, 7, 8], 4); -num = d3Array.bisect([0, 2, 3, 4, 7, 8], 4, 1); -num = d3Array.bisect([0, 2, 3, 4, 7, 8], 4, 1, 4); +num = d3Array.bisect(numbersArray, 4); +num = d3Array.bisect(numbersArray, 4, 1); +num = d3Array.bisect(numbersArray, 4, 1, 4); -num = d3Array.bisect(['0', '2', '3', '4', '7', '8'], '21'); -num = d3Array.bisect(['0', '2', '3', '4', '7', '8'], '21', 1); -num = d3Array.bisect(['0', '2', '3', '4', '7', '8'], '21', 1, 4); +num = d3Array.bisect(stringyNumbersArray, '21'); +num = d3Array.bisect(stringyNumbersArray, '21', 1); +num = d3Array.bisect(stringyNumbersArray, '21', 1, 4); -num = d3Array.bisect([new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)], new Date(2011, 2, 1)); -num = d3Array.bisect([new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)], new Date(2011, 2, 1), 1); -num = d3Array.bisect([new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)], new Date(2011, 2, 1), 1, 2); +num = d3Array.bisect(dateArray, new Date(2011, 2, 1)); +num = d3Array.bisect(dateArray, new Date(2011, 2, 1), 1); +num = d3Array.bisect(dateArray, new Date(2011, 2, 1), 1, 2); + +num = d3Array.bisect(typedArray, 4); +num = d3Array.bisect(typedArray, 4, 1); +num = d3Array.bisect(typedArray, 4, 1, 4); + +num = d3Array.bisect(readonlyNumbersArray, 4); +num = d3Array.bisect(readonlyNumbersArray, 4, 1); +num = d3Array.bisect(readonlyNumbersArray, 4, 1, 4); + +num = d3Array.bisect(readonlyStringyNumbersArray, '21'); +num = d3Array.bisect(readonlyStringyNumbersArray, '21', 1); +num = d3Array.bisect(readonlyStringyNumbersArray, '21', 1, 4); + +num = d3Array.bisect(readonlyDateArray, new Date(2011, 2, 1)); +num = d3Array.bisect(readonlyDateArray, new Date(2011, 2, 1), 1); +num = d3Array.bisect(readonlyDateArray, new Date(2011, 2, 1), 1, 2); // bisector() ------------------------------------------------------------------ @@ -283,11 +424,19 @@ num = mixedObjectDateBisectorObject.left(mixedObjectArray, new Date(2015, 3, 14) num = mixedObjectDateBisectorObject.left(mixedObjectArray, new Date(2015, 3, 14), 1); num = mixedObjectDateBisectorObject.left(mixedObjectArray, new Date(2015, 3, 14), 3, 4); +num = mixedObjectDateBisectorObject.left(readonlyMixedObjectArray, new Date(2015, 3, 14)); +num = mixedObjectDateBisectorObject.left(readonlyMixedObjectArray, new Date(2015, 3, 14), 1); +num = mixedObjectDateBisectorObject.left(readonlyMixedObjectArray, new Date(2015, 3, 14), 3, 4); + // bisect right num = mixedObjectDateBisectorObject.right(mixedObjectArray, new Date(2015, 3, 14)); num = mixedObjectDateBisectorObject.right(mixedObjectArray, new Date(2015, 3, 14), 1); num = mixedObjectDateBisectorObject.right(mixedObjectArray, new Date(2015, 3, 14), 3, 4); +num = mixedObjectDateBisectorObject.right(readonlyMixedObjectArray, new Date(2015, 3, 14)); +num = mixedObjectDateBisectorObject.right(readonlyMixedObjectArray, new Date(2015, 3, 14), 1); +num = mixedObjectDateBisectorObject.right(readonlyMixedObjectArray, new Date(2015, 3, 14), 3, 4); + // ascending() ----------------------------------------------------------------- num = d3Array.ascending(undefined, 20); @@ -308,32 +457,44 @@ num = d3Array.descending(new Date(2016, 6, 13), new Date(2016, 6, 14)); // merge() --------------------------------------------------------------------- -let testArrays: MixedObject[][] = [ - [ - new MixedObject(10, new Date(2016, 6, 1)), - new MixedObject(20, new Date(2016, 7, 30)), - new MixedObject(30, new Date(2015, 3, 15)), - new MixedObject(40, new Date(2014, 3, 15)), - new MixedObject(50, new Date(2017, 4, 15)) - ], - [ - new MixedObject(40, new Date(2016, 3, 1)), - new MixedObject(50, new Date(2016, 9, 30)), - ] +const testArray1 = [ + new MixedObject(10, new Date(2016, 6, 1)), + new MixedObject(20, new Date(2016, 7, 30)), + new MixedObject(30, new Date(2015, 3, 15)), + new MixedObject(40, new Date(2014, 3, 15)), + new MixedObject(50, new Date(2017, 4, 15)) ]; +const testArray2 = [ + new MixedObject(40, new Date(2016, 3, 1)), + new MixedObject(50, new Date(2016, 9, 30)), +]; + +let testArrays: MixedObject[][] = [testArray1, testArray2]; + +const readonlyTestArray1 = testArray1 as ReadonlyArray; +const readonlyTestArray2 = testArray2 as ReadonlyArray; +const readonlyTestArrays = [testArray1, testArray2] as ReadonlyArray>; + let mergedArray: MixedObject[]; mergedArray = d3Array.merge(testArrays); // inferred type mergedArray = d3Array.merge(testArrays); // explicit type // mergedArray = d3Array.merge([[10, 40, 30], [15, 30]]); // fails, type mismatch +// mergedArray = d3Array.merge([testArray1, [15, 30]]); // fails, type mismatch + +mergedArray = d3Array.merge(readonlyTestArrays); // inferred type +mergedArray = d3Array.merge(readonlyTestArrays); // explicit type // cross() --------------------------------------------------------------------- let crossed: Array<[string, number]>; -crossed = d3Array.cross(['x', 'y'], [1, 2]); -crossed = d3Array.cross(['x', 'y'], [1, 2]); +const chars = ['x', 'y']; +const nums = [1, 2]; + +crossed = d3Array.cross(chars, nums); +crossed = d3Array.cross(chars, nums); let strArray: string[] = d3Array.cross([2, 3], [5, 6], (a, b) => (a + b) + 'px'); strArray = d3Array.cross([2, 3], [5, 6], (a, b) => { @@ -342,6 +503,21 @@ strArray = d3Array.cross([2, 3], [5, 6], (a, b) => { return (aa + bb) + 'px'; }); +const readonlyChars = chars as ReadonlyArray; +const readonlyNums = new Uint8Array(nums); + +crossed = d3Array.cross(readonlyChars, readonlyNums); +crossed = d3Array.cross(readonlyChars, readonlyNums); + +strArray = d3Array.cross([2, 3] as ReadonlyArray, new Uint8ClampedArray([5, 6]), (a, b) => (a + b) + 'px'); +strArray = d3Array.cross([2, 3] as ReadonlyArray, new Uint8ClampedArray([5, 6]), (a, b) => { + const aa: number = a; + const bb: number = b; + return (aa + bb) + 'px'; +}); + +d3Array.cross(new Uint8Array([1, 2, 3, 4, 5]), new Uint8Array([10, 20, 30, 40, 50])); + // pairs() --------------------------------------------------------------------- let pairs: Array<[MixedObject, MixedObject]>; @@ -355,10 +531,21 @@ numbersArray = d3Array.pairs(mergedArray, (a, b) => { return bb.num - aa.num; }); +const readonlyMergedArray = mergedArray as ReadonlyArray; +pairs = d3Array.pairs(readonlyMergedArray); + +numbersArray = d3Array.pairs(readonlyMergedArray, (a, b) => b.num - a.num); +numbersArray = d3Array.pairs(readonlyMergedArray, (a, b) => { + const aa: MixedObject = a; + const bb: MixedObject = b; + return bb.num - aa.num; +}); + // permute() ------------------------------------------------------------------- // getting a permutation of array elements mergedArray = d3Array.permute(mergedArray, [1, 0, 2, 5, 3, 4, 6]); +mergedArray = d3Array.permute(readonlyMergedArray, [1, 0, 2, 5, 3, 4, 6]); // Getting an ordered array with object properties @@ -380,10 +567,20 @@ numbersArray = d3Array.range(1, 10, 0.5); // shuffle() ------------------------------------------------------------------- mergedArray = d3Array.shuffle(mergedArray); - mergedArray = d3Array.shuffle(mergedArray, 1); - mergedArray = d3Array.shuffle(mergedArray, 1, 3); +// mergedArray = d3Array.shuffle(readonlyMergedArray); // fails, shuffle mutates input array in-place + +// Test each TypedArray explicitly. Can't use ArrayLike in this case because shuffle is mutable and ArrayLike would include ReadonlyArray +const resultInt8: Int8Array = d3Array.shuffle(new Int8Array(numbersArray)); +const resultUint8: Uint8Array = d3Array.shuffle(new Uint8Array(numbersArray)); +const resultUint8Clamped: Uint8ClampedArray = d3Array.shuffle(new Uint8ClampedArray(numbersArray)); +const resultInt16: Int16Array = d3Array.shuffle(new Int16Array(numbersArray)); +const resultUint6: Uint16Array = d3Array.shuffle(new Uint16Array(numbersArray)); +const resultInt32: Int32Array = d3Array.shuffle(new Int32Array(numbersArray)); +const resultUint32: Uint32Array = d3Array.shuffle(new Uint32Array(numbersArray)); +const resultFloat32: Float32Array = d3Array.shuffle(new Float32Array(numbersArray)); +const resultFloat64: Float64Array = d3Array.shuffle(new Float64Array(numbersArray)); // ticks() --------------------------------------------------------------------- @@ -399,32 +596,13 @@ numDiff = d3Array.tickStep(1, 10, 5); // transpose() ----------------------------------------------------------------- -testArrays = d3Array.transpose([ - [ - new MixedObject(10, new Date(2016, 6, 1)), - new MixedObject(50, new Date(2017, 4, 15)) - ], - [ - new MixedObject(40, new Date(2016, 3, 1)), - new MixedObject(50, new Date(2016, 9, 30)), - ] -]); +testArrays = d3Array.transpose([testArray1, testArray2]); +testArrays = d3Array.transpose([readonlyTestArray1, readonlyTestArray2] as ReadonlyArray>); // zip() ----------------------------------------------------------------------- -testArrays = d3Array.zip( - [ - new MixedObject(10, new Date(2016, 6, 1)), - new MixedObject(20, new Date(2016, 7, 30)), - new MixedObject(30, new Date(2015, 3, 15)), - new MixedObject(40, new Date(2014, 3, 15)), - new MixedObject(50, new Date(2017, 4, 15)) - ], - [ - new MixedObject(40, new Date(2016, 3, 1)), - new MixedObject(50, new Date(2016, 9, 30)), - ] -); +testArrays = d3Array.zip(testArray1, testArray2); +testArrays = d3Array.zip(readonlyTestArray1, readonlyTestArray2); // ----------------------------------------------------------------------------- // Test Histogram @@ -447,7 +625,7 @@ testHistogram = d3Array.histogram(); testHistogram = testHistogram.value((d, i, data) => { const datum: MixedObject = d; // d is of type MixedObject const index: number = i; // i is number - const array: MixedObject[] = data; // data is of type MixedObject[] + const array: ArrayLike = data; // data is of type MixedObject[] return datum.date; }); @@ -496,8 +674,10 @@ testHistogram = testHistogram.thresholds(tScale.ticks(timeYear)); // Use histogram generator ===================================================== +numbersArray = [-1, 0, 1, 1, 3, 20, 234]; + let defaultBins: Array>; -defaultBins = defaultHistogram([-1, 0, 1, 1, 3, 20, 234]); +defaultBins = defaultHistogram(numbersArray); let defaultBin: d3Array.Bin; defaultBin = defaultBins[0]; @@ -509,6 +689,7 @@ num = defaultBin.x1; // bin upper bound is number let testBins: Array>; testBins = testHistogram(mixedObjectArray); +testBins = testHistogram(readonlyMixedObjectArray); let testBin: d3Array.Bin; testBin = testBins[0]; @@ -520,8 +701,18 @@ date = testBin.x1; // bin upper bound is Date // Histogram Tresholds ========================================================= -num = d3Array.thresholdFreedmanDiaconis([-1, 0, 1, 1, 3, 20, 234], -1, 234); +numbersArray = [-1, 0, 1, 1, 3, 20, 234]; +typedArray = new Uint8Array(numbersArray); +readonlyNumbersArray = numbersArray as ReadonlyArray; -num = d3Array.thresholdScott([-1, 0, 1, 1, 3, 20, 234], -1, 234); +num = d3Array.thresholdFreedmanDiaconis(numbersArray, -1, 234); +num = d3Array.thresholdFreedmanDiaconis(typedArray, -1, 234); +num = d3Array.thresholdFreedmanDiaconis(readonlyNumbersArray, -1, 234); -num = d3Array.thresholdSturges([-1, 0, 1, 1, 3, 20, 234]); +num = d3Array.thresholdScott(numbersArray, -1, 234); +num = d3Array.thresholdScott(typedArray, -1, 234); +num = d3Array.thresholdScott(readonlyNumbersArray, -1, 234); + +num = d3Array.thresholdSturges(numbersArray); +num = d3Array.thresholdSturges(typedArray); +num = d3Array.thresholdSturges(readonlyNumbersArray); diff --git a/types/d3-array/index.d.ts b/types/d3-array/index.d.ts index aee2ef38c7..67cd291f22 100644 --- a/types/d3-array/index.d.ts +++ b/types/d3-array/index.d.ts @@ -28,133 +28,133 @@ export interface Numeric { /** * Return the maximum value in the array of strings using natural order. */ -export function max(array: string[]): string | undefined; +export function max(array: ArrayLike): string | undefined; /** * Return the maximum value in the array of numbers using natural order. */ -export function max(array: T[]): T | undefined; +export function max(array: ArrayLike): T | undefined; /** * Return the maximum value in the array using natural order and a projection function to map values to strings. */ -export function max(array: T[], accessor: (datum: T, index: number, array: T[]) => string | undefined | null): string | undefined; +export function max(array: ArrayLike, accessor: (datum: T, index: number, array: ArrayLike) => string | undefined | null): string | undefined; /** * Return the maximum value in the array using natural order and a projection function to map values to easily-sorted values. */ -export function max(array: T[], accessor: (datum: T, index: number, array: T[]) => U | undefined | null): U | undefined; +export function max(array: ArrayLike, accessor: (datum: T, index: number, array: ArrayLike) => U | undefined | null): U | undefined; /** * Return the minimum value in the array using natural order. */ -export function min(array: string[]): string | undefined; +export function min(array: ArrayLike): string | undefined; /** * Return the minimum value in the array using natural order. */ -export function min(array: T[]): T | undefined; +export function min(array: ArrayLike): T | undefined; /** * Return the minimum value in the array using natural order. */ -export function min(array: T[], accessor: (datum: T, index: number, array: T[]) => string | undefined | null): string | undefined; +export function min(array: ArrayLike, accessor: (datum: T, index: number, array: ArrayLike) => string | undefined | null): string | undefined; /** * Return the minimum value in the array using natural order. */ -export function min(array: T[], accessor: (datum: T, index: number, array: T[]) => U | undefined | null): U | undefined; +export function min(array: ArrayLike, accessor: (datum: T, index: number, array: ArrayLike) => U | undefined | null): U | undefined; /** * Return the min and max simultaneously. */ -export function extent(array: string[]): [string, string] | [undefined, undefined]; +export function extent(array: ArrayLike): [string, string] | [undefined, undefined]; /** * Return the min and max simultaneously. */ -export function extent(array: T[]): [T, T] | [undefined, undefined]; +export function extent(array: ArrayLike): [T, T] | [undefined, undefined]; /** * Return the min and max simultaneously. */ -export function extent(array: T[], accessor: (datum: T, index: number, array: T[]) => string | undefined | null): [string, string] | [undefined, undefined]; +export function extent(array: ArrayLike, accessor: (datum: T, index: number, array: ArrayLike) => string | undefined | null): [string, string] | [undefined, undefined]; /** * Return the min and max simultaneously. */ -export function extent(array: T[], accessor: (datum: T, index: number, array: T[]) => U | undefined | null): [U, U] | [undefined, undefined]; +export function extent(array: ArrayLike, accessor: (datum: T, index: number, array: ArrayLike) => U | undefined | null): [U, U] | [undefined, undefined]; /** * Return the mean of an array of numbers */ -export function mean(array: Array): number | undefined; -export function mean(array: T[], accessor: (datum: T, index: number, array: T[]) => number | undefined | null): number | undefined; +export function mean(array: ArrayLike): number | undefined; +export function mean(array: ArrayLike, accessor: (datum: T, index: number, array: ArrayLike) => number | undefined | null): number | undefined; /** * Return the median of an array of numbers */ -export function median(array: Array): number | undefined; -export function median(array: T[], accessor: (element: T, i: number, array: T[]) => number | undefined | null): number | undefined; +export function median(array: ArrayLike): number | undefined; +export function median(array: ArrayLike, accessor: (element: T, i: number, array: ArrayLike) => number | undefined | null): number | undefined; /** * Returns the p-quantile of an array of numbers */ -export function quantile(array: Array, p: number): number | undefined; -export function quantile(array: T[], p: number, accessor: (element: T, i: number, array: T[]) => number | undefined | null): number | undefined; +export function quantile(array: ArrayLike, p: number): number | undefined; +export function quantile(array: ArrayLike, p: number, accessor: (element: T, i: number, array: ArrayLike) => number | undefined | null): number | undefined; /** * Compute the sum of an array of numbers. */ -export function sum(array: Array): number; +export function sum(array: ArrayLike): number; /** * Compute the sum of an array, using the given accessor to convert values to numbers. */ -export function sum(array: T[], accessor: (datum: T, index: number, array: T[]) => number | undefined | null): number; +export function sum(array: ArrayLike, accessor: (datum: T, index: number, array: ArrayLike) => number | undefined | null): number; /** * Compute the standard deviation, defined as the square root of the bias-corrected variance, of the given array of numbers. */ -export function deviation(array: Array): number | undefined; +export function deviation(array: ArrayLike): number | undefined; /** * Compute the standard deviation, defined as the square root of the bias-corrected variance, of the given array, * using the given accessor to convert values to numbers. */ -export function deviation(array: T[], accessor: (datum: T, index: number, array: T[]) => number | undefined | null): number | undefined; +export function deviation(array: ArrayLike, accessor: (datum: T, index: number, array: ArrayLike) => number | undefined | null): number | undefined; /** * Compute an unbiased estimator of the population variance of the given array of numbers. */ -export function variance(array: Array): number | undefined; +export function variance(array: ArrayLike): number | undefined; /** * Compute an unbiased estimator of the population variance of the given array, * using the given accessor to convert values to numbers. */ -export function variance(array: T[], accessor: (datum: T, index: number, array: T[]) => number | undefined | null): number | undefined; +export function variance(array: ArrayLike, accessor: (datum: T, index: number, array: ArrayLike) => number | undefined | null): number | undefined; // -------------------------------------------------------------------------------------- // Searching Arrays // -------------------------------------------------------------------------------------- -export function scan(array: number[], comparator?: (a: number, b: number) => number): number | undefined; -export function scan(array: T[], comparator: (a: T, b: T) => number): number | undefined; +export function scan(array: ArrayLike, comparator?: (a: number, b: number) => number): number | undefined; +export function scan(array: ArrayLike, comparator: (a: T, b: T) => number): number | undefined; -export function bisectLeft(array: number[], x: number, lo?: number, hi?: number): number; -export function bisectLeft(array: string[], x: string, lo?: number, hi?: number): number; -export function bisectLeft(array: Date[], x: Date, lo?: number, hi?: number): number; +export function bisectLeft(array: ArrayLike, x: number, lo?: number, hi?: number): number; +export function bisectLeft(array: ArrayLike, x: string, lo?: number, hi?: number): number; +export function bisectLeft(array: ArrayLike, x: Date, lo?: number, hi?: number): number; -export function bisectRight(array: number[], x: number, lo?: number, hi?: number): number; -export function bisectRight(array: string[], x: string, lo?: number, hi?: number): number; -export function bisectRight(array: Date[], x: Date, lo?: number, hi?: number): number; +export function bisectRight(array: ArrayLike, x: number, lo?: number, hi?: number): number; +export function bisectRight(array: ArrayLike, x: string, lo?: number, hi?: number): number; +export function bisectRight(array: ArrayLike, x: Date, lo?: number, hi?: number): number; export const bisect: typeof bisectRight; export interface Bisector { - left(array: T[], x: U, lo?: number, hi?: number): number; - right(array: T[], x: U, lo?: number, hi?: number): number; + left(array: ArrayLike, x: U, lo?: number, hi?: number): number; + right(array: ArrayLike, x: U, lo?: number, hi?: number): number; } export function bisector(comparator: (a: T, b: U) => number): Bisector; @@ -184,7 +184,7 @@ export function descending(a: Primitive | undefined, b: Primitive | undefined): * @param a First input array. * @param b Second input array. */ -export function cross(a: S[], b: T[]): Array<[S, T]>; +export function cross(a: ArrayLike, b: ArrayLike): Array<[S, T]>; /** * Returns the Cartesian product of the two arrays a and b. @@ -195,12 +195,12 @@ export function cross(a: S[], b: T[]): Array<[S, T]>; * @param b Second input array. * @param reducer A reducer function taking as input an element from "a" and "b" and returning a reduced value. */ -export function cross(a: S[], b: T[], reducer: (a: S, b: T) => U): U[]; +export function cross(a: ArrayLike, b: ArrayLike, reducer: (a: S, b: T) => U): U[]; /** * Merges the specified arrays into a single array. */ -export function merge(arrays: T[][]): T[]; +export function merge(arrays: ArrayLike>): T[]; /** * For each adjacent pair of elements in the specified array, returns a new array of tuples of elements i and i - 1. @@ -208,7 +208,7 @@ export function merge(arrays: T[][]): T[]; * * @param array Array of input elements */ -export function pairs(array: T[]): Array<[T, T]>; +export function pairs(array: ArrayLike): Array<[T, T]>; /** * For each adjacent pair of elements in the specified array, in order, invokes the specified reducer function passing the element i and element i - 1. * Returns the resulting array of pair-wise reduced elements. @@ -217,17 +217,17 @@ export function pairs(array: T[]): Array<[T, T]>; * @param array Array of input elements * @param reducer A reducer function taking as input to adjecent elements of the input array and returning a reduced value. */ -export function pairs(array: T[], reducer: (a: T, b: T) => U): U[]; +export function pairs(array: ArrayLike, reducer: (a: T, b: T) => U): U[]; /** * Given the specified array, return an array corresponding to the list of indices in 'keys'. */ -export function permute(array: { [key: number]: T }, keys: number[]): T[]; +export function permute(array: { [key: number]: T }, keys: ArrayLike): T[]; /** * Given the specified object, return an array corresponding to the list of property names in 'keys'. */ -export function permute(object: { [key: string]: T }, keys: string[]): T[]; +export function permute(object: { [key: string]: T }, keys: ArrayLike): T[]; /** * Generates a 0-based numeric sequence. The output range does not include 'stop'. @@ -243,6 +243,15 @@ export function range(start: number, stop: number, step?: number): number[]; * Randomizes the order of the specified array using the Fisher–Yates shuffle. */ export function shuffle(array: T[], lo?: number, hi?: number): T[]; +export function shuffle(array: Int8Array, lo?: number, hi?: number): Int8Array; +export function shuffle(array: Uint8Array, lo?: number, hi?: number): Uint8Array; +export function shuffle(array: Uint8ClampedArray, lo?: number, hi?: number): Uint8ClampedArray; +export function shuffle(array: Int16Array, lo?: number, hi?: number): Int16Array; +export function shuffle(array: Uint16Array, lo?: number, hi?: number): Uint16Array; +export function shuffle(array: Int32Array, lo?: number, hi?: number): Int32Array; +export function shuffle(array: Uint32Array, lo?: number, hi?: number): Uint32Array; +export function shuffle(array: Float32Array, lo?: number, hi?: number): Float32Array; +export function shuffle(array: Float64Array, lo?: number, hi?: number): Float64Array; /** * Generate an array of approximately count + 1 uniformly-spaced, nicely-rounded values between start and stop (inclusive). @@ -289,14 +298,14 @@ export function tickStep(start: number, stop: number, count: number): number; /** * Transpose a matrix provided in Array of Arrays format. */ -export function transpose(matrix: T[][]): T[][]; +export function transpose(matrix: ArrayLike>): T[][]; /** * Returns an array of arrays, where the ith array contains the ith element from each of the argument arrays. * The returned array is truncated in length to the shortest array in arrays. If arrays contains only a single array, the returned array * contains one-element arrays. With no arguments, the returned array is empty. */ -export function zip(...arrays: T[][]): T[][]; +export function zip(...arrays: Array>): T[][]; // -------------------------------------------------------------------------------------- // Histogram @@ -310,20 +319,20 @@ export interface Bin extends Array { /** * Type definition for threshold generator which returns the count of recommended thresholds */ -export type ThresholdCountGenerator = (values: number[], min?: number, max?: number) => number; +export type ThresholdCountGenerator = (values: ArrayLike, min?: number, max?: number) => number; /** * Type definition for threshold generator which returns an array of recommended thresholds */ -export type ThresholdArrayGenerator = (values: Value[], min?: Value, max?: Value) => Value[]; +export type ThresholdArrayGenerator = (values: ArrayLike, min?: Value, max?: Value) => Value[]; export interface HistogramGenerator { - (data: Datum[]): Array>; - value(): (d: Datum, i: number, data: Datum[]) => Value; - value(valueAccessor: (d: Datum, i: number, data: Datum[]) => Value): this; - domain(): (values: Value[]) => [Value, Value]; + (data: ArrayLike): Array>; + value(): (d: Datum, i: number, data: ArrayLike) => Value; + value(valueAccessor: (d: Datum, i: number, data: ArrayLike) => Value): this; + domain(): (values: ArrayLike) => [Value, Value]; domain(domain: [Value, Value]): this; - domain(domainAccessor: (values: Value[]) => [Value, Value]): this; + domain(domainAccessor: (values: ArrayLike) => [Value, Value]): this; thresholds(): ThresholdCountGenerator | ThresholdArrayGenerator; /** * Divide the domain uniformly into approximately count bins. IMPORTANT: This threshold @@ -357,7 +366,7 @@ export interface HistogramGenerator { * @param thresholds Array of threshold values used for binning. The elements must * be of the same type as the materialized values of the histogram. */ - thresholds(thresholds: Value[]): this; + thresholds(thresholds: ArrayLike): this; /** * Set a threshold accessor function, which returns the array of values to be used as * thresholds in determining the bins. @@ -379,8 +388,8 @@ export function histogram(): HistogramGenera // Histogram Thresholds // -------------------------------------------------------------------------------------- -export function thresholdFreedmanDiaconis(values: number[], min: number, max: number): number; // of type ThresholdCountGenerator +export function thresholdFreedmanDiaconis(values: ArrayLike, min: number, max: number): number; // of type ThresholdCountGenerator -export function thresholdScott(values: number[], min: number, max: number): number; // of type ThresholdCountGenerator +export function thresholdScott(values: ArrayLike, min: number, max: number): number; // of type ThresholdCountGenerator -export function thresholdSturges(values: number[]): number; // of type ThresholdCountGenerator +export function thresholdSturges(values: ArrayLike): number; // of type ThresholdCountGenerator diff --git a/types/d3-array/tslint.json b/types/d3-array/tslint.json index 08b1465cd6..54efb0b84e 100644 --- a/types/d3-array/tslint.json +++ b/types/d3-array/tslint.json @@ -1,6 +1,7 @@ { "extends": "dtslint/dt.json", "rules": { - "unified-signatures": false + "unified-signatures": false, + "no-unnecessary-generics": false } } diff --git a/types/d3-axis/tslint.json b/types/d3-axis/tslint.json index 08b1465cd6..54efb0b84e 100644 --- a/types/d3-axis/tslint.json +++ b/types/d3-axis/tslint.json @@ -1,6 +1,7 @@ { "extends": "dtslint/dt.json", "rules": { - "unified-signatures": false + "unified-signatures": false, + "no-unnecessary-generics": false } } diff --git a/types/d3-brush/d3-brush-tests.ts b/types/d3-brush/d3-brush-tests.ts index 2d9ee319aa..bce080f424 100644 --- a/types/d3-brush/d3-brush-tests.ts +++ b/types/d3-brush/d3-brush-tests.ts @@ -85,7 +85,6 @@ brush = brush.on('end', null); // re-apply brush.on('end', function(d, i, g) { - const that: SVGGElement = this; const datum: BrushDatum = d; const index: number = i; const group: SVGGElement[] | ArrayLike = g; diff --git a/types/d3-brush/tslint.json b/types/d3-brush/tslint.json index 08b1465cd6..54efb0b84e 100644 --- a/types/d3-brush/tslint.json +++ b/types/d3-brush/tslint.json @@ -1,6 +1,7 @@ { "extends": "dtslint/dt.json", "rules": { - "unified-signatures": false + "unified-signatures": false, + "no-unnecessary-generics": false } } diff --git a/types/d3-chord/tslint.json b/types/d3-chord/tslint.json index 08b1465cd6..54efb0b84e 100644 --- a/types/d3-chord/tslint.json +++ b/types/d3-chord/tslint.json @@ -1,6 +1,7 @@ { "extends": "dtslint/dt.json", "rules": { - "unified-signatures": false + "unified-signatures": false, + "no-unnecessary-generics": false } } diff --git a/types/d3-collection/d3-collection-tests.ts b/types/d3-collection/d3-collection-tests.ts index af9bf8d075..91a72479db 100644 --- a/types/d3-collection/d3-collection-tests.ts +++ b/types/d3-collection/d3-collection-tests.ts @@ -11,13 +11,13 @@ import { ascending } from 'd3-array'; // Preparatory steps -------------------------------------------------------------- -let keyValueObj = { +const keyValueObj = { a: 'test', b: 123, c: [true, true, false] }; -let keyValueObj2 = { +const keyValueObj2 = { a: 'test', b: 'same', c: 'type' @@ -29,7 +29,6 @@ let stringKVArray: Array<{ key: string, value: string }>; let anyKVArray: Array<{ key: string, value: any }>; let num: number; -let str: string; let booleanFlag: boolean; // --------------------------------------------------------------------- @@ -137,9 +136,9 @@ testObjKVArray = testObjMap.entries(); // each() -------------------------------------------------------------- testObjMap.each((value, key, map) => { - let v: TestObject = value; - let k: string = key; - let m: d3Collection.Map = map; + const v: TestObject = value; + const k: string = key; + const m: d3Collection.Map = map; console.log(v.val); }); @@ -169,9 +168,9 @@ basicSet = d3Collection.set(['foo', 'bar', 42]); // last element is coerced // from array without accessor basicSet = d3Collection.set(testObjArray, (value, index, array) => { - let v: TestObject = value; - let i: number = index; - let a: TestObject[] = array; + const v: TestObject = value; + const i: number = index; + const a: TestObject[] = array; return v.name; }); @@ -208,9 +207,9 @@ stringArray = basicSet.values(); // each() -------------------------------------------------------------- basicSet.each((value, valueRepeat, set) => { - let v: string = value; - let vr: string = valueRepeat; - let s: d3Collection.Set = set; + const v: string = value; + const vr: string = valueRepeat; + const s: d3Collection.Set = set; console.log(v); }); @@ -233,7 +232,7 @@ interface Yield { site: string; } -let raw: Yield[] = [ +const raw: Yield[] = [ { yield: 27.00, variety: 'Manchuria', year: 1931, site: 'University Farm' }, { yield: 48.87, variety: 'Manchuria', year: 1931, site: 'Waseca' }, { yield: 27.43, variety: 'Manchuria', year: 1931, site: 'Morris' }, @@ -279,8 +278,8 @@ nestL1Rollup = nestL1Rollup nestL2 = nestL2 .sortValues((a, b) => { - let val1: Yield = a; // data type Yield - let val2: Yield = b; // data type Yield + const val1: Yield = a; // data type Yield + const val2: Yield = b; // data type Yield return a.yield - b.yield; }); @@ -288,7 +287,7 @@ nestL2 = nestL2 nestL1Rollup = nestL1Rollup .rollup(values => { - let vs: Yield[] = values; // correct data array type + const vs: Yield[] = values; // correct data array type return vs.length; }); diff --git a/types/d3-collection/tslint.json b/types/d3-collection/tslint.json index 08b1465cd6..54efb0b84e 100644 --- a/types/d3-collection/tslint.json +++ b/types/d3-collection/tslint.json @@ -1,6 +1,7 @@ { "extends": "dtslint/dt.json", "rules": { - "unified-signatures": false + "unified-signatures": false, + "no-unnecessary-generics": false } } diff --git a/types/d3-contour/d3-contour-tests.ts b/types/d3-contour/d3-contour-tests.ts index 751dfe99c9..588750bf29 100644 --- a/types/d3-contour/d3-contour-tests.ts +++ b/types/d3-contour/d3-contour-tests.ts @@ -110,7 +110,7 @@ interface CustomDatum { // Get contour generator ------------------------------------------------------- -let contDensDefault: d3Contour.ContourDensity<[number, number]> = d3Contour.contourDensity(); +const contDensDefault: d3Contour.ContourDensity<[number, number]> = d3Contour.contourDensity(); let contDensCustom: d3Contour.ContourDensity = d3Contour.contourDensity(); // Configure contour generator ================================================= diff --git a/types/d3-contour/tslint.json b/types/d3-contour/tslint.json index 08016de61a..54efb0b84e 100644 --- a/types/d3-contour/tslint.json +++ b/types/d3-contour/tslint.json @@ -1,6 +1,7 @@ { - "extends": "dtslint/dt.json", - "rules": { - "unified-signatures": false - } + "extends": "dtslint/dt.json", + "rules": { + "unified-signatures": false, + "no-unnecessary-generics": false + } } diff --git a/types/d3-dispatch/d3-dispatch-tests.ts b/types/d3-dispatch/d3-dispatch-tests.ts index 436bc3d6d4..a9f29ef75d 100644 --- a/types/d3-dispatch/d3-dispatch-tests.ts +++ b/types/d3-dispatch/d3-dispatch-tests.ts @@ -16,8 +16,6 @@ interface Datum { } let dispatch: d3Dispatch.Dispatch; -let copy: d3Dispatch.Dispatch; -let copy2: d3Dispatch.Dispatch; // Signature Tests ---------------------------------------- @@ -50,5 +48,5 @@ dispatch.apply('bar', document.body, [{ a: 3, b: 'test' }, 1]); dispatch.on('bar', null); // Copy dispatch ----------------------------------------------- -copy = dispatch.copy(); -// copy2 = dispatch.copy(); // test fails type mismatch of underlying event target +const copy: d3Dispatch.Dispatch = dispatch.copy(); +// const copy2: d3Dispatch.Dispatch = dispatch.copy(); // test fails type mismatch of underlying event target diff --git a/types/d3-dispatch/tslint.json b/types/d3-dispatch/tslint.json index 08b1465cd6..54efb0b84e 100644 --- a/types/d3-dispatch/tslint.json +++ b/types/d3-dispatch/tslint.json @@ -1,6 +1,7 @@ { "extends": "dtslint/dt.json", "rules": { - "unified-signatures": false + "unified-signatures": false, + "no-unnecessary-generics": false } } diff --git a/types/d3-drag/tslint.json b/types/d3-drag/tslint.json index 08b1465cd6..26ee29cf50 100644 --- a/types/d3-drag/tslint.json +++ b/types/d3-drag/tslint.json @@ -1,6 +1,9 @@ { "extends": "dtslint/dt.json", "rules": { - "unified-signatures": false + // TODO + "no-this-assignment": false, + "unified-signatures": false, + "no-unnecessary-generics": false } } diff --git a/types/d3-dsv/d3-dsv-tests.ts b/types/d3-dsv/d3-dsv-tests.ts index 421add6e65..51127b7266 100644 --- a/types/d3-dsv/d3-dsv-tests.ts +++ b/types/d3-dsv/d3-dsv-tests.ts @@ -12,13 +12,13 @@ import * as d3Dsv from 'd3-dsv'; // Preperatory Steps // ------------------------------------------------------------------------------------------ -const csvTestString: string = '1997,Ford,E350,2.34\n2000,Mercury,Cougar,2.38'; -const tsvTestString: string = '1997\tFord\tE350\t2.34\n2000\tMercury\tCougar\t2.38'; -const pipedTestString: string = '1997|Ford|E350|2.34\n2000|Mercury|Cougar|2.38'; +const csvTestString = '1997,Ford,E350,2.34\n2000,Mercury,Cougar,2.38'; +const tsvTestString = '1997\tFord\tE350\t2.34\n2000\tMercury\tCougar\t2.38'; +const pipedTestString = '1997|Ford|E350|2.34\n2000|Mercury|Cougar|2.38'; -const csvTestStringWithHeader: string = 'Year,Make,Model,Length\n1997,Ford,E350,2.34\n2000,Mercury,Cougar,2.38'; -const tsvTestStringWithHeader: string = 'Year\tMake\tModel\tLength\n1997\tFord\tE350\t2.34\n2000\tMercury\tCougar\t2.38'; -const pipedTestStringWithHeader: string = 'Year|Make|Model|Length\n1997|Ford|E350|2.34\n2000|Mercury|Cougar|2.38'; +const csvTestStringWithHeader = 'Year,Make,Model,Length\n1997,Ford,E350,2.34\n2000,Mercury,Cougar,2.38'; +const tsvTestStringWithHeader = 'Year\tMake\tModel\tLength\n1997\tFord\tE350\t2.34\n2000\tMercury\tCougar\t2.38'; +const pipedTestStringWithHeader = 'Year|Make|Model|Length\n1997|Ford|E350|2.34\n2000|Mercury|Cougar|2.38'; interface ParsedTestObject { year: Date; diff --git a/types/d3-dsv/v0/tslint.json b/types/d3-dsv/v0/tslint.json index 3db14f85ea..bafaae7817 100644 --- a/types/d3-dsv/v0/tslint.json +++ b/types/d3-dsv/v0/tslint.json @@ -1 +1,7 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + // TODO + "dt-header": false + } +} diff --git a/types/d3-ease/d3-ease-tests.ts b/types/d3-ease/d3-ease-tests.ts index 67a0f32b1b..543f2fd375 100644 --- a/types/d3-ease/d3-ease-tests.ts +++ b/types/d3-ease/d3-ease-tests.ts @@ -8,7 +8,7 @@ import * as d3Ease from 'd3-ease'; -const t_in: number = 0.5; +const t_in = 0.5; let t_out: number; t_out = d3Ease.easeLinear(t_in); diff --git a/types/d3-force/tslint.json b/types/d3-force/tslint.json index 08b1465cd6..26ee29cf50 100644 --- a/types/d3-force/tslint.json +++ b/types/d3-force/tslint.json @@ -1,6 +1,9 @@ { "extends": "dtslint/dt.json", "rules": { - "unified-signatures": false + // TODO + "no-this-assignment": false, + "unified-signatures": false, + "no-unnecessary-generics": false } } diff --git a/types/d3-format/d3-format-tests.ts b/types/d3-format/d3-format-tests.ts index 9c11d07c70..def8994b70 100644 --- a/types/d3-format/d3-format-tests.ts +++ b/types/d3-format/d3-format-tests.ts @@ -36,17 +36,17 @@ formatFn = d3Format.formatPrefix(',.0', 1e-6); specifier = d3Format.formatSpecifier('.0%'); -let fill: string = specifier.fill; -let align: '>' | '<' | '^' | '=' = specifier.align; -let sign: '-' | '+' | '(' | ' ' = specifier.sign; -let symbol: '$' | '#' | '' = specifier.symbol; -let zero: boolean = specifier.zero; -let width: number | undefined = specifier.width; -let comma: boolean = specifier.comma; -let precision: number = specifier.precision; -let type: 'e' | 'f' | 'g' | 'r' | 's' | '%' | 'p' | 'b' | 'o' | 'd' | 'x' | 'X' | 'c' | '' | 'n' = specifier.type; +const fill: string = specifier.fill; +const align: '>' | '<' | '^' | '=' = specifier.align; +const sign: '-' | '+' | '(' | ' ' = specifier.sign; +const symbol: '$' | '#' | '' = specifier.symbol; +const zero: boolean = specifier.zero; +const width: number | undefined = specifier.width; +const comma: boolean = specifier.comma; +const precision: number = specifier.precision; +const type: 'e' | 'f' | 'g' | 'r' | 's' | '%' | 'p' | 'b' | 'o' | 'd' | 'x' | 'X' | 'c' | '' | 'n' = specifier.type; -let formatString: string = specifier.toString(); +const formatString: string = specifier.toString(); // ---------------------------------------------------------------------- // Test Precision Suggestors @@ -85,16 +85,16 @@ localeDef = { percent : "\u202f%" }; -let decimal: string = localeDef.decimal; -let thousands: string = localeDef.thousands; -let grouping: number[] = localeDef.grouping; -let currency: [string, string] = localeDef.currency; -let numerals: string[] | undefined = localeDef.numerals; -let percent: string | undefined = localeDef.percent; +const decimal: string = localeDef.decimal; +const thousands: string = localeDef.thousands; +const grouping: number[] = localeDef.grouping; +const currency: [string, string] = localeDef.currency; +const numerals: string[] | undefined = localeDef.numerals; +const percent: string | undefined = localeDef.percent; localeObj = d3Format.formatLocale(localeDef); localeObj = d3Format.formatDefaultLocale(localeDef); -let formatFactory: (specifier: string) => ((n: number) => string) = localeObj.format; -let formatPrefixFactory: (specifier: string, value: number) => ((n: number) => string) = localeObj.formatPrefix; +const formatFactory: (specifier: string) => ((n: number) => string) = localeObj.format; +const formatPrefixFactory: (specifier: string, value: number) => ((n: number) => string) = localeObj.formatPrefix; diff --git a/types/d3-format/index.d.ts b/types/d3-format/index.d.ts index 34cf80c047..6592756ef1 100644 --- a/types/d3-format/index.d.ts +++ b/types/d3-format/index.d.ts @@ -112,8 +112,8 @@ export interface FormatSpecifier { comma: boolean; /** * Depending on the type, the precision either indicates the number of digits that follow the decimal point (types 'f' and '%'), - * or the number of significant digits (types ''​ (none), 'e', 'g', 'r', 's' and 'p'). If the precision is not specified, - * it defaults to 6 for all types except ''​ (none), which defaults to 12. + * or the number of significant digits (types '' (none), 'e', 'g', 'r', 's' and 'p'). If the precision is not specified, + * it defaults to 6 for all types except '' (none), which defaults to 12. * Precision is ignored for integer formats (types 'b', 'o', 'd', 'x', 'X' and 'c'). * * See precisionFixed and precisionRound for help picking an appropriate precision @@ -137,7 +137,7 @@ export interface FormatSpecifier { * 'c' - converts the integer to the corresponding unicode character before printing. * '' (none) - like g, but trim insignificant trailing zeros. * - * The type 'n' is also supported as shorthand for ',g'. For the 'g', 'n' and ​''(none) types, + * The type 'n' is also supported as shorthand for ',g'. For the 'g', 'n' and ''(none) types, * decimal notation is used if the resulting string would have precision or fewer digits; otherwise, exponent notation is used. */ type: 'e' | 'f' | 'g' | 'r' | 's' | '%' | 'p' | 'b' | 'o' | 'd' | 'x' | 'X' | 'c' | '' | 'n'; @@ -170,7 +170,7 @@ export function formatDefaultLocale(defaultLocale: FormatLocaleDefinition): Form * * Uses the current default locale. * - * The general form of a specifier is [​[fill]align][sign][symbol][0][width][,][.precision][type]. + * The general form of a specifier is [[fill]align][sign][symbol][0][width][,][.precision][type]. * For reference, an explanation of the segments of the specifier string, refer to the FormatSpecifier interface properties. * * @param specifier A Specifier string @@ -185,7 +185,7 @@ export function format(specifier: string): (n: number) => string; * * Uses the current default locale. * - * The general form of a specifier is [​[fill]align][sign][symbol][0][width][,][.precision][type]. + * The general form of a specifier is [[fill]align][sign][symbol][0][width][,][.precision][type]. * For reference, an explanation of the segments of the specifier string, refer to the FormatSpecifier interface properties. * * @param specifier A Specifier string @@ -197,7 +197,7 @@ export function formatPrefix(specifier: string, value: number): (n: number) => s * Parses the specified specifier, returning an object with exposed fields that correspond to the * format specification mini-language and a toString method that reconstructs the specifier. * - * The general form of a specifier is [​[fill]align][sign][symbol][0][width][,][.precision][type]. + * The general form of a specifier is [[fill]align][sign][symbol][0][width][,][.precision][type]. * For reference, an explanation of the segments of the specifier string, refer to the FormatSpecifier interface properties. * * @param specifier A specifier string. diff --git a/types/d3-geo/d3-geo-tests.ts b/types/d3-geo/d3-geo-tests.ts index 8b8f9557e9..f698193878 100644 --- a/types/d3-geo/d3-geo-tests.ts +++ b/types/d3-geo/d3-geo-tests.ts @@ -607,7 +607,7 @@ let customTransformProto: CustomTranformProto; customTransformProto = { point(x, y) { - return this.stream.point(x + this.a, -y); + this.stream.point(x + this.a, -y); }, a: 10 }; diff --git a/types/d3-geo/tslint.json b/types/d3-geo/tslint.json index 657f2f02f7..3020672011 100644 --- a/types/d3-geo/tslint.json +++ b/types/d3-geo/tslint.json @@ -1,7 +1,13 @@ { "extends": "dtslint/dt.json", "rules": { + // TODO + "no-this-assignment": false, "unified-signatures": false, - "max-line-length": [false, 200] + "max-line-length": [ + false, + 200 + ], + "no-unnecessary-generics": false } } diff --git a/types/d3-hexbin/index.d.ts b/types/d3-hexbin/index.d.ts index 61d7330ca6..dba33cb292 100644 --- a/types/d3-hexbin/index.d.ts +++ b/types/d3-hexbin/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for D3JS d3-hexbin module v0.2.1 // Project: https://github.com/d3/d3-hexbin/ -// Definitions by: UNCOVER TRUTH Inc. , Tom Wanzek +// Definitions by: UNCOVER TRUTH Inc. , Tom Wanzek // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export interface HexbinBin extends Array { diff --git a/types/d3-interpolate/d3-interpolate-tests.ts b/types/d3-interpolate/d3-interpolate-tests.ts index 5cbb6fe3a0..6baaf06092 100644 --- a/types/d3-interpolate/d3-interpolate-tests.ts +++ b/types/d3-interpolate/d3-interpolate-tests.ts @@ -44,7 +44,6 @@ let iString: Interpolator; let iDate: Interpolator; let iArrayNum: Interpolator; let iArrayStr: Interpolator; -let iArrayDate: Interpolator; let iArrayMixed: Interpolator<[Date, string]>; let iKeyVal: Interpolator<{ [key: string]: any }>; let iRGBColorObj: Interpolator; @@ -56,7 +55,6 @@ let arrNum: number[]; let arrStr: string[]; let objKeyVal: { [key: string]: any }; let objRGBColor: d3Color.RGBColor; -let objHSVColor: d3Hsv.HSVColor; let zoom: [number, number, number]; // test interpolate(a, b) signature ---------------------------------------------------- diff --git a/types/d3-path/d3-path-tests.ts b/types/d3-path/d3-path-tests.ts index b11a3405e3..6a7b6a3fa0 100644 --- a/types/d3-path/d3-path-tests.ts +++ b/types/d3-path/d3-path-tests.ts @@ -12,7 +12,7 @@ import * as d3Path from 'd3-path'; // Test create new path serializer // ----------------------------------------------------------------------------------------- -let context: d3Path.Path = d3Path.path(); +const context: d3Path.Path = d3Path.path(); // ----------------------------------------------------------------------------------------- // Test path serializer methods @@ -35,4 +35,4 @@ context.rect(60, 60, 100, 200); context.closePath(); -let pathString: string = context.toString(); +const pathString: string = context.toString(); diff --git a/types/d3-polygon/d3-polygon-tests.ts b/types/d3-polygon/d3-polygon-tests.ts index 748054b727..28e1e464e1 100644 --- a/types/d3-polygon/d3-polygon-tests.ts +++ b/types/d3-polygon/d3-polygon-tests.ts @@ -15,8 +15,8 @@ import * as d3Polygon from 'd3-polygon'; let num: number; let containsFlag: boolean; let point: [number, number] = [15, 15]; -let polygon: Array<[number, number]> = [[10, 10], [20, 20], [10, 30]]; -let pointArray: Array<[number, number]> = [[10, 10], [20, 20], [10, 30], [15, 15]]; +const polygon: Array<[number, number]> = [[10, 10], [20, 20], [10, 30]]; +const pointArray: Array<[number, number]> = [[10, 10], [20, 20], [10, 30], [15, 15]]; let hull: Array<[number, number]>; // ----------------------------------------------------------------------------- diff --git a/types/d3-quadtree/d3-quadtree-tests.ts b/types/d3-quadtree/d3-quadtree-tests.ts index 5fabc66961..eda00fe130 100644 --- a/types/d3-quadtree/d3-quadtree-tests.ts +++ b/types/d3-quadtree/d3-quadtree-tests.ts @@ -39,7 +39,7 @@ let testData: TestDatum[] = [ let node: d3Quadtree.QuadtreeInternalNode | d3Quadtree.QuadtreeLeaf; let numberAccessor: (d: TestDatum) => number; -let simpleTestData: Array<[number, number]> = [ +const simpleTestData: Array<[number, number]> = [ [10, 20], [30, 10], [15, 80], @@ -216,7 +216,7 @@ quadtree = quadtree.visitAfter((node, x0, y0, x1, y1) => { // Test QuadtreeLeaf ========================================================= -let leaf: d3Quadtree.QuadtreeLeaf; +declare const leaf: d3Quadtree.QuadtreeLeaf; let nextLeaf: d3Quadtree.QuadtreeLeaf | undefined; testDatum = leaf.data; @@ -225,7 +225,7 @@ nextLeaf = leaf.next ? leaf.next : undefined; // Test QuadtreeInternalNode ================================================= -let internalNode: d3Quadtree.QuadtreeInternalNode; +declare const internalNode: d3Quadtree.QuadtreeInternalNode; let quadNode: d3Quadtree.QuadtreeInternalNode | d3Quadtree.QuadtreeLeaf | undefined; quadNode = internalNode[0]; diff --git a/types/d3-quadtree/tslint.json b/types/d3-quadtree/tslint.json index 38aa3fb5b3..9e3df4b94a 100644 --- a/types/d3-quadtree/tslint.json +++ b/types/d3-quadtree/tslint.json @@ -2,6 +2,7 @@ "extends": "dtslint/dt.json", "rules": { "unified-signatures": false, - "no-empty-interface": false + "no-empty-interface": false, + "no-unnecessary-generics": false } } diff --git a/types/d3-queue/d3-queue-tests.ts b/types/d3-queue/d3-queue-tests.ts index 312bb0c358..f387ea990a 100644 --- a/types/d3-queue/d3-queue-tests.ts +++ b/types/d3-queue/d3-queue-tests.ts @@ -29,7 +29,7 @@ qWithResults = d3Queue.queue(3); function delayedHello(name: string, delay: number, callback: (error: any | null) => void) { setTimeout(() => { - console.log('Hello, ' + name + '!'); + console.log(`Hello, ${name}!`); callback(null); }, delay); } diff --git a/types/d3-queue/tslint.json b/types/d3-queue/tslint.json index 08b1465cd6..c3beb085cb 100644 --- a/types/d3-queue/tslint.json +++ b/types/d3-queue/tslint.json @@ -1,6 +1,9 @@ { "extends": "dtslint/dt.json", "rules": { + // TODO + "no-any-union": false, + "no-this-assignment": false, "unified-signatures": false } } diff --git a/types/d3-request/d3-request-tests.ts b/types/d3-request/d3-request-tests.ts index 8d8061d76a..8b2130240a 100644 --- a/types/d3-request/d3-request-tests.ts +++ b/types/d3-request/d3-request-tests.ts @@ -16,7 +16,7 @@ import { DSVParsedArray, DSVRowString } from 'd3-dsv'; // Preparatory Steps // ------------------------------------------------------------------------------- -const url: string = 'http:// api.reddit.com'; +const url = 'http:// api.reddit.com'; interface RequestDatumGET { kind: 'Listing'; @@ -49,13 +49,12 @@ let listenerResult: (this: d3Request.Request, result: ResponseDatumGET[]) => voi // ------------------------------------------------------------------------------- // request to configure and send in follow-up -let request: d3Request.Request = d3Request.request(url); +const request: d3Request.Request = d3Request.request(url); // GET-request with callback, immediately sent -let requestWithCallback: d3Request.Request = d3Request.request(url, (error, xhr) => { - let x: XMLHttpRequest; +const requestWithCallback: d3Request.Request = d3Request.request(url, (error, xhr) => { if (!error) { - x = xhr; + const x: XMLHttpRequest = xhr; console.log(xhr.responseText); } }); @@ -65,36 +64,34 @@ let requestWithCallback: d3Request.Request = d3Request.request(url, (error, xhr) // ------------------------------------------------------------------------------- // Abort ----------------------------------------------------------------------- -let r1: d3Request.Request = request.abort(); +const r1: d3Request.Request = request.abort(); // Get ------------------------------------------------------------------------- // no arguments -let r2: d3Request.Request = d3Request.request(url) +const r2: d3Request.Request = d3Request.request(url) .get(); // with request datum -let r3: d3Request.Request = d3Request.request(url) +const r3: d3Request.Request = d3Request.request(url) .get({ kind: 'Listing' }); // with callback for response handling -let r4: d3Request.Request = d3Request.request(url) +const r4: d3Request.Request = d3Request.request(url) .response(xhr2Listing) .get((error, response) => { - let r: ResponseDatumGET[]; if (!error) { - r = response; + const r: ResponseDatumGET[] = response; console.log(r); } }); // with request datum and callback for response handling -let r5: d3Request.Request = d3Request.request(url) +const r5: d3Request.Request = d3Request.request(url) .response(xhr2Listing) .get({ kind: 'Listing' }, (error, response) => { - let r: ResponseDatumGET[]; if (!error) { - r = response; + const r: ResponseDatumGET[] = response; console.log(r); } }); @@ -102,20 +99,20 @@ let r5: d3Request.Request = d3Request.request(url) // Headers -------------------------------------------------------------------- // get -let acceptEncoding: string = request.header('Accept-Encoding'); +const acceptEncoding: string = request.header('Accept-Encoding'); // set -let r6: d3Request.Request = request.header('Accept-Encoding', 'gzip'); +const r6: d3Request.Request = request.header('Accept-Encoding', 'gzip'); // remove -let r7: d3Request.Request = request.header('Accept-Encoding', null); +const r7: d3Request.Request = request.header('Accept-Encoding', null); // Mime Type ------------------------------------------------------------------- // get let mimeType: string = request.mimeType(); // set -let r8: d3Request.Request = request.mimeType('application/json'); +const r8: d3Request.Request = request.mimeType('application/json'); // remove -let r9: d3Request.Request = request.mimeType(null); +const r9: d3Request.Request = request.mimeType(null); // Events - on ------------------------------------------------------------------ @@ -124,8 +121,8 @@ let r10: d3Request.Request = d3Request.request(url); // beforesent r10 = r10.on('beforesend', function(xhr) { - let that: d3Request.Request = this; - let x: XMLHttpRequest = xhr; + const that: d3Request.Request = this; + const x: XMLHttpRequest = xhr; // do something; }); @@ -134,8 +131,8 @@ listenerXhr = r10.on('beforesend'); // progress r10 = r10.on('progress', function(progEvent) { - let that: d3Request.Request = this; - let e: ProgressEvent = progEvent; + const that: d3Request.Request = this; + const e: ProgressEvent = progEvent; // do something; }); @@ -144,8 +141,8 @@ listenerProgress = r10.on('progress'); // error r10 = r10.on('error', function(error) { - let that: d3Request.Request = this; - let err: any = error; + const that: d3Request.Request = this; + const err: any = error; // do something; }); @@ -154,20 +151,20 @@ listenerError = r10.on('error'); // load r10 = r10.on('load', function(result) { - let that: d3Request.Request = this; - let res: ResponseDatumGET[] = result; + const that: d3Request.Request = this; + const res: ResponseDatumGET[] = result; // do something; }); r10 = r10.on('load', function(result: ResponseDatumGET[]) { - let that: d3Request.Request = this; - let res: ResponseDatumGET[] = result; + const that: d3Request.Request = this; + const res: ResponseDatumGET[] = result; // do something; }); // r10 = r10.on('load', function(result: number) { // fails, wrong argument type for callback -// let that: d3Request.Request = this; -// let res: number = result; +// const that: d3Request.Request = this; +// const res: number = result; // // do something; // }); @@ -176,16 +173,16 @@ listenerResult = r10.on('load'); // general (for unknown type additional event listener e.g. 'beforesent.custom' or 'load.custom') r10 = r10.on('progress.foo', function(progEvent: ProgressEvent) { - let that: d3Request.Request = this; - let e: any = ProgressEvent; + const that: d3Request.Request = this; + const e: any = ProgressEvent; // do something; }); listenerProgress = r10.on('progress.foo'); r10 = r10.on('error.foo', function(error) { - let that: d3Request.Request = this; - let err: any = error; + const that: d3Request.Request = this; + const err: any = error; // do something; }); @@ -194,95 +191,85 @@ listenerError = r10.on('error.foo'); // Password --------------------------------------------------------------------- // get -let password: string = request.password(); +const password: string = request.password(); // set -let r11: d3Request.Request = request.password('MyPassword'); +const r11: d3Request.Request = request.password('MyPassword'); // Post ------------------------------------------------------------------------- function xhr2Success(xhr: XMLHttpRequest): ResponseDatumPOST { - let result: ResponseDatumPOST; - - result = JSON.parse(xhr.responseText); - - return result; + return JSON.parse(xhr.responseText); } // no arguments -let r12: d3Request.Request = d3Request.request(url) +const r12: d3Request.Request = d3Request.request(url) .post(); // with request datum -let r13: d3Request.Request = d3Request.request(url) +const r13: d3Request.Request = d3Request.request(url) .post({ test: 'NewValue', value: 10 }); // with callback for response handling -let r14: d3Request.Request = d3Request.request(url).response(xhr2Success) +const r14: d3Request.Request = d3Request.request(url).response(xhr2Success) .post(function(error, response) { - let that: d3Request.Request = this; - let err: any = error; - let res: ResponseDatumPOST = response; + const that: d3Request.Request = this; + const err: any = error; + const res: ResponseDatumPOST = response; console.log('Success? ', res.success); }); -let r15: d3Request.Request = d3Request.request(url).response(xhr2Success) +const r15: d3Request.Request = d3Request.request(url).response(xhr2Success) .post({ test: 'NewValue', value: 10 }, function(error, response) { - let that: d3Request.Request = this; - let err: any = error; - let res: ResponseDatumPOST = response; + const that: d3Request.Request = this; + const err: any = error; + const res: ResponseDatumPOST = response; console.log('Success? ', res.success); }); // Response --------------------------------------------------------------------- function xhr2Listing(xhr: XMLHttpRequest): ResponseDatumGET[] { - let result: ResponseDatumGET[]; - - result = JSON.parse(xhr.responseText); - - return result; + return JSON.parse(xhr.responseText); } -let r16: d3Request.Request = d3Request.request(url) +const r16: d3Request.Request = d3Request.request(url) .response(xhr2Listing); // ResponseType ----------------------------------------------------------------- // get -let responseType: string = d3Request.request(url) +const responseType: string = d3Request.request(url) .responseType(); // set -let r17: d3Request.Request = d3Request.request(url) +const r17: d3Request.Request = d3Request.request(url) .responseType('application/json'); // Send ------------------------------------------------------------------------ // method only -let r18: d3Request.Request = d3Request.request(url) +const r18: d3Request.Request = d3Request.request(url) .send('GET'); // method and request datum -let r19: d3Request.Request = d3Request.request(url) +const r19: d3Request.Request = d3Request.request(url) .send('POST', { test: 'NewValue', value: 10 }); // method and callback for response handling -let r20: d3Request.Request = d3Request.request(url) +const r20: d3Request.Request = d3Request.request(url) .response(xhr2Listing) .send('GET', (error, response) => { - let r: ResponseDatumGET[]; if (!error) { - r = response; + const r: ResponseDatumGET[] = response; console.log(r); } }); // method,request datum and callback for response handling -let r21: d3Request.Request = d3Request.request(url) +const r21: d3Request.Request = d3Request.request(url) .response(xhr2Listing) .send('GET', { kind: 'Listing' }, (error, response) => { - let r: ResponseDatumGET[]; if (!error) { - r = response; + const r: ResponseDatumGET[] = response; console.log(r); } }); @@ -290,28 +277,28 @@ let r21: d3Request.Request = d3Request.request(url) // Timeout ----------------------------------------------------------------------- // get -let timeout: number = d3Request.request(url) +const timeout: number = d3Request.request(url) .timeout(); // set -let r22: d3Request.Request = d3Request.request(url) +const r22: d3Request.Request = d3Request.request(url) .timeout(500); // User---------------------------------------------------------------------------- // get -let user: string = request.user(); +const user: string = request.user(); // set -let r23: d3Request.Request = request.user('User'); +const r23: d3Request.Request = request.user('User'); // ------------------------------------------------------------------------------- // HTML Request // ------------------------------------------------------------------------------- -let html: d3Request.Request = d3Request.html(url); -let htmlWithCallback: d3Request.Request = d3Request.html(url, function(error, data) { - let that: d3Request.Request = this; - let err: any = error; - let d: DocumentFragment = data; +const html: d3Request.Request = d3Request.html(url); +const htmlWithCallback: d3Request.Request = d3Request.html(url, function(error, data) { + const that: d3Request.Request = this; + const err: any = error; + const d: DocumentFragment = data; console.log(d); }); @@ -319,11 +306,11 @@ let htmlWithCallback: d3Request.Request = d3Request.html(url, function(error, da // JSON Request // ------------------------------------------------------------------------------- -let json: d3Request.Request = d3Request.json(url); -let jsonWithCallback: d3Request.Request = d3Request.json(url, function(error, data) { - let that: d3Request.Request = this; - let err: any = error; - let d: ResponseDatumGET[] = data; +const json: d3Request.Request = d3Request.json(url); +const jsonWithCallback: d3Request.Request = d3Request.json(url, function(error, data) { + const that: d3Request.Request = this; + const err: any = error; + const d: ResponseDatumGET[] = data; console.log(d); }); @@ -331,11 +318,11 @@ let jsonWithCallback: d3Request.Request = d3Request.json(url // Text Request // ------------------------------------------------------------------------------- -let text: d3Request.Request = d3Request.text(url); -let textWithCallback: d3Request.Request = d3Request.text(url, function(error, data) { - let that: d3Request.Request = this; - let err: any = error; - let d: string = data; +const text: d3Request.Request = d3Request.text(url); +const textWithCallback: d3Request.Request = d3Request.text(url, function(error, data) { + const that: d3Request.Request = this; + const err: any = error; + const d: string = data; console.log(d); }); @@ -343,11 +330,11 @@ let textWithCallback: d3Request.Request = d3Request.text(url, function(error, da // XML Request // ------------------------------------------------------------------------------- -let xml: d3Request.Request = d3Request.xml(url); -let xmlWithCallback: d3Request.Request = d3Request.xml(url, function(error, data) { - let that: d3Request.Request = this; - let err: any = error; - let d: any = data; +const xml: d3Request.Request = d3Request.xml(url); +const xmlWithCallback: d3Request.Request = d3Request.xml(url, function(error, data) { + const that: d3Request.Request = this; + const err: any = error; + const d: any = data; console.log(d); }); @@ -359,32 +346,29 @@ let xmlWithCallback: d3Request.Request = d3Request.xml(url, function(error, data let csvRequest: d3Request.DsvRequest = d3Request.csv(url); // url and callback for response handling -let csvRequestWithCallback: d3Request.DsvRequest = d3Request.csv(url, function(error, data) { - let that: d3Request.Request = this; - let err: any = error; - let d: DSVParsedArray = data; +const csvRequestWithCallback: d3Request.DsvRequest = d3Request.csv(url, function(error, data) { + const that: d3Request.Request = this; + const err: any = error; + const d: DSVParsedArray = data; console.log(d); }); // url, row mapping function and callback for response handling -let csvRequestWithRowWithCallback: d3Request.DsvRequest = d3Request.csv(url, +const csvRequestWithRowWithCallback: d3Request.DsvRequest = d3Request.csv(url, (rawRow, index, columns) => { - let rr: DSVRowString = rawRow; - let i: number = index; - let cols: string[] = columns; - let mappedRow: ResponseDatumGET; - - mappedRow = { + const rr: DSVRowString = rawRow; + const i: number = index; + const cols: string[] = columns; + const mappedRow: ResponseDatumGET = { test: rr['test'], value: +rr['value'] }; - return mappedRow; }, function(error, data) { - let that: d3Request.Request = this; - let err: any = error; - let d: DSVParsedArray = data; + const that: d3Request.Request = this; + const err: any = error; + const d: DSVParsedArray = data; console.log(data); }); @@ -393,35 +377,32 @@ let csvRequestWithRowWithCallback: d3Request.DsvRequest = d3Request.csv = data; +const tsvRequestWithCallback: d3Request.DsvRequest = d3Request.tsv(url, function(error, data) { + const that: d3Request.Request = this; + const err: any = error; + const d: DSVParsedArray = data; console.log(d); }); // url, row mapping function and callback for response handling -let tsvRequestWithRowWithCallback: d3Request.DsvRequest = d3Request.tsv(url, +const tsvRequestWithRowWithCallback: d3Request.DsvRequest = d3Request.tsv(url, (rawRow, index, columns) => { - let rr: DSVRowString = rawRow; - let i: number = index; - let cols: string[] = columns; - let mappedRow: ResponseDatumGET; - - mappedRow = { + const rr: DSVRowString = rawRow; + const i: number = index; + const cols: string[] = columns; + const mappedRow: ResponseDatumGET = { test: rr['test'], value: +rr['value'] }; - return mappedRow; }, function(error, data) { - let that: d3Request.Request = this; - let err: any = error; - let d: DSVParsedArray = data; + const that: d3Request.Request = this; + const err: any = error; + const d: DSVParsedArray = data; console.log(data); }); @@ -433,16 +414,13 @@ let tsvRequestWithRowWithCallback: d3Request.DsvRequest = d3Request.tsv((rawRow, index, columns) => { - let rr: DSVRowString = rawRow; - let i: number = index; - let cols: string[] = columns; - let mappedRow: ResponseDatumGET; - - mappedRow = { + const rr: DSVRowString = rawRow; + const i: number = index; + const cols: string[] = columns; + const mappedRow: ResponseDatumGET = { test: rr['test'], value: +rr['value'] }; - return mappedRow; }); diff --git a/types/d3-request/tslint.json b/types/d3-request/tslint.json index da66196eee..a965459d61 100644 --- a/types/d3-request/tslint.json +++ b/types/d3-request/tslint.json @@ -1,6 +1,10 @@ { "extends": "dtslint/dt.json", "rules": { + // TODOs + "no-any-union": false, + "no-this-assignment": false, + "no-unnecessary-generics": false, "unified-signatures": false, "max-line-length": [false, 145] } diff --git a/types/d3-sankey/d3-sankey-tests.ts b/types/d3-sankey/d3-sankey-tests.ts index abf61775b8..ace13d7e3c 100644 --- a/types/d3-sankey/d3-sankey-tests.ts +++ b/types/d3-sankey/d3-sankey-tests.ts @@ -168,7 +168,7 @@ let sGraph: d3Sankey.SankeyGraph; // Obtain SankeyLayout Generator // --------------------------------------------------------------------------- -let slgDefault: d3Sankey.SankeyLayout, {}, {}> = d3Sankey.sankey(); +const slgDefault: d3Sankey.SankeyLayout, {}, {}> = d3Sankey.sankey(); let slgDAG: d3Sankey.SankeyLayout = d3Sankey.sankey(); let slgDAGCustomId: d3Sankey.SankeyLayout = d3Sankey.sankey(); @@ -299,7 +299,7 @@ slgDAG = slgDAG.nodes(d => d.customNodes); // Get ----------------------------------------------------------------------- -let nodesAccessor: (d: DAG) => SNode[] = slgDAG.nodes(); +const nodesAccessor: (d: DAG) => SNode[] = slgDAG.nodes(); // --------------------------------------------------------------------------- // Links @@ -315,7 +315,7 @@ slgDAG = slgDAG.links(d => d.customLinks); // Get ----------------------------------------------------------------------- -let linksAccessor: (d: DAG) => SLink[] = slgDAG.links(); +const linksAccessor: (d: DAG) => SLink[] = slgDAG.links(); // --------------------------------------------------------------------------- // Compute Initial Layout @@ -344,7 +344,7 @@ pathGen = d3Sankey.sankeyLinkHorizontal(); // Render to svg path -let svgPathString: string | null = pathGen(sGraph.links[0]); +const svgPathString: string | null = pathGen(sGraph.links[0]); svgLinkPaths.attr('d', pathGen); // Render to canvas @@ -361,7 +361,7 @@ pathGen(sGraph.links[0]); // Sankey Node -------------------------------------------------------------- sNodes = sGraph.nodes; -let sNode = sNodes[0]; +const sNode = sNodes[0]; // User-specified extra properties: @@ -386,7 +386,7 @@ linksArrMaybe = sNode.targetLinks; // Sankey Link -------------------------------------------------------------- sLinks = sGraph.links; -let sLink = sLinks[0]; +const sLink = sLinks[0]; // User-specified extra properties: diff --git a/types/d3-sankey/tslint.json b/types/d3-sankey/tslint.json index 08b1465cd6..54efb0b84e 100644 --- a/types/d3-sankey/tslint.json +++ b/types/d3-sankey/tslint.json @@ -1,6 +1,7 @@ { "extends": "dtslint/dt.json", "rules": { - "unified-signatures": false + "unified-signatures": false, + "no-unnecessary-generics": false } } diff --git a/types/d3-scale-chromatic/d3-scale-chromatic-tests.ts b/types/d3-scale-chromatic/d3-scale-chromatic-tests.ts index 1dac850043..ccf736d43b 100644 --- a/types/d3-scale-chromatic/d3-scale-chromatic-tests.ts +++ b/types/d3-scale-chromatic/d3-scale-chromatic-tests.ts @@ -11,50 +11,80 @@ import * as d3ScaleChromatic from 'd3-scale-chromatic'; // ----------------------------------------------------------------------- // Categorical // ----------------------------------------------------------------------- -let accent: string = d3ScaleChromatic.schemeAccent[0]; // #7fc97f -let dark: string = d3ScaleChromatic.schemeDark2[0]; // #1b9e77 -let paired: string = d3ScaleChromatic.schemePaired[0]; // #a6cee3 -let pastel1: string = d3ScaleChromatic.schemePastel1[0]; // #fbb4ae -let pastel2: string = d3ScaleChromatic.schemePastel2[0]; // #b3e2cd -let set1: string = d3ScaleChromatic.schemeSet1[0]; // #e41a1c -let set2: string = d3ScaleChromatic.schemeSet2[0]; // #66c2a5 -let set3: string = d3ScaleChromatic.schemeSet3[0]; // #8dd3c7 +const accent: string = d3ScaleChromatic.schemeAccent[0]; // #7fc97f +const dark: string = d3ScaleChromatic.schemeDark2[0]; // #1b9e77 +const paired: string = d3ScaleChromatic.schemePaired[0]; // #a6cee3 +const pastel1: string = d3ScaleChromatic.schemePastel1[0]; // #fbb4ae +const pastel2: string = d3ScaleChromatic.schemePastel2[0]; // #b3e2cd +const set1: string = d3ScaleChromatic.schemeSet1[0]; // #e41a1c +const set2: string = d3ScaleChromatic.schemeSet2[0]; // #66c2a5 +const set3: string = d3ScaleChromatic.schemeSet3[0]; // #8dd3c7 // ----------------------------------------------------------------------- // Diverging // ----------------------------------------------------------------------- -let BrBG: string = d3ScaleChromatic.interpolateBrBG(0); // rgb(84, 48, 5) -let PRGn: string = d3ScaleChromatic.interpolatePRGn(0); // rgb(64, 0, 75) -let PiYG: string = d3ScaleChromatic.interpolatePiYG(0); // rgb(142, 1, 82) -let PuOr: string = d3ScaleChromatic.interpolatePuOr(0); // rgb(127, 59, 8) -let RdBu: string = d3ScaleChromatic.interpolateRdBu(0); // rgb(103, 0, 31) -let RdGy: string = d3ScaleChromatic.interpolateRdGy(0); // rgb(103, 0, 31) -let RdYlBu: string = d3ScaleChromatic.interpolateRdYlBu(0); // rgb(103, 0, 31) -let RdYlGn: string = d3ScaleChromatic.interpolateRdYlGn(0); // rgb(103, 0, 31) -let Spectral: string = d3ScaleChromatic.interpolateSpectral(0); // rgb(158, 1, 66) +const BrBG: string = d3ScaleChromatic.interpolateBrBG(0); // rgb(84, 48, 5) +const PRGn: string = d3ScaleChromatic.interpolatePRGn(0); // rgb(64, 0, 75) +const PiYG: string = d3ScaleChromatic.interpolatePiYG(0); // rgb(142, 1, 82) +const PuOr: string = d3ScaleChromatic.interpolatePuOr(0); // rgb(127, 59, 8) +const RdBu: string = d3ScaleChromatic.interpolateRdBu(0); // rgb(103, 0, 31) +const RdGy: string = d3ScaleChromatic.interpolateRdGy(0); // rgb(103, 0, 31) +const RdYlBu: string = d3ScaleChromatic.interpolateRdYlBu(0); // rgb(103, 0, 31) +const RdYlGn: string = d3ScaleChromatic.interpolateRdYlGn(0); // rgb(103, 0, 31) +const Spectral: string = d3ScaleChromatic.interpolateSpectral(0); // rgb(158, 1, 66) + +const schemeBrBG: string = d3ScaleChromatic.schemeBrBG[3][0]; // #d8b365 +const schemePRGn: string = d3ScaleChromatic.schemePRGn[3][0]; // #af8dc3 +const schemePiYG: string = d3ScaleChromatic.schemePiYG[3][0]; // #e9a3c9 +const schemePuOr: string = d3ScaleChromatic.schemePuOr[3][0]; // #998ec3 +const schemeRdBu: string = d3ScaleChromatic.schemeRdBu[3][0]; // #ef8a62 +const schemeRdGy: string = d3ScaleChromatic.schemeRdGy[3][0]; // #ef8a62 +const schemeRdYlBu: string = d3ScaleChromatic.schemeRdYlBu[3][0]; // #fc8d59 +const schemeRdYlGn: string = d3ScaleChromatic.schemeRdYlGn[3][0]; // #fc8d59 +const schemeSpectral: string = d3ScaleChromatic.schemeSpectral[3][0]; // #fc8d59 // ----------------------------------------------------------------------- // Sequential // ----------------------------------------------------------------------- -let Blue: string = d3ScaleChromatic.interpolateBlues(1); // rgb(8, 48, 107) -let Green: string = d3ScaleChromatic.interpolateGreens(1); // rgb(0, 68, 27) -let Grey: string = d3ScaleChromatic.interpolateGreys(1); // rgb(0, 0, 0) -let Orange: string = d3ScaleChromatic.interpolateOranges(1); // rgb(127, 39, 4) -let Purple: string = d3ScaleChromatic.interpolatePurples(1); // rgb(63, 0, 125) -let Red: string = d3ScaleChromatic.interpolateReds(1); // rgb(103, 0, 13) +const Blue: string = d3ScaleChromatic.interpolateBlues(1); // rgb(8, 48, 107) +const Green: string = d3ScaleChromatic.interpolateGreens(1); // rgb(0, 68, 27) +const Grey: string = d3ScaleChromatic.interpolateGreys(1); // rgb(0, 0, 0) +const Orange: string = d3ScaleChromatic.interpolateOranges(1); // rgb(127, 39, 4) +const Purple: string = d3ScaleChromatic.interpolatePurples(1); // rgb(63, 0, 125) +const Red: string = d3ScaleChromatic.interpolateReds(1); // rgb(103, 0, 13) + +const schemeBlues: string = d3ScaleChromatic.schemeBlues[3][0]; // #deebf7 +const schemeGreens: string = d3ScaleChromatic.schemeGreens[3][0]; // #e5f5e0 +const schemeGreys: string = d3ScaleChromatic.schemeGreys[3][0]; // #f0f0f0 +const schemeOranges: string = d3ScaleChromatic.schemeOranges[3][0]; // #fee6ce +const schemePurples: string = d3ScaleChromatic.schemePurples[3][0]; // #efedf5 +const schemeReds: string = d3ScaleChromatic.schemeReds[3][0]; // #fee0d2 // ----------------------------------------------------------------------- // Sequential(Multi-Hue) // ----------------------------------------------------------------------- -let BuGn: string = d3ScaleChromatic.interpolateBuGn(1); // rgb(0, 68, 27) -let BuPu: string = d3ScaleChromatic.interpolateBuPu(1); // rgb(77, 0, 75) -let GnBu: string = d3ScaleChromatic.interpolateGnBu(1); // rgb(8, 64, 129) -let OrRd: string = d3ScaleChromatic.interpolateOrRd(1); // rgb(127, 0, 0) -let PuBuGn: string = d3ScaleChromatic.interpolatePuBuGn(1); // rgb(1, 70, 54) -let PuBu: string = d3ScaleChromatic.interpolatePuBu(1); // rgb(2, 56, 88) -let PuRd: string = d3ScaleChromatic.interpolatePuRd(1); // rgb(103, 0, 31) -let RdPu: string = d3ScaleChromatic.interpolateRdPu(1); // rgb(73, 0, 106) -let YlGnBu: string = d3ScaleChromatic.interpolateYlGnBu(1); // rgb(8, 29, 88) -let YlGn: string = d3ScaleChromatic.interpolateYlGn(1); // rgb(0, 69, 41) -let YlOrBr: string = d3ScaleChromatic.interpolateYlOrBr(1); // rgb(102, 37, 6) -let YlOrRd: string = d3ScaleChromatic.interpolateYlOrRd(1); // rgb(128, 0, 38) +const BuGn: string = d3ScaleChromatic.interpolateBuGn(1); // rgb(0, 68, 27) +const BuPu: string = d3ScaleChromatic.interpolateBuPu(1); // rgb(77, 0, 75) +const GnBu: string = d3ScaleChromatic.interpolateGnBu(1); // rgb(8, 64, 129) +const OrRd: string = d3ScaleChromatic.interpolateOrRd(1); // rgb(127, 0, 0) +const PuBuGn: string = d3ScaleChromatic.interpolatePuBuGn(1); // rgb(1, 70, 54) +const PuBu: string = d3ScaleChromatic.interpolatePuBu(1); // rgb(2, 56, 88) +const PuRd: string = d3ScaleChromatic.interpolatePuRd(1); // rgb(103, 0, 31) +const RdPu: string = d3ScaleChromatic.interpolateRdPu(1); // rgb(73, 0, 106) +const YlGnBu: string = d3ScaleChromatic.interpolateYlGnBu(1); // rgb(8, 29, 88) +const YlGn: string = d3ScaleChromatic.interpolateYlGn(1); // rgb(0, 69, 41) +const YlOrBr: string = d3ScaleChromatic.interpolateYlOrBr(1); // rgb(102, 37, 6) +const YlOrRd: string = d3ScaleChromatic.interpolateYlOrRd(1); // rgb(128, 0, 38) + +const schemeBuGn: string = d3ScaleChromatic.schemeBuGn[3][0]; // #e5f5f9 +const schemeBuPu: string = d3ScaleChromatic.schemeBuPu[3][0]; // #e0ecf4 +const schemeGnBu: string = d3ScaleChromatic.schemeGnBu[3][0]; // #e0f3db +const schemeOrRd: string = d3ScaleChromatic.schemeOrRd[3][0]; // #fee8c8 +const schemePuBuGn: string = d3ScaleChromatic.schemePuBuGn[3][0]; // #ece2f0 +const schemePuBu: string = d3ScaleChromatic.schemePuBu[3][0]; // #ece7f2 +const schemePuRd: string = d3ScaleChromatic.schemePuRd[3][0]; // #e7e1ef +const schemeRdPu: string = d3ScaleChromatic.schemeRdPu[3][0]; // #fde0dd +const schemeYlGnBu: string = d3ScaleChromatic.schemeYlGnBu[3][0]; // #edf8b1 +const schemeYlGn: string = d3ScaleChromatic.schemeYlGn[3][0]; // #f7fcb9 +const schemeYlOrBr: string = d3ScaleChromatic.schemeYlOrBr[3][0]; // #fff7bc +const schemeYlOrRd: string = d3ScaleChromatic.schemeYlOrRd[3][0]; // #ffeda0 diff --git a/types/d3-scale-chromatic/index.d.ts b/types/d3-scale-chromatic/index.d.ts index 450d103259..1345371e2a 100644 --- a/types/d3-scale-chromatic/index.d.ts +++ b/types/d3-scale-chromatic/index.d.ts @@ -1,6 +1,9 @@ -// Type definitions for D3JS d3-scale-chromatic module 1.0 +// Type definitions for D3JS d3-scale-chromatic module 1.1 // Project: https://github.com/d3/d3-scale-chromatic/ -// Definitions by: Hugues Stefanski , Alex Ford , Boris Yankov +// Definitions by: Hugues Stefanski , +// Alex Ford , +// Boris Yankov , +// Henrique Machado // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Last module patch version validated against: 1.0.2 @@ -11,35 +14,35 @@ /** * An array of eight categorical colors represented as RGB hexadecimal strings. */ -export const schemeAccent: string[]; +export const schemeAccent: ReadonlyArray; /** * An array of eight categorical colors represented as RGB hexadecimal strings. */ -export const schemeDark2: string[]; +export const schemeDark2: ReadonlyArray; /** * An array of twelve categorical colors represented as RGB hexadecimal strings. */ -export const schemePaired: string[]; +export const schemePaired: ReadonlyArray; /** * An array of nine categorical colors represented as RGB hexadecimal strings. */ -export const schemePastel1: string[]; +export const schemePastel1: ReadonlyArray; /** * An array of eight categorical colors represented as RGB hexadecimal strings. */ -export const schemePastel2: string[]; +export const schemePastel2: ReadonlyArray; /** * An array of nine categorical colors represented as RGB hexadecimal strings. */ -export const schemeSet1: string[]; +export const schemeSet1: ReadonlyArray; /** * An array of eight categorical colors represented as RGB hexadecimal strings. */ -export const schemeSet2: string[]; +export const schemeSet2: ReadonlyArray; /** * An array of twelve categorical colors represented as RGB hexadecimal strings. */ -export const schemeSet3: string[]; +export const schemeSet3: ReadonlyArray; // ----------------------------------------------------------------------- // Diverging @@ -50,48 +53,112 @@ export const schemeSet3: string[]; * @param value Number in the range [0, 1]. */ export function interpolateBrBG(value: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “BrBG” diverging color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeBrBG[9] contains an array of nine strings representing the nine colors of the + * brown-blue-green diverging color scheme. Diverging color schemes support a size k ranging from 3 to 11. + */ +export const schemeBrBG: ReadonlyArray>; + /** * Given a number t in the range [0,1], returns the corresponding color from the “PRGn” diverging color scheme represented as an RGB string. * * @param value Number in the range [0, 1]. */ export function interpolatePRGn(value: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “PRGn” diverging color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemePRGn[9] contains an array of nine strings representing the nine colors of the + * purple-green diverging color scheme. Diverging color schemes support a size k ranging from 3 to 11. + */ +export const schemePRGn: ReadonlyArray>; + /** * Given a number t in the range [0,1], returns the corresponding color from the “PiYG” diverging color scheme represented as an RGB string. * * @param value Number in the range [0, 1]. */ export function interpolatePiYG(value: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “PiYG” diverging color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemePiYG[9] contains an array of nine strings representing the nine colors of the + * pink-yellow-green diverging color scheme. Diverging color schemes support a size k ranging from 3 to 11. + */ +export const schemePiYG: ReadonlyArray>; + /** * Given a number t in the range [0,1], returns the corresponding color from the “PuOr” diverging color scheme represented as an RGB string. * * @param value Number in the range [0, 1]. */ export function interpolatePuOr(value: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “PuOr” diverging color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemePuOr[9] contains an array of nine strings representing the nine colors of the + * purple-orange diverging color scheme. Diverging color schemes support a size k ranging from 3 to 11. + */ +export const schemePuOr: ReadonlyArray>; + /** * Given a number t in the range [0,1], returns the corresponding color from the “RdBu” diverging color scheme represented as an RGB string. * * @param value Number in the range [0, 1]. */ export function interpolateRdBu(value: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “RdBu” diverging color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeRdBu[9] contains an array of nine strings representing the nine colors of the + * red-blue diverging color scheme. Diverging color schemes support a size k ranging from 3 to 11. + */ +export const schemeRdBu: ReadonlyArray>; + /** * Given a number t in the range [0,1], returns the corresponding color from the “RdGy” diverging color scheme represented as an RGB string. * * @param value Number in the range [0, 1]. */ export function interpolateRdGy(value: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “RdGy” diverging color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeRdGy[9] contains an array of nine strings representing the nine colors of the + * red-grey diverging color scheme. Diverging color schemes support a size k ranging from 3 to 11. + */ +export const schemeRdGy: ReadonlyArray>; + /** * Given a number t in the range [0,1], returns the corresponding color from the “RdYlBu” diverging color scheme represented as an RGB string. * * @param value Number in the range [0, 1]. */ export function interpolateRdYlBu(value: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “RdYlBu” diverging color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeRdYlBu[9] contains an array of nine strings representing the nine colors of the + * red-yellow-blue diverging color scheme. Diverging color schemes support a size k ranging from 3 to 11. + */ +export const schemeRdYlBu: ReadonlyArray>; + /** * Given a number t in the range [0,1], returns the corresponding color from the “RdYlGn” diverging color scheme represented as an RGB string. * * @param value Number in the range [0, 1]. */ export function interpolateRdYlGn(value: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “RdYlGn” diverging color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeRdYlGn[9] contains an array of nine strings representing the nine colors of the + * red-yellow-green diverging color scheme. Diverging color schemes support a size k ranging from 3 to 11. + */ +export const schemeRdYlGn: ReadonlyArray>; + /** * Given a number t in the range [0,1], returns the corresponding color from the “Spectral” diverging color scheme represented as an RGB string. * @@ -99,6 +166,13 @@ export function interpolateRdYlGn(value: number): string; */ export function interpolateSpectral(value: number): string; +/** + * An array of arrays of hexadecimal color strings from the “Spectral” diverging color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeSpectral[9] contains an array of nine strings representing the nine colors of the + * spectral diverging color scheme. Diverging color schemes support a size k ranging from 3 to 11. + */ +export const schemeSpectral: ReadonlyArray>; + // ----------------------------------------------------------------------- // Sequential // ----------------------------------------------------------------------- @@ -108,30 +182,70 @@ export function interpolateSpectral(value: number): string; * @param value Number in the range [0, 1]. */ export function interpolateBlues(value: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “Blues” sequential color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeBlues[9] contains an array of nine strings representing the nine colors of the + * blue sequential color scheme. Sequential, single-hue color schemes support a size k ranging from 3 to 9. + */ +export const schemeBlues: ReadonlyArray>; + /** * Given a number t in the range [0,1], returns the corresponding color from the “Greens” sequential color scheme represented as an RGB string. * * @param value Number in the range [0, 1]. */ export function interpolateGreens(value: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “Greens” sequential color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeGreens[9] contains an array of nine strings representing the nine colors of the + * green sequential color scheme. Sequential, single-hue color schemes support a size k ranging from 3 to 9. + */ +export const schemeGreens: ReadonlyArray>; + /** * Given a number t in the range [0,1], returns the corresponding color from the “Greys” sequential color scheme represented as an RGB string. * * @param value Number in the range [0, 1]. */ export function interpolateGreys(value: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “Greys” sequential color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeGreys[9] contains an array of nine strings representing the nine colors of the + * grey sequential color scheme. Sequential, single-hue color schemes support a size k ranging from 3 to 9. + */ +export const schemeGreys: ReadonlyArray>; + /** * Given a number t in the range [0,1], returns the corresponding color from the “Oranges” sequential color scheme represented as an RGB string. * * @param value Number in the range [0, 1]. */ export function interpolateOranges(value: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “Oranges” sequential color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeOranges[9] contains an array of nine strings representing the nine colors of the + * orange sequential color scheme. Sequential, single-hue color schemes support a size k ranging from 3 to 9. + */ +export const schemeOranges: ReadonlyArray>; + /** * Given a number t in the range [0,1], returns the corresponding color from the “Purples” sequential color scheme represented as an RGB string. * * @param value Number in the range [0, 1]. */ export function interpolatePurples(value: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “Purples” sequential color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemePurples[9] contains an array of nine strings representing the nine colors of the + * purple sequential color scheme. Sequential, single-hue color schemes support a size k ranging from 3 to 9. + */ +export const schemePurples: ReadonlyArray>; + /** * Given a number t in the range [0,1], returns the corresponding color from the “Reds” sequential color scheme represented as an RGB string. * @@ -139,6 +253,13 @@ export function interpolatePurples(value: number): string; */ export function interpolateReds(value: number): string; +/** + * An array of arrays of hexadecimal color strings from the “Reds” sequential color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeReds[9] contains an array of nine strings representing the nine colors of the + * red sequential color scheme. Sequential, single-hue color schemes support a size k ranging from 3 to 9. + */ +export const schemeReds: ReadonlyArray>; + // ----------------------------------------------------------------------- // Sequential(Multi-Hue) // ----------------------------------------------------------------------- @@ -149,69 +270,164 @@ export function interpolateReds(value: number): string; * @param value Number in the range [0, 1]. */ export function interpolateBuGn(value: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “BuGn” sequential color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeBuGn[9] contains an array of nine strings representing the nine colors of the + * blue-green sequential color scheme. Sequential, multi-hue color schemes support a size k ranging from 3 to 9. + */ +export const schemeBuGn: ReadonlyArray>; + /** * Given a number t in the range [0,1], returns the corresponding color from the “BuPu” sequential color scheme represented as an RGB string. * * @param value Number in the range [0, 1]. */ export function interpolateBuPu(value: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “BuPu” sequential color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeBuPu[9] contains an array of nine strings representing the nine colors of the + * blue-purple sequential color scheme. Sequential, multi-hue color schemes support a size k ranging from 3 to 9. + */ +export const schemeBuPu: ReadonlyArray>; + /** * Given a number t in the range [0,1], returns the corresponding color from the “GnBu” sequential color scheme represented as an RGB string. * * @param value Number in the range [0, 1]. */ export function interpolateGnBu(value: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “GnBu” sequential color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeGnBu[9] contains an array of nine strings representing the nine colors of the + * green-blue sequential color scheme. Sequential, multi-hue color schemes support a size k ranging from 3 to 9. + */ +export const schemeGnBu: ReadonlyArray>; + /** * Given a number t in the range [0,1], returns the corresponding color from the “OrRd” sequential color scheme represented as an RGB string. * * @param value Number in the range [0, 1]. */ export function interpolateOrRd(value: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “OrRd” sequential color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeOrRd[9] contains an array of nine strings representing the nine colors of the + * orange-red sequential color scheme. Sequential, multi-hue color schemes support a size k ranging from 3 to 9. + */ +export const schemeOrRd: ReadonlyArray>; + /** * Given a number t in the range [0,1], returns the corresponding color from the “PuBuGn” sequential color scheme represented as an RGB string. * * @param value Number in the range [0, 1]. */ export function interpolatePuBuGn(value: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “PuBuGn” sequential color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemePuBuGn[9] contains an array of nine strings representing the nine colors of the + * purple-blue-green sequential color scheme. Sequential, multi-hue color schemes support a size k ranging from 3 to 9. + */ +export const schemePuBuGn: ReadonlyArray>; + /** * Given a number t in the range [0,1], returns the corresponding color from the “PuBu” sequential color scheme represented as an RGB string. * * @param value Number in the range [0, 1]. */ export function interpolatePuBu(value: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “PuBu” sequential color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemePuBu[9] contains an array of nine strings representing the nine colors of the + * purple-blue sequential color scheme. Sequential, multi-hue color schemes support a size k ranging from 3 to 9. + */ +export const schemePuBu: ReadonlyArray>; + /** * Given a number t in the range [0,1], returns the corresponding color from the “PuRd” sequential color scheme represented as an RGB string. * * @param value Number in the range [0, 1]. */ export function interpolatePuRd(value: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “PuRd” sequential color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemePuRd[9] contains an array of nine strings representing the nine colors of the + * purple-red sequential color scheme. Sequential, multi-hue color schemes support a size k ranging from 3 to 9. + */ +export const schemePuRd: ReadonlyArray>; + /** * Given a number t in the range [0,1], returns the corresponding color from the “RdPu” sequential color scheme represented as an RGB string. * * @param value Number in the range [0, 1]. */ export function interpolateRdPu(value: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “RdPu” sequential color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeRdPu[9] contains an array of nine strings representing the nine colors of the + * red-purple sequential color scheme. Sequential, multi-hue color schemes support a size k ranging from 3 to 9. + */ +export const schemeRdPu: ReadonlyArray>; + /** * Given a number t in the range [0,1], returns the corresponding color from the “YlGnBu” sequential color scheme represented as an RGB string. * * @param value Number in the range [0, 1]. */ export function interpolateYlGnBu(value: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “YlGnBu” sequential color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeYlGnBu[9] contains an array of nine strings representing the nine colors of the + * yellow-green-blue sequential color scheme. Sequential, multi-hue color schemes support a size k ranging from 3 to 9. + */ +export const schemeYlGnBu: ReadonlyArray>; + /** * Given a number t in the range [0,1], returns the corresponding color from the “YlGn” sequential color scheme represented as an RGB string. * * @param value Number in the range [0, 1]. */ export function interpolateYlGn(value: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “YlGn” sequential color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeYlGn[9] contains an array of nine strings representing the nine colors of the + * yellow-green sequential color scheme. Sequential, multi-hue color schemes support a size k ranging from 3 to 9. + */ +export const schemeYlGn: ReadonlyArray>; + /** * Given a number t in the range [0,1], returns the corresponding color from the “YlOrBr” sequential color scheme represented as an RGB string. * * @param value Number in the range [0, 1]. */ export function interpolateYlOrBr(value: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “YlOrBr” sequential color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeYlOrBr[9] contains an array of nine strings representing the nine colors of the + * yellow-orange-brown sequential color scheme. Sequential, multi-hue color schemes support a size k ranging from 3 to 9. + */ +export const schemeYlOrBr: ReadonlyArray>; + /** * Given a number t in the range [0,1], returns the corresponding color from the “YlOrRd” sequential color scheme represented as an RGB string. * * @param value Number in the range [0, 1]. */ export function interpolateYlOrRd(value: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “YlOrRd” sequential color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeYlOrRd[9] contains an array of nine strings representing the nine colors of the + * yellow-orange-red sequential color scheme. Sequential, multi-hue color schemes support a size k ranging from 3 to 9. + */ +export const schemeYlOrRd: ReadonlyArray>; diff --git a/types/d3-scale/tslint.json b/types/d3-scale/tslint.json index 604d5950cf..9846c79a4d 100644 --- a/types/d3-scale/tslint.json +++ b/types/d3-scale/tslint.json @@ -2,6 +2,7 @@ "extends": "dtslint/dt.json", "rules": { "unified-signatures": false, - "callable-types": false + "callable-types": false, + "no-unnecessary-generics": false } } diff --git a/types/d3-selection-multi/tslint.json b/types/d3-selection-multi/tslint.json index 08b1465cd6..b8825c1674 100644 --- a/types/d3-selection-multi/tslint.json +++ b/types/d3-selection-multi/tslint.json @@ -1,6 +1,8 @@ { "extends": "dtslint/dt.json", "rules": { + // TODO + "no-this-assignment": false, "unified-signatures": false } } diff --git a/types/d3-selection/d3-selection-tests.ts b/types/d3-selection/d3-selection-tests.ts index baae76bad2..e2a4d6ffd9 100644 --- a/types/d3-selection/d3-selection-tests.ts +++ b/types/d3-selection/d3-selection-tests.ts @@ -484,7 +484,7 @@ body = body const datum: BodyDatum = d; const index: number = i; const group: HTMLBodyElement[] | d3Selection.ArrayLike = g; - return '
      Body Background Color: ' + this.bgColor + ', Foo Datum: ' + d.foo + '
      '; // this context HTMLBodyElement, datum BodyDatum + return `
      Body Background Color: ${this.bgColor}, Foo Datum: ${d.foo}
      `; // this context HTMLBodyElement, datum BodyDatum }); // --------------------------------------------------------------------------------------- @@ -993,7 +993,7 @@ let customListener: (this: HTMLBodyElement, finalOpponent: string) => string; customListener = finalOpponent => { const e = d3Selection.event; - return e.team + ' defeated ' + finalOpponent + ' in the EURO 2016 Cup. Who would have thought!!!'; + return `${e.team} defeated ${finalOpponent} in the EURO 2016 Cup. Who would have thought!!!`; }; const resultText: string = d3Selection.customEvent(successEvent, customListener, body.node(), 'Wales'); diff --git a/types/d3-selection/tslint.json b/types/d3-selection/tslint.json index 08b1465cd6..26ee29cf50 100644 --- a/types/d3-selection/tslint.json +++ b/types/d3-selection/tslint.json @@ -1,6 +1,9 @@ { "extends": "dtslint/dt.json", "rules": { - "unified-signatures": false + // TODO + "no-this-assignment": false, + "unified-signatures": false, + "no-unnecessary-generics": false } } diff --git a/types/d3-shape/d3-shape-tests.ts b/types/d3-shape/d3-shape-tests.ts index ee9a8fbb98..4199d2f170 100644 --- a/types/d3-shape/d3-shape-tests.ts +++ b/types/d3-shape/d3-shape-tests.ts @@ -447,8 +447,8 @@ let lineRadial: d3Shape.LineRadial = d3Shape.lineRadial = defaultLineRadial; -let radialLine: d3Shape.RadialLine = lineRadial; +const defaultRadialLine: d3Shape.RadialLine<[number, number]> = defaultLineRadial; +const radialLine: d3Shape.RadialLine = lineRadial; defaultLineRadial = d3Shape.radialLine(); lineRadial = d3Shape.radialLine(); @@ -685,8 +685,8 @@ let areaRadial: d3Shape.AreaRadial = d3Shape.areaRadial = defaultAreaRadial; -let radialArea: d3Shape.RadialArea = areaRadial; +const defaultRadialArea: d3Shape.RadialArea<[number, number]> = defaultAreaRadial; +const radialArea: d3Shape.RadialArea = areaRadial; defaultAreaRadial = d3Shape.radialArea(); areaRadial = d3Shape.radialArea(); @@ -1322,7 +1322,7 @@ customSymbol = d3Shape.symbolWye; // Test pointRadial // ----------------------------------------------------------------------------------- -let coordinatates: [number, number] = d3Shape.pointRadial(0, 12); +const coordinatates: [number, number] = d3Shape.pointRadial(0, 12); // ----------------------------------------------------------------------------------- // Test Stacks diff --git a/types/d3-shape/tslint.json b/types/d3-shape/tslint.json index 604d5950cf..b1ba182ba6 100644 --- a/types/d3-shape/tslint.json +++ b/types/d3-shape/tslint.json @@ -1,7 +1,10 @@ { "extends": "dtslint/dt.json", "rules": { + // TODO + "no-this-assignment": false, "unified-signatures": false, - "callable-types": false + "callable-types": false, + "no-unnecessary-generics": false } } diff --git a/types/d3-time-format/d3-time-format-tests.ts b/types/d3-time-format/d3-time-format-tests.ts index 547a77aabe..eb569dd779 100644 --- a/types/d3-time-format/d3-time-format-tests.ts +++ b/types/d3-time-format/d3-time-format-tests.ts @@ -12,8 +12,6 @@ import * as d3TimeFormat from 'd3-time-format'; // Preparatory Steps // ---------------------------------------------------------------------- -let num: number; - let formatFn: (n: Date) => string; let parseFn: (dateString: string) => (Date | null); @@ -38,21 +36,21 @@ parseFn = d3TimeFormat.utcParse('.%L'); // iso ------------------------------------------------------------------ -let dateString: string = d3TimeFormat.isoFormat(new Date(2016, 6, 6)); -let date: Date = d3TimeFormat.isoParse('2016-07-08T14:06:41.386Z'); +const dateString: string = d3TimeFormat.isoFormat(new Date(2016, 6, 6)); +const date: Date = d3TimeFormat.isoParse('2016-07-08T14:06:41.386Z'); // ---------------------------------------------------------------------- // Test Locale Definition // ---------------------------------------------------------------------- -let dateTimeSpecifier: string = localeDef.dateTime; -let dateSpecifier: string = localeDef.date; -let timeSpecifier: string = localeDef.time; -let periods: [string, string] = localeDef.periods; -let days: [string, string, string, string, string, string, string] = localeDef.days; -let shortDays: [string, string, string, string, string, string, string] = localeDef.shortDays; -let months: [string, string, string, string, string, string, string, string, string, string, string, string] = localeDef.months; -let shortMonths: [string, string, string, string, string, string, string, string, string, string, string, string] = localeDef.shortMonths; +const dateTimeSpecifier: string = localeDef.dateTime; +const dateSpecifier: string = localeDef.date; +const timeSpecifier: string = localeDef.time; +const periods: [string, string] = localeDef.periods; +const days: [string, string, string, string, string, string, string] = localeDef.days; +const shortDays: [string, string, string, string, string, string, string] = localeDef.shortDays; +const months: [string, string, string, string, string, string, string, string, string, string, string, string] = localeDef.months; +const shortMonths: [string, string, string, string, string, string, string, string, string, string, string, string] = localeDef.shortMonths; localeDef = { dateTime: '%a %b %e %X %Y', diff --git a/types/d3-time/d3-time-tests.ts b/types/d3-time/d3-time-tests.ts index a99cd818a0..57905d5286 100644 --- a/types/d3-time/d3-time-tests.ts +++ b/types/d3-time/d3-time-tests.ts @@ -11,9 +11,9 @@ import * as d3Time from 'd3-time'; let countableI: d3Time.CountableTimeInterval; let simpleI: d3Time.TimeInterval; let dateArray: Date[]; -let start: Date = new Date(2014, 1, 1, 6, 0, 0, 0); -let end: Date = new Date(2016, 6, 13, 1, 25, 15, 500); -let inBetween: Date = new Date(2015, 6, 13, 1, 30, 5, 700); +const start: Date = new Date(2014, 1, 1, 6, 0, 0, 0); +const end: Date = new Date(2016, 6, 13, 1, 25, 15, 500); +const inBetween: Date = new Date(2015, 6, 13, 1, 30, 5, 700); let resultDate: Date; let count: number; @@ -75,7 +75,7 @@ simpleI = countableI.filter((d: Date) => d.getMonth() === 2); count = countableI.count(start, end); // let countableIOrNull: d3Time.CountableTimeInterval | null = countableI.every(10); // Test fails, since .every(...) return Interval and not CountableInterval -let simpleIOrNull: d3Time.TimeInterval | null = countableI.every(10); +const simpleIOrNull: d3Time.TimeInterval | null = countableI.every(10); resultDate = simpleI.floor(inBetween); resultDate = simpleI.round(inBetween); diff --git a/types/d3-timer/d3-timer-tests.ts b/types/d3-timer/d3-timer-tests.ts index d3e755ede1..042fc11072 100644 --- a/types/d3-timer/d3-timer-tests.ts +++ b/types/d3-timer/d3-timer-tests.ts @@ -9,7 +9,7 @@ import * as d3Timer from 'd3-timer'; // Test now definition -let now: number = d3Timer.now(); +const now: number = d3Timer.now(); // Test timer and timerFlush definitions ------------ diff --git a/types/d3-transition/tslint.json b/types/d3-transition/tslint.json index 08b1465cd6..26ee29cf50 100644 --- a/types/d3-transition/tslint.json +++ b/types/d3-transition/tslint.json @@ -1,6 +1,9 @@ { "extends": "dtslint/dt.json", "rules": { - "unified-signatures": false + // TODO + "no-this-assignment": false, + "unified-signatures": false, + "no-unnecessary-generics": false } } diff --git a/types/d3-voronoi/d3-voronoi-tests.ts b/types/d3-voronoi/d3-voronoi-tests.ts index 7dea86241e..434055dc4d 100644 --- a/types/d3-voronoi/d3-voronoi-tests.ts +++ b/types/d3-voronoi/d3-voronoi-tests.ts @@ -24,7 +24,7 @@ interface VoronoiTestDatum { y: number; } -let testData: VoronoiTestDatum[] = [ +const testData: VoronoiTestDatum[] = [ { x: 10, y: 10 }, { x: 20, y: 10 }, { x: 10, y: 20 }, @@ -84,7 +84,7 @@ pointPair = [[10, 10], [50, 50]]; // VoronoiPolygon ------------------------------------------------------- -let voronoiPolygon: d3Voronoi.VoronoiPolygon; +declare const voronoiPolygon: d3Voronoi.VoronoiPolygon; voronoiPolygon[0][0] = 10; // x-coordinate of first point voronoiPolygon[0][1] = 10; // y-coordinate of first point @@ -183,7 +183,7 @@ cell = cells[0]; site = cell.site; -numArray = cell.halfEdges; +numArray = cell.halfedges; // VoronoiSite interface =============================================== @@ -229,7 +229,6 @@ testDatum = link.target; // find() =============================================================== let nearestSite: d3Voronoi.VoronoiSite | null; -let wrongSiteDataType: d3Voronoi.VoronoiSite<[number, number]> | null; // Without search radius nearestSite = voronoiDiagram.find(10, 50); @@ -238,4 +237,4 @@ nearestSite = voronoiDiagram.find(10, 50); nearestSite = voronoiDiagram.find(10, 50, 20); // wrong data type -// wrongSiteDataType = voronoiDiagram.find(10, 50); // fails, due to data type mismatch +// const wrongSiteDataType: d3Voronoi.VoronoiSite<[number, number]> | null; = voronoiDiagram.find(10, 50); // fails, due to data type mismatch diff --git a/types/d3-voronoi/index.d.ts b/types/d3-voronoi/index.d.ts index 1a529e4a71..c3dc03c9de 100644 --- a/types/d3-voronoi/index.d.ts +++ b/types/d3-voronoi/index.d.ts @@ -69,7 +69,7 @@ export interface VoronoiSite extends VoronoiPoint { /** * A Voronoi Cell in the diagram is an object with the following properties: - * site and halfEdges + * site and halfedges * * The generic refers to the type of the data for the corresponding element. */ @@ -81,7 +81,7 @@ export interface VoronoiCell { /** * An array of indexes into diagram.edges representing the cell’s polygon. */ - halfEdges: number[]; + halfedges: number[]; } /** diff --git a/types/d3-voronoi/tslint.json b/types/d3-voronoi/tslint.json index 08b1465cd6..54efb0b84e 100644 --- a/types/d3-voronoi/tslint.json +++ b/types/d3-voronoi/tslint.json @@ -1,6 +1,7 @@ { "extends": "dtslint/dt.json", "rules": { - "unified-signatures": false + "unified-signatures": false, + "no-unnecessary-generics": false } } diff --git a/types/d3-zoom/tslint.json b/types/d3-zoom/tslint.json index 08b1465cd6..26ee29cf50 100644 --- a/types/d3-zoom/tslint.json +++ b/types/d3-zoom/tslint.json @@ -1,6 +1,9 @@ { "extends": "dtslint/dt.json", "rules": { - "unified-signatures": false + // TODO + "no-this-assignment": false, + "unified-signatures": false, + "no-unnecessary-generics": false } } diff --git a/types/dagre/index.d.ts b/types/dagre/index.d.ts index 2c6c6e38ab..6f008ad1c8 100644 --- a/types/dagre/index.d.ts +++ b/types/dagre/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for dagre 0.7 // Project: https://github.com/cpettitt/dagre -// Definitions by: Qinfeng Chen +// Definitions by: Qinfeng Chen , Lisa Vallfors // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export as namespace dagre; @@ -30,8 +30,14 @@ export interface GraphLabel { height?: number; compound?: boolean; rankdir?: string; + align?: string; nodesep?: number; edgesep?: number; + ranksep?: number; + marginx?: number; + marginy?: number; + acyclicer?: string; + ranker?: string; } export function layout(graph: graphlib.Graph): void; diff --git a/types/dargs/dargs-tests.ts b/types/dargs/dargs-tests.ts new file mode 100644 index 0000000000..86ded8a0a8 --- /dev/null +++ b/types/dargs/dargs-tests.ts @@ -0,0 +1,29 @@ +import dargs = require('dargs'); + +const input = { + _: ['some', 'option'], + foo: 'bar', + hello: true, + cake: false, + camelCase: 5, + multiple: ['value', 'value2'], + pieKind: 'cherry', + sad: ':(' +}; + +const excludes = ['sad', /.*Kind$/]; +const includes = ['camelCase', 'multiple', 'sad', /^pie.*/]; +const aliases = {file: 'f'}; + +// $ExpectType string[] +dargs(input, {excludes}); +dargs(input, {excludes, includes}); +dargs(input, {includes}); +dargs({ + foo: 'bar', + hello: true, + file: 'baz' +}, {aliases}); +dargs({foo: 'bar'}, {useEquals: false}); +dargs({foo: 'bar'}, {ignoreFalse: true}); +dargs({fooBar: 'baz'}, {allowCamelCase: true}); diff --git a/types/dargs/index.d.ts b/types/dargs/index.d.ts new file mode 100644 index 0000000000..62ad42a9c1 --- /dev/null +++ b/types/dargs/index.d.ts @@ -0,0 +1,20 @@ +// Type definitions for dargs 5.1 +// Project: https://github.com/sindresorhus/dargs#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +export = dargs; + +declare function dargs(input: object, options?: dargs.Options): string[]; + +declare namespace dargs { + interface Options { + excludes?: ReadonlyArray; + includes?: ReadonlyArray; + aliases?: { [key: string]: string }; + useEquals?: boolean; + ignoreFalse?: boolean; + allowCamelCase?: boolean; + } +} diff --git a/types/dargs/tsconfig.json b/types/dargs/tsconfig.json new file mode 100644 index 0000000000..fd5bee5051 --- /dev/null +++ b/types/dargs/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "dargs-tests.ts" + ] +} diff --git a/types/dargs/tslint.json b/types/dargs/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/dargs/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/datatables.net-buttons/datatables.net-buttons-tests.ts b/types/datatables.net-buttons/datatables.net-buttons-tests.ts index 015917c456..3323f6fdb9 100644 --- a/types/datatables.net-buttons/datatables.net-buttons-tests.ts +++ b/types/datatables.net-buttons/datatables.net-buttons-tests.ts @@ -8,10 +8,20 @@ $(document).ready(function () { extend: 'excel', text: 'Excel', className: 'class', + filename: "exported_file.csv", exportOptions: { columns: ':visible' } }, + { + extend: 'excel', + text: 'Excel', + className: 'class', + filename: "exported_file.csv", + exportOptions: { + columns: [1, 6, 2, 3, 4] + } + }, { action: function (e, dt, node, config) { }, available: function (dt, config) { return true; }, diff --git a/types/datatables.net-buttons/index.d.ts b/types/datatables.net-buttons/index.d.ts index a5b32c1bf6..1bdf212b03 100644 --- a/types/datatables.net-buttons/index.d.ts +++ b/types/datatables.net-buttons/index.d.ts @@ -86,6 +86,11 @@ declare namespace DataTables { */ title?: string; + /** + * Define what the exported filename should be + */ + filename?: string; + exportOptions?: ButtonExportOptions; autoPrint?: boolean; customize?: FunctionButtonCustomize; @@ -95,7 +100,7 @@ declare namespace DataTables { (dt: DataTables.Api, config: any): boolean } export interface ButtonExportOptions { - columns?: string; + columns?: string | number | string[] | number[]; } export interface ButtonKey { diff --git a/types/datatables.net/index.d.ts b/types/datatables.net/index.d.ts index 99a2aae7b8..85f6d05857 100644 --- a/types/datatables.net/index.d.ts +++ b/types/datatables.net/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for JQuery DataTables 1.10.9 // Project: http://www.datatables.net -// Definitions by: Kiarash Ghiaseddin , Omid Rad , Armin Sander , Denise Mauldin +// Definitions by: Kiarash Ghiaseddin , Omid Rad , Armin Sander , Denise Mauldin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -1321,7 +1321,7 @@ declare namespace DataTables { /** * Set an initial filter in DataTables and / or filtering options. Since: 1.10 */ - search?: SearchSettings; + search?: SearchSettings | boolean; /** * Set placeholder attribute for input type="text" tag elements. Since: 1.10 diff --git a/types/datejs/index.d.ts b/types/datejs/index.d.ts index d7c1854253..1863dc2a6f 100644 --- a/types/datejs/index.d.ts +++ b/types/datejs/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for DateJS // Project: http://www.datejs.com/ -// Definitions by: David Khristepher Santos +// Definitions by: David Khristepher Santos // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped //NOTE: This definition file is for the library located at http://datejs.googlecode.com/svn/ and documented at https://code.google.com/p/datejs/wiki/APIDocumentation diff --git a/types/datejs/sugarpak.d.ts b/types/datejs/sugarpak.d.ts index b4077960ad..b389f2c723 100644 --- a/types/datejs/sugarpak.d.ts +++ b/types/datejs/sugarpak.d.ts @@ -1,6 +1,6 @@ // Type definitions for DateJS - SugarPak Extensions // Project: http://www.datejs.com/ -// Definitions by: David Khristepher Santos +// Definitions by: David Khristepher Santos // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /** SugarPak.js - Domain Specific Language - Syntactical Sugar */ diff --git a/types/daterangepicker/index.d.ts b/types/daterangepicker/index.d.ts index 3846ea2472..f01ffd59a3 100644 --- a/types/daterangepicker/index.d.ts +++ b/types/daterangepicker/index.d.ts @@ -1,6 +1,7 @@ -// Type definitions for Date Range Picker v2.1.19 +// Type definitions for Date Range Picker v2.1.25 // Project: http://www.daterangepicker.com/ -// Definitions by: SirMartin +// Definitions by: SirMartin +// Steven Masala // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -24,6 +25,10 @@ declare namespace daterangepicker { startDate: moment.Moment; endDate: moment.Moment; + + setStartDate(date: Date | moment.Moment | string): void; + setEndDate(date: Date | moment.Moment | string): void; + remove(): void; } interface DatepickerEventObject extends JQueryEventObject { diff --git a/types/daterangepicker/package.json b/types/daterangepicker/package.json index 4c6d24a445..fce08a048d 100644 --- a/types/daterangepicker/package.json +++ b/types/daterangepicker/package.json @@ -1,4 +1,5 @@ { + "private": true, "dependencies": { "moment": ">=2.14.0" } diff --git a/types/db-migrate-pg/index.d.ts b/types/db-migrate-pg/index.d.ts index 6a72fd1109..09cba26317 100644 --- a/types/db-migrate-pg/index.d.ts +++ b/types/db-migrate-pg/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for db-migrate-pg // Project: https://github.com/db-migrate/pg -// Definitions by: nickiannone +// Definitions by: nickiannone // Definitions: https://github.com/nickiannone/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/deasync/deasync-tests.ts b/types/deasync/deasync-tests.ts index e4e77561e9..982e34c338 100644 --- a/types/deasync/deasync-tests.ts +++ b/types/deasync/deasync-tests.ts @@ -7,7 +7,7 @@ function handle(res: number) {} asyncFunction(42, handle); // deasync -let wrapped = deasync(asyncFunction); +const wrapped = deasync(asyncFunction); handle(wrapped(42)); // deasync.loopWhile diff --git a/types/debessmann/debessmann-tests.ts b/types/debessmann/debessmann-tests.ts index 4a247827fd..ab135de254 100644 --- a/types/debessmann/debessmann-tests.ts +++ b/types/debessmann/debessmann-tests.ts @@ -1,9 +1,9 @@ import { DM, Event, EventId } from 'debessmann'; -let eventId: EventId = {seq: 0, time: new Date()}; -let e: Event = {_id: eventId, headers: {header1: 'header1Val'}}; +const eventId: EventId = {seq: 0, time: new Date()}; +const e: Event = {_id: eventId, headers: {header1: 'header1Val'}}; -let dm: DM = { +const dm: DM = { init(endpoint: string, auth: string): void { }, send(data: Event): void { diff --git a/types/debug/debug-tests.ts b/types/debug/debug-tests.ts index fc8d3c5e56..73a16fe782 100644 --- a/types/debug/debug-tests.ts +++ b/types/debug/debug-tests.ts @@ -12,6 +12,7 @@ log("Formatted test (%d arg)", 1); log("Formatted %s (%d args)", "test", 2); log("Enabled?: %s", debug.enabled("DefinitelyTyped:log")); +log("Name Enabled: %s", debug.names.some(name => name.test("DefinitelyTyped:log"))); log("Namespace: %s", log.namespace); var error:debug.IDebugger = debug("DefinitelyTyped:error"); diff --git a/types/debug/index.d.ts b/types/debug/index.d.ts index 45d3ad02f3..8987b13a26 100644 --- a/types/debug/index.d.ts +++ b/types/debug/index.d.ts @@ -1,6 +1,8 @@ // Type definitions for debug // Project: https://github.com/visionmedia/debug -// Definitions by: Seon-Wook Park , Gal Talmor +// Definitions by: Seon-Wook Park +// Gal Talmor +// John McLaughlin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare var debug: debug.IDebug; @@ -16,8 +18,8 @@ declare namespace debug { enable: (namespaces: string) => void, enabled: (namespaces: string) => boolean, - names: string[], - skips: string[], + names: RegExp[], + skips: RegExp[], formatters: IFormatters } diff --git a/types/decamelize/decamelize-tests.ts b/types/decamelize/decamelize-tests.ts index af35c41943..836c67e64c 100644 --- a/types/decamelize/decamelize-tests.ts +++ b/types/decamelize/decamelize-tests.ts @@ -1,5 +1,4 @@ - import decamelize = require('decamelize'); decamelize('unicornRainbow'); -decamelize('unicornRainbow', '-'); \ No newline at end of file +decamelize('unicornRainbow', '-'); diff --git a/types/decamelize/index.d.ts b/types/decamelize/index.d.ts index 5ee1f76f35..e159cd43bb 100644 --- a/types/decamelize/index.d.ts +++ b/types/decamelize/index.d.ts @@ -1,9 +1,9 @@ -// Type definitions for decamelize +// Type definitions for decamelize 1.2 // Project: https://github.com/sindresorhus/decamelize // Definitions by: Sam Verschueren // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +export = decamelize; declare function decamelize(input: string, separator?: string): string; -declare namespace decamelize { } -export = decamelize; +declare namespace decamelize {} diff --git a/types/decamelize/tsconfig.json b/types/decamelize/tsconfig.json index ac086e266d..31205a3949 100644 --- a/types/decamelize/tsconfig.json +++ b/types/decamelize/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -19,4 +19,4 @@ "index.d.ts", "decamelize-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/decamelize/tslint.json b/types/decamelize/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/decamelize/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/decimal.js/index.d.ts b/types/decimal.js/index.d.ts index 69521a46cc..27f4213612 100644 --- a/types/decimal.js/index.d.ts +++ b/types/decimal.js/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for decimal.js // Project: http://mikemcl.github.io/decimal.js -// Definitions by: Joseph Rossi +// Definitions by: Joseph Rossi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare var Decimal: decimal.IDecimalStatic; diff --git a/types/deep-diff/index.d.ts b/types/deep-diff/index.d.ts index f07fc39ef6..de17a03bc8 100644 --- a/types/deep-diff/index.d.ts +++ b/types/deep-diff/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for deep-diff // Project: https://github.com/flitbit/diff/ -// Definitions by: ZauberNerd +// Definitions by: ZauberNerd // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace deepDiff { diff --git a/types/deep-equal/index.d.ts b/types/deep-equal/index.d.ts index d9c4b5f6cf..7451fbc255 100644 --- a/types/deep-equal/index.d.ts +++ b/types/deep-equal/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for deep-equal 1.0 // Project: https://github.com/substack/node-deep-equal -// Definitions by: remojansen , Jay Anslow +// Definitions by: remojansen , Jay Anslow // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped interface DeepEqualOptions { diff --git a/types/deepmerge/deepmerge-tests.ts b/types/deepmerge/deepmerge-tests.ts index 5467cb83f0..dcd21ff3c3 100644 --- a/types/deepmerge/deepmerge-tests.ts +++ b/types/deepmerge/deepmerge-tests.ts @@ -1,19 +1,29 @@ import * as deepmerge from "deepmerge"; const x = { - foo: { bar: 3 }, - array: [{ does: 'work', too: [1, 2, 3] }] + foo: { bar: 3 }, + array: [{ does: 'work', too: [1, 2, 3] }] }; const y = { - foo: { baz: 4 }, - quux: 5, - array: [{ does: 'work', too: [4, 5, 6] }, { really: 'yes' }] + foo: { baz: 4 }, + quux: 5, + array: [{ does: 'work', too: [4, 5, 6] }, { really: 'yes' }] }; const expected = { - foo: { bar: 3, baz: 4 }, - array: [{ does: 'work', too: [1, 2, 3, 4, 5, 6] }, { really: 'yes' }], - quux: 5 + foo: { bar: 3, baz: 4 }, + array: [{ does: 'work', too: [1, 2, 3, 4, 5, 6] }, { really: 'yes' }], + quux: 5 }; -const result = deepmerge(x, y); +const result = deepmerge(x, y); +const anyResult = deepmerge(x, y); + +function reverseConcat(dest: number[], src: number[]) { + return src.concat(dest); +} + +const withOptions = deepmerge(x, y, { + clone: false, + arrayMerge: reverseConcat +}); diff --git a/types/deepmerge/index.d.ts b/types/deepmerge/index.d.ts index 96d0412aa6..797e52c8a5 100644 --- a/types/deepmerge/index.d.ts +++ b/types/deepmerge/index.d.ts @@ -1,17 +1,20 @@ // Type definitions for deepmerge 1.3 // Project: https://github.com/KyleAMathews/deepmerge // Definitions by: marvinscharle +// syy1125 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 export = deepmerge; -declare function deepmerge(x: T, y: T, options?: deepmerge.Options): T; +declare function deepmerge(x: Partial, y: Partial, options?: deepmerge.Options): T; +declare function deepmerge(x: T1, y: T2, options?: deepmerge.Options): T1 & T2; declare namespace deepmerge { - interface Options { + interface Options { clone?: boolean; - arrayMerge?(destination: T, source: T, options?: Options): T; + arrayMerge?(destination: any[], source: any[], options?: Options): any[]; } - function all(objects: T[], options?: Options): T; + function all(objects: Array>, options?: Options): T; } diff --git a/types/defaults/index.d.ts b/types/defaults/index.d.ts index 024df0558b..717f80a5a7 100644 --- a/types/defaults/index.d.ts +++ b/types/defaults/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for defaults 1.0.3 // Project: https://github.com/tmpvar/defaults/ -// Definitions by: Ibtihel CHNAB +// Definitions by: Ibtihel CHNAB // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare function defaults(options: any, defaultOptions: any): any; diff --git a/types/define-lazy-prop/define-lazy-prop-tests.ts b/types/define-lazy-prop/define-lazy-prop-tests.ts new file mode 100644 index 0000000000..31efb3f861 --- /dev/null +++ b/types/define-lazy-prop/define-lazy-prop-tests.ts @@ -0,0 +1,10 @@ +import defineLazyProp = require('define-lazy-prop'); + +const unicorn = { + foo: 'bar' +}; + +const rainbowUnicorn = defineLazyProp(unicorn, 'rainbow', () => 1); + +rainbowUnicorn.rainbow; // $ExpectType number +rainbowUnicorn.foo; // $ExpectType string diff --git a/types/define-lazy-prop/index.d.ts b/types/define-lazy-prop/index.d.ts new file mode 100644 index 0000000000..4cffe79a66 --- /dev/null +++ b/types/define-lazy-prop/index.d.ts @@ -0,0 +1,9 @@ +// Type definitions for define-lazy-prop 1.0 +// Project: https://github.com/sindresorhus/define-lazy-prop#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +export = defineLazyProp; + +declare function defineLazyProp(obj: O, prop: P, fn: () => T): O & {[K in P]: T}; diff --git a/types/define-lazy-prop/tsconfig.json b/types/define-lazy-prop/tsconfig.json new file mode 100644 index 0000000000..3a5611afb1 --- /dev/null +++ b/types/define-lazy-prop/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "define-lazy-prop-tests.ts" + ] +} diff --git a/types/define-lazy-prop/tslint.json b/types/define-lazy-prop/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/define-lazy-prop/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/defined/defined-tests.ts b/types/defined/defined-tests.ts new file mode 100644 index 0000000000..5a9d055114 --- /dev/null +++ b/types/defined/defined-tests.ts @@ -0,0 +1,7 @@ +import defined = require('defined'); + +const opts = { x: undefined, y : false, w : 4 }; +// $ExpectType number | boolean | undefined +defined(opts.x, opts.y, opts.w, 100); +// $ExpectType any +defined(opts.x, opts.y, opts.w, 100); diff --git a/types/defined/index.d.ts b/types/defined/index.d.ts new file mode 100644 index 0000000000..1e7f4afc6a --- /dev/null +++ b/types/defined/index.d.ts @@ -0,0 +1,9 @@ +// Type definitions for defined 1.0 +// Project: https://github.com/substack/defined +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = defined; + +declare function defined(...args: T[]): T; +declare function defined(...args: any[]): any; diff --git a/types/defined/tsconfig.json b/types/defined/tsconfig.json new file mode 100644 index 0000000000..63c6202b4c --- /dev/null +++ b/types/defined/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "defined-tests.ts" + ] +} diff --git a/types/defined/tslint.json b/types/defined/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/defined/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/deku/index.d.ts b/types/deku/index.d.ts index ff5a68f8bb..595e2521e9 100644 --- a/types/deku/index.d.ts +++ b/types/deku/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for deku v2.0 // Project: https://github.com/anthonyshort/deku -// Definitions by: Sho Fuji +// Definitions by: Sho Fuji // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export = deku; diff --git a/types/del/del-tests.ts b/types/del/del-tests.ts index 09702c4b39..fc6c63b6fa 100644 --- a/types/del/del-tests.ts +++ b/types/del/del-tests.ts @@ -3,8 +3,10 @@ import del = require("del"); let paths = ["build", "dist/**/*.js"]; del(["tmp/*.js", "!tmp/unicorn.js"]); - del(["tmp/*.js", "!tmp/unicorn.js"], {force: true}); +del(["tmp/*.js", "!tmp/unicorn.js"], {dryRun: true}); +del(["tmp/*.js", "!tmp/unicorn.js"], {concurrency: 20}); +del(["tmp/*.js", "!tmp/unicorn.js"], {cwd: ''}); del(["tmp/*.js", "!tmp/unicorn.js"]).then((paths: string[]) => { console.log('Deleted files/folders:\n', paths.join('\n')); @@ -15,9 +17,10 @@ del(["tmp/*.js", "!tmp/unicorn.js"], {force: true}).then((paths: string[]) => { }); del("tmp/*.js"); - del("tmp/*.js", {force: true}); - +del("tmp/*.js", {dryRun: true}); +del("tmp/*.js", {concurrency: 20}); +del("tmp/*.js", {cwd: ''}); del("tmp/*.js").then((paths: string[]) => { console.log('Deleted files/folders:\n', paths.join('\n')); }); @@ -27,11 +30,10 @@ del("tmp/*.js", {force: true}).then((paths: string[]) => { }); paths = del.sync(["tmp/*.js", "!tmp/unicorn.js"]); - paths = del.sync(["tmp/*.js", "!tmp/unicorn.js"], {force: true}); paths = del.sync("tmp/*.js"); - paths = del.sync("tmp/*.js", {force: true}); - paths = del.sync("tmp/*.js", {dryRun: true}); +paths = del.sync("tmp/*.js", {concurrency: 20}); +paths = del.sync("tmp/*.js", {cwd: ''}); diff --git a/types/del/index.d.ts b/types/del/index.d.ts index 50634e39eb..e3c250e69b 100644 --- a/types/del/index.d.ts +++ b/types/del/index.d.ts @@ -1,6 +1,8 @@ -// Type definitions for del 2.2 +// Type definitions for del 3.0 // Project: https://github.com/sindresorhus/del -// Definitions by: Asana , Aya Morisawa +// Definitions by: Asana +// Aya Morisawa +// BendingBender // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import glob = require("glob"); @@ -13,6 +15,7 @@ declare namespace del { interface Options extends glob.IOptions { force?: boolean; dryRun?: boolean; + concurrency?: number; } } diff --git a/types/del/tsconfig.json b/types/del/tsconfig.json index dd4981bd08..ba10982e67 100644 --- a/types/del/tsconfig.json +++ b/types/del/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -19,4 +19,4 @@ "index.d.ts", "del-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/del/tslint.json b/types/del/tslint.json index 3db14f85ea..26bcea6634 100644 --- a/types/del/tslint.json +++ b/types/del/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "dt-header": false + } +} diff --git a/types/del/v2/del-tests.ts b/types/del/v2/del-tests.ts new file mode 100644 index 0000000000..09702c4b39 --- /dev/null +++ b/types/del/v2/del-tests.ts @@ -0,0 +1,37 @@ +import del = require("del"); + +let paths = ["build", "dist/**/*.js"]; + +del(["tmp/*.js", "!tmp/unicorn.js"]); + +del(["tmp/*.js", "!tmp/unicorn.js"], {force: true}); + +del(["tmp/*.js", "!tmp/unicorn.js"]).then((paths: string[]) => { + console.log('Deleted files/folders:\n', paths.join('\n')); +}); + +del(["tmp/*.js", "!tmp/unicorn.js"], {force: true}).then((paths: string[]) => { + console.log('Deleted files/folders:\n', paths.join('\n')); +}); + +del("tmp/*.js"); + +del("tmp/*.js", {force: true}); + +del("tmp/*.js").then((paths: string[]) => { + console.log('Deleted files/folders:\n', paths.join('\n')); +}); + +del("tmp/*.js", {force: true}).then((paths: string[]) => { + console.log('Deleted files/folders:\n', paths.join('\n')); +}); + +paths = del.sync(["tmp/*.js", "!tmp/unicorn.js"]); + +paths = del.sync(["tmp/*.js", "!tmp/unicorn.js"], {force: true}); + +paths = del.sync("tmp/*.js"); + +paths = del.sync("tmp/*.js", {force: true}); + +paths = del.sync("tmp/*.js", {dryRun: true}); diff --git a/types/del/v2/index.d.ts b/types/del/v2/index.d.ts new file mode 100644 index 0000000000..50634e39eb --- /dev/null +++ b/types/del/v2/index.d.ts @@ -0,0 +1,19 @@ +// Type definitions for del 2.2 +// Project: https://github.com/sindresorhus/del +// Definitions by: Asana , Aya Morisawa +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import glob = require("glob"); + +declare function del(patterns: string | string[], options?: del.Options): Promise; + +declare namespace del { + function sync(patterns: string | string[], options?: Options): string[]; + + interface Options extends glob.IOptions { + force?: boolean; + dryRun?: boolean; + } +} + +export = del; diff --git a/types/del/v2/tsconfig.json b/types/del/v2/tsconfig.json new file mode 100644 index 0000000000..4ec5576309 --- /dev/null +++ b/types/del/v2/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "paths": { + "del": ["del/v2"] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "del-tests.ts" + ] +} diff --git a/types/del/v2/tslint.json b/types/del/v2/tslint.json new file mode 100644 index 0000000000..65c83fb1e3 --- /dev/null +++ b/types/del/v2/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "dt-header": false + } +} diff --git a/types/delaunator/tslint.json b/types/delaunator/tslint.json index 3db14f85ea..f2ffe2445b 100644 --- a/types/delaunator/tslint.json +++ b/types/delaunator/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-duplicate-imports": false + } +} diff --git a/types/delay/delay-tests.ts b/types/delay/delay-tests.ts new file mode 100644 index 0000000000..9714bfd86d --- /dev/null +++ b/types/delay/delay-tests.ts @@ -0,0 +1,47 @@ +import delay = require('delay'); + +delay(200) + .then(() => { + }); + +let str: string; +let num: number; +Promise.resolve(delay(100)) + .then(() => { + }); + +Promise.resolve("foo") + .then(delay(100)) + .then(result => { + str = result; + }); + +Promise.resolve('foo') + .then(delay(100, 10)) + .then(result => { + num = result; + }); + +Promise.resolve('foo') + .then(delay.reject(100)) + .then(x => 10) + .catch(err => { + }); + +Promise.resolve('foo') + .then(delay.reject(100, 'bar')) + .then(x => 10) + .catch(err => { + }); + +(async () => { + const delaying = delay(1000); + delaying.cancel(); + try { + await delaying; + } catch (err) { + // `err` is an instance of `delay.CancelError` + } +})(); + +throw new delay.CancelError('bar'); diff --git a/types/delay/index.d.ts b/types/delay/index.d.ts new file mode 100644 index 0000000000..f84c7ab5e4 --- /dev/null +++ b/types/delay/index.d.ts @@ -0,0 +1,30 @@ +// Type definitions for delay 2.0 +// Project: https://github.com/sindresorhus/delay#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +export = delay; + +declare function delay(ms: number): delay.PDelayedPassThroughThunk; +declare function delay(ms: number, value: T): delay.PDelayedThunk; + +declare namespace delay { + function reject(ms: number, rejectionValue?: any): PDelayedThunk; + + class CancelError extends Error { + readonly name: 'CancelError'; + constructor(message?: string); + } + + type PDelayedThunk = ((value: any) => DelayedPromiseLike) & DelayedPromiseLike; + + type PDelayedPassThroughThunk = ((value: TValue) => DelayedPromiseLike) & DelayedPromiseLike; + + interface DelayedPromiseLike { + then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, + onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): Promise; + catch(onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null): Promise; + cancel(): void; + } +} diff --git a/types/delay/tsconfig.json b/types/delay/tsconfig.json new file mode 100644 index 0000000000..2004ba50ba --- /dev/null +++ b/types/delay/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "delay-tests.ts" + ] +} diff --git a/types/delay/tslint.json b/types/delay/tslint.json new file mode 100644 index 0000000000..bf610ae17f --- /dev/null +++ b/types/delay/tslint.json @@ -0,0 +1,8 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + // TODO + "await-promise": false, + "no-unnecessary-generics": false + } +} diff --git a/types/denodeify/index.d.ts b/types/denodeify/index.d.ts index d5283bf777..4c180e63d8 100644 --- a/types/denodeify/index.d.ts +++ b/types/denodeify/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for denodeify 1.2.1 // Project: https://github.com/matthew-andrews/denodeify -// Definitions by: joaomoreno +// Definitions by: joaomoreno // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/depd/depd-tests.ts b/types/depd/depd-tests.ts index 62a4470f15..f201cb504a 100644 --- a/types/depd/depd-tests.ts +++ b/types/depd/depd-tests.ts @@ -1,52 +1,41 @@ import depd = require('depd'); -var deprecate = depd("depd-tests"); +const deprecate = depd("depd-tests"); -function assert(condition: boolean, message: string): void { - if (!condition) { - throw new Error(message); - } -} +deprecate('message'); -function testDepdMessage(...args: string[]): boolean { - if (arguments.length < 1) { - deprecate('testDepdMessage argument.lenth<1'); - return true; - } else { - console.log('normal logic'); - return false; - } -} - -assert(testDepdMessage() === true, "Deprecated code must be triggered!"); -assert(testDepdMessage('a') === false, "Deprecated code must be triggered!"); - -interface ITestObject { - p1: string; - p2: string; -} - -var obj = { p1: 'deprecated property', p2: 'normal property' }; +const obj = { p1: 'deprecated property', p2: 'normal property' }; deprecate.property(obj, 'p1', 'property [p1] is deprecated!'); +deprecate.property(obj, 'p3', 'property [p3] is deprecated!'); // $ExpectError -console.log(obj.p1); - -interface ITestDeprecatedFunction { - func1?: Function; - func2?: Function; +interface TestDeprecatedFunction { + func1?(): void; + func2?(arg: string): boolean; } +const obj2 = {}; -var obj2 = {}; - -// message automatically derived from function name -obj2.func1 = deprecate.function(function func1() { +obj2.func1 = deprecate.function(() => { console.log('all calls to [func1] are deprecated '); }); -// specific message -obj2.func2 = deprecate.function(function () { +// $ExpectError +obj2.func2 = deprecate.function(() => { console.log('all calls to [func2] are deprecated '); }, 'func2'); +obj2.func2 = deprecate.function((arg: string) => { + console.log('all calls to [func2] are deprecated '); + return true; +}, 'func2'); + obj2.func1(); -obj2.func2(); \ No newline at end of file +obj2.func2(''); + +process.on('deprecation', error => { + const err: depd.DeprecationError = error; + error; // $ExpectType DeprecationError + + err.name; // $ExpectType "DeprecationError" + err.namespace; // $ExpectType string + err.stack; // $ExpectType string +}); diff --git a/types/depd/index.d.ts b/types/depd/index.d.ts index 147393a332..fa1c3a71fe 100644 --- a/types/depd/index.d.ts +++ b/types/depd/index.d.ts @@ -1,16 +1,41 @@ -// Type definitions for depd 1.1.0 +// Type definitions for depd 1.1 // Project: https://github.com/dougwilson/nodejs-depd -// Definitions by: Zhiyuan Wang +// Definitions by: Zhiyuan Wang +// BendingBender // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 - - -declare function depd(namespace: string): Deprecate; - -interface Deprecate { - (message: string): void; - function(fn: Function, message?: string): Function; - property(obj: Object, prop: string, message: string): void; -} +/// export = depd; + +declare function depd(namespace: string): depd.Deprecate; + +declare namespace depd { + interface Deprecate { + (message: string): void; + // tslint:disable-next-line ban-types + function(fn: T, message?: string): T; + property(obj: T, prop: keyof T, message: string): void; + } + + interface DeprecationError extends Error { + readonly name: 'DeprecationError'; + namespace: string; + stack: string; + } +} + +declare global { + namespace NodeJS { + interface Process { + addListener(event: 'deprecation', listener: (deprecationError: depd.DeprecationError) => void): this; + emit(event: 'deprecation', code: depd.DeprecationError): boolean; + on(event: 'deprecation', listener: (deprecationError: depd.DeprecationError) => void): this; + once(event: 'deprecation', listener: (deprecationError: depd.DeprecationError) => void): this; + prependListener(event: 'deprecation', listener: (deprecationError: depd.DeprecationError) => void): this; + prependOnceListener(event: 'deprecation', listener: (deprecationError: depd.DeprecationError) => void): this; + listeners(event: 'deprecation'): depd.DeprecationError[]; + } + } +} diff --git a/types/depd/tsconfig.json b/types/depd/tsconfig.json index 14bec0a373..23aa25d9e0 100644 --- a/types/depd/tsconfig.json +++ b/types/depd/tsconfig.json @@ -7,7 +7,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -20,4 +20,4 @@ "index.d.ts", "depd-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/depd/tslint.json b/types/depd/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/depd/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/destroy-on-hwm/destroy-on-hwm-tests.ts b/types/destroy-on-hwm/destroy-on-hwm-tests.ts new file mode 100644 index 0000000000..9c32a27e26 --- /dev/null +++ b/types/destroy-on-hwm/destroy-on-hwm-tests.ts @@ -0,0 +1,10 @@ +import { PassThrough } from 'stream'; +import destroyOnHWM = require('destroy-on-hwm'); + +const stream = new PassThrough(); + +destroyOnHWM(stream); // $ExpectType PassThrough +destroyOnHWM(stream, function(stream) { + this; // $ExpectType PassThrough + stream; // $ExpectType PassThrough +}); diff --git a/types/destroy-on-hwm/index.d.ts b/types/destroy-on-hwm/index.d.ts new file mode 100644 index 0000000000..5c5dcb43e9 --- /dev/null +++ b/types/destroy-on-hwm/index.d.ts @@ -0,0 +1,12 @@ +// Type definitions for destroy-on-hwm 1.0 +// Project: https://github.com/stream-utils/destroy-on-hwm +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +/// +import { Writable } from 'stream'; + +export = destroyOnHwm; + +declare function destroyOnHwm(stream: T, callback?: (this: T, stream: T) => void): T; diff --git a/types/destroy-on-hwm/tsconfig.json b/types/destroy-on-hwm/tsconfig.json new file mode 100644 index 0000000000..9bcad7ee9b --- /dev/null +++ b/types/destroy-on-hwm/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "destroy-on-hwm-tests.ts" + ] +} diff --git a/types/destroy-on-hwm/tslint.json b/types/destroy-on-hwm/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/destroy-on-hwm/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/destroy/destroy-tests.ts b/types/destroy/destroy-tests.ts new file mode 100644 index 0000000000..15dbe62e32 --- /dev/null +++ b/types/destroy/destroy-tests.ts @@ -0,0 +1,9 @@ +import destroy = require('destroy'); +import * as fs from 'fs'; + +const stream = fs.createReadStream('package.json'); + +// $ExpectType ReadStream +destroy(stream); +// $ExpectType WriteStream +destroy(process.stderr); diff --git a/types/destroy/index.d.ts b/types/destroy/index.d.ts new file mode 100644 index 0000000000..7427655ace --- /dev/null +++ b/types/destroy/index.d.ts @@ -0,0 +1,11 @@ +// Type definitions for destroy 1.0 +// Project: https://github.com/stream-utils/destroy +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +import { Stream } from 'stream'; + +export = destroy; + +declare function destroy(stream: T): T; diff --git a/types/destroy/tsconfig.json b/types/destroy/tsconfig.json new file mode 100644 index 0000000000..197ac0c669 --- /dev/null +++ b/types/destroy/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "destroy-tests.ts" + ] +} diff --git a/types/destroy/tslint.json b/types/destroy/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/destroy/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/detect-indent/detect-indent-tests.ts b/types/detect-indent/detect-indent-tests.ts index 166b89d1ec..dc962b86fc 100644 --- a/types/detect-indent/detect-indent-tests.ts +++ b/types/detect-indent/detect-indent-tests.ts @@ -1,7 +1,9 @@ +import detectIndent = require('detect-indent'); -import di = require('detect-indent'); +const indent = detectIndent('').indent || ' '; -var str: string; - -str = di(str); -str = di(str, str); +const indentInfo = detectIndent(''); +indentInfo; // $ExpectType IndentInfo +const num: number = indentInfo.amount; +const str: string = indentInfo.indent; +const type: 'space' | 'tab' | null = indentInfo.type; diff --git a/types/detect-indent/index.d.ts b/types/detect-indent/index.d.ts index 15e82d0015..7c1838ce10 100644 --- a/types/detect-indent/index.d.ts +++ b/types/detect-indent/index.d.ts @@ -1,11 +1,17 @@ -// Type definitions for detect-indent 0.1.3 +// Type definitions for detect-indent 5.0 // Project: https://github.com/sindresorhus/detect-indent // Definitions by: Bart van der Schoor +// BendingBender // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +export = detectIndent; -interface DetectIndent { - (dir: string, alt?: string): string; +declare function detectIndent(str: string): detectIndent.IndentInfo; + +declare namespace detectIndent { + interface IndentInfo { + amount: number; + type: 'tab' | 'space' | null; + indent: string; + } } -declare var _: DetectIndent; -export = _; diff --git a/types/detect-indent/tsconfig.json b/types/detect-indent/tsconfig.json index 4eae731f48..07d6d5adc2 100644 --- a/types/detect-indent/tsconfig.json +++ b/types/detect-indent/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -19,4 +19,4 @@ "index.d.ts", "detect-indent-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/detect-indent/tslint.json b/types/detect-indent/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/detect-indent/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/detect-indent/v0/detect-indent-tests.ts b/types/detect-indent/v0/detect-indent-tests.ts new file mode 100644 index 0000000000..4bb8171494 --- /dev/null +++ b/types/detect-indent/v0/detect-indent-tests.ts @@ -0,0 +1,6 @@ +import di = require('detect-indent'); + +let str = ''; + +str = di(str); +str = di(str, str); diff --git a/types/detect-indent/v0/index.d.ts b/types/detect-indent/v0/index.d.ts new file mode 100644 index 0000000000..17e8459281 --- /dev/null +++ b/types/detect-indent/v0/index.d.ts @@ -0,0 +1,9 @@ +// Type definitions for detect-indent 0.1 +// Project: https://github.com/sindresorhus/detect-indent +// Definitions by: Bart van der Schoor +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +type DetectIndent = (dir: string, alt?: string) => string; + +declare const _: DetectIndent; +export = _; diff --git a/types/detect-indent/v0/tsconfig.json b/types/detect-indent/v0/tsconfig.json new file mode 100644 index 0000000000..f80769f598 --- /dev/null +++ b/types/detect-indent/v0/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "paths": { + "detect-indent": ["detect-indent/v0"] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "detect-indent-tests.ts" + ] +} diff --git a/types/detect-indent/v0/tslint.json b/types/detect-indent/v0/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/detect-indent/v0/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/detect-newline/detect-newline-tests.ts b/types/detect-newline/detect-newline-tests.ts new file mode 100644 index 0000000000..b660d01ffc --- /dev/null +++ b/types/detect-newline/detect-newline-tests.ts @@ -0,0 +1,7 @@ +import detectNewline = require('detect-newline'); + +const res1 = detectNewline('foo\nbar\nbaz\r\n'); +res1; // $ExpectType "\r\n" | "\n" | null + +const res2 = detectNewline.graceful('foo\nbar\nbaz\r\n'); +res2; // $ExpectType "\r\n" | "\n" diff --git a/types/detect-newline/index.d.ts b/types/detect-newline/index.d.ts new file mode 100644 index 0000000000..4a7aaad673 --- /dev/null +++ b/types/detect-newline/index.d.ts @@ -0,0 +1,12 @@ +// Type definitions for detect-newline 2.1 +// Project: https://github.com/sindresorhus/detect-newline#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = detectNewline; + +declare function detectNewline(str: string): '\r\n' | '\n' | null; + +declare namespace detectNewline { + function graceful(str: string): '\r\n' | '\n'; +} diff --git a/types/detect-newline/tsconfig.json b/types/detect-newline/tsconfig.json new file mode 100644 index 0000000000..bbb57f1823 --- /dev/null +++ b/types/detect-newline/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "detect-newline-tests.ts" + ] +} diff --git a/types/detect-newline/tslint.json b/types/detect-newline/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/detect-newline/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/detect-port/detect-port-tests.ts b/types/detect-port/detect-port-tests.ts index 759313665b..afd532ead0 100644 --- a/types/detect-port/detect-port-tests.ts +++ b/types/detect-port/detect-port-tests.ts @@ -1,6 +1,6 @@ import * as detect from "detect-port"; -const port: number = 8000; +const port = 8000; /** * callback usage diff --git a/types/dhtmlxgantt/index.d.ts b/types/dhtmlxgantt/index.d.ts index f94ba88a33..53626662ec 100644 --- a/types/dhtmlxgantt/index.d.ts +++ b/types/dhtmlxgantt/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for dhtmlxGantt 4.0.0 // Project: http://dhtmlx.com/docs/products/dhtmlxGantt -// Definitions by: Maksim Kozhukh , Christophe Camicas +// Definitions by: Maksim Kozhukh , Christophe Camicas // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/dhtmlxscheduler/index.d.ts b/types/dhtmlxscheduler/index.d.ts index 2a5ff01c87..96c9670a4d 100644 --- a/types/dhtmlxscheduler/index.d.ts +++ b/types/dhtmlxscheduler/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for dhtmlxScheduler 4.3.0 // Project: http://dhtmlx.com/docs/products/dhtmlxScheduler -// Definitions by: Maksim Kozhukh +// Definitions by: Maksim Kozhukh // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped interface SchedulerCallback { (...args: any[]): any } diff --git a/types/di-lite/di-lite-tests.ts b/types/di-lite/di-lite-tests.ts index efe45738ae..37d220fc6d 100644 --- a/types/di-lite/di-lite-tests.ts +++ b/types/di-lite/di-lite-tests.ts @@ -7,13 +7,13 @@ interface Dependency { function doTest(test: (ctx: any, ...obj: Dependency[]) => void) { // create di context var ctx = di.createContext(), - A: Dependency = () => { - this.dependencies = "b, c"; + A: Dependency = { + dependencies: "b, c", }, - B: Dependency = () => { - this.dependencies = "c"; + B: Dependency = { + dependencies: "c", }, - C: Dependency = () => {}; + C: Dependency = {}; // register a class with an unique name ctx.register("a", A); diff --git a/types/diacritics/diacritics-tests.ts b/types/diacritics/diacritics-tests.ts new file mode 100644 index 0000000000..c6419c8593 --- /dev/null +++ b/types/diacritics/diacritics-tests.ts @@ -0,0 +1,12 @@ +import * as diacritics from "diacritics"; + +const replacementListItem = diacritics.replacementList[1]; + +// tslint:disable-next-line:no-unused-expression +replacementListItem.base === "0"; +replacementListItem.chars === "\u07C0"; + +const mapItem = diacritics.diacriticsMap["A"]; + +// tslint:disable-next-line:no-unused-expression +diacritics.remove("foo") === "bar"; diff --git a/types/diacritics/index.d.ts b/types/diacritics/index.d.ts new file mode 100644 index 0000000000..c25988cb37 --- /dev/null +++ b/types/diacritics/index.d.ts @@ -0,0 +1,14 @@ +// Type definitions for diacritics 1.3 +// Project: https://github.com/andrewrk/node-diacritics +// Definitions by: Oto Ciulis +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export function remove(str: string): string; +export const replacementList: Array<{ + base: string; + chars: string; +}>; + +export const diacriticsMap: { + [key: string]: string; +}; diff --git a/types/diacritics/tsconfig.json b/types/diacritics/tsconfig.json new file mode 100644 index 0000000000..c5df557fe5 --- /dev/null +++ b/types/diacritics/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "diacritics-tests.ts" + ] +} \ No newline at end of file diff --git a/types/diacritics/tslint.json b/types/diacritics/tslint.json new file mode 100644 index 0000000000..2750cc0197 --- /dev/null +++ b/types/diacritics/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } \ No newline at end of file diff --git a/types/diff/diff-tests.ts b/types/diff/diff-tests.ts index e1b1025495..e787c44f48 100644 --- a/types/diff/diff-tests.ts +++ b/types/diff/diff-tests.ts @@ -1,14 +1,13 @@ -// tslint:disable:no-var only-arrow-functions import jsdiff = require('diff'); -var one = 'beep boop'; -var other = 'beep boob blah'; +const one = 'beep boop'; +const other = 'beep boob blah'; -var diff = jsdiff.diffChars(one, other); +let diff = jsdiff.diffChars(one, other); -diff.forEach(function(part) { - var mark = part.added ? '+' : +diff.forEach(part => { + const mark = part.added ? '+' : part.removed ? '-' : ' '; - console.log(mark + " " + part.value); + console.log(`${mark} ${part.value}`); }); // -------------------------- @@ -23,8 +22,8 @@ class LineDiffWithoutWhitespace extends jsdiff.Diff { } } -var obj = new LineDiffWithoutWhitespace(true); -var diff = obj.diff(one, other); +const obj = new LineDiffWithoutWhitespace(true); +diff = obj.diff(one, other); printDiff(diff); function printDiff(diff: jsdiff.IDiffResult[]) { @@ -50,7 +49,7 @@ function printDiff(diff: jsdiff.IDiffResult[]) { } function verifyPatchMethods(oldStr: string, newStr: string, uniDiff: jsdiff.IUniDiff) { - var verifyPatch = jsdiff.parsePatch( + const verifyPatch = jsdiff.parsePatch( jsdiff.createTwoFilesPatch("oldFile.ts", "newFile.ts", oldStr, newStr, "old", "new", { context: 1 })); if (JSON.stringify(verifyPatch) !== JSON.stringify(uniDiff)) { @@ -58,7 +57,7 @@ function verifyPatchMethods(oldStr: string, newStr: string, uniDiff: jsdiff.IUni } } function verifyApplyMethods(oldStr: string, newStr: string, uniDiff: jsdiff.IUniDiff) { - var verifyApply = [ + const verifyApply = [ jsdiff.applyPatch(oldStr, uniDiff), jsdiff.applyPatch(oldStr, [uniDiff]) ]; @@ -83,7 +82,7 @@ function verifyApplyMethods(oldStr: string, newStr: string, uniDiff: jsdiff.IUni }); } -verifyPatchMethods(one, other, uniDiff); -var uniDiff = jsdiff.structuredPatch("oldFile.ts", "newFile.ts", one, other, +const uniDiff = jsdiff.structuredPatch("oldFile.ts", "newFile.ts", one, other, "old", "new", { context: 1 }); +verifyPatchMethods(one, other, uniDiff); verifyApplyMethods(one, other, uniDiff); diff --git a/types/diff/index.d.ts b/types/diff/index.d.ts index 03228269e0..720a8d3270 100644 --- a/types/diff/index.d.ts +++ b/types/diff/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for diff 3.2 // Project: https://github.com/kpdecker/jsdiff -// Definitions by: vvakame +// Definitions by: vvakame // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -8,6 +8,15 @@ export = JsDiff; export as namespace JsDiff; declare namespace JsDiff { + interface ICaseOptions { + ignoreCase: boolean; + } + + interface ILinesOptions { + ignoreWhitespace?: boolean; + newlineIsToken?: boolean; + } + interface IDiffResult { value: string; count?: number; @@ -54,18 +63,15 @@ declare namespace JsDiff { tokenize(value: string): any; // return types are string or string[] } - function diffChars(oldStr: string, newStr: string): IDiffResult[]; + function diffChars(oldStr: string, newStr: string, options?: ICaseOptions): IDiffResult[]; - function diffWords(oldStr: string, newStr: string): IDiffResult[]; + function diffWords(oldStr: string, newStr: string, options?: ICaseOptions): IDiffResult[]; function diffWordsWithSpace(oldStr: string, newStr: string): IDiffResult[]; function diffJson(oldObj: object, newObj: object): IDiffResult[]; - function diffLines(oldStr: string, newStr: string, options?: { - ignoreWhitespace?: boolean, - newlineIsToken?: boolean, - }): IDiffResult[]; + function diffLines(oldStr: string, newStr: string, options?: ILinesOptions): IDiffResult[]; function diffCss(oldStr: string, newStr: string): IDiffResult[]; diff --git a/types/diff2html/index.d.ts b/types/diff2html/index.d.ts index 398cb1aba1..ce2522d444 100644 --- a/types/diff2html/index.d.ts +++ b/types/diff2html/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for diff2html // Project: https://github.com/rtfpessoa/diff2html -// Definitions by: rtfpessoa +// Definitions by: rtfpessoa // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace Diff2Html { diff --git a/types/dockerode/index.d.ts b/types/dockerode/index.d.ts index aa6c03bf29..199fe1de75 100644 --- a/types/dockerode/index.d.ts +++ b/types/dockerode/index.d.ts @@ -488,6 +488,7 @@ declare namespace Dockerode { CpusetCpus: string; CpusetMems: string; Devices?: any; + DiskQuota: number; KernelMemory: number; Memory: number; MemoryReservation: number; diff --git a/types/dockerode/tslint.json b/types/dockerode/tslint.json index 3db14f85ea..aac1f69ee8 100644 --- a/types/dockerode/tslint.json +++ b/types/dockerode/tslint.json @@ -1 +1,7 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + // TODO + "await-promise": false + } +} diff --git a/types/docopt/index.d.ts b/types/docopt/index.d.ts index a40904bf76..8d8b23a0c0 100644 --- a/types/docopt/index.d.ts +++ b/types/docopt/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Docopt v0.6.2 // Project: http://docopt.org/ -// Definitions by: Giovanni Bassi +// Definitions by: Giovanni Bassi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /** diff --git a/types/documentdb-server/documentdb-server-tests.ts b/types/documentdb-server/documentdb-server-tests.ts index aa5c45b73d..d4e8e7f40c 100644 --- a/types/documentdb-server/documentdb-server-tests.ts +++ b/types/documentdb-server/documentdb-server-tests.ts @@ -20,10 +20,12 @@ function filter() { .value(); if (!result.isAccepted) throw new Error("The call was not accepted"); // Example 3: get document (person) with id = 1 and delete it. - var result: IQueryResponse = __.filter(function (doc: any) { return doc.id === 1; }, function (err: IFeedCallbackError, feed: Array, options: IFeedCallbackOptions) { - if (err) throw err; - if (!__.deleteDocument(feed[0].getSelfLink())) throw new Error("deleteDocument was not accepted"); - }); + var result: IQueryResponse = __.filter( + function (doc: any) { return doc.id === 1; }, + function (err: IFeedCallbackError, feed: Array, options: IFeedCallbackOptions) { + if (err) throw err; + if (!__.deleteDocument(feed[0].getSelfLink())) throw new Error("deleteDocument was not accepted"); + }); if (!result.isAccepted) throw new Error("The call was not accepted"); } function flatten() { @@ -103,7 +105,7 @@ function value() { // Samples taken from https://github.com/Azure/azure-documentdb-js-server/tree/master/samples /** * This script called as stored procedure to import lots of documents in one batch. -* The script sets response body to the number of docs imported and is called multiple times +* The script sets response body to the number of docs imported and is called multiple times * by the client until total number of docs desired by the client is imported. * @param {Object[]} docs - Array of documents to import. */ @@ -127,7 +129,7 @@ function bulkImport(docs: Array) { tryCreate(docs[count], callback); // Note that there are 2 exit conditions: - // 1) The createDocument request was not accepted. + // 1) The createDocument request was not accepted. // In this case the callback will not be called, we just call setBody and we are done. // 2) The callback was called docs.length times. // In this case all documents were created and we don't need to call tryCreate anymore. Just call setBody and we are done. @@ -135,7 +137,7 @@ function bulkImport(docs: Array) { var isAccepted = collection.createDocument(collectionLink, doc, callback); // If the request was accepted, callback will be called. - // Otherwise report current count back to the client, + // Otherwise report current count back to the client, // which will call the script again with remaining set of docs. // This condition will happen when this stored procedure has been running too long // and is about to get cancelled by the server. This will allow the calling client @@ -164,7 +166,7 @@ function bulkImport(docs: Array) { * This is executed as stored procedure to count the number of docs in the collection. * To avoid script timeout on the server when there are lots of documents (100K+), the script executed in batches, * each batch counts docs to some number and returns continuation token. -* The script is run multiple times, starting from empty continuation, +* The script is run multiple times, starting from empty continuation, * then using continuation returned by last invocation script until continuation returned by the script is null/empty string. * * @param {String} filterQuery - Optional filter for query (e.g. "SELECT * FROM docs WHERE docs.category = 'food'"). @@ -172,7 +174,7 @@ function bulkImport(docs: Array) { */ function count(filterQuery: string, continuationToken: string) { var collection: ICollection = getContext().getCollection(); - var maxResult: number = 25; // MAX number of docs to process in one batch, when reached, return to client/request continuation. + var maxResult: number = 25; // MAX number of docs to process in one batch, when reached, return to client/request continuation. // intentionally set low to demonstrate the concept. This can be much higher. Try experimenting. // We've had it in to the high thousands before seeing the stored proceudre timing out. @@ -186,7 +188,7 @@ function count(filterQuery: string, continuationToken: string) { var responseOptions: Object = { continuation: nextContinuationToken, pageSize: maxResult }; // In case the server is running this script for long time/near timeout, it would return false, - // in this case we set the response to current continuation token, + // in this case we set the response to current continuation token, // and the client will run this script again starting from this continuation. // When the client calls this script 1st time, is passes empty continuation token. if (result >= maxResult || !query(responseOptions)) { @@ -210,7 +212,7 @@ function count(filterQuery: string, continuationToken: string) { // Increament the number of documents counted so far. result += docFeed.length; - // If there is continuation, call query again with it, + // If there is continuation, call query again with it, // otherwise we are done, in which case set continuation to null. if (responseOptions.continuation) { tryQuery(responseOptions.continuation); @@ -324,7 +326,7 @@ function orderBy(filterQuery: string, orderByFieldName: string, continuationToke break; } } - + // Now next batch to return to client has i elements. // Slice the continuationResult if needed and discard the end. var partialResult: Array = continuationResult; @@ -341,7 +343,7 @@ function orderBy(filterQuery: string, orderByFieldName: string, continuationToke /** * This is run as stored procedure and does the following: -* - get 1st document in the collection, convert to JSON, prepend string specified by the prefix parameter +* - get 1st document in the collection, convert to JSON, prepend string specified by the prefix parameter * and set response to the result of that. * * @param {String} prefix - The string to prepend to the 1st document in collection. @@ -750,8 +752,8 @@ function updateSproc(id: string, update: Object) { /** * A DocumentDB stored procedure that upserts a given document (insert new or update if present) using its id property.
      - * This implementation tries to create, and if the create fails then query for the document with the specified document's id, then replace it. - * Use this sproc if creates are more common than replaces, otherwise use "upsertOptimizedForReplace" + * This implementation tries to create, and if the create fails then query for the document with the specified document's id, then replace it. + * Use this sproc if creates are more common than replaces, otherwise use "upsertOptimizedForReplace" * * @function * @param {Object} document - A document that should be upserted into this collection. @@ -820,7 +822,7 @@ function upsert(document: IDocumentMeta) { /** * A DocumentDB stored procedure that upserts a given document (insert new or update if present) using its id property.
      * This implementation queries for the document's id, and creates if absent and replaces if found. - * Use this sproc if replaces are more common than creates, otherwise use "upsert" + * Use this sproc if replaces are more common than creates, otherwise use "upsert" * * @function * @param {Object} document - A document that should be upserted into this collection. @@ -941,17 +943,17 @@ function updateMetadata() { // for 1st document use doc.Size, for all the rest see if it's less than last min. if (metaDoc.minSize == 0) metaDoc.minSize = doc.size; else metaDoc.minSize = Math.min(metaDoc.minSize, doc.size); - + // Update metaDoc.maxSize. metaDoc.maxSize = Math.max(metaDoc.maxSize, doc.size); // Update metaDoc.totalSize. metaDoc.totalSize += doc.size; - + // Update/replace the metadata document in the store. var isAccepted: boolean = collection.replaceDocument(metaDoc._self, metaDoc, function (err: IRequestCallbackError) { if (err) throw err; - // Note: in case concurrent updates causes conflict with ErrorCode.RETRY_WITH, we can't read the meta again + // Note: in case concurrent updates causes conflict with ErrorCode.RETRY_WITH, we can't read the meta again // and update again because due to Snapshot isolation we will read same exact version (we are in same transaction). // We have to take care of that on the client side. }); diff --git a/types/documentdb-server/index.d.ts b/types/documentdb-server/index.d.ts index 907fbd3d8c..974c0661fa 100644 --- a/types/documentdb-server/index.d.ts +++ b/types/documentdb-server/index.d.ts @@ -36,6 +36,8 @@ interface IQueryAPI { * @param options Optional query options. Should not be used in a chained call. * @param callback Optional callback for the operation. If no callback is provided, any error in the operation will be thrown and the result document set will be written to the Response body. Should not be used in a chained call. */ + filter(predicate: (document: Object) => boolean, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; filter(predicate: (document: Object) => boolean, options?: IFeedOptions, callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; @@ -49,6 +51,8 @@ interface IQueryAPI { * @param options Optional query options. Should not be used in a chained call. * @param callback Optional callback for the operation. If no callback is provided, any error in the operation will be thrown and the result document set will be written to the Response body. Should not be used in a chained call. */ + map(predicate: (document: Object) => Object, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; map(predicate: (document: Object) => Object, options?: IFeedOptions, callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; @@ -62,6 +66,8 @@ interface IQueryAPI { * @param options Optional query options. Should not be used in a chained call. * @param callback Optional callback for the operation. If no callback is provided, any error in the operation will be thrown and the result document set will be written to the Response body. Should not be used in a chained call. */ + pluck(propertyName: string, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; pluck(propertyName: string, options?: IFeedOptions, callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; @@ -75,6 +81,8 @@ interface IQueryAPI { * @param options Optional query options. Should not be used in a chained call. * @param callback Optional callback for the operation. If no callback is provided, any error in the operation will be thrown and the result document set will be written to the Response body. Should not be used in a chained call. */ + flatten(isShallow?: boolean, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; flatten(isShallow?: boolean, options?: IFeedOptions, callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; @@ -88,16 +96,12 @@ interface IQueryAPI { * @param options Optional query options. Should not be used in a chained call. * @param Optional callback for the operation. If no callback is provided, any error in the operation will be thrown and the result document set will be written to the Response body. Should not be used in a chained call. */ - sortBy(predicate: (document: Object) => string, + sortBy(predicate: (document: Object) => string | number, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; + sortBy(predicate: (document: Object) => string | number, options?: IFeedOptions, callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; - sortBy(predicate: (document: Object) => number, - options?: IFeedOptions, - callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; - sortBy(predicate: (document: Object) => string, - options?: IFeedOptions, - callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; - sortBy(predicate: (document: Object) => number, + sortBy(predicate: (document: Object) => string | number, options?: IFeedOptions, callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; /** @@ -107,16 +111,12 @@ interface IQueryAPI { * @param options Optional query options. Should not be used in a chained call. * @param callback Optional callback for the operation. If no callback is provided, any error in the operation will be thrown and the result document set will be written to the Response body. Should not be used in a chained call. */ - sortByDescending(predicate: (document: Object) => string, + sortByDescending(predicate: (document: Object) => string | number, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; + sortByDescending(predicate: (document: Object) => string | number, options?: IFeedOptions, callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; - sortByDescending(predicate: (document: Object) => number, - options?: IFeedOptions, - callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; - sortByDescending(predicate: (document: Object) => string, - options?: IFeedOptions, - callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; - sortByDescending(predicate: (document: Object) => number, + sortByDescending(predicate: (document: Object) => string | number, options?: IFeedOptions, callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; /** @@ -125,19 +125,20 @@ interface IQueryAPI { * @param options Optional query options for the entire chained call. * @param callback Optional callback for the operation. If no callback is provided, any error in the operation will be thrown and the result document set will be written to the Response body. */ + value(callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; value(options?: IFeedOptions, callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; value(options?: IFeedOptions, callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; } - + /** * Stored procedures and triggers are registered for a particular collection. The Collection object supports create, read, update and delete (CRUD) and query operations on documents and attachments in the current collection. * All collection operations are completed asynchronously. You can provide a callback to handle the result of the operation, and to perform error handling if necessary. * Stored procedures and triggers are executed in a time-limited manner. Long-running stored procedures and triggers are defensively timed out and all transactions performed are rolled back. * We stop queuing collection operations if the stored procedure is close to timing out. You can inspect the boolean return value of all collection operations to see if an operation was not queued and handle this situation gracefully. */ -interface ICollection extends IQueryAPI { +interface ICollection extends IQueryAPI { /** Opening call to start a chained query. Should be used in conjunction with the closing value call to perform chained queries. */ chain(): IQueryResponse; @@ -148,11 +149,14 @@ interface ICollection extends IQueryAPI { * @param options optional create options * @param callback optional callback for the operation. If no callback is provided, any error in the operation will be thrown. */ + createAttachment(documentLink: string, + body: IAttachment, + callback?: (error: IRequestCallbackError, resources: Object, options: IRequestCallbackOptions) => void): boolean; createAttachment(documentLink: string, body: IAttachment, options?: ICreateOptions, callback?: (error: IRequestCallbackError, resources: Object, options: IRequestCallbackOptions) => void): boolean; - + /** * Create a document under the collection. * @param collectionLink resource link of the collection under which the document will be created @@ -160,37 +164,44 @@ interface ICollection extends IQueryAPI { * @param optional create options * @param optional callback for the operation. If no callback is provided, any error in the operation will be thrown. */ + createDocument(collectionLink: string, + body: Object, + callback?: (error: IRequestCallbackError, resources: Object, options: IRequestCallbackOptions) => void): boolean; createDocument(collectionLink: string, body: Object, options?: ICreateOptions, callback?: (error: IRequestCallbackError, resources: Object, options: IRequestCallbackOptions) => void): boolean; - + /** * Delete an attachment. * @param attachmentLink resource link of the attachment to be deleted * @param options optional delete options. * @param callback optional callback for the operation. If no callback is provided, any error in the operation will be thrown. */ + deleteAttachment(attachmentLink: string, + callback?: (error: IRequestCallbackError, resources: Object, options: IRequestCallbackOptions) => void): boolean; deleteAttachment(attachmentLink: string, options?: IDeleteOptions, callback?: (error: IRequestCallbackError, resources: Object, options: IRequestCallbackOptions) => void): boolean; - + /** * Delete a document. * @param documentLink resource link of the document to delete * @param options optional delete options * @param callback optional callback for the operation. If no callback is provided, any error in the operation will be thrown. */ + deleteDocument(documentLink: string, + callback?: (error: IRequestCallbackError, resources: Object, options: IRequestCallbackOptions) => void): boolean; deleteDocument(documentLink: string, options?: IDeleteOptions, callback?: (error: IRequestCallbackError, resources: Object, options: IRequestCallbackOptions) => void): boolean; - + /** Get alt link (name-based link) of current collection. */ getAltLink(): string; /** Get self link of current collection. */ getSelfLink(): string; - + /** * Execute a SQL query on the attachments for the document. * @param documentLink resource link of the document whose attachments are being queried @@ -199,14 +210,13 @@ interface ICollection extends IQueryAPI { * @param callback optional callback for the operation. If no callback is provided, any error in the operation will be thrown. */ queryAttachments(documentLink: string, - query: string, - options?: IFeedOptions, + query: string | IParameterizedQuery, callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): boolean; queryAttachments(documentLink: string, - query: IParameterizedQuery, + query: string | IParameterizedQuery, options?: IFeedOptions, callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): boolean; - + /** * Execute a SQL query on the documents of the collection. * @param collectionLink resource link of the collection whose documents are being queried @@ -214,6 +224,9 @@ interface ICollection extends IQueryAPI { * @param options optional query options. * @param callback optional callback for the operation. If no callback is provided, any error in the operation will be thrown. */ + queryDocuments(collectionLink: string, + filterQuery: string, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): boolean; queryDocuments(collectionLink: string, filterQuery: string, options?: IFeedOptions, @@ -222,6 +235,9 @@ interface ICollection extends IQueryAPI { filterQuery: string, options?: IFeedOptions, callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): boolean; + queryDocuments(collectionLink: string, + filterQuery: IParameterizedQuery, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): boolean; queryDocuments(collectionLink: string, filterQuery: IParameterizedQuery, options?: IFeedOptions, @@ -230,53 +246,61 @@ interface ICollection extends IQueryAPI { filterQuery: IParameterizedQuery, options?: IFeedOptions, callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): boolean; - + /** * Read an Attachment. * @param attachmenLink resource link of the attachment to read * @param options optional read options * @param callback optional callback for the operation. If no callback is provided, any error in the operation will be thrown. */ + readAttachment(attachmenLink: string, + callback?: (error: IRequestCallbackError, resources: Object, options: IRequestCallbackOptions) => void): boolean; readAttachment(attachmenLink: string, options?: IReadOptions, callback?: (error: IRequestCallbackError, resources: Object, options: IRequestCallbackOptions) => void): boolean; - + /** * Get all attachments for the document. * @param documentLink resource link of the document whose attachments are being read * @param options optional read feed options * @param callback optional callback for the operation. If no callback is provided, any error in the operation will be thrown. */ + readAttachments(documentLink: string, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): boolean; readAttachments(documentLink: string, options?: IFeedOptions, callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): boolean; - + /** * Read a document. * @param documentLink resource link of the document to read * @param options optional read options * @param callback optional callback for the operation. If no callback is provided, any error in the operation will be thrown. */ + readDocument(documentLink: string, + callback?: (error: IRequestCallbackError, resources: Object, options: IRequestCallbackOptions) => void): boolean; readDocument(documentLink: string, options?: IReadOptions, callback?: (error: IRequestCallbackError, resources: Object, options: IRequestCallbackOptions) => void): boolean; readDocument(documentLink: string, options?: IReadOptions, callback?: (error: IRequestCallbackError, resources: T, options: IRequestCallbackOptions) => void): boolean; - + /** * Get all documents for the collection. * @param collectionLink resource link of the collection whose documents are being read * @param options optional read feed options * @param callback optional callback for the operation. If no callback is provided, any error in the operation will be thrown. */ + readDocuments(collectionLink: string, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): boolean; readDocuments(collectionLink: string, options?: IFeedOptions, callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): boolean; readDocuments(collectionLink: string, options?: IFeedOptions, callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): boolean; - + /** * Replace an attachment. * @param attachmentLink resource link of the attachment to be replaced @@ -284,11 +308,14 @@ interface ICollection extends IQueryAPI { * @param options optional replace options * @param callback optional callback for the operation. If no callback is provided, any error in the operation will be thrown. */ + replaceAttachment(attachmentLink: string, + attachment: Object, + callback?: (error: IRequestCallbackError, resources: Object, options: IRequestCallbackOptions) => void): boolean; replaceAttachment(attachmentLink: string, attachment: Object, options?: IReplaceOptions, callback?: (error: IRequestCallbackError, resources: Object, options: IRequestCallbackOptions) => void): boolean; - + /** * Replace a document. * @param documentLink resource link of the document @@ -296,12 +323,15 @@ interface ICollection extends IQueryAPI { * @param options optional replace options * @param callback optional callback for the operation. If no callback is provided, any error in the operation will be thrown. */ + replaceDocument(documentLink: string, + document: Object, + callback?: (error: IRequestCallbackError, resources: Object, options: IRequestCallbackOptions) => void): boolean; replaceDocument(documentLink: string, document: Object, options?: IReplaceOptions, callback?: (error: IRequestCallbackError, resources: Object, options: IRequestCallbackOptions) => void): boolean; } - + /** Options associated with a create operation. */ interface ICreateOptions { /** Specifies indexing directives. */ @@ -309,7 +339,7 @@ interface ICreateOptions { /** Disables automatic generation of "id" field of the document to be created (if it is not provided) */ disableAutomaticIdGeneration?: string; } - + /** Options associated with a delete operation. */ interface IDeleteOptions { /** @@ -318,7 +348,7 @@ interface IDeleteOptions { */ etag?: string; } - + /** Will contain error information if an error occurs, undefined otherwise. */ interface IFeedCallbackError { /** The HTTP response code corresponding to the error. */ @@ -326,7 +356,7 @@ interface IFeedCallbackError { /** A string containing the error information. */ body: string; } - + /** Information associated with the response to the operation. */ interface IFeedCallbackOptions { /** Opaque token for continuing the read feed or query. */ @@ -336,7 +366,7 @@ interface IFeedCallbackOptions { /** Comma delimited string containing the collection's maximum quota metrics (storage, number of stored procedure, triggers and UDFs). */ maxCollectionSizeInMB: string; } - + /** Options associated with a read feed or query operation. */ interface IFeedOptions { /** @@ -360,13 +390,13 @@ interface IQueryResponse extends IQueryAPI { /** True if the query has been queued, false if it is not queued because of a pending timeout. */ isAccepted: boolean; } - + /** Options associated with a read operation. */ interface IReadOptions { /** The conditional HTTP method ifNoneMatch value. */ ifNoneMatch?: string; } - + /** Options associated with a replace operation. */ interface IReplaceOptions { /** Specifies indexing directives. */ @@ -377,7 +407,7 @@ interface IReplaceOptions { */ etag?: string; } - + /** Will contain error information if an error occurs, undefined otherwise. */ interface IRequestCallbackError { /** The HTTP response code corresponding to the error. */ @@ -385,7 +415,7 @@ interface IRequestCallbackError { /** A string containing the error information. */ body: string; } - + /** Information associated with the response to the operation. */ interface IRequestCallbackOptions { /** Comma delimited string containing the collection's current quota metrics (storage, number of stored procedure, triggers and UDFs) after completion of the operation. */ @@ -411,7 +441,7 @@ interface IDocumentMeta extends Object { _etag?: string; _attachments?: string; } - + /** * The Request object represents the request message that was sent to the server. This includes information about HTTP headers and the body of the HTTP request sent to the server. * For triggers, the request represents the operation that is executing when the trigger is run. For example, if the trigger is being run ("triggered") on the creation of a document, then @@ -445,7 +475,7 @@ interface IRequest { */ setValue(key: string, value: string): void; } - + /** * The Response object represents the response message that will be sent from the server in response to the requested operation. This includes information about the HTTP headers and body of the response from the server. * The Response object is not present in pre-triggers because they are run before the response is generated. diff --git a/types/documentdb/tslint.json b/types/documentdb/tslint.json index 2750cc0197..71ee04c4e1 100644 --- a/types/documentdb/tslint.json +++ b/types/documentdb/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } \ No newline at end of file +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/dojo/dojox.gfx3d.d.ts b/types/dojo/dojox.gfx3d.d.ts index 42483ab8d4..6d584c4b50 100644 --- a/types/dojo/dojox.gfx3d.d.ts +++ b/types/dojo/dojox.gfx3d.d.ts @@ -23,8 +23,8 @@ declare namespace dojox { * * */ - class object { - constructor(); + const object: { new(): objectInstance }; + interface objectInstance { /** * multiplies the existing matrix with an argument on left side * (matrix * this.matrix) @@ -2529,7 +2529,7 @@ declare namespace dojox { * @param outline */ class BinarySearchTree { - constructor(obj: dojox.gfx3d.object, outline: any); + constructor(obj: dojox.gfx3d.objectInstance, outline: any); /** * * @param obj @@ -3240,7 +3240,7 @@ declare module "dojox/gfx3d" { export=exp; } declare module "dojox/gfx3d/object" { - var exp: dojox.gfx3d.object + var exp: dojox.gfx3d.objectInstance; export=exp; } declare module "dojox/gfx3d/gradient" { diff --git a/types/dojo/dojox.lang.d.ts b/types/dojo/dojox.lang.d.ts index 4774941552..fa6b9ae07c 100644 --- a/types/dojo/dojox.lang.d.ts +++ b/types/dojo/dojox.lang.d.ts @@ -6293,7 +6293,7 @@ declare namespace dojox { * * */ - interface object { + interface objectInstance { /** * builds a function from a snippet, returns a string, which * represents the function. @@ -12082,7 +12082,7 @@ declare module "dojox/lang/functional/listcomp" { export=exp; } declare module "dojox/lang/functional/object" { - var exp: dojox.lang.functional.object + var exp: dojox.lang.functional.objectInstance export=exp; } declare module "dojox/lang/functional/zip" { diff --git a/types/dom-inputevent/tslint.json b/types/dom-inputevent/tslint.json index 3db14f85ea..b63c1c3846 100644 --- a/types/dom-inputevent/tslint.json +++ b/types/dom-inputevent/tslint.json @@ -1 +1,7 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + // TODO + "no-boolean-literal-compare": false + } +} diff --git a/types/dompurify/dompurify-tests.ts b/types/dompurify/dompurify-tests.ts index eb07cfcf14..356225b7c3 100644 --- a/types/dompurify/dompurify-tests.ts +++ b/types/dompurify/dompurify-tests.ts @@ -3,55 +3,60 @@ import dompurify = require('dompurify'); dompurify.sanitize(''); -dompurify.addHook('beforeSanitizeElements', (el, data, config) => { - return el; -}); +dompurify.addHook('beforeSanitizeElements', (el, data, config) => undefined); //examples from the DOMPurify README let dirty = '

      Totally safe

      Totally not safe

      '; +let str: string; +let elem: HTMLElement; +let frag: DocumentFragment; // allow only -dompurify.sanitize(dirty, {ALLOWED_TAGS: ['b']}); +str = dompurify.sanitize(dirty, { ALLOWED_TAGS: ['b'] }); // allow only and with style attributes (for whatever reason) -dompurify.sanitize(dirty, {ALLOWED_TAGS: ['b', 'q'], ALLOWED_ATTR: ['style']}); +str = dompurify.sanitize(dirty, { ALLOWED_TAGS: ['b', 'q'], ALLOWED_ATTR: ['style'] }); // leave all as it is but forbid