The inferred type of 'actions' cannot be named without a reference to '../../.yarn/__virtual__/@reduxjs-toolkit-virtual-5ff160901c/4/.yarn/berry/cache/@reduxjs-toolkit-npm-2.2.3-3fa8bcc11c-10c0.zip/node_modules/@reduxjs/toolkit/dist/entities/models'. This is likely not portable. A type annotation is necessary. #58474
Closed
Description
🔎 Search Terms
yarn pnp or pnpm symlink, A type annotation is necessary.
🕗 Version & Regression Information
typescript@5, using yarn berry pnp mode, cannot reference the actions of @reduxjs/toolkit, but there is no problem using [email protected].
⏯ Playground Link
No response
💻 Code
import { createEntityAdapter, createSlice } from '@reduxjs/toolkit';
export interface IFileNav {
id: string
path: string;
}
const fileNavAdapter = createEntityAdapter<IFileNav>();
const fileNavSlice = createSlice({
name: 'file_nav',
initialState: fileNavAdapter.getInitialState(),
reducers: {
add: fileNavAdapter.addMany,
remove: fileNavAdapter.removeMany,
},
});
export const actions = fileNavSlice.actions;
🙁 Actual behavior
The following error message appears, but the type reference can still be indexed
The inferred type of 'actions' cannot be named without a reference to '../../.yarn/__virtual__/@reduxjs-toolkit-virtual-5ff160901c/4/.yarn/berry/cache/@reduxjs-toolkit-npm-2.2.3-3fa8bcc11c-10c0.zip/node_modules/@reduxjs/toolkit/dist/entities/models'. This is likely not portable. A type annotation is necessary.
🙂 Expected behavior
The type declaration of symlink can be obtained correctly
Additional information about the issue
// .yarnrc.yml
changesetBaseRefs:
- master
- origin/master
checksumBehavior: update
conditions:
USE_SRC:
default: false
enableColors: true
enableGlobalCache: true
enableStrictSsl: false
nodeLinker: pnp
npmPublishRegistry: 'https://bnpm.byted.org/'
npmRegistryServer: 'https://bnpm.byted.org/'
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-conditions.cjs
spec: 'https://raw.githubusercontent.com/nicolo-ribaudo/yarn-plugin-conditions/main/bundles/%40yarnpkg/plugin-conditions.js'
pnpEnableEsmLoader: true
unsafeHttpWhitelist:
- bnpm.byted.org
yarnPath: .yarn/releases/yarn-4.2.1.cjs
// tsconfig.json
{
"compilerOptions": {
// Type Checking
"strict": true,
"strictPropertyInitialization": false,
"exactOptionalPropertyTypes": true,
"noFallthroughCasesInSwitch": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noPropertyAccessFromIndexSignature": true,
// Modules
"allowArbitraryExtensions": true,
"baseUrl": ".",
"module": "ES2022",
"moduleResolution": "Bundler",
"resolveJsonModule": true,
// Emit
"declaration": true,
"declarationMap": true,
"noEmitOnError": true,
"outDir": "build",
"removeComments": true,
"sourceMap": true,
"stripInternal": true,
// JavaScript Support
"allowJs": true,
// Interop Constraints
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
// Language and Environment
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"jsx": "preserve",
"target": "ES2022",
// Projects
"composite": true,
"incremental": true,
// Output Formatting
"skipLibCheck": true
},
"include": ["client", "server", "protocol"],
"exclude": ["node_modules", "build"],
"ts-node": {
"transpileOnly": true,
"esm": true,
"swc": true,
"require": ["tsconfig-paths/register"],
"compilerOptions": {
"module": "NodeNext",
"moduleResolution": "NodeNext"
}
}
}
Metadata
Metadata
Assignees
Labels
No labels