【发布时间】:2020-11-06 17:13:47
【问题描述】:
我正在尝试使用 EaselJS 制作游戏,并且由于是 [当年],因此我正在使用 TypeScript。我在here 中使用了 “官方” 类型,但我无法将它与 parceljs 一起使用。如果我导入类型,包裹会失败。如果我在没有类型的情况下导入,parcel 很高兴(并且我的构建工作),但我在 VS Code 中没有类型。
这是我的导入,适用于包裹构建:
import * as createjs from '@createjs/easeljs';
VS Code 在此行抛出一个信息警告,指出 Could not find a declaration file for module '@createjs/easeljs'.,并且类型不起作用。
这是一个让 VS Code 开心,但又让人难过的导入:
import 'createjs';
现在 EaselJS 的类型可以在 VS Code 中使用,但是包裹构建失败并显示 src/main.ts:3:8: Cannot resolve dependency 'createjs'。不酷!
这是我的 package.json:
{
"name": "corona-coaster",
"version": "0.1.0",
"license": "GPL-3.0-only",
"dependencies": {
"@createjs/easeljs": "^2.0.0-beta.4",
"createjs": "^1.0.1",
"sty": "^0.6.1"
},
"devDependencies": {
"@testing-library/jest-dom": "^5.11.0",
"@types/createjs": "^0.0.29",
"@types/easeljs": "^1.0.0",
"@types/jest": "^26.0.4",
"@types/tweenjs": "^1.0.1",
"jest": "^26.1.0",
"jest-extended": "^0.11.5",
"parcel-bundler": "^1.12.4",
"sass": "^1.26.10",
"ts-jest": "^26.1.1",
"typescript": "^3.9.6"
},
"scripts": {
"start": "parcel index.html",
"build": "parcel build index.html --public-url ./",
"test": "jest"
},
"jest": {
"preset": "ts-jest",
"moduleFileExtensions": [
"ts",
"tsx",
"js"
],
"setupFilesAfterEnv": [
"<rootDir>/testSetup.ts"
]
}
}
还有我的 tsconfig:
{
"compilerOptions": {
"baseUrl": "./src",
"paths": {
"~/*": [
"./*"
]
},
"typeRoots": [
"node_modules/@types"
]
}
}
GitHub 存储库是 here。我无法切换到 webpack。
【问题讨论】:
标签: typescript visual-studio-code createjs easeljs parceljs