guest271314 (2019-06-14T17:06:45.000Z)
Not following the module example. Would not ```ns``` be an instance of
```Module``` where ```* as ns``` is used?

For the ```class``` example would ```nameof``` be equivalent to
```Object.getOwnPropertyDescriptors(other).name.value```?

It's not that a language like TypeScript would need this, but rather that
> users of an editor like VS Code or WebStorm that have a JavaScript language
> service would benefit from it.


Is the primary use case a non-simple text editor; e.g., _not_ gedit (GUI)
or pico or nano (CLI), where the user is depending on the program

for diagnostics (logging and errors)


within a text editor _before_ actually running the code in a given
environment - not to log errors during code execution?

On Fri, Jun 14, 2019 at 4:29 PM Ron Buckton <Ron.Buckton at microsoft.com>
wrote:

> The 'nameof' operator provides the string name of a static symbol (in
> compiler/linker terms, not an ECMAScript 'Symbol'). This is often useful
> for diagnostics (logging and errors), and gives developers a way to reduce
> repetition. It is also extremely helpful in editors that support symbolic
> "rename" refactoring.
>
> While ES functions have a 'name' property, one of the main use cases is to
> get a string representation of the name of a thing that isn't itself
> reified as an object, such as a variable, parameter, or module namespace:
>
> ```
> import * as ns from "foo";
>
> nameof ns; // "ns"
>
> let fn = function g() {};
> fn.name; // "g"
> nameof fn; // "fn"
> ```
>
> Here is an example of two common use cases:
>
> ```
> class C {
>   compare(other) {
>     if (!(other instanceof C)) {
>       throw new TypeError(`Invalid argument: ${nameof other} `);
>     }
>
>   set prop(value) {
>     this._prop = value;
>     this.emit("propertychanged", nameof prop);
>   }
> }
> ```
>
> It's not that a language like TypeScript would need this, but rather that
> users of an editor like VS Code or WebStorm that have a JavaScript language
> service would benefit from it.
>
> Ron
> ------------------------------
> *From:* es-discuss <es-discuss-bounces at mozilla.org> on behalf of
> guest271314 <guest271314 at gmail.com>
> *Sent:* Friday, June 14, 2019 9:05:55 AM
> *To:* Stas Berkov
> *Cc:* es-discuss at mozilla.org
> *Subject:* Re: Re: What do you think about a C# 6 like nameof()
> expression for
>
> Have not tried TypeScript. What are the use cases for JavaScript where
> TypeScript is not used? Does ```nameof()``` check if an object has a
> specific property name defined (```"MutationObserver" in window```;
> ```window.MutationObserver```; ```"document" in globalThis```)?
>
> On Fri, Jun 14, 2019 at 1:05 PM Stas Berkov <stas.berkov at gmail.com> wrote:
>
>> Can we revisit this issue?
>>
>>
>> In C# there is `nameof`, in Swift you can do the same by calling
>>
>> ```
>>
>> let keyPath = \Person.mother.firstName
>>
>> NSPredicate(format: "%K == %@", keyPath, "Andrew")
>>
>> ```
>>
>> Let's introduce `nameof` in ES, please.
>>
>>
>> Devs from TypeScript don't want to introduce this feature in TypeScript
>> unless it is available in ES (
>> https://github.com/microsoft/TypeScript/issues/1579
>> <https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F1579&data=02%7C01%7Cron.buckton%40microsoft.com%7Ceab205c181fc4322b92208d6f0e23843%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636961251760815455&sdata=qeHDrSKENDcCczwAJFoOqAro5lo9NcXzBJA5eCXx9rA%3D&reserved=0>
>>  )
>>
>> This feature is eagarly being asked by TypeScript community.
>>
>>
>> I understand there are couple issues related to `nameof` feature in ES.
>> They are: minification and what to do if user already has `nameof` function.
>>
>>
>> Minification.
>>
>> 1. If your code to be minimized be prepared that variable names will also
>> change.
>>
>> 2. (just a possibility) Minimizer can have option to replace
>> `nameof(someVar)` with result of `nameof` function.
>>
>>
>>
>> What if user already has `nameof` function.
>>
>> 1. To maintain status quo we can user `nameof` function having priority
>> over newly introduced language feature.
>>
>> 2. OR we can use `typeof` syntax, e.g. `nameof msg.userName` (// returns
>> "userName" string)
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>> <https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.mozilla.org%2Flistinfo%2Fes-discuss&data=02%7C01%7Cron.buckton%40microsoft.com%7Ceab205c181fc4322b92208d6f0e23843%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636961251760815455&sdata=tJnR7LnmHuPm4dJOocLRVKUnaWxZvP5uAhywV2M25lM%3D&reserved=0>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20190614/fcab64c9/attachment.html>
guest271314 at gmail.com (2019-06-14T17:21:40.717Z)
Not following the module example. Would not ```ns``` be an instance of
```Module``` where ```* as ns``` is used?

For the ```class``` example would ```nameof``` be equivalent to
```Object.getOwnPropertyDescriptors(other).name.value```?

