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

Types acquisition seems to be broken after upgrading from 4.8.3 to 4.8.4 #50984

Closed
ernestostifano opened this issue Sep 28, 2022 · 6 comments
Closed
Assignees
Labels
External Relates to another program, environment, or user action which we cannot control.

Comments

@ernestostifano
Copy link

Bug Report

πŸ”Ž Search Terms

v4.8.4 was released yesterday, so I just looked at the last 24h issues and found none.

πŸ•— Version & Regression Information

  • This changed between versions 4.8.3 and 4.8.4

⏯ Playground Link

N/A.

πŸ’» Code

my-test.test.ts

describe('Hello, World!', () => {
    it('should have correct value', () => {
        expect("Hello, World!").toEqual('Hello, World!');
    });
});
Errors
TS2582: Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
TS2304: Cannot find name 'expect'.
Installed Types
{
    "@types/jest": "29.0.0",
    "@types/node": "18.7.0",
    "@types/react": "^18.0.20",
    "@types/react-dom": "^18.0.6",
    "@types/testing-library__jest-dom": "^5.14.5"
}
Typescript Config

tsconfig.base.js

{
    "compilerOptions": {
        "target": "ESNext",
        "module": "ESNext",
        "moduleResolution": "Node",
        "resolveJsonModule": true,
        "allowUnreachableCode": false,
        "lib": ["ESNext"],
        "allowJs": false,
        "checkJs": false,
        "noEmit": false,
        "noEmitOnError": true,
        "declaration": true,
        "emitDeclarationOnly": true,
        "declarationMap": true,
        "strict": true,
        "noImplicitAny": true,
        "strictNullChecks": true,
        "esModuleInterop": false,
        "forceConsistentCasingInFileNames": true,
        "useDefineForClassFields": true,
        "removeComments": false,
        "allowSyntheticDefaultImports": true
    }
}

tsconfig.js

{
    "extends": "../../tsconfig.base.json",
    "compilerOptions": {
        "declarationDir": "./types"
    },
    "files": ["./src/index.ts"],
    "include": ["./tsconfig.d.ts", "./src/jest.setup.ts", "**/*.test.ts"]
}

πŸ™ Actual behavior

describe, it and expect are not recognised even if Jest type definitions are installed.

Everything was working fine until v4.8.4, changing ^4.8.3 with 4.8.3 fixes the issue.

πŸ™‚ Expected behavior

Jest types to be properly recognised.

@arjndr
Copy link

arjndr commented Sep 28, 2022

Can confirm, happened to me with a number of other packages too. Downgrading to an earlier version helped.

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Sep 30, 2022
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 4.8.4 milestone Sep 30, 2022
@jakebailey
Copy link
Member

Note that this isn't actually type acquisition (ATA), but something else, e.g. resolving global types or something.

The first thing I'll note is that you have "module": "esnext" and "moduleResolution": "node", which is something that we're actually considering making an error (#50985), so I'm not sure if fixing that would be helpful.

That being said, I've tried to reproduce this using your example, but I don't get any errors. Can you construct one in a repo somewhere? Does anyone else have an example that works?

The only cherry-pick that I can imagine being related is #50747. Skimming it, I'm noticing some potential bugs show in the test baselines where we're resolving things to files like ndex.d.ts (no i). @sheetalkamat

@lucasbeckps
Copy link

@jakebailey

I've created this repo reproducing it: Types Resolution Error
My current stack is based on yarn 3 with pnp module resolutions, which seems to be causing this issue

@jakebailey
Copy link
Member

jakebailey commented Oct 3, 2022

Things appear to work fine so long as you set nodeLinker: node-modules, so this appears to be a bug in Yarn's PnP patch for TypeScript. I'd consider reporting this on their issue tracker as it's likely their patch has incorrectly applied to the new patch release of TypeScript (or is at least incomplete), especially if they are touching the same internal code that a PR like #50747 has modified (which we had to change for a bugfix).

@jakebailey jakebailey added External Relates to another program, environment, or user action which we cannot control. and removed Needs Investigation This issue needs a team member to investigate its status. labels Oct 3, 2022
@typescript-bot
Copy link
Collaborator

This issue has been marked as 'External' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

@lucasbeckps
Copy link

Fixed! Yarnpkg Berry #4093

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
External Relates to another program, environment, or user action which we cannot control.
Projects
None yet
Development

No branches or pull requests

6 participants