TypeScript: allowJs: why is `import "x.js"` being ignored?
Source:
// ./src/main.ts
import './console-log';
import './console-log.js';
console.log('console-log main')
// ./src/console-log.js
console.log('console-log JS')
// ./src/console-log.ts
console.log('console-log TS')
Config:
{
"compilerOptions": {
"module": "amd",
"outFile": "./target/main.js",
"allowJs": true
},
"files": ["./src/main.ts"]
}
Output:
// ./target/main.ts
console.log('console-log TS');
define("main", ["require", "exports", './console-log', './console-log.js'], function (require, exports) {
"use strict";
console.log('console-log main');
});
Notice that the output is missing the contents of the ./console-log.js
import.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 18 (17 by maintainers)
I guess the question is why do you have to be explicit about the file extension on your modules?
I see you are outputting to AMD… it is considered not a good idea to specify the file extension in AMD, because of portability issues just like this.