44 ObjectPrototypeHasOwnProperty,
55} = primordials ;
66const {
7- validateBoolean,
87 validateOneOf,
98 validateObject,
109 validateString,
@@ -25,17 +24,9 @@ const { Buffer } = require('buffer');
2524const {
2625 getCompileCacheEntry,
2726 saveCompileCacheEntry,
28- cachedCodeTypes : { kStrippedTypeScript, kTransformedTypeScript , kTransformedTypeScriptWithSourceMaps } ,
27+ cachedCodeTypes : { kStrippedTypeScript } ,
2928} = internalBinding ( 'modules' ) ;
3029
31- /**
32- * The TypeScript parsing mode, either 'strip-only' or 'transform'.
33- * @type {function(): TypeScriptMode }
34- */
35- const getTypeScriptParsingMode = getLazy ( ( ) =>
36- ( getOptionValue ( '--experimental-transform-types' ) ?
37- ( emitExperimentalWarning ( 'Transform Types' ) , 'transform' ) : 'strip-only' ) ,
38- ) ;
3930
4031/**
4132 * Load the TypeScript parser.
@@ -109,8 +100,7 @@ function stripTypeScriptTypes(code, options = kEmptyObject) {
109100 sourceUrl = '' ,
110101 } = options ;
111102 let { mode = 'strip' } = options ;
112- validateOneOf ( mode , 'options.mode' , [ 'strip' , 'transform' ] ) ;
113- validateBoolean ( sourceMap , 'options.sourceMap' ) ;
103+ validateOneOf ( mode , 'options.mode' , [ 'strip' ] ) ;
114104 validateString ( sourceUrl , 'options.sourceUrl' ) ;
115105 if ( mode === 'strip' ) {
116106 validateOneOf ( sourceMap , 'options.sourceMap' , [ false , undefined ] ) ;
@@ -122,7 +112,6 @@ function stripTypeScriptTypes(code, options = kEmptyObject) {
122112
123113 return processTypeScriptCode ( code , {
124114 mode,
125- sourceMap,
126115 filename : sourceUrl ,
127116 } ) ;
128117}
@@ -156,19 +145,6 @@ function processTypeScriptCode(code, options) {
156145 return transformedCode ;
157146}
158147
159- /**
160- * Get the type enum used for compile cache.
161- * @param {TypeScriptMode } mode Mode of transpilation.
162- * @param {boolean } sourceMap Whether source maps are enabled.
163- * @returns {number }
164- */
165- function getCachedCodeType ( mode , sourceMap ) {
166- if ( mode === 'transform' ) {
167- if ( sourceMap ) { return kTransformedTypeScriptWithSourceMaps ; }
168- return kTransformedTypeScript ;
169- }
170- return kStrippedTypeScript ;
171- }
172148
173149/**
174150 * Performs type-stripping to TypeScript source code internally.
@@ -184,24 +160,18 @@ function stripTypeScriptModuleTypes(source, filename) {
184160 }
185161 const sourceMap = getOptionValue ( '--enable-source-maps' ) ;
186162
187- const mode = getTypeScriptParsingMode ( ) ;
188-
189- // Instead of caching the compile cache status, just go into C++ to fetch it,
190- // as checking process.env equally involves calling into C++ anyway, and
191- // the compile cache can be enabled dynamically.
192- const type = getCachedCodeType ( mode , sourceMap ) ;
193163 // Get a compile cache entry into the native compile cache store,
194164 // keyed by the filename. If the cache can already be loaded on disk,
195165 // cached.transpiled contains the cached string. Otherwise we should do
196166 // the transpilation and save it in the native store later using
197167 // saveCompileCacheEntry().
198- const cached = ( filename ? getCompileCacheEntry ( source , filename , type ) : undefined ) ;
168+ const cached = ( filename ? getCompileCacheEntry ( source , filename , kStrippedTypeScript ) : undefined ) ;
199169 if ( cached ?. transpiled ) { // TODO(joyeecheung): return Buffer here.
200170 return cached . transpiled ;
201171 }
202172
203173 const options = {
204- mode,
174+ mode : 'strip-only' ,
205175 sourceMap,
206176 filename,
207177 } ;
0 commit comments