22
33const jsDocPrefix = 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/' ;
44
5- const jsPrimitiveUrl = `${ jsDocPrefix } Data_structures` ;
5+ const jsDataStructuresUrl = `${ jsDocPrefix } Data_structures` ;
66const 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'
1414} ;
1515
1616const jsGlobalObjectsUrl = `${ jsDocPrefix } Reference/Global_Objects/` ;
@@ -25,13 +25,15 @@ const jsGlobalTypes = [
2525] ;
2626
2727const customTypesMap = {
28+ 'any' : `${ jsDataStructuresUrl } #Data_types` ,
29+
30+ 'this' : `${ jsDocPrefix } Reference/Operators/this` ,
31+
2832 'Iterable' :
2933 `${ jsDocPrefix } Reference/Iteration_protocols#The_iterable_protocol` ,
3034 'Iterator' :
3135 `${ jsDocPrefix } Reference/Iteration_protocols#The_iterator_protocol` ,
3236
33- 'this' : `${ jsDocPrefix } Reference/Operators/this` ,
34-
3537 'AsyncHook' : 'async_hooks.html#async_hooks_async_hooks_createhook_callbacks' ,
3638
3739 'Buffer' : 'buffer.html#buffer_class_buffer' ,
@@ -63,12 +65,14 @@ const customTypesMap = {
6365 'http.Server' : 'http.html#http_class_http_server' ,
6466 'http.ServerResponse' : 'http.html#http_class_http_serverresponse' ,
6567
68+ 'ClientHttp2Session' : 'http2.html#http2_class_clienthttp2session' ,
6669 'ClientHttp2Stream' : 'http2.html#http2_class_clienthttp2stream' ,
6770 'HTTP/2 Headers Object' : 'http2.html#http2_headers_object' ,
6871 'HTTP/2 Settings Object' : 'http2.html#http2_settings_object' ,
6972 'http2.Http2ServerRequest' : 'http2.html#http2_class_http2_http2serverrequest' ,
7073 'http2.Http2ServerResponse' :
7174 'http2.html#http2_class_http2_http2serverresponse' ,
75+ 'Http2SecureServer' : 'http2.html#http2_class_http2secureserver' ,
7276 'Http2Server' : 'http2.html#http2_class_http2server' ,
7377 'Http2Session' : 'http2.html#http2_class_http2session' ,
7478 'Http2Stream' : 'http2.html#http2_class_http2stream' ,
@@ -83,6 +87,8 @@ const customTypesMap = {
8387 'os.constants.dlopen' : 'os.html#os_dlopen_constants' ,
8488
8589 '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
8692 'PerformanceObserver' :
8793 'perf_hooks.html#perf_hooks_class_performanceobserver_callback' ,
8894 'PerformanceObserverEntryList' :
@@ -123,10 +129,10 @@ function toLink(typeInput) {
123129 const typeTextFull = typeText ;
124130 typeText = typeText . replace ( arrayPart , '' ) ;
125131
126- const primitive = jsPrimitives [ typeText . toLowerCase ( ) ] ;
132+ const primitive = jsPrimitives [ typeText ] ;
127133
128134 if ( primitive !== undefined ) {
129- typeUrl = `${ jsPrimitiveUrl } #${ primitive } _type` ;
135+ typeUrl = `${ jsDataStructuresUrl } #${ primitive } _type` ;
130136 } else if ( jsGlobalTypes . includes ( typeText ) ) {
131137 typeUrl = `${ jsGlobalObjectsUrl } ${ typeText } ` ;
132138 } else if ( customTypesMap [ typeText ] ) {
@@ -137,7 +143,10 @@ function toLink(typeInput) {
137143 typeLinks . push (
138144 `<a href="${ typeUrl } " class="type"><${ typeTextFull } ></a>` ) ;
139145 } 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+ ) ;
141150 }
142151 } else {
143152 throw new Error ( `Empty type slot: ${ typeInput } ` ) ;
0 commit comments