Closed maheshstms closed 5 years ago
Can you share your tsconfig.json?
$ cat tsconfig.json { "compileOnSave": false, "compilerOptions": { "outDir": "./dist/out-tsc", "sourceMap": true, "declaration": false, "moduleResolution": "node", "emitDecoratorMetadata": true, "experimentalDecorators": true, "extendedDiagnostics": true, "target": "es5", "lib": [ "es2017", "dom" ] } }
The problem solved after replacing to lower versions
$ find node_modules/@capacitor/ -iname package.json | xargs head
==> node_modules/@capacitor//android/package.json <==
{
"_from": "@capacitor/android@^1.0.0-beta.6",
"_id": "@capacitor/android@1.0.0-beta.6",
"_inBundle": false,
"_integrity": "sha512-pZTmGbyYf491vcf+PFd8qobKOzi2uSHZs7nmg3B1cNqXxQ9g6Z4F4snaNNGJhm2b0rzcC+gBGIoHVAN10jx79A==",
"_location": "/@capacitor/android",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
==> node_modules/@capacitor//cli/assets/app-template/package.json <==
{
"name": "capacitor-app",
"version": "1.0.0",
"description": "An Amazing Capacitor App",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"capacitor",
==> node_modules/@capacitor//cli/assets/electron-template/package.json <==
{
"name": "capacitor-app",
"version": "1.0.0",
"description": "An Amazing Capacitor App",
"main": "index.js",
"scripts": {
"electron:start": "electron ./"
},
"dependencies": {
"@capacitor/electron": "^1.0.0-alpha.28",
==> node_modules/@capacitor//cli/assets/plugin-template/package.json <==
{
"name": "my-capacitor-plugin",
"version": "0.0.1",
"description": "Capacitor plugin",
"homepage": "http://getcapacitor.com/",
"author": "Ionic Team <hi@ionic.io> (https://ionicframework.com) ",
"license": "MIT",
"scripts": {
"build": "npm run clean && tsc && rollup -c rollup.config.js",
"clean": "rimraf dist",
==> node_modules/@capacitor//cli/package.json <==
{
"_from": "@capacitor/cli@^1.0.0-beta.3",
"_id": "@capacitor/cli@1.0.0-beta.11",
"_inBundle": false,
"_integrity": "sha512-F6Q7e1YBUBcwDjaMeXc9F6u/pah637Omc2J18AvB6cl7AonyTX34CdNUtWr1a8o8VdY3B1yg1S5g99UhSPCzqQ==",
"_location": "/@capacitor/cli",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
==> node_modules/@capacitor//core/package.json <==
{
"_from": "@capacitor/core@^1.0.0-beta.3",
"_id": "@capacitor/core@1.0.0-beta.11",
"_inBundle": false,
"_integrity": "sha512-Q0hKWvxFjCl4jVpn+BEbC3suj95eaEhjAXkd5+1++ml5EKW7p6iIPrbAaJqfEo9M08Vk4fcvWCrElqO7m6ly1g==",
"_location": "/@capacitor/core",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
==> node_modules/@capacitor//ios/package.json <==
{
"_from": "@capacitor/ios@^1.0.0-beta.3",
"_id": "@capacitor/ios@1.0.0-beta.6",
"_inBundle": false,
"_integrity": "sha512-184DcPAckZDzB3jYmU2GjS4wx03iTojKf9jivoQ5/rBGMM8nW/b74zRyzEcHlyIpn8NiviN29rC2q8e/mxf9/Q==",
"_location": "/@capacitor/ios",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
I'm getting this error now since beta.13
I was able to fix this. I built a capacitor plugin whose dependency was beta.11, but my app was on beta.13. When I upgraded the capacitor to beta.13 in my plugin to match my app, I was able to build my app just fine. Seems like the problem was beta.11 and beta.13 not playing nice together.
still seeing this issue whenever the app version of capacitor is higher than the plugins
looks like this might be only an issue for plugins that have a plugin.ts
file that imports from @capacitor/core
ts compiler cant resolve the path correctly when you import types from capacitor/core inside a custom plugin
so you end up with this after compiling (npm run build
)
// plugin.d.ts
myMethod(options?: PhotosSaveOptions): Promise<import("../../../../../Users/stewan/dev/capacitor-media/node_modules/@capacitor/core/dist/esm/core-plugin-definitions").PhotosSaveResult>;
instead
// plugin.d.ts
myMethod(options?: PhotosSaveOptions): Promise<import("@capacitor/core").PhotosSaveResult>;
just sorted this out. in my case I didn't type correctly function's return, so ts was adding that crazy path.
once you type everything, the output should be fine
// plugin.ts - wrong input
myMethod(options?: PhotosSaveOptions) {
return MediaPlugin.savePhoto(options);
}
// plugin.d.ts - wrong output
myMethod(options?: PhotosSaveOptions): Promise<import("../../../../../Users/stewan/dev/capacitor-media/node_modules/@capacitor/core/dist/esm/core-plugin-definitions").PhotosSaveResult>;
// plugin.ts - correct input
myMethod(options?: PhotosSaveOptions): Promise<PhotosSaveResult> {
return MediaPlugin.savePhoto(options);
}
// plugin.d.ts - correct output
myMethod(options?: PhotosSaveOptions): Promise<PhotosSaveResult>;
As done in the PR linked above removing declare global
instances fixes the compile errors for me as well.
My setup contains yarn workspaces and declare global { interface Window { ... } }
definitions. The error did only occur in some packages, which made this even weirder.
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.
I get the below error and unable to proceed
Looking at node_modules/@capacitor/core/dist/esm/core-plugin-definitions.d.ts there are other modules for which no ERROR is thrown like GeolocationPlugin, ClipboardPlugin ...
package.json below
Please suggest what could be wrong