@ttsc/wasm 0.15.5 → 0.15.6
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/dist/ttsc.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttsc/wasm",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.6",
|
|
4
4
|
"description": "Build in-browser ttsc playgrounds. Compose ttsc + typescript-go with your own plugins via the Go host helper.",
|
|
5
5
|
"main": "lib/src/index.js",
|
|
6
6
|
"types": "lib/src/index.d.ts",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"homepage": "https://ttsc.dev",
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/node": "^25.3.0",
|
|
41
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
41
|
+
"@typescript/native-preview": "7.0.0-dev.20260617.2",
|
|
42
42
|
"rimraf": "^6.1.2"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
@@ -225,3 +225,104 @@ func Checker_getMinArgumentCount(recv *innerchecker.Checker, signature *innerche
|
|
|
225
225
|
}
|
|
226
226
|
return checkerGetMinArgumentCount(recv, signature)
|
|
227
227
|
}
|
|
228
|
+
|
|
229
|
+
// Checker_getSignaturesOfType returns the call or construct signatures declared
|
|
230
|
+
// on t, selected by kind (SignatureKindCall / SignatureKindConstruct). This is
|
|
231
|
+
// the producer companion to Checker_getMinArgumentCount and
|
|
232
|
+
// Checker_getReturnTypeOfSignature: without it the *Signature those two consume
|
|
233
|
+
// could not be obtained. A type-transform plugin uses the construct signatures
|
|
234
|
+
// of a class's constructor type to detect the `new C(x)` strategy and the call
|
|
235
|
+
// signatures of a static `from` member to detect the `C.from(x)` strategy.
|
|
236
|
+
// Returns nil if recv or t is nil.
|
|
237
|
+
func Checker_getSignaturesOfType(recv *innerchecker.Checker, t *innerchecker.Type, kind innerchecker.SignatureKind) []*innerchecker.Signature {
|
|
238
|
+
if recv == nil || t == nil {
|
|
239
|
+
return nil
|
|
240
|
+
}
|
|
241
|
+
return recv.GetSignaturesOfType(t, kind)
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// Checker_getReturnTypeOfSignature returns the return type of signature, used to
|
|
245
|
+
// verify that a static `from(x)` factory actually returns the class instance
|
|
246
|
+
// type before selecting the `C.from(x)` construction strategy. Returns nil if
|
|
247
|
+
// recv or signature is nil.
|
|
248
|
+
func Checker_getReturnTypeOfSignature(recv *innerchecker.Checker, signature *innerchecker.Signature) *innerchecker.Type {
|
|
249
|
+
if recv == nil || signature == nil {
|
|
250
|
+
return nil
|
|
251
|
+
}
|
|
252
|
+
return recv.GetReturnTypeOfSignature(signature)
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// Signature_parameterCount returns the number of declared value parameters of a
|
|
256
|
+
// call/construct signature. A rest parameter counts as one and the `this`
|
|
257
|
+
// parameter is excluded (it is held separately from the value parameters).
|
|
258
|
+
//
|
|
259
|
+
// Checker_getMinArgumentCount alone cannot tell a zero-parameter signature
|
|
260
|
+
// (`()` — minimum 0) from a single-optional-parameter one (`(x?)` — also
|
|
261
|
+
// minimum 0). A type-transform plugin needs that distinction to replicate the
|
|
262
|
+
// type-level "single meaningful argument" rule — a FIRST parameter must exist
|
|
263
|
+
// and every later parameter must be optional or rest — as
|
|
264
|
+
// `Signature_parameterCount(sig) >= 1 && Checker_getMinArgumentCount(c, sig) <= 1`.
|
|
265
|
+
// Without it the `new C(x)` / `C.from(x)` strategies silently fall back to field
|
|
266
|
+
// copy for every optional-first constructor or factory. Returns 0 if signature
|
|
267
|
+
// is nil.
|
|
268
|
+
func Signature_parameterCount(signature *innerchecker.Signature) int {
|
|
269
|
+
if signature == nil {
|
|
270
|
+
return 0
|
|
271
|
+
}
|
|
272
|
+
return len(signature.Parameters())
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// Signature_parameters returns the declared value-parameter symbols of a
|
|
276
|
+
// call/construct signature, in declaration order, excluding the synthetic
|
|
277
|
+
// `this` parameter. The first element is the seed parameter of a `new C(seed)`
|
|
278
|
+
// constructor or a `C.from(seed)` factory; feeding it to Checker_getTypeOfSymbol
|
|
279
|
+
// yields the seed TYPE the plugin must decode before constructing the instance.
|
|
280
|
+
//
|
|
281
|
+
// Signature_parameterCount is len() of this slice; the slice itself is needed
|
|
282
|
+
// because detection (count + min-args) is not enough — emission requires the
|
|
283
|
+
// seed parameter's type. Returns nil if signature is nil.
|
|
284
|
+
func Signature_parameters(signature *innerchecker.Signature) []*innerast.Symbol {
|
|
285
|
+
if signature == nil {
|
|
286
|
+
return nil
|
|
287
|
+
}
|
|
288
|
+
return signature.Parameters()
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// Signature_hasRestParameter reports whether the signature's last value
|
|
292
|
+
// parameter is a rest parameter (`...xs: S[]`). It is the signal a from/new
|
|
293
|
+
// transform needs to tell a rest-only single-seed call `(...xs: S[])` — whose
|
|
294
|
+
// seed is the ELEMENT S — from a genuine array-typed parameter `(seed: S[])` —
|
|
295
|
+
// whose seed is the array S[]: getTypeOfSymbol yields `S[]` for BOTH, so without
|
|
296
|
+
// this flag they are indistinguishable and the rest case decodes the wrong
|
|
297
|
+
// shape.
|
|
298
|
+
//
|
|
299
|
+
// The rest ELEMENT is the seed ONLY when the rest parameter is the sole value
|
|
300
|
+
// parameter, i.e. `Signature_hasRestParameter(sig) && Signature_parameterCount(sig) == 1`.
|
|
301
|
+
// A leading-required + rest-tail signature `(s: S, ...r: R[])` also has a rest
|
|
302
|
+
// parameter (this returns true), but its seed is the FIRST parameter S — read it
|
|
303
|
+
// from Signature_parameters(sig)[0], NOT the rest element — matching
|
|
304
|
+
// ClassifiableSeed, whose `[infer P, ...Rest]` arm picks P=S there. Returns
|
|
305
|
+
// false if signature is nil.
|
|
306
|
+
func Signature_hasRestParameter(signature *innerchecker.Signature) bool {
|
|
307
|
+
if signature == nil {
|
|
308
|
+
return false
|
|
309
|
+
}
|
|
310
|
+
return signature.HasRestParameter()
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// Checker_getRestTypeOfSignature returns the ELEMENT type of the signature's
|
|
314
|
+
// rest parameter (`...xs: S[]` -> S; a tuple rest unwraps to its element too),
|
|
315
|
+
// which is the seed type for a rest-ONLY single-argument constructor/factory —
|
|
316
|
+
// matching ClassifiableSeed, which unwraps the rest to its element. When the
|
|
317
|
+
// signature has NO rest parameter it falls back to `any` upstream; and a
|
|
318
|
+
// leading-required + rest-tail `(s: S, ...r: R[])` has a rest parameter yet its
|
|
319
|
+
// seed is the FIRST parameter S, not the rest element. So take the rest element
|
|
320
|
+
// only when `Signature_hasRestParameter(sig) && Signature_parameterCount(sig) == 1`;
|
|
321
|
+
// otherwise read Signature_parameters(sig)[0]. Returns nil if recv or signature
|
|
322
|
+
// is nil.
|
|
323
|
+
func Checker_getRestTypeOfSignature(recv *innerchecker.Checker, signature *innerchecker.Signature) *innerchecker.Type {
|
|
324
|
+
if recv == nil || signature == nil {
|
|
325
|
+
return nil
|
|
326
|
+
}
|
|
327
|
+
return recv.GetRestTypeOfSignature(signature)
|
|
328
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
package checker
|
|
2
|
+
|
|
3
|
+
// Compile-time guard: the signature-introspection surface that typia's
|
|
4
|
+
// plain.classify from/new construction-strategy detection depends on must
|
|
5
|
+
// compose end-to-end through the shim.
|
|
6
|
+
//
|
|
7
|
+
// 0.15.5 exposed a CONSUMER of a *Signature (Checker_getMinArgumentCount)
|
|
8
|
+
// without the PRODUCER that yields one (Checker_getSignaturesOfType): a
|
|
9
|
+
// *Signature was nameable (the `Signature` alias) but unobtainable. The closure
|
|
10
|
+
// auditor checks that every escaping type can be NAMED, not that it can be
|
|
11
|
+
// PRODUCED, so it did not catch the gap and the feature stayed blocked.
|
|
12
|
+
//
|
|
13
|
+
// This lives in a NORMAL (non-_test) file on purpose. The shim/checker package
|
|
14
|
+
// is a nested Go module that no CI job runs `go test` against, so a _test.go
|
|
15
|
+
// guard would never be compiled and would silently stop guarding. As ordinary
|
|
16
|
+
// package code it is type-checked by every build that links the shim (typia's
|
|
17
|
+
// native plugin, ttsc's lint engine), so dropping or renaming any leg below
|
|
18
|
+
// turns those builds red. It never runs (assigned to blank, never called).
|
|
19
|
+
var _ = func(c *Checker, instanceType *Type) {
|
|
20
|
+
// class instance type -> class symbol -> constructor (static) type, which
|
|
21
|
+
// carries both the construct signatures and the static `from` member.
|
|
22
|
+
classSymbol := Type_getTypeNameSymbol(instanceType)
|
|
23
|
+
ctorType := Checker_getTypeOfSymbol(c, classSymbol)
|
|
24
|
+
|
|
25
|
+
// `new C(seed)` strategy: construct signatures -> arity (min args +
|
|
26
|
+
// parameter count, together disambiguating `()` from `(x?)`) -> return type
|
|
27
|
+
// -> the seed parameter's type. The seed is Signature_parameters[0]'s type,
|
|
28
|
+
// EXCEPT a rest-ONLY parameter `(...xs: S[])` — when
|
|
29
|
+
// `hasRestParameter && parameterCount == 1` — whose seed is the rest ELEMENT
|
|
30
|
+
// (getRestTypeOfSignature). A leading-required + rest-tail `(s, ...r)` still
|
|
31
|
+
// has hasRestParameter true but its seed is the first parameter S.
|
|
32
|
+
for _, sig := range Checker_getSignaturesOfType(c, ctorType, SignatureKindConstruct) {
|
|
33
|
+
_ = Checker_getMinArgumentCount(c, sig)
|
|
34
|
+
_ = Signature_parameterCount(sig)
|
|
35
|
+
_ = Checker_getReturnTypeOfSignature(c, sig)
|
|
36
|
+
if Signature_hasRestParameter(sig) {
|
|
37
|
+
_ = Checker_getRestTypeOfSignature(c, sig)
|
|
38
|
+
}
|
|
39
|
+
for _, p := range Signature_parameters(sig) {
|
|
40
|
+
_ = Checker_getTypeOfSymbol(c, p)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// `C.from(seed)` strategy: static `from` member -> its call signatures, read
|
|
45
|
+
// identically (arity, return type, seed parameter / rest element type).
|
|
46
|
+
fromType := Checker_getTypeOfPropertyOfType(c, ctorType, "from")
|
|
47
|
+
for _, sig := range Checker_getSignaturesOfType(c, fromType, SignatureKindCall) {
|
|
48
|
+
_ = Checker_getMinArgumentCount(c, sig)
|
|
49
|
+
_ = Signature_parameterCount(sig)
|
|
50
|
+
_ = Checker_getReturnTypeOfSignature(c, sig)
|
|
51
|
+
if Signature_hasRestParameter(sig) {
|
|
52
|
+
_ = Checker_getRestTypeOfSignature(c, sig)
|
|
53
|
+
}
|
|
54
|
+
for _, p := range Signature_parameters(sig) {
|
|
55
|
+
_ = Checker_getTypeOfSymbol(c, p)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|