-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
Description
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.
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue