@twin.org/nameof 0.0.3-next.21 → 0.0.3-next.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # TWIN Nameof
2
2
 
3
- The methods in this package are used to convert TypeScript class/type/property names to embedded strings, so that they are available to your JavaScript code at runtime.
4
-
5
- This package is used in conjunction with the `@twin.org/nameof-transformer` package, without using the transformer for compilation you will end up with an error string embedded in your code instead of the runtime name you are expecting.
3
+ This package is part of the framework workspace and provides the definitions for the methods which are processed by the nameof-transformer to support consistent development workflows across the ecosystem.
6
4
 
7
5
  ## Installation
8
6
 
package/docs/changelog.md CHANGED
@@ -1,4 +1,32 @@
1
- # @twin.org/nameof - Changelog
1
+ # Changelog
2
+
3
+ ## [0.0.3-next.23](https://github.com/twinfoundation/framework/compare/nameof-v0.0.3-next.22...nameof-v0.0.3-next.23) (2026-03-17)
4
+
5
+
6
+ ### Miscellaneous Chores
7
+
8
+ * **nameof:** Synchronize repo versions
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * devDependencies
15
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.22 to 0.0.3-next.23
16
+
17
+ ## [0.0.3-next.22](https://github.com/twinfoundation/framework/compare/nameof-v0.0.3-next.21...nameof-v0.0.3-next.22) (2026-02-26)
18
+
19
+
20
+ ### Miscellaneous Chores
21
+
22
+ * **nameof:** Synchronize repo versions
23
+
24
+
25
+ ### Dependencies
26
+
27
+ * The following workspace dependencies were updated
28
+ * devDependencies
29
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.21 to 0.0.3-next.22
2
30
 
3
31
  ## [0.0.3-next.21](https://github.com/twinfoundation/framework/compare/nameof-v0.0.3-next.20...nameof-v0.0.3-next.21) (2026-02-26)
4
32
 
package/docs/examples.md CHANGED
@@ -1,74 +1,60 @@
1
- # @twin.org/nameof - Examples
1
+ # Nameof Examples
2
2
 
3
- ## `nameof<T>`
3
+ Use these snippets for strongly typed name extraction patterns that remain safe during refactors.
4
4
 
5
- One of the internal transformers in the TypeScript compiler will reduce an interface to no code, which means that at runtime the type information is missing. So operations where you might like to find the name of a class/type etc are not available.
6
-
7
- We have many places in our code where we want to use the name of the class, we could do the following.
5
+ ## `nameof`
8
6
 
9
7
  ```typescript
10
- export class MyClass {
11
- public static className(): string {
12
- return 'MyClass';
13
- }
14
- }
15
- console.log(MyClass.className()); // Outputs "MyClass"
16
- ```
8
+ import { nameof } from '@twin.org/nameof';
17
9
 
18
- But if you changed the name of the class you would have to make sure you also replaced all string instances where it was mentioned as well, this is prone to lots of errors.
10
+ class AccountState {
11
+ public id!: string;
12
+ }
19
13
 
20
- We can use the `nameof` transformer as follows.
14
+ nameof<AccountState>(); // 'AccountState'
15
+ ```
21
16
 
22
17
  ```typescript
23
18
  import { nameof } from '@twin.org/nameof';
24
19
 
25
- export class MyClass {
26
- public static className(): string {
27
- return nameof<MyClass>();
28
- }
20
+ interface Profile {
21
+ displayName: string;
22
+ stats?: {
23
+ loginCount: number;
24
+ };
29
25
  }
30
- console.log(MyClass.className()); // Outputs "MyClass"
31
- ```
32
-
33
- Now if we rename `MyClass` without updating the references in the `nameof` call we will get a compiler error, code auto refactoring would actually perform the rename for us.
34
26
 
35
- Since `nameof` is performed as a compile time transform, the actual code produced looks like this.
27
+ const profile: Profile = {
28
+ displayName: 'Ari',
29
+ stats: {
30
+ loginCount: 12
31
+ }
32
+ };
36
33
 
37
- ```javascript
38
- export class MyClass {
39
- static public className(): string {
40
- return "MyClass";
41
- }
42
- }
43
- console.log(MyClass.className()); // Outputs "MyClass"
34
+ nameof(profile.displayName); // 'displayName'
35
+ nameof(profile.stats?.loginCount); // 'stats.loginCount'
44
36
  ```
45
37
 
46
- This means there is no additional overheads in function calls at runtime.
47
-
48
- ## `nameof(propName)`
49
-
50
- The `nameof(propName)` transform behaves in much the same way as `nameof<T>`, but instead works on properties passed to it.
38
+ ## `nameofKebabCase`
51
39
 
52
40
  ```typescript
53
- import { nameof } from '@twin.org/nameof';
41
+ import { nameofKebabCase } from '@twin.org/nameof';
54
42
 
55
- export class MyClass {
56
- public static propName(aProp: string): string {
57
- return nameof(aProp);
58
- }
43
+ class ReportSummary {
44
+ public totalCount!: number;
59
45
  }
60
- console.log(MyClass.propName()); // Outputs "aProp"
46
+
47
+ nameofKebabCase<ReportSummary>(); // 'report-summary'
61
48
  ```
62
49
 
63
- You can also used it with chained properties, nullish operators can also be used, but are removed.
50
+ ## `nameofCamelCase`
64
51
 
65
52
  ```typescript
66
- import { nameof } from '@twin.org/nameof';
53
+ import { nameofCamelCase } from '@twin.org/nameof';
67
54
 
68
- export class MyClass {
69
- public static propName(aProp: { inner?: boolean }): string {
70
- return nameof(aProp?.inner);
71
- }
55
+ class UserProfileRecord {
56
+ public profileImageUrl!: string;
72
57
  }
73
- console.log(MyClass.propName()); // Outputs "aProp.inner"
58
+
59
+ nameofCamelCase<UserProfileRecord>(); // 'userProfileRecord'
74
60
  ```
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@twin.org/nameof",
3
- "version": "0.0.3-next.21",
4
- "description": "Provides the definitions for the methods which are processed by the nameof-transformer",
3
+ "version": "0.0.3-next.23",
4
+ "description": "The definitions for the methods which are processed by the nameof-transformer",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/twinfoundation/framework.git",