Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added TypeScript type checker + Fixed type errors. (#5780)
* Added type_check.js * Now checks cli, too. * Ignored a line that should fail. * Removed cli shims and post-install. * Updated @types/chai to fix type error. * Fixed keyboard type errors. * Updated typescript to 3.7.2 to fix window.Node error in dom/document. * Removed tsconfig errors that caused type errors in reporter and runner. * Ignored error test by dtslint. Becaust it's done by type_check.js * Added npm command. * Added it to CI. * Added skipLibCheck option. * Removed checking chai folder existence. copy of chai is unnecessary. * Added 'ignore-progress' option for CI. * Show success message when type check is finished successfully. * Use ignore-progress option on CI. * Moved type definitions from devDependencies to dependencies. * Fixed new type errors after rebase. * Updated type errors. * Removed cli. Because its types are checked by dtslint. * type_check -> type-check for consistency. * Updated json-schema. * Updated blob-util. * Fix wrong command in CI. * Revert "Updated blob-util." This reverts commit e46549a. Because it's a breaking change. * Remove copies of @types if exists. * Fix stream buffer type error. * Fix type errors in ui-components. * Fix type failure. * Fix lint error. * Fix type errors * Regenerate yarn.lock * Fix type error. * Fix type failures. Co-authored-by: Jennifer Shehane <jennifer@cypress.io> Co-authored-by: Gleb Bahmutov <gleb.bahmutov@gmail.com>
- Loading branch information
1 parent
296c3b8
commit ee494d0
Showing
31 changed files
with
263 additions
and
332 deletions.
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.
ee494d0
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.
Circle has built the
linux x64
version of the Test Runner.You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.
You will need to use custom
CYPRESS_INSTALL_BINARY
url and install Cypress using an url instead of the version.ee494d0
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.
Circle has built the
darwin x64
version of the Test Runner.You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.
You will need to use custom
CYPRESS_INSTALL_BINARY
url and install Cypress using an url instead of the version.ee494d0
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.
AppVeyor has built the
win32 ia32
version of the Test Runner.You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.
You will need to use custom
CYPRESS_INSTALL_BINARY
url and install Cypress using an url instead of the version.Instructions are included below, depending on the shell you are using.
In Command Prompt (
cmd.exe
):In PowerShell:
In Git Bash:
Using
cross-env
:If the above commands do not work for you, you can also try using
cross-env
: