Skip to content

Commit

Permalink
chore: Add dtslint and Cypress static types (#1044)
Browse files Browse the repository at this point in the history
* chore: Add dtslint and Cypress static types

* chore: Fix types location for cli build

* chore: Removed api from api command paths

* chore: Remove semicolons from type definitions

* chore: Removed semicolons not caught by tslint

* chore: Add type tests
  • Loading branch information
NicholasBoll authored and brian-mann committed Dec 8, 2017
1 parent 4d41d3d commit 6db7a83
Show file tree
Hide file tree
Showing 11 changed files with 1,236 additions and 922 deletions.
918 changes: 0 additions & 918 deletions cli/index.d.ts

This file was deleted.

13 changes: 11 additions & 2 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,28 @@
},
"scripts": {
"test": "npm run test-unit",
"test-unit": "bin-up mocha --reporter mocha-multi-reporters --reporter-options configFile=../mocha-reporter-config.json",
"test-unit": "npm run dtslint && bin-up mocha --reporter mocha-multi-reporters --reporter-options configFile=../mocha-reporter-config.json",
"test-watch": "bin-up mocha --watch",
"test-dependencies": "bin-up deps-ok && dependency-check . --no-dev",
"test-debug": "node --inspect --debug-brk $(bin-up _mocha)",
"lint": "bin-up eslint --fix *.js bin/* lib/*.js lib/**/*.js test/*.js test/**/*.js",
"dtslint": "dtslint types",
"prebuild": "npm run test-dependencies && node ./scripts/start-build.js",
"build": "node ./scripts/build.js",
"prerelease": "npm run build",
"release": "cd build && releaser --no-node --no-changelog",
"size": "t=\"$(npm pack .)\"; wc -c \"${t}\"; tar tvf \"${t}\"; rm \"${t}\";"
},
"types": "types",
"dependencies": {
"@cypress/listr-verbose-renderer": "0.4.1",
"@cypress/xvfb": "1.0.4",
"@types/blob-util": "1.3.3",
"@types/bluebird": "3.5.18",
"@types/jquery": "3.2.16",
"@types/lodash": "4.14.87",
"@types/minimatch": "3.0.1",
"@types/sinon": "4.0.0",
"bluebird": "3.5.0",
"chalk": "2.1.0",
"check-more-types": "2.24.0",
Expand Down Expand Up @@ -60,6 +68,7 @@
"chai-string": "1.4.0",
"clear-module": "^2.1.0",
"dependency-check": "^2.8.0",
"dtslint": "0.2.0",
"execa-wrap": "1.1.0",
"nock": "^9.0.9",
"shelljs": "0.7.8",
Expand All @@ -71,6 +80,6 @@
"bin",
"lib",
"index.js",
"index.d.ts"
"types/*.d.ts"
]
}
2 changes: 1 addition & 1 deletion cli/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function preparePackageForNpmRelease (json) {
bugs,
repository,
engines,
types: 'index.d.ts', // typescript types
types: 'types', // typescript types
scripts: {
postinstall: 'node index.js --exec install',
size: 't=\"$(npm pack .)\"; wc -c \"${t}\"; tar tvf \"${t}\"; rm \"${t}\";',
Expand Down
3 changes: 2 additions & 1 deletion cli/scripts/start-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ shell.set('-e') // any error is fatal

shell.rm('-rf', 'build')
shell.mkdir('-p', 'build/bin')
shell.mkdir('-p', 'build/types')
shell.cp('bin/cypress', 'build/bin/cypress')
shell.cp('NPM_README.md', 'build/README.md')
shell.cp('.release.json', 'build/.release.json')
shell.cp('index.d.ts', 'build/index.d.ts')
shell.cp('-R', 'types/*.ts', 'build/types/')

shell.exec('babel lib -d build/lib')
shell.exec('babel index.js -o build/index.js')
13 changes: 13 additions & 0 deletions cli/types/blob-util.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Shim definition to export a namespace. Cypress is actually a global module
// so import/export isn't allowed there. We import here and define a global module
// so that Cypress can get and use the Blob type

// tslint:disable-next-line:no-implicit-dependencies
import * as blobUtil from 'blob-util'

export = BlobUtil
export as namespace BlobUtil

declare namespace BlobUtil {
type BlobUtilStatic = typeof blobUtil
}
11 changes: 11 additions & 0 deletions cli/types/bluebird.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Shim definition to export a namespace. Cypress is actually a global module
// so import/export isn't allowed there. We import here and define a global module
// so that Cypress can get and use the Blob type
import * as BluebirdStatic from 'bluebird'

export = Bluebird
export as namespace Bluebird

declare namespace Bluebird {
type BluebirdStatic = typeof BluebirdStatic
}
Loading

0 comments on commit 6db7a83

Please sign in to comment.