> It's not that a language like TypeScript would need this, but rather that
> users of an editor like VS Code or WebStorm that have a JavaScript language
> service would benefit from it.


Is the primary use case a non-simple text editor e.g., _not_ notepad or gedit (GUI)
or pico or nano (CLI); where the user is depending on the local program (text editor or "IDE")

> for diagnostics (logging and errors)


_before_ actually running the code in a given
environment - not to log errors (that is, for example, ```Uncaught SyntaxError: Identifier 'fn' has already been declared```) during code execution?
guest271314 at gmail.com (2019-06-14T17:21:07.291Z)
Not following the module example. Would not ```ns``` be an instance of
```Module``` where ```* as ns``` is used?

For the ```class``` example would ```nameof``` be equivalent to
```Object.getOwnPropertyDescriptors(other).name.value```?

> It's not that a language like TypeScript would need this, but rather that
> users of an editor like VS Code or WebStorm that have a JavaScript language
> service would benefit from it.


Is the primary use case a non-simple text editor e.g., _not_ notepad or gedit (GUI)
or pico or nano (CLI); where the user is depending on the local program (text editor or "IDE")

> for diagnostics (logging and errors)


_before_ actually running the code in a given
environment - not to log errors (that is, for example, ```Uncaught SyntaxError: Identifier 'ns' has already been declared```) during code execution?
guest271314 at gmail.com (2019-06-14T17:16:56.212Z)
Not following the module example. Would not ```ns``` be an instance of
```Module``` where ```* as ns``` is used?

For the ```class``` example would ```nameof``` be equivalent to
```Object.getOwnPropertyDescriptors(other).name.value```?

> It's not that a language like TypeScript would need this, but rather that
> users of an editor like VS Code or WebStorm that have a JavaScript language
> service would benefit from it.


Is the primary use case a non-simple text editor e.g., _not_ notepad or gedit (GUI)
or pico or nano (CLI); where the user is depending on the local program (text editor or "IDE")

> for diagnostics (logging and errors)


_before_ actually running the code in a given
environment - not to log errors during code execution?
guest271314 at gmail.com (2019-06-14T17:15:39.906Z)
Not following the module example. Would not ```ns``` be an instance of
```Module``` where ```* as ns``` is used?

For the ```class``` example would ```nameof``` be equivalent to
```Object.getOwnPropertyDescriptors(other).name.value```?

> It's not that a language like TypeScript would need this, but rather that
> users of an editor like VS Code or WebStorm that have a JavaScript language
> service would benefit from it.


Is the primary use case a non-simple text editor e.g., _not_ notepad or gedit (GUI)
or pico or nano (CLI); where the user is depending on the text editor program (or "IDE")

> for diagnostics (logging and errors)


_before_ actually running the code in a given
environment - not to log errors during code execution?
guest271314 at gmail.com (2019-06-14T17:15:01.147Z)
Not following the module example. Would not ```ns``` be an instance of
```Module``` where ```* as ns``` is used?

For the ```class``` example would ```nameof``` be equivalent to
```Object.getOwnPropertyDescriptors(other).name.value```?

> It's not that a language like TypeScript would need this, but rather that
> users of an editor like VS Code or WebStorm that have a JavaScript language
> service would benefit from it.


Is the primary use case a non-simple text editor e.g., _not_ notepad, gedit (GUI)
or pico or nano (CLI); where the user is depending on the text editor program (or "IDE")

> for diagnostics (logging and errors)


_before_ actually running the code in a given
environment - not to log errors during code execution?
guest271314 at gmail.com (2019-06-14T17:13:05.539Z)
Not following the module example. Would not ```ns``` be an instance of
```Module``` where ```* as ns``` is used?

For the ```class``` example would ```nameof``` be equivalent to
```Object.getOwnPropertyDescriptors(other).name.value```?

> It's not that a language like TypeScript would need this, but rather that
> users of an editor like VS Code or WebStorm that have a JavaScript language
> service would benefit from it.


Is the primary use case a non-simple text editor (roll your own, by hand, then test); e.g., _not_ gedit (GUI)
or pico or nano (CLI); where the user is depending on the text editor program (or "IDE")

> for diagnostics (logging and errors)


_before_ actually running the code in a given
environment - not to log errors during code execution?
guest271314 at gmail.com (2019-06-14T17:08:25.509Z)
Not following the module example. Would not ```ns``` be an instance of
```Module``` where ```* as ns``` is used?

For the ```class``` example would ```nameof``` be equivalent to
```Object.getOwnPropertyDescriptors(other).name.value```?

> It's not that a language like TypeScript would need this, but rather that
> users of an editor like VS Code or WebStorm that have a JavaScript language
> service would benefit from it.


Is the primary use case a non-simple text editor; e.g., _not_ gedit (GUI)
or pico or nano (CLI), where the user is depending on the program

> for diagnostics (logging and errors)


within a text editor _before_ actually running the code in a given
environment - not to log errors during code execution?