mirror of https://github.com/nodejs/node.git
lib: add util.stripTypescriptTypes
This commit is contained in:
parent
a4f609faf5
commit
e310d28b99
|
@ -72,6 +72,8 @@ const {
|
|||
defineLazyProperties,
|
||||
} = require('internal/util');
|
||||
|
||||
const { getOptionValue } = require('internal/options');
|
||||
|
||||
let abortController;
|
||||
|
||||
function lazyAbortController() {
|
||||
|
@ -338,3 +340,8 @@ defineLazyProperties(
|
|||
'internal/mime',
|
||||
['MIMEType', 'MIMEParams'],
|
||||
);
|
||||
|
||||
if (getOptionValue('--experimental-strip-types')) {
|
||||
const { tsParse } = require('internal/modules/helpers');
|
||||
module.exports.stripTypescriptTypes = tsParse;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const util = require('util');
|
||||
|
||||
assert.strictEqual(util.stripTypescriptTypes('let s: string'), 'let s ');
|
|
@ -0,0 +1,19 @@
|
|||
'use strict';
|
||||
|
||||
const { skip, spawnPromisified } = require('../common');
|
||||
const fixtures = require('../common/fixtures');
|
||||
const { strictEqual } = require('node:assert');
|
||||
const { test } = require('node:test');
|
||||
|
||||
if (!process.config.variables.node_use_amaro) skip('Requires Amaro');
|
||||
|
||||
test('util.stripTypescriptTypes', async () => {
|
||||
const result = await spawnPromisified(process.execPath, [
|
||||
'--experimental-strip-types',
|
||||
fixtures.path('test-util-stripTypescriptTypes.js'),
|
||||
]);
|
||||
|
||||
strictEqual(result.stdout, '');
|
||||
strictEqual(result.stderr, '');
|
||||
strictEqual(result.code, 0);
|
||||
});
|
Loading…
Reference in New Issue