MCPcopy Index your code
hub / github.com/nodejs/node / stripTypeScriptTypes

Function stripTypeScriptTypes

lib/internal/modules/typescript.js:91–115  ·  view source on GitHub ↗

* Performs type-stripping to TypeScript source code. * @param {string} code TypeScript code to parse. * @param {TransformOptions} options The configuration for type stripping. * @returns {string} The stripped TypeScript code.

(code, options = kEmptyObject)

Source from the content-addressed store, hash-verified

89 * @returns {string} The stripped TypeScript code.
90 */
91function stripTypeScriptTypes(code, options = kEmptyObject) {
92 emitExperimentalWarning('stripTypeScriptTypes');
93 validateString(code, 'code');
94 validateObject(options, 'options');
95
96 const {
97 sourceMap = false,
98 sourceUrl = '',
99 } = options;
100 let { mode = 'strip' } = options;
101 validateOneOf(mode, 'options.mode', ['strip']);
102 validateString(sourceUrl, 'options.sourceUrl');
103 if (mode === 'strip') {
104 validateOneOf(sourceMap, 'options.sourceMap', [false, undefined]);
105 // Rename mode from 'strip' to 'strip-only'.
106 // The reason is to match `process.features.typescript` which returns `strip`,
107 // but the parser expects `strip-only`.
108 mode = 'strip-only';
109 }
110
111 return processTypeScriptCode(code, {
112 mode,
113 filename: sourceUrl,
114 });
115}
116
117/**
118 * @typedef {object} TypeScriptOptions

Callers 1

Calls 2

emitExperimentalWarningFunction · 0.85
processTypeScriptCodeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…