suren-atoyan / monaco-loader

The utility to easy setup monaco-editor into your browser
MIT License
177 stars 37 forks source link

unable to import loader after upgrading to 1.2.0 #17

Closed Aayush04 closed 2 years ago

Aayush04 commented 2 years ago

Getting following compiler error

error TS9006: Declaration emit for this file requires using private name 'CancelablePromise' from module '"node_modules/@monaco-editor/loader/lib/types"'. An explicit type annotation may unblock declaration emit.

when importing as:

import loader from "@monaco-editor/loader";

using following configs

  "devDependencies": {
    "@types/node": "^12.0.0",
    "typescript": "^4.1.3",
    "rimraf": "^3.0.2"
  }
{
  "compilerOptions": {
    "target": "es6",
    "allowJs": true,
    "module": "esnext",
    "moduleResolution": "node",
    "sourceMap": true,
    "declarationMap": true,
    "emitDeclarationOnly": true,
    "inlineSources": false,
    "declaration": true,
    "stripInternal": true,
    "lib": [
    "es2016",
    "dom"
    ],
    "outDir": "lib",
    "strict": true,
    "noImplicitReturns": true,
    "noUnusedLocals": true,
    "rootDir": "src",
    "baseUrl": ".",
    "skipLibCheck": true,
    "noImplicitAny": false
  },
  "include": [
    "src"
  ]
}
suren-atoyan commented 2 years ago

hey @Aayush04 we haven't faced issues with v1.2.0, but as there is a new version, may I ask you to check the latest version? (v1.3.0). Feel free to re-open it if there is an issue

Aayush04 commented 2 years ago

@suren-atoyan Facing same issue with v1.3.0 also.

Aayush04 commented 2 years ago

@suren-atoyan This is working when I changed my file extension to .ts. But don't know why it is not working with .js file.

This is how my file look like: monaco-editor-loader.js

import loader, { Monaco } from "@monaco-editor/loader";

const DEFAULT_PATH = "https://unpkg.com/monaco-editor@0.32.0/min/vs";

export function init(url): Promise<Monaco> {

    if (!url) {
        url = DEFAULT_PATH;
    }

    loader.config({
        paths: {
            vs: url
        },
    })

    return loader.init();
}

But the same code was working with v1.1.1.

suren-atoyan commented 2 years ago

@Aayush04 I can't reproduce your issue.

Here is a code snippet - with .js file and with the latest (1.3.0) and it seems to be working.

Could you please create a snippet that shows your issue?

suren-atoyan commented 2 years ago

your issue is related to typescript. I guess it's about this line:

export function init(url): Promise<Monaco>

loader.init() doesn't return Promise<Monaco> it returns CancelablePromise<Monaco>. Check this

suren-atoyan commented 2 years ago

In version 1.2.0 we fixed exactly that 🙂