@tsonic/globals-pure 0.3.0

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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +32 -0
  3. package/index.d.ts +217 -0
  4. package/package.json +34 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 tsoniclang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # @tsonic/globals-pure
2
+
3
+ Global type definitions for Tsonic with CLR naming conventions (PascalCase).
4
+
5
+ ## Overview
6
+
7
+ This package provides base TypeScript types for Tsonic projects using CLR naming conventions:
8
+ - Base types required by TypeScript (Array, String, Object, Function, etc.)
9
+ - Utility types (Partial, Required, Readonly, Pick, Record, etc.)
10
+ - Iterator and async iterator types
11
+ - Promise types
12
+ - BCL primitive methods on String with PascalCase naming
13
+
14
+ ## Usage
15
+
16
+ ```typescript
17
+ // String methods are available with PascalCase naming
18
+ const str: string = "hello world";
19
+ str.Contains("hello"); // true
20
+ str.StartsWith("hello"); // true
21
+ str.IndexOf("world"); // 6
22
+ ```
23
+
24
+ ## Related Packages
25
+
26
+ - **@tsonic/globals** - Same functionality but with camelCase naming (TypeScript-friendly)
27
+ - **@tsonic/dotnet-pure** - Full .NET BCL type definitions with CLR naming
28
+ - **@tsonic/dotnet** - Full .NET BCL type definitions with camelCase naming
29
+
30
+ ## License
31
+
32
+ MIT
package/index.d.ts ADDED
@@ -0,0 +1,217 @@
1
+ /**
2
+ * @tsonic/globals-pure
3
+ *
4
+ * Global type definitions for Tsonic with CLR naming conventions.
5
+ *
6
+ * This package provides:
7
+ * 1. Base types required by TypeScript (Array, String, Object, Function, etc.)
8
+ * 2. Shared types used by both modes (utility types, iterators, Promise, Symbol)
9
+ * 3. BCL primitive methods on String, Number, Boolean (from @tsonic/dotnet-pure)
10
+ *
11
+ * For dotnet mode: Use this package alone. Primitives have BCL methods with PascalCase naming.
12
+ * For JS mode: Use with @tsonic/js-globals which extends base types with JS methods.
13
+ */
14
+
15
+ import { String$instance } from "@tsonic/dotnet-pure/System";
16
+
17
+ declare global {
18
+ /**
19
+ * Array type - minimal base definition
20
+ * In dotnet mode, use List<T> methods or LINQ
21
+ * In JS mode, @tsonic/js-globals extends this with .map, .filter, etc.
22
+ */
23
+ interface Array<T> {
24
+ [n: number]: T;
25
+ [Symbol.iterator](): IterableIterator<T>;
26
+ }
27
+
28
+ interface ReadonlyArray<T> {
29
+ readonly [n: number]: T;
30
+ [Symbol.iterator](): IterableIterator<T>;
31
+ }
32
+
33
+ /**
34
+ * String - augmented with BCL methods from System.String
35
+ * All System.String instance methods are available on string primitives.
36
+ * Uses CLR PascalCase naming: Contains(), IndexOf(), StartsWith(), etc.
37
+ * In JS mode, @tsonic/js-globals may override with JS-specific methods.
38
+ */
39
+ interface String extends String$instance {}
40
+
41
+ interface Number {}
42
+
43
+ interface Boolean {}
44
+
45
+ /**
46
+ * Object - minimal base definition
47
+ */
48
+ interface Object {
49
+ constructor: Function;
50
+ }
51
+
52
+ /**
53
+ * Function - minimal base definition
54
+ */
55
+ interface Function {
56
+ prototype: any;
57
+ }
58
+
59
+ /**
60
+ * Required TypeScript compiler internals
61
+ */
62
+ interface CallableFunction extends Function {}
63
+ interface NewableFunction extends Function {}
64
+ interface IArguments {}
65
+
66
+ /**
67
+ * RegExp - minimal base definition
68
+ */
69
+ interface RegExp {}
70
+
71
+ /**
72
+ * Symbol
73
+ */
74
+ interface SymbolConstructor {
75
+ readonly iterator: symbol;
76
+ readonly asyncIterator: symbol;
77
+ readonly hasInstance: symbol;
78
+ readonly isConcatSpreadable: symbol;
79
+ readonly species: symbol;
80
+ readonly toPrimitive: symbol;
81
+ readonly toStringTag: symbol;
82
+ }
83
+
84
+ const Symbol: SymbolConstructor;
85
+
86
+ /**
87
+ * PropertyKey - required for index signatures
88
+ */
89
+ type PropertyKey = string | number | symbol;
90
+
91
+ /**
92
+ * Utility types
93
+ */
94
+ type Partial<T> = { [P in keyof T]?: T[P] };
95
+ type Required<T> = { [P in keyof T]-?: T[P] };
96
+ type Readonly<T> = { readonly [P in keyof T]: T[P] };
97
+ type Pick<T, K extends keyof T> = { [P in K]: T[P] };
98
+ type Record<K extends keyof any, T> = { [P in K]: T };
99
+ type Exclude<T, U> = T extends U ? never : T;
100
+ type Extract<T, U> = T extends U ? T : never;
101
+ type Omit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>;
102
+ type NonNullable<T> = T extends null | undefined ? never : T;
103
+ type Parameters<T extends (...args: any) => any> = T extends (...args: infer P) => any ? P : never;
104
+ type ConstructorParameters<T extends new (...args: any) => any> = T extends new (...args: infer P) => any ? P : never;
105
+ type ReturnType<T extends (...args: any) => any> = T extends (...args: any) => infer R ? R : any;
106
+ type InstanceType<T extends new (...args: any) => any> = T extends new (...args: any) => infer R ? R : any;
107
+ type Awaited<T> = T extends PromiseLike<infer U> ? Awaited<U> : T;
108
+
109
+ /**
110
+ * Promise types
111
+ */
112
+ interface Promise<T> {
113
+ then<TResult1 = T, TResult2 = never>(
114
+ onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null,
115
+ onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null
116
+ ): Promise<TResult1 | TResult2>;
117
+ catch<TResult = never>(
118
+ onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null
119
+ ): Promise<T | TResult>;
120
+ finally(onfinally?: (() => void) | undefined | null): Promise<T>;
121
+ }
122
+
123
+ interface PromiseLike<T> {
124
+ then<TResult1 = T, TResult2 = never>(
125
+ onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null,
126
+ onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null
127
+ ): PromiseLike<TResult1 | TResult2>;
128
+ }
129
+
130
+ interface PromiseConstructor {
131
+ new <T>(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;
132
+ resolve(): Promise<void>;
133
+ resolve<T>(value: T | PromiseLike<T>): Promise<T>;
134
+ reject<T = never>(reason?: any): Promise<T>;
135
+ all<T>(values: readonly (T | PromiseLike<T>)[]): Promise<T[]>;
136
+ race<T>(values: readonly (T | PromiseLike<T>)[]): Promise<T>;
137
+ }
138
+
139
+ const Promise: PromiseConstructor;
140
+
141
+ /**
142
+ * Iterator types
143
+ */
144
+ interface Iterator<T, TReturn = any, TNext = undefined> {
145
+ next(...args: [] | [TNext]): IteratorResult<T, TReturn>;
146
+ return?(value?: TReturn): IteratorResult<T, TReturn>;
147
+ throw?(e?: any): IteratorResult<T, TReturn>;
148
+ }
149
+
150
+ interface IteratorResult<T, TReturn = any> {
151
+ done: boolean;
152
+ value: T | TReturn;
153
+ }
154
+
155
+ interface IteratorYieldResult<T> {
156
+ done: false;
157
+ value: T;
158
+ }
159
+
160
+ interface IteratorReturnResult<TReturn> {
161
+ done: true;
162
+ value: TReturn;
163
+ }
164
+
165
+ interface Iterable<T, TReturn = any, TNext = undefined> {
166
+ [Symbol.iterator](): Iterator<T, TReturn, TNext>;
167
+ }
168
+
169
+ interface IterableIterator<T, TReturn = any, TNext = undefined> extends Iterator<T, TReturn, TNext> {
170
+ [Symbol.iterator](): IterableIterator<T, TReturn, TNext>;
171
+ }
172
+
173
+ /**
174
+ * Async Iterator types
175
+ */
176
+ interface AsyncIterator<T, TReturn = any, TNext = undefined> {
177
+ next(...args: [] | [TNext]): Promise<IteratorResult<T, TReturn>>;
178
+ return?(value?: TReturn | PromiseLike<TReturn>): Promise<IteratorResult<T, TReturn>>;
179
+ throw?(e?: any): Promise<IteratorResult<T, TReturn>>;
180
+ }
181
+
182
+ interface AsyncIterable<T, TReturn = any, TNext = undefined> {
183
+ [Symbol.asyncIterator](): AsyncIterator<T, TReturn, TNext>;
184
+ }
185
+
186
+ interface AsyncIterableIterator<T, TReturn = any, TNext = undefined> extends AsyncIterator<T, TReturn, TNext> {
187
+ [Symbol.asyncIterator](): AsyncIterableIterator<T, TReturn, TNext>;
188
+ }
189
+
190
+ /**
191
+ * Generator types
192
+ */
193
+ interface Generator<T = unknown, TReturn = any, TNext = unknown> extends Iterator<T, TReturn, TNext> {
194
+ next(...args: [] | [TNext]): IteratorResult<T, TReturn>;
195
+ return(value: TReturn): IteratorResult<T, TReturn>;
196
+ throw(e: any): IteratorResult<T, TReturn>;
197
+ [Symbol.iterator](): Generator<T, TReturn, TNext>;
198
+ }
199
+
200
+ interface AsyncGenerator<T = unknown, TReturn = any, TNext = unknown> extends AsyncIterator<T, TReturn, TNext> {
201
+ next(...args: [] | [TNext]): Promise<IteratorResult<T, TReturn>>;
202
+ return(value: TReturn | PromiseLike<TReturn>): Promise<IteratorResult<T, TReturn>>;
203
+ throw(e: any): Promise<IteratorResult<T, TReturn>>;
204
+ [Symbol.asyncIterator](): AsyncGenerator<T, TReturn, TNext>;
205
+ }
206
+
207
+ /**
208
+ * Template literal type utilities
209
+ */
210
+ type Uppercase<S extends string> = intrinsic;
211
+ type Lowercase<S extends string> = intrinsic;
212
+ type Capitalize<S extends string> = intrinsic;
213
+ type Uncapitalize<S extends string> = intrinsic;
214
+ }
215
+
216
+ // This export is required to make this file a module
217
+ export {};
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@tsonic/globals-pure",
3
+ "version": "0.3.0",
4
+ "description": "Global type definitions for Tsonic with BCL primitive methods (CLR naming)",
5
+ "main": "index.d.ts",
6
+ "types": "index.d.ts",
7
+ "files": [
8
+ "index.d.ts",
9
+ "README.md"
10
+ ],
11
+ "scripts": {
12
+ "typecheck": "tsc --noEmit"
13
+ },
14
+ "dependencies": {
15
+ "@tsonic/dotnet-pure": "^0.7.6"
16
+ },
17
+ "devDependencies": {
18
+ "typescript": "^5.0.0"
19
+ },
20
+ "keywords": [
21
+ "tsonic",
22
+ "typescript",
23
+ "types",
24
+ "globals",
25
+ "utility-types",
26
+ "clr-naming"
27
+ ],
28
+ "author": "Tsonic Team",
29
+ "license": "MIT",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/tsoniclang/globals-pure.git"
33
+ }
34
+ }