What is the problem this feature will solve?
Currently it’s not possible to use Node.js type stripping to load a TypeScript CJS file:
import fs = require('fs')
export = fs
This is equivalent to the following JavaScript:
var fs = require('fs')
module.exports = fs
You could use the JavaScript style syntax, but then it’s no longer proper TypeScript. So you miss out on type checking features.
What is the feature you are proposing to solve the problem?
The import and export statements are long enough, that they can be replaced with whitespace and a temporary variable. Some helper code can be added to the end of the file. The code above can be replaced with:
// `import` → `var `
var fs = require('fs')
// `export` → `var xp`
var xp = fs
// Helper code
module.exports = xp
What alternatives have you considered?
No response
What is the problem this feature will solve?
Currently it’s not possible to use Node.js type stripping to load a TypeScript CJS file:
This is equivalent to the following JavaScript:
You could use the JavaScript style syntax, but then it’s no longer proper TypeScript. So you miss out on type checking features.
What is the feature you are proposing to solve the problem?
The
importandexportstatements are long enough, that they can be replaced with whitespace and a temporary variable. Some helper code can be added to the end of the file. The code above can be replaced with:What alternatives have you considered?
No response