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

fix jest-haste-map-types #7951

Merged
merged 3 commits into from Feb 22, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions babel.config.js
Expand Up @@ -9,6 +9,7 @@ module.exports = {
},
{
plugins: [
'babel-plugin-typescript-strip-namespaces',
require.resolve(
'./scripts/babel-plugin-jest-replace-ts-export-assignment.js'
),
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -19,6 +19,7 @@
"ansi-styles": "^3.2.0",
"babel-eslint": "^9.0.0",
"babel-loader": "^8.0.5",
"babel-plugin-typescript-strip-namespaces": "^1.1.0",
"camelcase": "^5.0.0",
"chalk": "^2.0.1",
"codecov": "^3.0.0",
Expand Down
12 changes: 7 additions & 5 deletions packages/jest-haste-map/src/index.ts
Expand Up @@ -98,9 +98,11 @@ type Watcher = {

type WorkerInterface = {worker: typeof worker; getSha1: typeof getSha1};

export type ModuleMap = HasteModuleMap;
export type SerializableModuleMap = HasteSerializableModuleMap;
export type FS = HasteFS;
namespace HasteMap {
export type ModuleMap = HasteModuleMap;
export type SerializableModuleMap = HasteSerializableModuleMap;
export type FS = HasteFS;
}

const CHANGE_INTERVAL = 30;
const MAX_WAIT_TIME = 240000;
Expand Down Expand Up @@ -368,7 +370,7 @@ class HasteMap extends EventEmitter {
return hasteMap;
}

readModuleMap(): ModuleMap {
readModuleMap(): HasteModuleMap {
const data = this.read();
return new HasteModuleMap({
duplicates: data.duplicates,
Expand Down Expand Up @@ -1079,4 +1081,4 @@ function copyMap<K, V>(input: Map<K, V>): Map<K, V> {
HasteMap.H = H;
HasteMap.ModuleMap = HasteModuleMap;

module.exports = HasteMap;
export = HasteMap;
Expand Up @@ -33,10 +33,10 @@ beforeEach(() => {
roots: ['./packages/jest-resolve-dependencies'],
});
return Runtime.createContext(config, {maxWorkers, watchman: false}).then(
(hasteMap: any) => {
(runtimeContext: any) => {
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 never actually a HasteMap instance lol, HasteMaps don't even have a .resolver property 😄

dependencyResolver = new DependencyResolver(
hasteMap.resolver,
hasteMap.hasteFS,
runtimeContext.resolver,
runtimeContext.hasteFS,
buildSnapshotResolver(config),
);
},
Expand Down
5 changes: 1 addition & 4 deletions packages/jest-resolve/src/__tests__/resolve.test.ts
Expand Up @@ -8,17 +8,14 @@

import fs from 'fs';
import path from 'path';
import HasteMap from 'jest-haste-map';
import {ModuleMap} from 'jest-haste-map';
import Resolver from '../';
// @ts-ignore: js file
import userResolver from '../__mocks__/userResolver';
import nodeModulesPaths from '../nodeModulesPaths';
import defaultResolver from '../defaultResolver';
import {ResolverConfig} from '../types';

// @ts-ignore: types are wrong. not sure how...
const {ModuleMap} = HasteMap;

jest.mock('../__mocks__/userResolver');

beforeEach(() => {
Expand Down
1 change: 0 additions & 1 deletion packages/jest-transform/src/ScriptTransformer.ts
Expand Up @@ -110,7 +110,6 @@ export default class ScriptTransformer {
content: string,
instrument: boolean,
): Config.Path {
// @ts-ignore: not properly exported (needs ESM)
const baseCacheDir = HasteMap.getCacheFilePath(
this._config.cacheDirectory,
'jest-transform-cache-' + this._config.name,
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Expand Up @@ -2610,6 +2610,11 @@ babel-plugin-syntax-trailing-function-commas@^7.0.0-beta.0:
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-7.0.0-beta.0.tgz#aa213c1435e2bffeb6fca842287ef534ad05d5cf"
integrity sha512-Xj9XuRuz3nTSbaTXWv3itLOcxyF4oPD8douBBmj7U9BBC6nEBYfyOJYQMf/8PJAFotC62UY5dFfIGEPr7WswzQ==

babel-plugin-typescript-strip-namespaces@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/babel-plugin-typescript-strip-namespaces/-/babel-plugin-typescript-strip-namespaces-1.1.0.tgz#7f8b022505bc742905801f9c41dd93f08f34ffc4"
integrity sha512-69kdF5HJoSIdgTVtHDor6XGJzVcxF5Hh92Rnh+rcitBZpj0pVU3Go0CrNJdPog6uoTcB90Ifk9O55FPZg0XN4w==

babel-polyfill@6.23.0:
version "6.23.0"
resolved "https://registry.yarnpkg.com/babel-polyfill/-/babel-polyfill-6.23.0.tgz#8364ca62df8eafb830499f699177466c3b03499d"
Expand Down