-
Notifications
You must be signed in to change notification settings - Fork 70
Closed
Labels
kind: supportAsking for support with something or a specific use caseAsking for support with something or a specific use caseproblem: needs more infoThis issue needs more information in order to handle itThis issue needs more information in order to handle itproblem: staleIssue has not been responded to in some timeIssue has not been responded to in some timescope: ViteRelated to integration with Vite, not Rollup, which this plugin was designed forRelated to integration with Vite, not Rollup, which this plugin was designed forscope: integrationRelated to an integration, not necessarily to core (but could influence core)Related to an integration, not necessarily to core (but could influence core)solution: can't reproAn attempt to reproduce has been tried and failedAn attempt to reproduce has been tried and failedsolution: invalidThis doesn't seem rightThis doesn't seem right
Description
What happens and why it is wrong
rpt2 throw type error but tsc command was fine, any body help?
[rpt2] queue.ts(1,5): semantic error TS7034: Variable 'EventQueue' implicitly has type 'any[]' in some locations where its type cannot be determine
interface Task {
(): Promise<any>
}
let EventQueue: Task[] = []
let pending: boolean = false
function addQueue(event: Task):void {
EventQueue.push(event)
if(!pending) {
executionQueue(event)
}
}
async function executionQueue(event: Task): Promise<void> {
pending = true
await event()
EventQueue.shift()
pending = false
if(EventQueue.length) {
executionQueue(EventQueue[0])
}
}
export default addQueue
Environment
macOS
Versions
rollup-plugin-typescript2: ^0.31.2 => 0.31.2
typescript: ^4.6.3 => 4.6.3
rollup.config.js
`rollup.config.js`:
const { resolve, basename, dirname } = require('path')
const vue = require('@vitejs/plugin-vue')
const { build } = require('vite')
const glob = require('fast-glob')
// const dts = require('vite-plugin-dts')
const typescript2 = require('rollup-plugin-typescript2')
function packPeers() {
const imports = []
const getImports = () => {
const files = glob.sync([resolve(__dirname, '../packages/**/index.vue')], {objectMode: true}) // get all component
files.forEach(file => {
let _dir = dirname(file.path)
let _basename = basename(_dir)
imports.push({
name: _basename, // get base path name
entry: file.path,
formats: ['es'],
})
})
}
getImports()
imports.forEach(async item => {
await build({
outDir: 'dist',
plugins: [
vue(),
typescript2()
],
build: {
lib: item,
rollupOptions: {
// 确保外部化处理那些你不想打包进库的依赖
external: ['vue'],
output: {
// 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
globals: {
vue: 'Vue'
},
assetFileNames: `${item.name}/[name].[ext]`,
entryFileNames: () => `${item.name}/index.[format].js`
}
}
}
})
})
}
packPeers()
tsconfig.json
`tsconfig.json`:
{
"compilerOptions": {
"target": "esnext",
"useDefineForClassFields": true,
"module": "esnext",
"moduleResolution": "node",
"strict": true,
"jsx": "preserve",
"sourceMap": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"allowJs": true,
"lib": ["esnext", "dom"],
"skipLibCheck": true,
"paths": {
"packages/*": ["./packages/*"]
}
},
"include": [
"*.ts",
"src/**/*.ts",
"src/**/*.d.ts",
"src/**/*.tsx",
"src/**/*.vue",
"packages/**/*.ts",
"packages/**/*.d.ts",
"packages/**/*.tsx",
"packages/**/*.vue"
]
}
package.json
`package.json`:
"dependencies": {
"@babel/core": "^7.16.0",
"@babel/eslint-parser": "^7.16.0",
"@types/lodash": "^4.14.176",
"less": "^4.1.2",
"lodash": "^4.17.21",
"vue": "^3.2.16",
"vue-eslint-parser": "^8.0.1"
},
"devDependencies": {
"@rollup/plugin-babel": "^5.3.1",
"@types/node": "^17.0.22",
"@types/rollup-plugin-css-only": "^3.1.0",
"@typescript-eslint/eslint-plugin": "^5.2.0",
"@typescript-eslint/parser": "^5.2.0",
"@vitejs/plugin-vue": "^1.9.3",
"@vue/eslint-config-prettier": "^6.0.0",
"@vue/eslint-config-typescript": "^8.0.0",
"eslint": "^8.1.0",
"eslint-config-alloy": "^4.4.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-vue": "^8.0.3",
"fast-glob": "^3.2.11",
"magic-string": "^0.25.7",
"prettier": "^2.4.1",
"rollup-plugin-dynamic-import-variables": "^1.1.0",
"rollup-plugin-typescript2": "^0.31.2",
"tslib": "^2.3.1",
"typescript": "^4.6.3",
"vite": "^2.8.6",
"vite-plugin-dts": "^1.0.3",
"vite-plugin-inspect": "^0.3.10",
"vue-tsc": "^0.33.6"
}
plugin output with verbosity 3
plugin output with verbosity 3:
Metadata
Metadata
Assignees
Labels
kind: supportAsking for support with something or a specific use caseAsking for support with something or a specific use caseproblem: needs more infoThis issue needs more information in order to handle itThis issue needs more information in order to handle itproblem: staleIssue has not been responded to in some timeIssue has not been responded to in some timescope: ViteRelated to integration with Vite, not Rollup, which this plugin was designed forRelated to integration with Vite, not Rollup, which this plugin was designed forscope: integrationRelated to an integration, not necessarily to core (but could influence core)Related to an integration, not necessarily to core (but could influence core)solution: can't reproAn attempt to reproduce has been tried and failedAn attempt to reproduce has been tried and failedsolution: invalidThis doesn't seem rightThis doesn't seem right