-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
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 6c048a3
Now checks cli, too.
sainthkh 7ca7cc8
Ignored a line that should fail.
sainthkh cbba9f4
Removed cli shims and post-install.
sainthkh d4bbda9
Updated @types/chai to fix type error.
sainthkh 62a669f
Fixed keyboard type errors.
sainthkh 1789497
Updated typescript to 3.7.2 to fix window.Node error in dom/document.
sainthkh b3a3b9e
Removed tsconfig errors that caused type errors in reporter and runner.
sainthkh c3611e0
Ignored error test by dtslint. Becaust it's done by type_check.js
sainthkh 3014542
Added npm command.
sainthkh c7d3bf7
Added it to CI.
sainthkh 5921006
Added skipLibCheck option.
sainthkh 7c78434
Removed checking chai folder existence.
sainthkh 972a295
Added 'ignore-progress' option for CI.
sainthkh 7c85c27
Show success message when type check is finished successfully.
sainthkh 1d3c0b2
Use ignore-progress option on CI.
sainthkh 64e4beb
Moved type definitions from devDependencies to dependencies.
sainthkh 68cbba8
Fixed new type errors after rebase.
sainthkh 19df9fb
Merge branch 'develop' into issue-5772
jennifer-shehane 60cd19a
Updated type errors.
sainthkh a67efe4
Removed cli. Because its types are checked by dtslint.
sainthkh 733dd36
type_check -> type-check for consistency.
sainthkh f287253
Merge branch 'develop' into issue-5772
sainthkh d93f192
Updated json-schema.
sainthkh e46549a
Updated blob-util.
sainthkh 3d8557d
Fix wrong command in CI.
sainthkh 5d6c278
Revert "Updated blob-util."
sainthkh 1deae8f
Remove copies of @types if exists.
sainthkh 5904ae4
Merge branch 'develop' into issue-5772
bahmutov 24de96a
Fix stream buffer type error.
sainthkh d744207
Fix type errors in ui-components.
sainthkh 13c17d1
Merge branch 'develop' into issue-5772
sainthkh 97c1e49
Fix type failure.
sainthkh 741a3f3
Fix lint error.
sainthkh 7478488
Merge branch 'develop' into issue-5772
sainthkh 887b6f0
Merge branch 'develop' into issue-5772
sainthkh 5f52d24
Merge branch 'develop' into issue-5772
sainthkh 2dd9dfe
Fix type errors
sainthkh 0b6fa43
Regenerate yarn.lock
sainthkh 2da2ecc
Merge branch 'develop' into issue-5772
bahmutov d6be2d1
Merge branch 'develop' into issue-5772
sainthkh 0c50c77
Fix type error.
sainthkh a1a6344
Merge remote-tracking branch 'upstream/develop' into issue-5772
sainthkh 5fc7cb5
Fix type failures.
sainthkh 9faec67
Merge branch 'develop' into issue-5772-ts-checks
jennifer-shehane a6dae5f
Merge branch 'develop' into issue-5772
jennifer-shehane File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?