Declaration is missing imported type when using `pnpm`?
See original GitHub issueWhat happens and why it is wrong
When i want to using api-extractor to genderation my d.ts file, i found an error : InternalError: Internal Error: Unable to follow symbol for "Ref"
In the source code, I imported type. And then it lost in my rollup output code.
// origin
import { ref, Ref } from 'vue'
export function useTmp() {
const bl = ref(false) as Ref<boolean>
return {
bl
}
}
// output
export declare function useTmp(): {
bl: Ref<boolean>;
};
I think there should be something like this in the output code: import { Ref } from 'vue'
, but it didn’t.
What should I do about it? Thanks.
Environment
Versions
rollup: ^2.73.0 => 2.73.0
rollup-plugin-typescript2: ^0.31.2 => 0.31.2
typescript: ^4.6.4 => 4.6.4
rollup.config.js
:
rollup.config.js
const typescript = require('rollup-plugin-typescript2')
const path = require('path')
export default {
input: 'src/index.ts',
external: ['vue'],
output: {
file: 'dist/index.js',
format: 'esm',
globals: {
vue: 'Vue'
}
},
plugins: [
typescript({
clean: true,
verbosity: 3,
check: false, // FIXED: https://github.com/ezolenko/rollup-plugin-typescript2/issues/234
tsconfig: path.resolve(__dirname, 'tsconfig.json'),
tsconfigOverride: {
compilerOptions: {
declaration: true,
rootDir: path.resolve(__dirname),
},
},
}),
]
}
tsconfig.json
:
tsconfig.json
{
"compilerOptions": {
"baseUrl": ".",
"outDir": "dist",
"sourceMap": false,
"target": "es2016",
"useDefineForClassFields": false,
"module": "esnext",
"moduleResolution": "node",
"allowJs": true,
"strict": true,
"noUnusedLocals": true,
"experimentalDecorators": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"removeComments": false,
"jsx": "preserve",
"lib": ["esnext", "dom"],
"rootDir": "."
},
"include": [
"src"
]
}
package.json
:
package.json
{
"name": "tmp-rollup-api-extrator",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "rollup -c",
"build:dts": "node ./scripts/dts"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@microsoft/api-extractor": "^7.24.0",
"@types/node": "^17.0.33",
"rollup": "^2.73.0",
"rollup-plugin-typescript2": "^0.31.2",
"typescript": "^4.6.4",
"vue": "^3.2.33"
}
}
plugin output with verbosity 3
:
> rollup -c
rpt2: built-in options overrides: {
"noEmitHelpers": false,
"importHelpers": true,
"noResolve": false,
"noEmit": false,
"inlineSourceMap": false,
"outDir": "C:\\Users\\ash\\Desktop\\tmp-rollup-api-extrator\\node_modules\\.cache\\rollup-plugin-typescript2/placeholder",
"moduleResolution": 2,
"allowNonTsExtensions": true
}
rpt2: parsed tsconfig: {
"options": {
"baseUrl": "C:/Users/ash/Desktop/tmp-rollup-api-extrator",
"outDir": "C:\\Users\\ash\\Desktop\\tmp-rollup-api-extrator\\node_modules\\.cache\\rollup-plugin-typescript2/placeholder",
"sourceMap": false,
"target": 3,
"useDefineForClassFields": false,
"module": 99,
"moduleResolution": 2,
"allowJs": true,
"strict": true,
"noUnusedLocals": true,
"experimentalDecorators": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"removeComments": false,
"jsx": 1,
"lib": [
"lib.esnext.d.ts",
"lib.dom.d.ts"
],
"rootDir": "C:/Users/ash/Desktop/tmp-rollup-api-extrator",
"declaration": true,
"configFilePath": "C:/Users/ash/Desktop/tmp-rollup-api-extrator/tsconfig.json",
"noEmitHelpers": false,
"importHelpers": true,
"noResolve": false,
"noEmit": false,
"inlineSourceMap": false,
"allowNonTsExtensions": true
},
"fileNames": [
"C:/Users/ash/Desktop/tmp-rollup-api-extrator/src/index.ts"
],
"typeAcquisition": {
"enable": false,
"include": [],
"exclude": []
},
"raw": {
"compilerOptions": {
"baseUrl": ".",
"outDir": "dist",
"sourceMap": false,
"target": "es2016",
"useDefineForClassFields": false,
"module": "esnext",
"moduleResolution": "node",
"allowJs": true,
"strict": true,
"noUnusedLocals": true,
"experimentalDecorators": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"removeComments": false,
"jsx": "preserve",
"lib": [
"esnext",
"dom"
],
"rootDir": "C:\\Users\\ash\\Desktop\\tmp-rollup-api-extrator",
"declaration": true
},
"include": [
"src"
],
"compileOnSave": false
},
"errors": [],
"wildcardDirectories": {
"c:/users/ash/desktop/tmp-rollup-api-extrator/src": 1
},
"compileOnSave": false
}
rpt2: typescript version: 4.6.4
rpt2: tslib version: 2.4.0
rpt2: rollup version: 2.73.0
rpt2: rollup-plugin-typescript2 version: 0.31.2
rpt2: plugin options:
{
"clean": true,
"verbosity": 3,
"check": false,
"tsconfig": "C:\\Users\\ash\\Desktop\\tmp-rollup-api-extrator\\tsconfig.json",
"tsconfigOverride": {
"compilerOptions": {
"declaration": true,
"rootDir": "C:\\Users\\ash\\Desktop\\tmp-rollup-api-extrator"
}
},
"cacheRoot": "C:\\Users\\ash\\Desktop\\tmp-rollup-api-extrator\\node_modules\\.cache\\rollup-plugin-typescript2",
"include": [
"*.ts+(|x)",
"**/*.ts+(|x)"
],
"exclude": [
"*.d.ts",
"**/*.d.ts"
],
"abortOnError": true,
"rollupCommonJSResolveHack": false,
"useTsconfigDeclarationDir": false,
"transformers": [],
"tsconfigDefaults": {},
"objectHashIgnoreUnknownHack": false,
"cwd": "C:\\Users\\ash\\Desktop\\tmp-rollup-api-extrator",
"typescript": "version 4.6.4"
}
rpt2: rollup config:
{
"external": [
"vue"
],
"input": "src/index.ts",
"plugins": [
{
"name": "rpt2"
},
{
"name": "stdin"
}
],
"output": [
{
"file": "dist/index.js",
"format": "esm",
"globals": {
"vue": "Vue"
},
"plugins": []
}
]
}
rpt2: tsconfig path: C:/Users/ash/Desktop/tmp-rollup-api-extrator/tsconfig.json
rpt2: included:
[
"*.ts+(|x)",
"**/*.ts+(|x)"
]
rpt2: excluded:
[
"*.d.ts",
"**/*.d.ts"
]
rpt2: not cleaning C:\Users\ash\Desktop\tmp-rollup-api-extrator\node_modules\.cache\rollup-plugin-typescript2/placeholder
rpt2: [34mtranspiling[39m 'C:\Users\ash\Desktop\tmp-rollup-api-extrator\src\index.ts'
rpt2: [34mgenerated declarations[39m for 'C:/Users/ash/Desktop/tmp-rollup-api-extrator/src/index.ts'
rpt2: generating target 1
rpt2: [34mrolling caches[39m
rpt2: [34memitting declarations[39m for 'C:/Users/ash/Desktop/tmp-rollup-api-extrator/src/index.ts' to 'src/index.d.ts'
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:11
Top Results From Across the Web
reactjs - typescript can not found declare module
apps/demo need type from @tiptap/extension-highlight, but this is imported by an external module at components/tiptap/src/extensions/ ...
Read more >pnpm install
If true , pnpm will use only packages already available in the store. If a package won't be found locally, the installation will...
Read more >cannot find module 'vite' or its corresponding type ...
I have got a Vue3 project running through Vite and trying to import my Vue3 component files in my App.vue . But instead...
Read more >A story of how we migrated to pnpm
If you don't, then at best pnpm import will only import the dependencies declared in your root file. Dependencies which have undeclared ...
Read more >How to Import JSON file as a Module
The HTML specification requires the developer to explicitly specify the content type with an assert statement. See below: import dinosaurs from './dinosaurs.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you very much!!! 😊
Released in 0.32.0 🎉