2
2
3
3
const jsDocPrefix = 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/' ;
4
4
5
- const jsPrimitiveUrl = `${ jsDocPrefix } Data_structures` ;
5
+ const jsDataStructuresUrl = `${ jsDocPrefix } Data_structures` ;
6
6
const jsPrimitives = {
7
- ' boolean' : 'Boolean' ,
8
- ' integer' : 'Number' , // Not a primitive, used for clarification.
9
- ' null' : 'Null' ,
10
- ' number' : 'Number' ,
11
- ' string' : 'String' ,
12
- ' symbol' : 'Symbol' ,
13
- ' undefined' : 'Undefined'
7
+ boolean : 'Boolean' ,
8
+ integer : 'Number' , // Not a primitive, used for clarification.
9
+ null : 'Null' ,
10
+ number : 'Number' ,
11
+ string : 'String' ,
12
+ symbol : 'Symbol' ,
13
+ undefined : 'Undefined'
14
14
} ;
15
15
16
16
const jsGlobalObjectsUrl = `${ jsDocPrefix } Reference/Global_Objects/` ;
@@ -25,13 +25,15 @@ const jsGlobalTypes = [
25
25
] ;
26
26
27
27
const customTypesMap = {
28
+ 'any' : `${ jsDataStructuresUrl } #Data_types` ,
29
+
30
+ 'this' : `${ jsDocPrefix } Reference/Operators/this` ,
31
+
28
32
'Iterable' :
29
33
`${ jsDocPrefix } Reference/Iteration_protocols#The_iterable_protocol` ,
30
34
'Iterator' :
31
35
`${ jsDocPrefix } Reference/Iteration_protocols#The_iterator_protocol` ,
32
36
33
- 'this' : `${ jsDocPrefix } Reference/Operators/this` ,
34
-
35
37
'AsyncHook' : 'async_hooks.html#async_hooks_async_hooks_createhook_callbacks' ,
36
38
37
39
'Buffer' : 'buffer.html#buffer_class_buffer' ,
@@ -63,12 +65,14 @@ const customTypesMap = {
63
65
'http.Server' : 'http.html#http_class_http_server' ,
64
66
'http.ServerResponse' : 'http.html#http_class_http_serverresponse' ,
65
67
68
+ 'ClientHttp2Session' : 'http2.html#http2_class_clienthttp2session' ,
66
69
'ClientHttp2Stream' : 'http2.html#http2_class_clienthttp2stream' ,
67
70
'HTTP/2 Headers Object' : 'http2.html#http2_headers_object' ,
68
71
'HTTP/2 Settings Object' : 'http2.html#http2_settings_object' ,
69
72
'http2.Http2ServerRequest' : 'http2.html#http2_class_http2_http2serverrequest' ,
70
73
'http2.Http2ServerResponse' :
71
74
'http2.html#http2_class_http2_http2serverresponse' ,
75
+ 'Http2SecureServer' : 'http2.html#http2_class_http2secureserver' ,
72
76
'Http2Server' : 'http2.html#http2_class_http2server' ,
73
77
'Http2Session' : 'http2.html#http2_class_http2session' ,
74
78
'Http2Stream' : 'http2.html#http2_class_http2stream' ,
@@ -83,6 +87,8 @@ const customTypesMap = {
83
87
'os.constants.dlopen' : 'os.html#os_dlopen_constants' ,
84
88
85
89
'PerformanceEntry' : 'perf_hooks.html#perf_hooks_class_performanceentry' ,
90
+ 'PerformanceNodeTiming' :
91
+ 'perf_hooks.html#perf_hooks_class_performancenodetiming_extends_performanceentry' , // eslint-disable-line max-len
86
92
'PerformanceObserver' :
87
93
'perf_hooks.html#perf_hooks_class_performanceobserver_callback' ,
88
94
'PerformanceObserverEntryList' :
@@ -123,10 +129,10 @@ function toLink(typeInput) {
123
129
const typeTextFull = typeText ;
124
130
typeText = typeText . replace ( arrayPart , '' ) ;
125
131
126
- const primitive = jsPrimitives [ typeText . toLowerCase ( ) ] ;
132
+ const primitive = jsPrimitives [ typeText ] ;
127
133
128
134
if ( primitive !== undefined ) {
129
- typeUrl = `${ jsPrimitiveUrl } #${ primitive } _type` ;
135
+ typeUrl = `${ jsDataStructuresUrl } #${ primitive } _type` ;
130
136
} else if ( jsGlobalTypes . includes ( typeText ) ) {
131
137
typeUrl = `${ jsGlobalObjectsUrl } ${ typeText } ` ;
132
138
} else if ( customTypesMap [ typeText ] ) {
@@ -137,7 +143,10 @@ function toLink(typeInput) {
137
143
typeLinks . push (
138
144
`<a href="${ typeUrl } " class="type"><${ typeTextFull } ></a>` ) ;
139
145
} else {
140
- typeLinks . push ( `<span class="type"><${ typeTextFull } ></span>` ) ;
146
+ throw new Error (
147
+ `Unrecognized type: '${ typeTextFull } '.\n` +
148
+ "Please, edit the type or update the 'tools/doc/type-parser.js'."
149
+ ) ;
141
150
}
142
151
} else {
143
152
throw new Error ( `Empty type slot: ${ typeInput } ` ) ;
0 commit comments