Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added TypeScript type checker + Fixed type errors. #5780

Merged
merged 46 commits into from
Mar 17, 2020
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
7b22fd9
Added type_check.js
sainthkh Nov 23, 2019
6c048a3
Now checks cli, too.
sainthkh Nov 23, 2019
7ca7cc8
Ignored a line that should fail.
sainthkh Nov 25, 2019
cbba9f4
Removed cli shims and post-install.
sainthkh Nov 25, 2019
d4bbda9
Updated @types/chai to fix type error.
sainthkh Nov 25, 2019
62a669f
Fixed keyboard type errors.
sainthkh Nov 25, 2019
1789497
Updated typescript to 3.7.2 to fix window.Node error in dom/document.
sainthkh Nov 25, 2019
b3a3b9e
Removed tsconfig errors that caused type errors in reporter and runner.
sainthkh Nov 25, 2019
c3611e0
Ignored error test by dtslint. Becaust it's done by type_check.js
sainthkh Nov 25, 2019
3014542
Added npm command.
sainthkh Nov 25, 2019
c7d3bf7
Added it to CI.
sainthkh Nov 25, 2019
5921006
Added skipLibCheck option.
sainthkh Nov 25, 2019
7c78434
Removed checking chai folder existence.
sainthkh Nov 25, 2019
972a295
Added 'ignore-progress' option for CI.
sainthkh Nov 25, 2019
7c85c27
Show success message when type check is finished successfully.
sainthkh Nov 25, 2019
1d3c0b2
Use ignore-progress option on CI.
sainthkh Nov 25, 2019
64e4beb
Moved type definitions from devDependencies to dependencies.
sainthkh Nov 26, 2019
68cbba8
Fixed new type errors after rebase.
sainthkh Nov 28, 2019
19df9fb
Merge branch 'develop' into issue-5772
jennifer-shehane Jan 10, 2020
60cd19a
Updated type errors.
sainthkh Jan 10, 2020
a67efe4
Removed cli. Because its types are checked by dtslint.
sainthkh Jan 10, 2020
733dd36
type_check -> type-check for consistency.
sainthkh Jan 10, 2020
f287253
Merge branch 'develop' into issue-5772
sainthkh Jan 16, 2020
d93f192
Updated json-schema.
sainthkh Jan 16, 2020
e46549a
Updated blob-util.
sainthkh Jan 16, 2020
3d8557d
Fix wrong command in CI.
sainthkh Jan 16, 2020
5d6c278
Revert "Updated blob-util."
sainthkh Jan 16, 2020
1deae8f
Remove copies of @types if exists.
sainthkh Jan 16, 2020
5904ae4
Merge branch 'develop' into issue-5772
bahmutov Feb 3, 2020
24de96a
Fix stream buffer type error.
sainthkh Feb 4, 2020
d744207
Fix type errors in ui-components.
sainthkh Feb 4, 2020
13c17d1
Merge branch 'develop' into issue-5772
sainthkh Feb 11, 2020
97c1e49
Fix type failure.
sainthkh Feb 11, 2020
741a3f3
Fix lint error.
sainthkh Feb 11, 2020
7478488
Merge branch 'develop' into issue-5772
sainthkh Feb 11, 2020
887b6f0
Merge branch 'develop' into issue-5772
sainthkh Feb 21, 2020
5f52d24
Merge branch 'develop' into issue-5772
sainthkh Mar 2, 2020
2dd9dfe
Fix type errors
sainthkh Mar 2, 2020
0b6fa43
Regenerate yarn.lock
sainthkh Mar 2, 2020
2da2ecc
Merge branch 'develop' into issue-5772
bahmutov Mar 5, 2020
d6be2d1
Merge branch 'develop' into issue-5772
sainthkh Mar 9, 2020
0c50c77
Fix type error.
sainthkh Mar 13, 2020
a1a6344
Merge remote-tracking branch 'upstream/develop' into issue-5772
sainthkh Mar 13, 2020
5fc7cb5
Fix type failures.
sainthkh Mar 13, 2020
9faec67
Merge branch 'develop' into issue-5772-ts-checks
jennifer-shehane Mar 16, 2020
a6dae5f
Merge branch 'develop' into issue-5772
jennifer-shehane Mar 16, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,10 @@ jobs:
- run:
command: ls -la types
working_directory: cli
- run:
command: ls -la chai
working_directory: cli/types
- run:
command: yarn lerna exec --scope cypress "yarn dtslint"
- run:
command: yarn type-check --ignore-progress
Comment on lines +323 to +324
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CypressJoseph I added this to CI. Or is there anything more to do?

- store-npm-logs

