# Monaco clarification

**URL:** <https://discourse.nodered.org/t/monaco-clarification/47004>\
**Category:** General\
**Created:** [11 June 2021 01:41 UTC](https://discourse.nodered.org/t/monaco-clarification/47004 "2021-06-11T01:41:29Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![Buckskin](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Buckskin](https://discourse.nodered.org/u/Buckskin)\
**Post date:** [11 June 2021 19:30 UTC](https://discourse.nodered.org/t/monaco-clarification/47004/21 "2021-06-11T19:30:19Z")

</div>

Yes. No difference. I even loaded the new default settings.js and amended it to match the existing to see if there was something there but no change (that was on the Pi with the official upgrade command)

The ace editor still works OK as I reverted to check

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [12 June 2021 08:39 UTC](https://discourse.nodered.org/t/monaco-clarification/47004/22 "2021-06-12T08:39:54Z")

</div>

@Buckskin Do you have another computer/laptop on your network that you can try accessing the faulty node-red installs (using `http://IP:port`) ?

Alternatively, if you can present your instance to the internet (node-red-contrib-ngrok can do this safely and easily) then PM me the URL & password - I'll see if your install works on my machine.

---

<div class="post-metadata">

**Author:** ![Buckskin](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Buckskin](https://discourse.nodered.org/u/Buckskin)\
**Post date:** [12 June 2021 08:56 UTC](https://discourse.nodered.org/t/monaco-clarification/47004/23 "2021-06-12T08:56:13Z")

</div>

Hi Steve. Tried it on another PC, same - keyboard does not work.

I have installed node-red-contrib-ngrok and will try and work out the rest

Well that is jolly annoying. I have no idea how to PM and so far I haven't found anything to explain how (either that or I am just very slow)

Late update:

I have just installed on another pi (no previous NR);  
Node-red v1.35 using normal bash script (node.js v14)  
Node-red v2 using update install

and Monaco works on that NR instance. So, it would seem that there is possibly an installed node on my existing systems that is causing the problem. I will just have to install them on the new system one at a time until something falls over.

I have found the culprit. It is the `node-red-contrib-zigbee2mqtt` node. When I remove it the editor works as expected. That is a bit of a nuisance 😒

---

<div class="post-metadata">

**Author:** ![Buckskin](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Buckskin](https://discourse.nodered.org/u/Buckskin)\
**Post date:** [15 June 2021 20:20 UTC](https://discourse.nodered.org/t/monaco-clarification/47004/24 "2021-06-15T20:20:41Z")

</div>

Is there an easy way to update the version of Javascript that is used for error checking.

A couple of examples :  
a comma after the last property in an Object or Array is flagged as an error, which it isn't anymore  
the 'options' in Intl.DateTimeFormat are flagged as invalid string type

Other than that, using Monaco is certainly improving the way I document my code 😀

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [15 June 2021 20:28 UTC](https://discourse.nodered.org/t/monaco-clarification/47004/25 "2021-06-15T20:28:03Z")

</div>

Can you post an example/sample of code please?

---

<div class="post-metadata">

**Author:** ![Buckskin](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Buckskin](https://discourse.nodered.org/u/Buckskin)\
**Post date:** [15 June 2021 20:47 UTC](https://discourse.nodered.org/t/monaco-clarification/47004/26 "2021-06-15T20:47:07Z")

</div>

My bad on the comma issue, I need to check my code more carefully - apologies, it DOES allow a final comma.

```auto
const UK_TIME_OPTIONS = { hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: false };

function UKTime(dirtyDate) {
    const date = new Date(dirtyDate);

    return date.toLocaleTimeString('en-GB', UK_TIME_OPTIONS);

}

```

This problem also crops up with `Intl.DateTimeFormat`

The error shown is;

> Argument of type '{ hour: string; minute: string; second: string; hour12: boolean; }' is not assignable to parameter of type 'DateTimeFormatOptions'.  
> Types of property 'hour' are incompatible.  
> Type 'string' is not assignable to type '"2-digit" | "numeric"'.(2345)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [15 June 2021 21:08 UTC](https://discourse.nodered.org/t/monaco-clarification/47004/27 "2021-06-15T21:08:25Z")

</div>

Yes. That one is odd.

I'm looking into it.

---

<div class="post-metadata">

**Author:** ![Buckskin](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Buckskin](https://discourse.nodered.org/u/Buckskin)\
**Post date:** [15 June 2021 21:10 UTC](https://discourse.nodered.org/t/monaco-clarification/47004/28 "2021-06-15T21:10:29Z")

</div>

Cheers. Sorry about my confusion with the comma, teach me to be more careful about using `;` instead of `,`

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [15 June 2021 21:12 UTC](https://discourse.nodered.org/t/monaco-clarification/47004/29 "2021-06-15T21:12:28Z")

</div>

Easily done. I stopped using `;` in Node/JS some years ago though and I _always_ use trailing comma's.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [15 June 2021 21:42 UTC](https://discourse.nodered.org/t/monaco-clarification/47004/30 "2021-06-15T21:42:58Z")

</div>

This is quite odd - possibly a bug in typescript or monaco?

If I put the options directly into the call, it doesn't complain

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/f/af1f6e9fd110cef35e0c456f04b379d6d67fc9ac.png)

For now, the solution is to disable error 2345. I will add that to the src.

I'll also post this on the monaco repo - see what they say.

---

<div class="post-metadata">

**Author:** ![Buckskin](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Buckskin](https://discourse.nodered.org/u/Buckskin)\
**Post date:** [15 June 2021 21:45 UTC](https://discourse.nodered.org/t/monaco-clarification/47004/31 "2021-06-15T21:45:46Z")

</div>

Thank you, saves having to add `// @ts-ignore` . Be interesting to see the reply.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [16 June 2021 21:43 UTC](https://discourse.nodered.org/t/monaco-clarification/47004/32 "2021-06-16T21:43:25Z")

</div>

An official answer...

> The problem occurs because `.weekday` is required to be one of `"long" | "short" | "narrow"` but assigning the object literal to a variable first, with no further context, causes it to be widened to `string` , which TS then can't verify is compatible when you pass it to the function later. Passing the object literal directly works because contextual typing prevents the widening (i.e. TS can verify on the spot that you're passing a compatible string literal).

And a work around - use a JSdoc `@type` hint...

```javascript
/** @type {Intl.DateTimeFormatOptions} */
const options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };

```

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/0/d02295cef9d43698da08a1a2a2dc7e8c30785d15.png)

---

<div class="post-metadata">

**Author:** ![Buckskin](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Buckskin](https://discourse.nodered.org/u/Buckskin)\
**Post date:** [16 June 2021 22:40 UTC](https://discourse.nodered.org/t/monaco-clarification/47004/33 "2021-06-16T22:40:18Z")

</div>

Thanks for that, appreciate you taking the time (although I have had to put the `@type` in front of every `DateTimeFormatOption const`, and I have a few.) 😁

I must admit to not quite understanding because to me `'long'` is a `string` but I guess it is to do with how TS identifies a valid entry (obviously not by checking the value as a string)

For anyone else looking at this, note that the `/**` at the beginning is mandatory (`/*` does not work)

Errm, sorry to be a pain but I have another one for you

> ```
> class DeviceModel {
> static #deviceModelList = []
> 
> ```

`'static' modifier cannot be used with a private identifier.(18019)`

This is a stage 3 proposal according to MDN, but if I `// @ts-ignore` it works. (it was something that I thought was a good idea so I tried it). It may be that this hasn't worked its way into a proper release yet

I'm not sure if you are actually willing to look at these niggles, so if not please let me know and I will stop pestering you. It's not as if they cannot be got round..

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [16 June 2021 23:30 UTC](https://discourse.nodered.org/t/monaco-clarification/47004/34 "2021-06-16T23:30:10Z")

</div>

> [@Buckskin](#):
>
> `/**` at the beginning is mandatory

That's because Monaco uses JSDoc for type hinting.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [17 June 2021 07:42 UTC](https://discourse.nodered.org/t/monaco-clarification/47004/35 "2021-06-17T07:42:24Z")

</div>

> [@Buckskin](#):
>
> `'static' modifier cannot be used with a private identifier.(18019)`
> 
> This is a stage 3 proposal according to MDN, but if I `// @ts-ignore` it works. (it was something that I thought was a good idea so I tried it). It may be that this hasn't worked its way into a proper release yet

I dont think it is unreasonable. According to MDN, nodejs 12.0.0 has support for this since monaco is for node-red 2.0.0 and node-red 2.0.0 states a minimum of nodejs 12.0.0. I will add this to the draft PR for next node-red beta.

> **Click to show working demo**
>
> Visit [monaco playground](https://microsoft.github.io/monaco-editor/playground.html#extending-language-services-configure-javascript-defaults) & paste the below code into the left-hand editor, then click the **run** button
> 
> ```javascript
> // validation settings
> monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
> noSemanticValidation: false,
> noSyntaxValidation: false,
> });
> 
> // compiler options
> monaco.languages.typescript.javascriptDefaults.setCompilerOptions({
> target: monaco.languages.typescript.ScriptTarget.ESNext,
> allowNonTsExtensions: true,
> useDefineForClassFields: true //permit class Static fields with private name to have initializer
> });
> 
> var jsCode = `class A {
> static #statPriv = 4;
> #priv = 123;
> t = 345;
> getValues() {
> return [this.t, this.#priv, A.#statPriv];
> }
> #setValues(statPriv, priv, t) {
> A.#statPriv = statPriv;
> this.#priv = priv;
> this.t = t;
> }
> constructor() {
> this.#setValues(1,2,3);
> }
> }
> const aA = new A();
> aA.t = 999;
> const v = aA.getValues();
> // aA.#priv = 999; //error
> // A.#statPriv = 999; //error
> // aA.#setValues(); //error`;
> 
> monaco.editor.create(document.getElementById('container'), {
> value: jsCode,
> language: 'javascript'
> });
> 
> ```

---

<div class="post-metadata">

**Author:** ![Buckskin](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Buckskin](https://discourse.nodered.org/u/Buckskin)\
**Post date:** [17 June 2021 11:56 UTC](https://discourse.nodered.org/t/monaco-clarification/47004/36 "2021-06-17T11:56:03Z")

</div>

Cheers Steve. Good to know I'm not chasing rainbows

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [2 July 2021 15:08 UTC](https://discourse.nodered.org/t/monaco-clarification/47004/37 "2021-07-02T15:08:34Z")

</div>

@Buckskin

With beta-2 now released, these issues should be gone.

Do you want to evaluate and feedback?

Ta.

---

<div class="post-metadata">

**Author:** ![Buckskin](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Buckskin](https://discourse.nodered.org/u/Buckskin)\
**Post date:** [2 July 2021 16:03 UTC](https://discourse.nodered.org/t/monaco-clarification/47004/38 "2021-07-02T16:03:41Z")

</div>

Both issues I raised have been resolved. Thank you

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [2 July 2021 18:11 UTC](https://discourse.nodered.org/t/monaco-clarification/47004/39 "2021-07-02T18:11:28Z")

</div>

The issue that I raised is also now fixed -

> [@Monaco clarification](https://discourse.nodered.org/t/monaco-clarification/47004/11):
>
> Noticed that when I open some of my function nodes, the node is then marked with a red triangle, signifying a problem. I don't think that there is an actual code problem, and it wasn't identified as such with the ace editor. I realize that I can select 'ignore the error message', but should it be recognised as an error in the first place?

Thanks 👍

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [1 August 2021 18:12 UTC](https://discourse.nodered.org/t/monaco-clarification/47004/40 "2021-08-01T18:12:11Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.

[Previous page](https://discourse.nodered.org/t/monaco-clarification/47004.md?page=1)
