Skip to content

std: survey and reduce untyped usage (1066 → 1025)#12850

Draft
Copilot wants to merge 2 commits intodevelopmentfrom
copilot/reduce-untyped-usage
Draft

std: survey and reduce untyped usage (1066 → 1025)#12850
Copilot wants to merge 2 commits intodevelopmentfrom
copilot/reduce-untyped-usage

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 20, 2026

Browsed std/ for all 1066 untyped occurrences, categorized them, and eliminated 41 that were genuinely unnecessary.

Categories found

Category Count Removable?
Magic compiler identifiers (__define_feature__, __feature__, __resources__) ~35 No — compiler built-ins
Platform inline code injection (__lua__, __dollar__, __global__, __lock__, etc.) ~300 No — platform magic
Compiler-generated runtime metadata (__class__, __enum__, __name__, _hx_index, etc.) ~154 Mostly no
Platform-specific internal representations (.__s, .cca(), __unsafe_get, etc.) ~200 No — intrinsic to target
untyped { } blocks ~142 Mostly no; some redundant nesting
Dynamic field/index access ~50 Some — see fixes
Bare global function calls ~50 JS ones — see fixes
Constructor access bypass ~20 Yes — use @:privateAccess
Private method access ~10 Yes — use @:access(Class)

Changes made

JS global functions → js.Lib.global.*

untyped console, untyped setTimeout, untyped setInterval, untyped clearInterval, untyped encodeURIComponent, untyped decodeURIComponent replaced with js.Lib.global.* calls in Log.hx, Timer.hx, EntryPoint.hx, StringTools.hx.

Dynamic field access → typed alternatives

  • untyped this[key] / untyped this[key] = value in DynamicAccess.hxjs.Syntax.code("{0}[{1}]", ...)
  • untyped obj.__id__ / untyped h[id] in ObjectMap.hx (JS) → js.Syntax.code
  • untyped t.__meta__ in Meta.hxt.__meta__ (t is already Dynamic)
  • untyped o.toString inside outer untyped {} in Boot.hx (JS) → redundant untyped removed
  • untyped s == null ? "null" : s.toString() in Std.hx (CPP) → direct call on Dynamic
  • untyped Array.prototype.slice.call(...) in Reflect.hx (JS) → js.Syntax.code("Array.prototype.slice.call(arguments)")
  • untyped js.Lib.document.selection.createRange() in Selection.hx(js.Lib.document : Dynamic).selection...
  • untyped d.toGMTString() in Cookie.hx(d : Dynamic).toGMTString()

Constructor access → @:privateAccess

untyped new FileInput/FileOutput(...) in cpp/_std/sys/io/File.hx, php/_std/sys/io/File.hx, neko/_std/Sys.hx replaced with @:privateAccess new.

Private method access → @:access

untyped lua.Boot.__instanceof(v, t) and untyped neko.Boot.__instanceof(v, t) in Std.hx replaced with @:access(lua.Boot) / @:access(neko.Boot) annotations (consistent with how JS already does @:privateAccess js.Boot.__instanceof).

JVM typed casts

untyped s.hashCode() / untyped k.equals(get()) in WeakMap.hx replaced with (cast s : java.lang.Object).hashCode() etc.

Misc

  • untyped cur.substring(...) in JVM EReg.hx (String.substring is standard — untyped was just historical baggage)
  • untyped Math.imul in Int32.hx(cast Math : Dynamic).imul with if/else for clarity
  • untyped { } wrapper in ArrayBuffer.hx IE10 polyfill removed (body only uses js.Syntax.code)
  • untyped x <= 0 ? 0 : Math.floor(...) in Lua Std.random → typed (both branches are Int)

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…d alternatives

Co-authored-by: Simn <634365+Simn@users.noreply.github.com>
Copilot AI changed the title [WIP] Categorize and reduce occurrences of untyped in std std: survey and reduce untyped usage (1066 → 1025) Mar 20, 2026
Copilot AI requested a review from Simn March 20, 2026 15:57
Copilot finished work on behalf of Simn March 20, 2026 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants