@tsonic/core 0.1.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.
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,58 @@
1
+ # @tsonic/core
2
+
3
+ Core type definitions for Tsonic - a TypeScript to native compiler.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @tsonic/core
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import { int, float, bool } from "@tsonic/core/types.js";
15
+
16
+ const age: int = 42 as int;
17
+ const temp: float = 98.6 as float;
18
+ const isActive: bool = true;
19
+ ```
20
+
21
+ ## Type Aliases
22
+
23
+ ### Signed Integer Types
24
+ - `sbyte` - System.SByte (-128 to 127)
25
+ - `short` - System.Int16 (-32,768 to 32,767)
26
+ - `int` - System.Int32 (-2,147,483,648 to 2,147,483,647)
27
+ - `long` - System.Int64
28
+ - `nint` - System.IntPtr (native int)
29
+ - `int128` - System.Int128
30
+
31
+ ### Unsigned Integer Types
32
+ - `byte` - System.Byte (0 to 255)
33
+ - `ushort` - System.UInt16 (0 to 65,535)
34
+ - `uint` - System.UInt32 (0 to 4,294,967,295)
35
+ - `ulong` - System.UInt64
36
+ - `nuint` - System.UIntPtr (native uint)
37
+ - `uint128` - System.UInt128
38
+
39
+ ### Floating-Point Types
40
+ - `half` - System.Half (16-bit float)
41
+ - `float` - System.Single (32-bit float)
42
+ - `double` - System.Double (64-bit float)
43
+ - `decimal` - System.Decimal (128-bit decimal)
44
+
45
+ ### Other Types
46
+ - `bool` - System.Boolean
47
+ - `char` - System.Char (single UTF-16 code unit)
48
+ - `ptr<T>` - C# unsafe pointer types
49
+
50
+ ## Important Notes
51
+
52
+ These are simple type aliases with NO runtime enforcement. TypeScript treats all numeric types as `number`, `bool` as `boolean`, etc.
53
+
54
+ **Tsonic enforces semantic correctness at compile time via its proof system.** TypeScript alone will NOT catch type errors between int/byte/long etc.
55
+
56
+ ## License
57
+
58
+ MIT
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @tsonic/core - Type Definitions
3
+ *
4
+ * TypeScript type aliases for CLR/.NET runtime primitives.
5
+ *
6
+ * IMPORTANT: These are simple type aliases with NO runtime enforcement.
7
+ * TypeScript treats all numeric types as `number`, bool as `boolean`, etc.
8
+ * Tsonic enforces semantic correctness at compile time via its proof system.
9
+ *
10
+ * TypeScript will NOT catch type errors between int/byte/long etc.
11
+ * Only Tsonic compilation validates numeric correctness.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * import { int, float, bool } from "@tsonic/core/types.js";
16
+ *
17
+ * const age: int = 42 as int; // Tsonic validates 42 fits in Int32
18
+ * const temp: float = 98.6 as float; // Tsonic validates for Single
19
+ * const isActive: bool = true; // bool is just boolean
20
+ * ```
21
+ */
22
+ export type sbyte = number;
23
+ export type short = number;
24
+ export type int = number;
25
+ export type long = number;
26
+ export type nint = number;
27
+ export type int128 = number;
28
+ export type byte = number;
29
+ export type ushort = number;
30
+ export type uint = number;
31
+ export type ulong = number;
32
+ export type nuint = number;
33
+ export type uint128 = number;
34
+ export type half = number;
35
+ export type float = number;
36
+ export type double = number;
37
+ export type decimal = number;
38
+ export type bool = boolean;
39
+ export type char = string;
40
+ export type ptr<T> = unknown;
41
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC;AAC3B,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC;AAC3B,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC;AACzB,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC;AAC1B,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC;AAC1B,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAG5B,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC;AAC1B,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAC5B,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC;AAC1B,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC;AAC3B,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC;AAC3B,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAG7B,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC;AAC1B,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC;AAC3B,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAC5B,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAG7B,MAAM,MAAM,IAAI,GAAG,OAAO,CAAC;AAC3B,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC;AAM1B,MAAM,MAAM,GAAG,CAAC,CAAC,IAAI,OAAO,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @tsonic/core - Type Definitions
3
+ *
4
+ * TypeScript type aliases for CLR/.NET runtime primitives.
5
+ *
6
+ * IMPORTANT: These are simple type aliases with NO runtime enforcement.
7
+ * TypeScript treats all numeric types as `number`, bool as `boolean`, etc.
8
+ * Tsonic enforces semantic correctness at compile time via its proof system.
9
+ *
10
+ * TypeScript will NOT catch type errors between int/byte/long etc.
11
+ * Only Tsonic compilation validates numeric correctness.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * import { int, float, bool } from "@tsonic/core/types.js";
16
+ *
17
+ * const age: int = 42 as int; // Tsonic validates 42 fits in Int32
18
+ * const temp: float = 98.6 as float; // Tsonic validates for Single
19
+ * const isActive: bool = true; // bool is just boolean
20
+ * ```
21
+ */
22
+ export {};
23
+ // NOTE: ref<T>, out<T>, In<T> have been removed.
24
+ // Parameter modifiers will be expressed via syntax, not types.
25
+ // See spec for forthcoming ref/out/in parameter syntax.
26
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;AAkCH,iDAAiD;AACjD,+DAA+D;AAC/D,wDAAwD"}
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@tsonic/core",
3
+ "version": "0.1.0",
4
+ "description": "Core type definitions for Tsonic - TypeScript to native compiler",
5
+ "type": "module",
6
+ "exports": {
7
+ "./types.js": {
8
+ "types": "./dist/types.d.ts",
9
+ "import": "./dist/types.js"
10
+ }
11
+ },
12
+ "files": [
13
+ "dist",
14
+ "src",
15
+ "README.md",
16
+ "LICENSE"
17
+ ],
18
+ "scripts": {
19
+ "build": "tsc",
20
+ "prepublishOnly": "npm run build"
21
+ },
22
+ "keywords": [
23
+ "typescript",
24
+ "dotnet",
25
+ "clr",
26
+ "runtime",
27
+ "primitives",
28
+ "interop",
29
+ "csharp",
30
+ "tsonic"
31
+ ],
32
+ "author": "Tsonic Team",
33
+ "license": "MIT",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://github.com/tsoniclang/core.git"
37
+ },
38
+ "bugs": {
39
+ "url": "https://github.com/tsoniclang/core/issues"
40
+ },
41
+ "homepage": "https://github.com/tsoniclang/core#readme",
42
+ "devDependencies": {
43
+ "typescript": "^5.7.2"
44
+ }
45
+ }
package/src/types.ts ADDED
@@ -0,0 +1,57 @@
1
+ /**
2
+ * @tsonic/core - Type Definitions
3
+ *
4
+ * TypeScript type aliases for CLR/.NET runtime primitives.
5
+ *
6
+ * IMPORTANT: These are simple type aliases with NO runtime enforcement.
7
+ * TypeScript treats all numeric types as `number`, bool as `boolean`, etc.
8
+ * Tsonic enforces semantic correctness at compile time via its proof system.
9
+ *
10
+ * TypeScript will NOT catch type errors between int/byte/long etc.
11
+ * Only Tsonic compilation validates numeric correctness.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * import { int, float, bool } from "@tsonic/core/types.js";
16
+ *
17
+ * const age: int = 42 as int; // Tsonic validates 42 fits in Int32
18
+ * const temp: float = 98.6 as float; // Tsonic validates for Single
19
+ * const isActive: bool = true; // bool is just boolean
20
+ * ```
21
+ */
22
+
23
+ // Signed integer types
24
+ export type sbyte = number; // System.SByte (-128 to 127)
25
+ export type short = number; // System.Int16 (-32,768 to 32,767)
26
+ export type int = number; // System.Int32 (-2,147,483,648 to 2,147,483,647)
27
+ export type long = number; // System.Int64 (approx -9.2e18 to 9.2e18)
28
+ export type nint = number; // System.IntPtr (native int)
29
+ export type int128 = number; // System.Int128 (128-bit signed)
30
+
31
+ // Unsigned integer types
32
+ export type byte = number; // System.Byte (0 to 255)
33
+ export type ushort = number; // System.UInt16 (0 to 65,535)
34
+ export type uint = number; // System.UInt32 (0 to 4,294,967,295)
35
+ export type ulong = number; // System.UInt64 (approx 0 to 1.8e19)
36
+ export type nuint = number; // System.UIntPtr (native uint)
37
+ export type uint128 = number; // System.UInt128 (128-bit unsigned)
38
+
39
+ // Floating-point types
40
+ export type half = number; // System.Half (16-bit float)
41
+ export type float = number; // System.Single (32-bit float)
42
+ export type double = number; // System.Double (64-bit float)
43
+ export type decimal = number; // System.Decimal (128-bit decimal)
44
+
45
+ // Other primitive types
46
+ export type bool = boolean; // System.Boolean
47
+ export type char = string; // System.Char (single UTF-16 code unit)
48
+ // Tsonic enforces char must be length-1 literal or proven conversion
49
+
50
+ // Pointer type
51
+ // Represents C# unsafe pointer types (T*, void*, int*, etc.)
52
+ // Erases to unknown for type safety - requires explicit handling
53
+ export type ptr<T> = unknown;
54
+
55
+ // NOTE: ref<T>, out<T>, In<T> have been removed.
56
+ // Parameter modifiers will be expressed via syntax, not types.
57
+ // See spec for forthcoming ref/out/in parameter syntax.