Rewrite your app in Rust, piece by piece, checked against the original at every step. Works with TypeScript, JavaScript, Python, Go, Ruby, Java, C, PHP, C#, Kotlin, PowerShell and Swift.
Rust agent-skillsclaude-codeclicode-migrationcodexffigolangjavajavascriptmcpmigrationnapiperformanceportingpyo3pythonrewriterubyrusttypescript
PowerShell: keep [decimal] and [uint64] parameters in PowerShell (#1370)
jakalijey3a5475cc784c
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex d0dcc1c2..9bab2003 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -221,6 +221,9 @@(#1337 by @jakalijey).from one JVM start to the next. `List.of`, `Collectors.toList`, and a `toMap` or `groupingBy`given a `TreeMap` or `LinkedHashMap` supplier are not (#1343 by @jakalijey).+- PowerShell: a parameter typed `[decimal]`, `[uint64]` or `[ulong]` keeps its function in+ PowerShell, with the reasons C# gives for the same types, instead of bridging it as `f64` or+ `i64`. `[uint32]`, `[double]` and `[single]` bridge as before (#1341 by @jakalijey).## 5.1.1 (2026-12-02)diff --git a/docs/types.md b/docs/types.mdindex 321fc128..51308ef5 100644--- a/docs/types.md+++ b/docs/types.md@@ -335,12 +335,14 @@ Types are read from the `[type]` before each parameter in `param()`, and the res| Source type | Port type | Notes ||---|---|---|| `[string]`, `[char]` | `String` | |-| `[int]`, `[long]`, `[byte]`, `[uint64]` | `i64` | |-| `[double]`, `[float]`, `[decimal]` | `f64` | |+| `[int]`, `[long]`, `[byte]`, `[uint32]` | `i64` | |+| `[double]`, `[float]`, `[single]` | `f64` | || `[bool]`, `[switch]` | `bool` | || `[string[]]` | `Vec<String>` | || `[array]`, `[object[]]` | `Vec<serde_json::Value>` | || `[hashtable]`, `[ordered]`, `[pscustomobject]`, `[object]` | `serde_json::Value` | |+| `[uint64]`, `[ulong]` | refused | wider than a JSON-safe integer |+| `[decimal]` | refused | a 128-bit decimal no JSON number keeps exactly || `[datetime]`, `[guid]` | refused | takes a .NET object || `[scriptblock]` | refused | takes a script block |diff --git a/src/lang/powershell.rs b/src/lang/powershell.rsindex a90df8d6..9c7556db 100644--- a/src/lang/powershell.rs+++ b/src/lang/powershell.rs@@ -541,8 +541,8 @@ pub fn ps_to_ts(t: &str) -> Option<String> {match lower {"string" | "char" => "string","int" | "int32" | "long" | "int64" | "int16" | "short" | "byte" | "sbyte"- | "uint16" | "ushort" | "uint32" | "uint" | "uint64" | "ulong" => "int",- "double" | "single" | "float" | "decimal" => "number",+ | "uint16" | "ushort" | "uint32" | "uint" => "int",+ "double" | "single" | "float" => "number","bool" | "boolean" | "switch" | "management.automation.switchparameter" => "boolean","array" | "object[]" | "collections.arraylist" => "unknown[]","hashtable"@@ -694,7 +694,14 @@ fn wildcard(pattern: &str, name: &str) -> bool {/// What keeps a parameter of type `t` in PowerShell, if anything.fn parameter_blocker(name: &str, t: &str) -> String {let lower = t.to_ascii_lowercase();- if lower == "scriptblock" || lower.ends_with(".scriptblock") {+ let element = lower.trim_end_matches("[]");+ let element = element.strip_prefix("system.").unwrap_or(element);+ // The reasons C# gives for the same .NET types.+ if matches!(element, "uint64" | "ulong") {+ format!("takes `${name}` (`[{t}]`), wider than a JSON-safe integer")+ } else if element == "decimal" {+ format!("takes `${name}` (`[{t}]`), a 128-bit decimal no JSON number keeps exactly")+ } else if lower == "scriptblock" || lower.ends_with(".scriptblock") {format!("takes a script block `${name}`")} else if lower == "ref" {format!("takes `${name}` by reference (`[ref]`)")@@ -1064,6 +1071,35 @@ mod tests {);assert_eq!(ps_to_ts("switch").as_deref(), Some("boolean"));assert_eq!(ps_to_ts("DateTime"), None);+ assert_eq!(ps_to_ts("decimal"), None);+ assert_eq!(ps_to_ts("System.UInt64"), None);+ assert_eq!(ps_to_ts("ulong"), None);+ assert_eq!(ps_to_ts("decimal[]"), None);+ assert_eq!(ps_to_ts("uint32").as_deref(), Some("int"));+ assert_eq!(ps_to_ts("double").as_deref(), Some("number"));+ assert_eq!(ps_to_ts("single").as_deref(), Some("number"));+ }++ #[test]+ fn decimal_and_uint64_stay_in_powershell_with_the_csharp_reasons() {+ let text = "function Add-Tax {\n param([decimal]$Amount, [decimal]$Rate)\n return $Amount * (1 + $Rate)\n}\n\nfunction Get-Next {\n param([uint64]$Id)\n return $Id + 1\n}\n\nfunction Get-Big {\n param([System.UInt64[]]$Ids)\n $Ids\n}\n\nfunction Get-Half {\n param([uint32]$N, [double]$X, [single]$Y)\n $N / 2\n}\n";+ let fns = exports("Money.psm1", text);+ assert_eq!(+ find(&fns, "Add-Tax").blocker.as_deref(),+ Some("takes `$Amount` (`[decimal]`), a 128-bit decimal no JSON number keeps exactly")+ );+ assert_eq!(+ find(&fns, "Get-Next").blocker.as_deref(),+ Some("takes `$Id` (`[uint64]`), wider than a JSON-safe integer")+ );+ assert_eq!(+ find(&fns, "Get-Big").blocker.as_deref(),+ Some("takes `$Ids` (`[System.UInt64[]]`), wider than a JSON-safe integer")+ );+ let half = find(&fns, "Get-Half");+ assert!(half.blocker.is_none(), "{:?}", half.blocker);+ let types: Vec<&str> = half.params.iter().map(|p| p.ts_type.as_str()).collect();+ assert_eq!(types, ["int", "number", "number"]);}#[test]