File tree Expand file tree Collapse file tree 4 files changed +30
-4
lines changed Expand file tree Collapse file tree 4 files changed +30
-4
lines changed Original file line number Diff line number Diff line change @@ -2343,6 +2343,17 @@ OpenSSL crypto support.
23432343An attempt was made to use features that require [ ICU] [ ] , but Node.js was not
23442344compiled with ICU support.
23452345
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+
23462357<a id =" ERR_OPERATION_FAILED " ></a >
23472358
23482359### ` ERR_OPERATION_FAILED `
@@ -4112,6 +4123,7 @@ An error occurred trying to allocate memory. This should never happen.
41124123[ ICU ] : intl.md#internationalization-support
41134124[ JSON Web Key Elliptic Curve Registry ] : https://www.iana.org/assignments/jose/jose.xhtml#web-key-elliptic-curve
41144125[ JSON Web Key Types Registry ] : https://www.iana.org/assignments/jose/jose.xhtml#web-key-types
4126+ [ Native TypeScript support ] : typescript.md#type-stripping
41154127[ Node.js error codes ] : #nodejs-error-codes
41164128[ Permission Model ] : permissions.md#permission-model
41174129[ 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',
16051605 'Node.js is not compiled with OpenSSL crypto support' , Error ) ;
16061606E ( 'ERR_NO_ICU' ,
16071607 '%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 ) ;
16081610E ( 'ERR_OPERATION_FAILED' , 'Operation failed: %s' , Error , TypeError ) ;
16091611E ( 'ERR_OUT_OF_RANGE' ,
16101612 ( str , range , input , replaceDefaultBoolean = false ) => {
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ const assert = require('internal/assert');
2828
2929const { Buffer } = require ( 'buffer' ) ;
3030const { getOptionValue } = require ( 'internal/options' ) ;
31- const { setOwnProperty, getLazy } = require ( 'internal/util' ) ;
31+ const { assertTypeScript , setOwnProperty, getLazy } = require ( 'internal/util' ) ;
3232const { inspect } = require ( 'internal/util/inspect' ) ;
3333
3434const lazyTmpdir = getLazy ( ( ) => require ( 'os' ) . tmpdir ( ) ) ;
@@ -328,6 +328,7 @@ const getTypeScriptParsingMode = getLazy(() =>
328328 * @returns {Function } The TypeScript parser function.
329329 */
330330const loadTypeScriptParser = getLazy ( ( ) => {
331+ assertTypeScript ( ) ;
331332 const amaro = require ( 'internal/deps/amaro/dist/index' ) ;
332333 return amaro . transformSync ;
333334} ) ;
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ const {
4545const {
4646 codes : {
4747 ERR_NO_CRYPTO ,
48+ ERR_NO_TYPESCRIPT ,
4849 ERR_UNKNOWN_SIGNAL ,
4950 } ,
5051 isErrorStackTraceLimitWritable,
@@ -65,6 +66,7 @@ const { getOptionValue } = require('internal/options');
6566const { encodings } = internalBinding ( 'string_decoder' ) ;
6667
6768const noCrypto = ! process . versions . openssl ;
69+ const noTypeScript = ! process . versions . amaro ;
6870
6971const isWindows = process . platform === 'win32' ;
7072const isMacOS = process . platform === 'darwin' ;
@@ -196,9 +198,17 @@ function assertCrypto() {
196198 throw new ERR_NO_CRYPTO ( ) ;
197199}
198200
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+ */
202212function normalizeEncoding ( enc ) {
203213 if ( enc == null || enc === 'utf8' || enc === 'utf-8' ) return 'utf8' ;
204214 return slowCases ( enc ) ;
@@ -862,6 +872,7 @@ for (let i = 0; i < encodings.length; ++i)
862872module . exports = {
863873 getLazy,
864874 assertCrypto,
875+ assertTypeScript,
865876 cachedResult,
866877 convertToValidSignal,
867878 createClassWrapper,
You can’t perform that action at this time.
0 commit comments