@inthedark/dxlint 0.1.14 → 0.1.17
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/README.md +16 -9
- package/bin/dxlint-darwin-arm64 +0 -0
- package/bin/dxlint-linux-x64 +0 -0
- package/bin/dxlint-win32-x64.exe +0 -0
- package/esbuild.mjs +134 -0
- package/package.json +20 -2
- package/rules/bugs.dx +1 -0
- package/std/ts/arithmetic.dx +10 -0
- package/std/ts/assertions.dx +56 -4
- package/std/ts/calls.dx +45 -15
- package/std/ts/conditions.dx +2 -0
- package/std/ts/constants.dx +2 -1
- package/std/ts/content-mapper.dx +48 -0
- package/std/ts/deprecation.dx +38 -18
- package/std/ts/effects.dx +8 -1
- package/std/ts/enums.dx +32 -4
- package/std/ts/format.dx +1 -1
- package/std/ts/grammar.dx +29 -15
- package/std/ts/import-no-deprecated.dx +4 -2
- package/std/ts/javascript.dx +496 -0
- package/std/ts/layout/literals.dx +14 -7
- package/std/ts/layout/separators.dx +6 -1
- package/std/ts/layout/shared.dx +36 -37
- package/std/ts/layout/types.dx +4 -0
- package/std/ts/literals.dx +1 -0
- package/std/ts/methods.dx +3 -0
- package/std/ts/modules.dx +60 -2
- package/std/ts/names.dx +30 -13
- package/std/ts/narrowing.dx +20 -14
- package/std/ts/parentheses.dx +27 -0
- package/std/ts/problems/control-flow.dx +1 -0
- package/std/ts/problems/numeric-precision.dx +1 -0
- package/std/ts/problems/regexp.dx +1 -0
- package/std/ts/regex/checks.dx +1 -0
- package/std/ts/regex/findings.dx +10 -6
- package/std/ts/regex/values.dx +4 -15
- package/std/ts/restrictions.dx +76 -0
- package/std/ts/scoping/member-uses.dx +5 -3
- package/std/ts/scoping/shadowing.dx +1 -0
- package/std/ts/scoping/usage.dx +3 -3
- package/std/ts/spreads.dx +1 -1
- package/std/ts/structure/padding.dx +10 -8
- package/std/ts/style/expressions.dx +8 -4
- package/std/ts/style/returns.dx +3 -1
- package/std/ts/style/signatures.dx +5 -0
- package/std/ts/style/type-exports.dx +1 -0
- package/std/ts/suggestions/builtins.dx +1 -1
- package/std/ts/suggestions/comparisons.dx +1 -0
- package/std/ts/suggestions/expressions.dx +1 -0
- package/std/ts/suggestions/object-spread.dx +1 -1
- package/std/ts/tokens.dx +14 -5
- package/std/ts/type-specifiers.dx +19 -3
- package/std/ts/typed/awaitability.dx +1 -0
- package/std/ts/typed/collection-iteration.dx +24 -0
- package/std/ts/typed/floating-promises.dx +45 -14
- package/std/ts/typed/includes.dx +3 -4
- package/std/ts/typed/promises.dx +16 -13
- package/std/ts/typed/readonly-parameters.dx +11 -2
- package/std/ts/typed/string-boundaries.dx +1 -0
- package/std/ts/typed/switches.dx +1 -0
- package/std/ts/typed/transfers.dx +54 -7
- package/std/ts/typed/type-arguments.dx +19 -20
- package/std/ts/typed/type-conversions.dx +1 -0
- package/std/ts/typed/type-parameters.dx +1 -1
- package/std/ts/typed/using-disposable.dx +98 -0
- package/std/ts/typed.dx +22 -9
- package/std/ts/values/arguments.dx +1 -1
- package/std/ts/values/enums.dx +5 -1
- package/std/ts/values/inspection.dx +26 -7
- package/std/ts/values.dx +98 -39
- package/std/ts.dx +10 -4
package/std/ts/values.dx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import .ts/javascript
|
|
1
2
|
import .ts/values/enums
|
|
2
3
|
import .ts/values/arguments
|
|
3
4
|
import .ts/values/inspection
|
|
@@ -11,8 +12,10 @@ define {
|
|
|
11
12
|
exclusive null, undefined, string, number, boolean, bigint, symbol, object
|
|
12
13
|
exclusive falsy, truthy
|
|
13
14
|
exclusive thenable, nonthenable
|
|
14
|
-
# TypeScript's `object` keyword takes every non-primitive: a shape
|
|
15
|
+
# TypeScript's `object` keyword takes every non-primitive: a shape is one,
|
|
16
|
+
# even `{}` (`{} extends object` holds; as a target `{}` still takes `"abc"`).
|
|
15
17
|
trait shaped implies object
|
|
18
|
+
trait structural implies object
|
|
16
19
|
trait array implies object
|
|
17
20
|
trait tuple implies object
|
|
18
21
|
trait callable implies object
|
|
@@ -42,7 +45,7 @@ in ts_namespace {
|
|
|
42
45
|
when !ts_value_namespace_runtime { unwraps unknown }
|
|
43
46
|
}
|
|
44
47
|
|
|
45
|
-
fn ts_value_key(key) = {
|
|
48
|
+
fn ts_value_key(key) = if key is ts_identifier && !contains(key.text, "\\") then key.text else {
|
|
46
49
|
value literal: if key is ts_computed_key then key.expression.node else key
|
|
47
50
|
value allowed: key not ts_computed_key || literal is (ts_string, ts_number, ts_bigint, ts_boolean, ts_null)
|
|
48
51
|
|| literal is ts_template && count(literal.expression.nodes) == 0
|
|
@@ -306,7 +309,11 @@ fn ts_value_nonthenable(n) = {
|
|
|
306
309
|
})
|
|
307
310
|
value if certain then true else {
|
|
308
311
|
value shape: ts_value_then_headers(member_call_parameters(n, "then"))
|
|
309
|
-
|
|
312
|
+
# No arm has a `then` at all (not even through an indexer).
|
|
313
|
+
value then_arms: value_lookup(n, "then").alternatives
|
|
314
|
+
value absent: then_arms != null && count(then_arms) > 0 && all(then_arms, arm => arm.matched == false)
|
|
315
|
+
value if parts == null || len(parts) == 0 then null else if absent then true
|
|
316
|
+
else if !shape.known then null else !shape.thenable
|
|
310
317
|
}
|
|
311
318
|
}
|
|
312
319
|
# Read from certain traits: `always any` stays unknown for an open type
|
|
@@ -327,9 +334,11 @@ in ts_null {
|
|
|
327
334
|
}
|
|
328
335
|
in ts_null { fits nonthenable }
|
|
329
336
|
in ts_boolean, ts_number, ts_bigint, ts_string { fits literal }
|
|
337
|
+
# Only a literal expression is fresh and widens; a written literal type
|
|
338
|
+
# (`(): true`, `x as 1`, inside `ts_literal_type`) keeps its literal.
|
|
330
339
|
in ts_boolean {
|
|
331
340
|
fits boolean
|
|
332
|
-
widens (trait boolean, truthy) | (trait boolean, falsy)
|
|
341
|
+
when parent not ts_literal_type { widens (trait boolean, truthy) | (trait boolean, falsy) }
|
|
333
342
|
fits falsy when text == "false"
|
|
334
343
|
fits truthy when text == "true"
|
|
335
344
|
identity text == "true"
|
|
@@ -338,21 +347,21 @@ in ts_number {
|
|
|
338
347
|
let ts_value_number_raw replace(text, "_", "")
|
|
339
348
|
let ts_value_number js_number(ts_value_number_raw)
|
|
340
349
|
fits number
|
|
341
|
-
widens (trait number, truthy) | (trait number, falsy)
|
|
350
|
+
when parent not ts_literal_type { widens (trait number, truthy) | (trait number, falsy) }
|
|
342
351
|
fits falsy when ts_value_number == 0
|
|
343
352
|
fits truthy when ts_value_number != 0
|
|
344
353
|
identity ts_value_number
|
|
345
354
|
}
|
|
346
355
|
in ts_bigint {
|
|
347
356
|
fits bigint
|
|
348
|
-
widens (trait bigint, truthy) | (trait bigint, falsy)
|
|
357
|
+
when parent not ts_literal_type { widens (trait bigint, truthy) | (trait bigint, falsy) }
|
|
349
358
|
fits falsy when js_bigint(text) == "0"
|
|
350
359
|
fits truthy when js_bigint(text) != "0"
|
|
351
360
|
identity { type: "bigint", value: js_bigint(text) }
|
|
352
361
|
}
|
|
353
362
|
in ts_string {
|
|
354
363
|
fits string
|
|
355
|
-
widens (trait string, truthy) | (trait string, falsy)
|
|
364
|
+
when parent not ts_literal_type { widens (trait string, truthy) | (trait string, falsy) }
|
|
356
365
|
fits falsy when js_string(text) == ""
|
|
357
366
|
fits truthy when js_string(text) != ""
|
|
358
367
|
identity js_string(text)
|
|
@@ -375,10 +384,18 @@ in ts_template {
|
|
|
375
384
|
}
|
|
376
385
|
in ts_regex { unwraps instance "RegExp" }
|
|
377
386
|
|
|
387
|
+
# `class X extends B<number>`: the heritage arguments sit on the class and
|
|
388
|
+
# instantiate the base its name reads.
|
|
389
|
+
in ts_identifier { when parent is ts_class && node == parent.extends.node { arguments parent.type_argument } }
|
|
378
390
|
in ts_identifier {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
391
|
+
# One answer for which recipe applies: an identifier's value asks once.
|
|
392
|
+
let ts_value_name_route when {
|
|
393
|
+
text == "undefined" && scope_declaration == null && contains(name_role_classes(node, "reference"), "value") then "undefined"
|
|
394
|
+
ts_value_missing_name(node, "value") then "unresolved"
|
|
395
|
+
ts_value_pattern_name != null then "pattern"
|
|
396
|
+
text == "arguments" && ts_value_implicit_arguments then "arguments"
|
|
397
|
+
else then "definition"
|
|
398
|
+
}
|
|
382
399
|
# A name a destructuring pattern binds takes the value that pattern gives
|
|
383
400
|
# it, not the declarator's whole value.
|
|
384
401
|
let ts_value_pattern_name if declaration != null
|
|
@@ -390,12 +407,12 @@ in ts_identifier {
|
|
|
390
407
|
then index_of(ts_value_pattern_name.parent.element.nodes, ts_value_pattern_name) else 0
|
|
391
408
|
let ts_value_pattern_any ts_value_pattern_name != null && ts_value_pattern_name.parent is ts_array_pattern
|
|
392
409
|
&& ts_value_has_trait(ts_value_pattern_name.parent.node, "any") == true
|
|
393
|
-
when
|
|
410
|
+
when ts_value_name_route == "undefined" {
|
|
394
411
|
fits undefined, nullable, falsy, nonthenable
|
|
395
412
|
identity { type: "undefined" }
|
|
396
413
|
}
|
|
397
|
-
when
|
|
398
|
-
when
|
|
414
|
+
when ts_value_name_route == "unresolved" { fits any, error open }
|
|
415
|
+
when ts_value_name_route == "pattern" {
|
|
399
416
|
when ts_value_pattern_any { unwraps ts_value_pattern_name.parent }
|
|
400
417
|
when ts_value_pattern_name.parent is ts_array_pattern && !ts_value_pattern_any {
|
|
401
418
|
unwraps ts_value_pattern_name.parent.[ts_value_pattern_slot]
|
|
@@ -404,7 +421,7 @@ in ts_identifier {
|
|
|
404
421
|
unwraps ts_value_pattern_name.parent
|
|
405
422
|
}
|
|
406
423
|
}
|
|
407
|
-
when
|
|
424
|
+
when ts_value_name_route == "definition" {
|
|
408
425
|
unwraps definition
|
|
409
426
|
widens definition.widened
|
|
410
427
|
}
|
|
@@ -547,10 +564,17 @@ in ts_assignment_pattern {
|
|
|
547
564
|
when parent is ts_pattern_property && !ts_value_assignment_any { unwraps (parent.parent.[ts_value_assignment_key]) \ undefined | right.widened }
|
|
548
565
|
when parent not (ts_array_pattern, ts_pattern_property) { unwraps left ?? right }
|
|
549
566
|
}
|
|
550
|
-
in ts_import, ts_import_specifier, ts_meta_property
|
|
567
|
+
in ts_import, ts_import_specifier, ts_meta_property {
|
|
551
568
|
unwraps unknown
|
|
552
569
|
}
|
|
570
|
+
# A promise of the module's namespace (`await import("./m")`).
|
|
571
|
+
in ts_import_call {
|
|
572
|
+
when ts_module_dynamic_source != null { unwraps instance "Promise" of definition }
|
|
573
|
+
when ts_module_dynamic_source == null { unwraps unknown }
|
|
574
|
+
}
|
|
553
575
|
in ts_import_equals { when value.node is ts_call { unwraps unknown } }
|
|
576
|
+
# `import Box = ns.Box; Box<number>`: the reference's arguments pass through the alias.
|
|
577
|
+
in ts_import_equals { when value.node not ts_call { arguments through.type_argument } }
|
|
554
578
|
in ts_super {
|
|
555
579
|
let ts_value_super_context ts_value_this_context(node)
|
|
556
580
|
let ts_value_super_base ts_value_super_context.container.extends.node
|
|
@@ -584,7 +608,9 @@ in ts_this {
|
|
|
584
608
|
}
|
|
585
609
|
}
|
|
586
610
|
|
|
587
|
-
in ts_parenthesized, ts_satisfies
|
|
611
|
+
in ts_parenthesized, ts_satisfies { unwraps expression }
|
|
612
|
+
# `take<Callback>`: `take`'s signature with `T` fixed (no inference at calls).
|
|
613
|
+
in ts_instantiation { unwraps instantiate expression with type_argument }
|
|
588
614
|
in ts_as, ts_type_assertion {
|
|
589
615
|
when type.text == "const" { unwraps expression }
|
|
590
616
|
when type.text != "const" { unwraps type }
|
|
@@ -743,8 +769,20 @@ in ts_object {
|
|
|
743
769
|
let ts_value_any_spreads filter(property.nodes, item => item is ts_spread && item.argument always any)
|
|
744
770
|
when len(ts_value_any_spreads) > 0 { unwraps ...ts_value_any_spreads.argument }
|
|
745
771
|
when len(ts_value_any_spreads) == 0 { unwraps scope members from it }
|
|
772
|
+
# Spread members under the own ones; of two spreads, the later wins.
|
|
773
|
+
let ts_value_spread_sources reverse(filter(property.nodes, item => item is ts_spread))
|
|
774
|
+
let ts_value_last_spread first(ts_value_spread_sources)
|
|
775
|
+
let ts_value_earlier_spreads slice(ts_value_spread_sources, 1)
|
|
776
|
+
when ts_value_last_spread != null { members members inherits ts_value_last_spread.argument }
|
|
777
|
+
when len(ts_value_earlier_spreads) > 0 { members members inherits &...ts_value_earlier_spreads.argument }
|
|
746
778
|
}
|
|
747
779
|
in ts_object { fits object, truthy in members }
|
|
780
|
+
# `{ [Symbol.dispose]() {} }`: a computed key is keyed by its value (a real symbol).
|
|
781
|
+
in ts_object {
|
|
782
|
+
let ts_value_object_computed filter(property.nodes, item => item is (ts_property, ts_method)
|
|
783
|
+
&& item.key is ts_computed_key && ts_value_key(item.key.node) == null)
|
|
784
|
+
indexed keyed ts_value_object_computed by key.expression using it in members
|
|
785
|
+
}
|
|
748
786
|
in ts_interface {
|
|
749
787
|
when extends != null { members members inherits &...extends }
|
|
750
788
|
fits builtin_function in members when
|
|
@@ -816,16 +854,16 @@ fn ts_value_optional_member(n, key) = value_member_optional(n.object.node, key)
|
|
|
816
854
|
in ts_member {
|
|
817
855
|
refers object.[ts_value_member_key]
|
|
818
856
|
let ts_value_member_key ts_value_key(property.node)
|
|
819
|
-
let ts_value_member_nullish in_optional_chain == true && object could nullable
|
|
820
|
-
|| ts_value_optional_member(node, ts_value_member_key)
|
|
821
857
|
# `always any` stays open for a type parameter; one whose parts are
|
|
822
858
|
# certainly not `any` (its constraint's) reads its members.
|
|
823
|
-
let
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
when ts_value_member_nullish { unwraps (object \ null, undefined).[ts_value_member_key] | trait undefined, nullable, falsy, nonthenable }
|
|
859
|
+
let ts_value_member_route when {
|
|
860
|
+
ts_value_has_trait(object.node, "any") != false && object always any then "any"
|
|
861
|
+
in_optional_chain == true && object could nullable || ts_value_optional_member(node, ts_value_member_key) then "nullish"
|
|
862
|
+
else then "plain"
|
|
828
863
|
}
|
|
864
|
+
when ts_value_member_route == "any" { unwraps object }
|
|
865
|
+
when ts_value_member_route == "plain" { unwraps (object \ null, undefined).[ts_value_member_key] }
|
|
866
|
+
when ts_value_member_route == "nullish" { unwraps (object \ null, undefined).[ts_value_member_key] | trait undefined, nullable, falsy, nonthenable }
|
|
829
867
|
}
|
|
830
868
|
fn ts_value_unchecked_index(n) = {
|
|
831
869
|
value lookup: value_lookup(n.object.node, n.index.node)
|
|
@@ -841,8 +879,10 @@ in ts_index {
|
|
|
841
879
|
let ts_value_index_nullish in_optional_chain == true && object could nullable
|
|
842
880
|
|| ts_value_optional_member(node, index.node)
|
|
843
881
|
|| (if ts_compiler_option(node, "noUncheckedIndexedAccess") == true then ts_value_unchecked_index(node) else false)
|
|
844
|
-
|
|
845
|
-
|
|
882
|
+
# As for `ts_member`: a type parameter whose parts are certainly not `any` reads its indexes.
|
|
883
|
+
let ts_value_index_dynamic ts_value_has_trait(object.node, "any") != false && object always any
|
|
884
|
+
when ts_value_index_dynamic { unwraps object }
|
|
885
|
+
when !ts_value_index_dynamic {
|
|
846
886
|
when !ts_value_index_nullish { unwraps (object \ nullable, undefined).[index] }
|
|
847
887
|
when ts_value_index_nullish { unwraps (object \ nullable, undefined).[index] | trait undefined, nullable, falsy, nonthenable }
|
|
848
888
|
}
|
|
@@ -874,6 +914,11 @@ in ts_class {
|
|
|
874
914
|
members statics inherits extends
|
|
875
915
|
members members inherits extends.["prototype"]
|
|
876
916
|
}
|
|
917
|
+
# A base class is a function too (`C.name`, `C.length`).
|
|
918
|
+
# (A program without that global has no such layer.)
|
|
919
|
+
when extends == null && count(global_declarations(node, "Function", "type") ?? []) > 0 {
|
|
920
|
+
members statics inherits instance "Function"
|
|
921
|
+
}
|
|
877
922
|
# An interface of the same name merges into the instance (`implements`
|
|
878
923
|
# adds nothing).
|
|
879
924
|
let ts_value_merged_interfaces if name == null then [] else
|
|
@@ -892,6 +937,8 @@ in ts_parameter {
|
|
|
892
937
|
}
|
|
893
938
|
}
|
|
894
939
|
in ts_property { flag readonly when ts_value_const_context(node) }
|
|
940
|
+
# `{ old: 1, ...a }`: a later spread's member of the same key wins.
|
|
941
|
+
in ts_property { flag yields when parent is ts_object && any(parent.property.nodes, item => item is ts_spread && item.offset > offset) }
|
|
895
942
|
in ts_property_signature, ts_index_signature, ts_class_property, ts_parameter {
|
|
896
943
|
flag readonly when any([] modifier, modifier => modifier == "readonly")
|
|
897
944
|
}
|
|
@@ -937,29 +984,40 @@ in ts_class, ts_interface {
|
|
|
937
984
|
fits truthy in members
|
|
938
985
|
}
|
|
939
986
|
}
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
#
|
|
944
|
-
|
|
945
|
-
value
|
|
946
|
-
|
|
947
|
-
value remote: map(filter(value_sources(name.node).sites ?? [], site => contains(["ts_class", "ts_interface", "ts_type_alias"], site.kind)),
|
|
948
|
-
site => map(site_field(node, site, "type_parameter") ?? [], parameter => count(site_field(node, parameter, "default") ?? []) > 0))
|
|
987
|
+
fn ts_value_name_needs_arguments(n) = {
|
|
988
|
+
value local: map(filter(name_binding(n).declarations ?? [], item => item.parent is (ts_class, ts_interface, ts_type_alias)),
|
|
989
|
+
item => map(item.parent.type_parameter.nodes, parameter => parameter.default != null))
|
|
990
|
+
# A plain local declaration settles it: merged declarations share parameters.
|
|
991
|
+
value if count(local) > 0 && all(local, parameters => count(parameters) == 0) then false else {
|
|
992
|
+
value remote: map(filter(value_sources(n).sites ?? [], site => contains(["ts_class", "ts_interface", "ts_type_alias"], site.kind)),
|
|
993
|
+
site => map(site_field(n, site, "type_parameter") ?? [], parameter => count(site_field(n, parameter, "default") ?? []) > 0))
|
|
949
994
|
value declarations: flat_map([local, remote], group => group)
|
|
950
995
|
value any(declarations, parameters => any(parameters, (parameter, index) =>
|
|
951
996
|
all(declarations, other => !any(other, (defaulted, at) => at == index && defaulted))))
|
|
952
997
|
}
|
|
998
|
+
}
|
|
999
|
+
in ts_identifier let ts_value_needs_arguments ts_value_name_needs_arguments(node)
|
|
1000
|
+
in ts_type_reference {
|
|
1001
|
+
# `Promise` without its required arguments is an error type, read as any.
|
|
1002
|
+
# Merged declarations share their parameters: one declaring a default is enough.
|
|
1003
|
+
let ts_value_reference_error name is ts_identifier && (ts_value_missing_name(name.node, "type")
|
|
1004
|
+
|| count(type_argument.nodes) == 0 && {
|
|
1005
|
+
# Asked of the name's declaration in this file: every use agrees.
|
|
1006
|
+
value bound: name.node.scope_declaration
|
|
1007
|
+
value if bound is ts_identifier then bound.ts_value_needs_arguments else ts_value_name_needs_arguments(name.node)
|
|
1008
|
+
})
|
|
953
1009
|
arguments type_argument
|
|
954
|
-
when
|
|
1010
|
+
when ts_value_reference_error { fits any, error open }
|
|
955
1011
|
when name is ts_qualified_name { unwraps name }
|
|
956
|
-
when !
|
|
1012
|
+
when !ts_value_reference_error && name not ts_qualified_name { unwraps &...name.definition }
|
|
957
1013
|
}
|
|
958
1014
|
in ts_type_query {
|
|
959
1015
|
# `typeof f<T>` instantiates `f`'s own type parameters.
|
|
960
1016
|
arguments type_argument
|
|
961
1017
|
when name is ts_qualified_name { unwraps name }
|
|
962
|
-
when name not ts_qualified_name { unwraps name.definition }
|
|
1018
|
+
when name not ts_qualified_name && count(type_argument.nodes) == 0 { unwraps name.definition }
|
|
1019
|
+
# A value whose type is generic (`declare const take: <T>(fn: T) => T`) too.
|
|
1020
|
+
when name not ts_qualified_name && count(type_argument.nodes) > 0 { unwraps instantiate name.definition with type_argument }
|
|
963
1021
|
}
|
|
964
1022
|
in ts_type_predicate {
|
|
965
1023
|
carries as {
|
|
@@ -1000,14 +1058,12 @@ in ts_literal_type {
|
|
|
1000
1058
|
when !starts_with(text, "-") { unwraps value }
|
|
1001
1059
|
when starts_with(text, "-") && value is ts_number {
|
|
1002
1060
|
fits number, literal
|
|
1003
|
-
widens (trait number, truthy) | (trait number, falsy)
|
|
1004
1061
|
fits falsy when value always falsy
|
|
1005
1062
|
fits truthy when value always truthy
|
|
1006
1063
|
identity -value.ts_value_number
|
|
1007
1064
|
}
|
|
1008
1065
|
when starts_with(text, "-") && value is ts_bigint {
|
|
1009
1066
|
fits bigint, literal
|
|
1010
|
-
widens (trait bigint, truthy) | (trait bigint, falsy)
|
|
1011
1067
|
fits falsy when value always falsy
|
|
1012
1068
|
fits truthy when value always truthy
|
|
1013
1069
|
identity { type: "bigint", value: ts_value_negated_bigint(value.text) }
|
|
@@ -1194,6 +1250,9 @@ in ts_type_keyword {
|
|
|
1194
1250
|
fits falsy when ts_value_intrinsic_formal always falsy
|
|
1195
1251
|
}
|
|
1196
1252
|
}
|
|
1253
|
+
# The `this` type (`on(): this`) is the receiver of the call reading the
|
|
1254
|
+
# signature (`store.on(1)`: `store`'s type); elsewhere it stays unknown.
|
|
1255
|
+
when text == "this" { unwraps through.callee.object }
|
|
1197
1256
|
when text == "string" { unwraps (trait string, truthy) | (trait string, falsy) }
|
|
1198
1257
|
when text == "number" { unwraps (trait number, truthy) | (trait number, falsy) }
|
|
1199
1258
|
when text == "boolean" { unwraps (trait boolean, truthy) | (trait boolean, falsy) }
|
package/std/ts.dx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# .ts: JavaScript and TypeScript.
|
|
2
|
-
# every node kind is a `ts_*` layer with ESTree-style fields
|
|
3
|
-
# `ts_call.callee`, `ts_binary.operator`); `dxlint tree file.ts`
|
|
4
|
-
# Textual parts (comments, lines) are pattern layers in the same tree.
|
|
1
|
+
# .ts: JavaScript and TypeScript. The `ts` parser (`.ts/grammar`) owns the
|
|
2
|
+
# syntax: every node kind is a `ts_*` layer with ESTree-style fields
|
|
3
|
+
# (`ts_if.test`, `ts_call.callee`, `ts_binary.operator`); `dxlint tree file.ts`
|
|
4
|
+
# shows them. Textual parts (comments, lines) are pattern layers in the same tree.
|
|
5
5
|
#
|
|
6
6
|
# Brings every JS/TS rule definition, all off: turn on what you want with
|
|
7
7
|
# `rule name` lines, or a ruleset (`import rules:recommended`).
|
|
@@ -15,8 +15,14 @@ language .js {
|
|
|
15
15
|
option sourceType "script" | "module" | "commonjs" | null = null "Root source environment; null infers it from syntax and filename."
|
|
16
16
|
option impliedStrict boolean | null = null "Strict code without an explicit directive."
|
|
17
17
|
option globalReturn boolean | null = null "Wrap script declarations in a function scope, without CommonJS globals."
|
|
18
|
+
option jsx boolean = false "JSX syntax (on for .tsx and .jsx files)."
|
|
19
|
+
}
|
|
20
|
+
language .js {
|
|
21
|
+
files "*.tsx" "*.jsx"
|
|
22
|
+
set jsx true
|
|
18
23
|
}
|
|
19
24
|
|
|
25
|
+
import .ts/grammar
|
|
20
26
|
native ts
|
|
21
27
|
|
|
22
28
|
group ts_function_like ts_function, ts_arrow, ts_method
|