File tree 4 files changed +30
-4
lines changed
4 files changed +30
-4
lines changed Original file line number Diff line number Diff line change @@ -2343,6 +2343,17 @@ OpenSSL crypto support.
2343
2343
An attempt was made to use features that require [ ICU] [ ] , but Node.js was not
2344
2344
compiled with ICU support.
2345
2345
2346
+ <a id =" ERR_NO_TYPESCRIPT " ></a >
2347
+
2348
+ ### ` ERR_NO_TYPESCRIPT `
2349
+
2350
+ <!-- YAML
2351
+ added: REPLACEME
2352
+ -->
2353
+
2354
+ An attempt was made to use features that require [ Native TypeScript support] [ ] , but Node.js was not
2355
+ compiled with TypeScript support.
2356
+
2346
2357
<a id =" ERR_OPERATION_FAILED " ></a >
2347
2358
2348
2359
### ` ERR_OPERATION_FAILED `
@@ -4112,6 +4123,7 @@ An error occurred trying to allocate memory. This should never happen.
4112
4123
[ ICU ] : intl.md#internationalization-support
4113
4124
[ JSON Web Key Elliptic Curve Registry ] : https://www.iana.org/assignments/jose/jose.xhtml#web-key-elliptic-curve
4114
4125
[ JSON Web Key Types Registry ] : https://www.iana.org/assignments/jose/jose.xhtml#web-key-types
4126
+ [ Native TypeScript support ] : typescript.md#type-stripping
4115
4127
[ Node.js error codes ] : #nodejs-error-codes
4116
4128
[ Permission Model ] : permissions.md#permission-model
4117
4129
[ RFC 7230 Section 3 ] : https://tools.ietf.org/html/rfc7230#section-3
Original file line number Diff line number Diff line change @@ -1605,6 +1605,8 @@ E('ERR_NO_CRYPTO',
1605
1605
'Node.js is not compiled with OpenSSL crypto support' , Error ) ;
1606
1606
E ( 'ERR_NO_ICU' ,
1607
1607
'%s is not supported on Node.js compiled without ICU' , TypeError ) ;
1608
+ E ( 'ERR_NO_TYPESCRIPT' ,
1609
+ 'Node.js is not compiled with TypeScript support' , Error ) ;
1608
1610
E ( 'ERR_OPERATION_FAILED' , 'Operation failed: %s' , Error , TypeError ) ;
1609
1611
E ( 'ERR_OUT_OF_RANGE' ,
1610
1612
( str , range , input , replaceDefaultBoolean = false ) => {
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ const assert = require('internal/assert');
28
28
29
29
const { Buffer } = require ( 'buffer' ) ;
30
30
const { getOptionValue } = require ( 'internal/options' ) ;
31
- const { setOwnProperty, getLazy } = require ( 'internal/util' ) ;
31
+ const { assertTypeScript , setOwnProperty, getLazy } = require ( 'internal/util' ) ;
32
32
const { inspect } = require ( 'internal/util/inspect' ) ;
33
33
34
34
const lazyTmpdir = getLazy ( ( ) => require ( 'os' ) . tmpdir ( ) ) ;
@@ -328,6 +328,7 @@ const getTypeScriptParsingMode = getLazy(() =>
328
328
* @returns {Function } The TypeScript parser function.
329
329
*/
330
330
const loadTypeScriptParser = getLazy ( ( ) => {
331
+ assertTypeScript ( ) ;
331
332
const amaro = require ( 'internal/deps/amaro/dist/index' ) ;
332
333
return amaro . transformSync ;
333
334
} ) ;
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ const {
45
45
const {
46
46
codes : {
47
47
ERR_NO_CRYPTO ,
48
+ ERR_NO_TYPESCRIPT ,
48
49
ERR_UNKNOWN_SIGNAL ,
49
50
} ,
50
51
isErrorStackTraceLimitWritable,
@@ -65,6 +66,7 @@ const { getOptionValue } = require('internal/options');
65
66
const { encodings } = internalBinding ( 'string_decoder' ) ;
66
67
67
68
const noCrypto = ! process . versions . openssl ;
69
+ const noTypeScript = ! process . versions . amaro ;
68
70
69
71
const isWindows = process . platform === 'win32' ;
70
72
const isMacOS = process . platform === 'darwin' ;
@@ -196,9 +198,17 @@ function assertCrypto() {
196
198
throw new ERR_NO_CRYPTO ( ) ;
197
199
}
198
200
199
- // Return undefined if there is no match.
200
- // Move the "slow cases" to a separate function to make sure this function gets
201
- // inlined properly. That prioritizes the common case.
201
+ function assertTypeScript ( ) {
202
+ if ( noTypeScript )
203
+ throw new ERR_NO_TYPESCRIPT ( ) ;
204
+ }
205
+
206
+ /**
207
+ * Move the "slow cases" to a separate function to make sure this function gets
208
+ * inlined properly. That prioritizes the common case.
209
+ * @param {unknown } enc
210
+ * @returns {string | undefined } Returns undefined if there is no match.
211
+ */
202
212
function normalizeEncoding ( enc ) {
203
213
if ( enc == null || enc === 'utf8' || enc === 'utf-8' ) return 'utf8' ;
204
214
return slowCases ( enc ) ;
@@ -862,6 +872,7 @@ for (let i = 0; i < encodings.length; ++i)
862
872
module . exports = {
863
873
getLazy,
864
874
assertCrypto,
875
+ assertTypeScript,
865
876
cachedResult,
866
877
convertToValidSignal,
867
878
createClassWrapper,
You can’t perform that action at this time.
0 commit comments