"server-unit-tests":
Expand Down
20 changes: 10 additions & 10 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@
"dependencies": {
"@cypress/listr-verbose-renderer": "0.4.1",
"@cypress/xvfb": "1.2.4",
"@types/blob-util": "1.3.3",
"@types/bluebird": "3.5.29",
"@types/chai": "4.2.7",
"@types/chai-jquery": "1.1.40",
"@types/jquery": "3.3.31",
"@types/lodash": "4.14.149",
"@types/minimatch": "3.0.3",
"@types/mocha": "5.2.7",
"@types/sinon": "7.5.1",
"@types/sinon-chai": "3.2.3",
"@types/sizzle": "2.3.2",
"arch": "2.1.1",
"bluebird": "3.7.2",
Expand Down Expand Up @@ -60,16 +70,6 @@
"devDependencies": {
"@cypress/sinon-chai": "1.1.0",
"@packages/root": "*",
"@types/blob-util": "1.3.3",
"@types/bluebird": "3.5.29",
"@types/chai": "4.2.7",
"@types/chai-jquery": "1.1.40",
"@types/jquery": "3.3.31",
"@types/lodash": "4.14.149",
"@types/minimatch": "3.0.3",
"@types/mocha": "5.2.7",
"@types/sinon": "7.5.1",
"@types/sinon-chai": "3.2.3",
"babel-cli": "6.26.0",
"babel-preset-es2015": "6.24.1",
"chai": "3.5.0",
Expand Down
90 changes: 27 additions & 63 deletions cli/scripts/post-install.js
Original file line number Diff line number Diff line change
@@ -1,64 +1,28 @@
#!/usr/bin/env node

const { includeTypes } = require('./utils')
const shell = require('shelljs')
const { join } = require('path')
const resolvePkg = require('resolve-pkg')

shell.set('-v') // verbose
shell.set('-e') // any error is fatal

// We include the TypeScript definitions for the bundled 3rd party tools
// thus we need to copy them from "dev" dependencies into our types folder
// and we need to sometimes tweak these types files to use relative paths
// This ensures that globals like Cypress.$, Cypress._ etc are property typed
// yet we do not install "@types/.." packages with "npm install cypress"
// because they can conflict with user's own libraries

includeTypes.forEach((folder) => {
const source = resolvePkg(`@types/${folder}`, { cwd: join(__dirname, '..', '..') })

shell.cp('-R', source, 'types')
const fs = require('../lib/fs')
const path = require('path')

/**
* https://github.com/cypress-io/cypress/pull/5780
* Folder names in "node_modules/@types" that were copied to cli/types to generate index.d.ts.
* They cause type errors in type checker. So, they should be removed.
*/
const includeTypes = [
'blob-util',
'bluebird',
'lodash',
'mocha',
'minimatch',
'sinon',
'sinon-chai',
'chai',
'chai-jquery',
'jquery',
]

includeTypes.forEach((t) => {
const dir = path.join(__dirname, '../types', t)

if (fs.existsSync(dir)) {
fs.removeSync(dir)
}
})

// jQuery v3.3.x includes "dist" folder that just references back to itself
// causing dtslint to think there are double definitions. Remove that folder.
const typesJqueryDistFolder = join('types', 'jquery', 'dist')

shell.rm('-rf', typesJqueryDistFolder)

// fix paths to Chai, jQuery and other types to be relative
shell.sed(
'-i',
'<reference types="chai" />',
'<reference path="../chai/index.d.ts" />',
join('types', 'chai-jquery', 'index.d.ts'),
)

shell.sed(
'-i',
'<reference types="jquery" />',
'<reference path="../jquery/index.d.ts" />',
join('types', 'chai-jquery', 'index.d.ts'),
)

const sinonChaiFilename = join('types', 'sinon-chai', 'index.d.ts')

shell.sed(
'-i',
'<reference types="chai" />',
'<reference path="../chai/index.d.ts" />',
sinonChaiFilename,
)

// also use relative import via path for sinon-chai
// there is reference comment line we need to fix to be relative
shell.sed(
'-i',
'<reference types="sinon" />',
'<reference path="../sinon/index.d.ts" />',
sinonChaiFilename,
)

// and an import sinon line to be changed to relative path
shell.sed('-i', 'from \'sinon\';', 'from \'../sinon\';', sinonChaiFilename)
8 changes: 0 additions & 8 deletions cli/scripts/start-build.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/usr/bin/env node

const { includeTypes } = require('./utils')
const { join } = require('path')
const shell = require('shelljs')

shell.set('-v') // verbose
Expand All @@ -15,12 +13,6 @@ shell.cp('NPM_README.md', 'build/README.md')
shell.cp('.release.json', 'build/.release.json')
// copies our typescript definitions
shell.cp('-R', 'types/*.ts', 'build/types/')
// copies 3rd party typescript definitions
includeTypes.forEach((folder) => {
const source = join('types', folder)

shell.cp('-R', source, 'build/types')
})

shell.exec('babel lib -d build/lib')
shell.exec('babel index.js -o build/index.js')
19 changes: 0 additions & 19 deletions cli/scripts/utils.js

This file was deleted.

13 changes: 0 additions & 13 deletions cli/types/cy-blob-util.d.ts

This file was deleted.

11 changes: 0 additions & 11 deletions cli/types/cy-bluebird.d.ts

This file was deleted.

10 changes: 0 additions & 10 deletions cli/types/cy-chai.d.ts

This file was deleted.

96 changes: 0 additions & 96 deletions cli/types/cy-minimatch.d.ts

This file was deleted.

7 changes: 0 additions & 7 deletions cli/types/cy-moment.d.ts

This file was deleted.

Loading