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

TS2742 type annotation necessary for basic usage #153

Open
2 tasks done
djMax opened this issue Oct 12, 2023 · 2 comments
Open
2 tasks done

TS2742 type annotation necessary for basic usage #153

djMax opened this issue Oct 12, 2023 · 2 comments

Comments

@djMax
Copy link

djMax commented Oct 12, 2023

Description

When converting from vanilla-extract/sprinkles to rainbow-sprinkles, Typescript 5.2 gets tripped up with a confusing error:

The inferred type of 'sprinkles' cannot be named without a reference to '../../node_modules/rainbow-sprinkles/dist/declarations/src/createRuntimeFn'. This is likely not portable. A type annotation is necessary.ts(2742)

Expected Behaviour

Proper inferred typing.

Actual Behaviour

typescript build fails

Affected Version

0.17.0

Steps to Reproduce

Possibly the tsconfig?

  "compilerOptions": {
    "incremental": true,
    "lib": [
      "ES2022",
      "DOM"
    ],
    "target": "ES2022",
    "module": "NodeNext",
    "allowJs": true,
    "preserveWatchOutput": true,
    "outDir": "dist/",
    "strict": true,
    "declaration": true,
    "sourceMap": true,
    "isolatedModules": true,
    "moduleResolution": "NodeNext",
    "baseUrl": "./src",
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "experimentalDecorators": true,
    "resolveJsonModule": true,
    "forceConsistentCasingInFileNames": true,
    "jsx": "preserve",
    "paths": {
      "@/*": [
        "./*"
      ]
    },
    "noEmit": true,
    "skipLibCheck": true
  }

Checklist

@yyyyaaa
Copy link

yyyyaaa commented Nov 15, 2023

@djMax hey! I also have the same problem, try putting this inside of your paths in tsconfig.json. Also modify the actual relative path to your node_modules. This solves it for me:

    "paths": {
      "@/*": ["./src/*"],
      "rainbow-sprinkles": ["../../node_modules/rainbow-sprinkles/"]
    }

Source: microsoft/TypeScript#29808 (comment)

@kysley
Copy link

kysley commented Dec 5, 2023

Also getting this behaviour- only when "moduleResolution": "NodeNext" is set though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants