Bug 1786885 Comment 0 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

We are eventually removing osfile.jsm, which means you won't be able to get `OS.Constants` imported by importing a JSM.

The current way to define `OS.Constants` in a namespace is by doing:

```
  Cc["@mozilla.org/net/osfileconstantsservice;1"]
    .getService(Ci.nsIOSFileConstantsService)
    .init();
```

This grabs the current JS global and defines an `OS` object onto it. This seems magical and may lead to confusion. It might be better if we have something like:

```
  const {OS} = Cc["@mozilla.org/net/osfileconstantsservice;1"]
    .getService(Ci.nsIOSFileConstantsService)
    .init();
```

or maybe better still, have it available on Services directly

```
Services.osConstants.libc.O_CREAT
```
We are eventually removing osfile.jsm, which means you won't be able to get `OS.Constants` imported by importing a JSM.

The current way to define `OS.Constants` in a namespace is by doing:

```
  Cc["@mozilla.org/net/osfileconstantsservice;1"]
    .getService(Ci.nsIOSFileConstantsService)
    .init();
```

This grabs the current JS global and defines an `OS` object onto it. This seems magical and may lead to confusion. It might be better if we have something like:

```
  const {OS} = Cc["@mozilla.org/net/osfileconstantsservice;1"]
    .getService(Ci.nsIOSFileConstantsService)
    .init();

// or

const {OS} = Services.osConstants.init();
```

or maybe better still, have it available on Services directly

```
Services.osConstants.libc.O_CREAT
```

Back to Bug 1786885 Comment 0