-
Notifications
You must be signed in to change notification settings - Fork 16
/
tsd.node.txt
111 lines (81 loc) · 6.55 KB
/
tsd.node.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
TSD
ALTERNATIVES ==> # - tsd (preferred)
# - ts-expect: fewer features
# - deno test types
# - fewer features
# - preferred with Deno unless need more features
VERSION ==> #0.31.0
GOAL ==> #Automated testing of TypeScript typing
STATIC ANALYSIS ==> #The type files are not run, but only parsed statically.
#It looks for expect*<TYPE>(...) expressions.
LINTING ==> #Also lints:
# - PACKAGE.types is used, not PACKAGE.typings
# - PACKAGE.files contains OPTS.typingsFile
TOP-LEVEL AWAIT ==> #Can be used
/=+===============================+=\
/ : : \
)==: MAIN :==(
\ :_______________________________: /
\=+===============================+=/
tsd [DIR] #DIR is OPTS.cwd
TSD(OPTS)->PROMISE_ARR_DIAGNOSTIC #Programmatic usage.
DIAGNOSTIC #Error|warning instance
/=+===============================+=\
/ : : \
)==: CONFIG :==(
\ :_______________________________: /
\=+===============================+=/
OPTS #Can only be specified programmatically, except OPTS.cwd
TSD_CONF #Specified at PACKAGE.tsd
tsconfig.json #Is used, but with defaults:
# --strict
# --lib=es2017|dom|dom.iterable
# --target=es2017
# --module=commonjs
# --moduleResolution: 'nodenext|node16' (if --module=nodenext|node16), 'node' otherwise
# --esModuleIterop
# --jsx=react
#Can also be overridden by using any TSD_CONF.compilerOptions.*
OPTS.showDiff
--showDiff #Print actual vs expected TYPEs
/=+===============================+=\
/ : : \
)==: FILES :==(
\ :_______________________________: /
\=+===============================+=/
OPTS.testFiles #'GLOB'_ARR of *.test-d.ts[x] files
--files|-f #Def:
# - OPTS.typingsFile, but with *.test-d.ts[x] instead of *.d.ts
# - {TSD_CONF.directory}/**/*.ts[x]
OPTS.typingsFile #'FILENAME' of main *.d.ts file
--typings|-t #Def:
# - PACKAGE.types|typings
# - {PACKAGE.main}.d.ts
# - CWD/index.d.ts
TSD_CONF.directory #Def: 'test-d'
OPTS.cwd #Def: '.'
#Used to:
# - find `package.json`, `tsconfig.json`
# - resolve OPTS.typingsFile|testFiles and TSD_CONF.directory
/=+===============================+=\
/ : : \
)==: ASSERTIONS :==(
\ :_______________________________: /
\=+===============================+=/
expect[Not]Type<TYPE>(VAL) #Asserts that VAL is [not] exactly of TYPE
expect[Not]Assignable<TYPE>(VAL) #Asserts that VAL can [not] be transtyped to TYPE
expectError(VAL) #Asserts that VAL has assertion type errors, e.g. FUNC(...) with wrong argument types.
#Prefer @ts-expect-error because:
# - works with deeply nested VAL
# - does not make `tsc` type fail
expectNever(VAL) #Same as expectType<never>(...)
expect[Not]Deprecated(VAL) #Asserts that @deprecated is [not] used
expectDocCommentIncludes<STR>(VAL)#Expect that JSDoc comment includes STR
/=+===============================+=\
/ : : \
)==: DEBUG :==(
\ :_______________________________: /
\=+===============================+=/
printType(VAL) #Print TYPE, for debugging