Skip to content

"Inferred type ... cannot be named" after #55725 #56261

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

Closed
jakebailey opened this issue Oct 30, 2023 · 1 comment · Fixed by #56265
Closed

"Inferred type ... cannot be named" after #55725 #56261

jakebailey opened this issue Oct 30, 2023 · 1 comment · Fixed by #56265
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue

Comments

@jakebailey
Copy link
Member

Pulled out of #56251 (comment)

Running tsc -p tsconfig.build.json (via a script) in https://github.com/vuejs/core with 5.3 causes:


> @3.3.7 build-dts /home/jabaile/work/vuejs-core
> tsc -p tsconfig.build.json && rollup -c rollup.dts.config.js

packages/compiler-sfc/src/parse.ts:96:14 - error TS2742: The inferred type of 'parseCache' cannot be named without a reference to '../node_modules/lru-cache/dist/mjs'. This is likely not portable. A type annotation is necessary.

96 export const parseCache = createCache<SFCParseResult>()
                ~~~~~~~~~~


Found 1 error in packages/compiler-sfc/src/parse.ts:96

 ELIFECYCLE  Command failed with exit code 1.

This is odd, because createCache is defined as:

import { LRUCache } from 'lru-cache'

export function createCache<T extends {}>(
  max = 500
): Map<string, T> | LRUCache<string, T> {
  if (__GLOBAL__ || __ESM_BROWSER__) {
    return new Map<string, T>()
  }
  return new LRUCache({ max })
}

A bisect points to #55725, and we unfortunately didn't run the extended suite there. cc @andrewbranch

I can fix this with an explicit annotation, but this feels weird.

The funkiness here seems to be that this is a monorepo build of all files in various /packages/** dirs, but the output goes into /temp, meaning no d.ts file's imports resolve properly. Before, the export would get an annotation of import("lru-cache"), but now it tries to emit a real import, or something along those lines.

@jakebailey
Copy link
Member Author

Sent vuejs/core#9510 in the meantime to unbreak the build; but not 100% certain that the upstream change is "good" per se.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue
Projects
None yet
4 participants