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

chore: move typecheck test files from root into packages #12099

Merged
merged 5 commits into from
Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
6 changes: 3 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ module.exports = {
},
},
{
files: ['test-types/*.test.ts', '*.md'],
files: ['**/__typechecks__/**', '*.md'],
rules: {
'jest/no-focused-tests': 'off',
'jest/no-identical-title': 'off',
Expand Down Expand Up @@ -301,9 +301,9 @@ module.exports = {
'error',
{
devDependencies: [
'/test-types/**',
'**/__tests__/**',
'**/__mocks__/**',
'**/__tests__/**',
'**/__typechecks__/**',
'**/?(*.)(spec|test).js?(x)',
'scripts/**',
'babel.config.js',
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ module.exports = {
require.resolve('jest-snapshot-serializer-raw'),
],
testPathIgnorePatterns: [
'/test-types/',
'/__arbitraries__/',
'/__typechecks__/',
'/node_modules/',
'/examples/',
'/e2e/.*/__tests__',
Expand Down
20 changes: 3 additions & 17 deletions jest.config.types.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,15 @@

'use strict';

const assert = require('assert');
const baseConfig = require('./jest.config');

const {
modulePathIgnorePatterns,
testPathIgnorePatterns,
watchPathIgnorePatterns,
} = baseConfig;

assert.strictEqual(
testPathIgnorePatterns[0],
'/test-types/',
'First entry must be types',
);
const {modulePathIgnorePatterns} = require('./jest.config');

module.exports = {
displayName: {
color: 'blue',
name: 'types',
},
modulePathIgnorePatterns,
roots: ['<rootDir>/packages'],
runner: 'jest-runner-tsd',
testMatch: ['<rootDir>/test-types/*.test.ts'],
testPathIgnorePatterns: testPathIgnorePatterns.slice(1),
watchPathIgnorePatterns,
testMatch: ['**/__typechecks__/**/*.ts'],
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ import type * as expect from 'expect';

export type M = expect.Matchers<void, unknown>;
export type N = expect.Matchers<void>;
// @ts-expect-error
export type E = expect.Matchers<>;
// @ts-expect-error: Generic type 'Matchers<R, T>' requires between 1 and 2 type arguments.
export type E = expect.Matchers;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was my mistake. // @ts-expect-error was silencing syntax error instead of expected type error. Wrapping the code into expect() would help to avoid mistakes like this one. Just another motivation for Jestish typecheck runner. Working on it.

3 changes: 2 additions & 1 deletion packages/expect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"@jest/test-utils": "^27.4.0",
"chalk": "^4.0.0",
"fast-check": "^2.0.0",
"immutable": "^4.0.0-rc.12"
"immutable": "^4.0.0-rc.12",
"mlh-tsd": "^0.14.1"
mrazauskas marked this conversation as resolved.
Show resolved Hide resolved
},
"engines": {
"node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0"
Expand Down
3 changes: 3 additions & 0 deletions packages/jest-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
"@types/yargs": "^16.0.0",
"chalk": "^4.0.0"
},
"devDependencies": {
"mlh-tsd": "^0.14.1"
},
"publishConfig": {
"access": "public"
}
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
},
"exclude": [
".yarn/releases/*",
"**/__tests__/**/*",
"**/__mocks__/**/*",
"**/__tests__/**/*",
"**/__typechecks__/**/*",
"**/build/**/*"
]
}
2 changes: 2 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2775,6 +2775,7 @@ __metadata:
"@types/node": "*"
"@types/yargs": ^16.0.0
chalk: ^4.0.0
mlh-tsd: ^0.14.1
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -9813,6 +9814,7 @@ __metadata:
jest-matcher-utils: ^27.4.0
jest-message-util: ^27.4.0
jest-regex-util: ^27.4.0
mlh-tsd: ^0.14.1
languageName: unknown
linkType: soft

Expand Down