This has been already mentioned several times on different places, that tsc shall accept import b from './b.ts' as valid, despite the .ts exception, but the argument, that the input is valid JavaScript, but invalid TypeScript has never been raised.
Copied from #35148 (comment):
I want to use TypeScript to check the types. But to compile the code fast I want to strip the types with @babel/preset-typescript.
When I write in some of my files import x from ./x.ts tsc 3.9.2 says: “An import path cannot end with a .ts extension”, but rollup/@rollup/plugin-babel/@babel-preset-typescript eat the input happy.
When I write instead import x from ./x.js, typescript does eat the input, but rollup/@rollup/plugin-babel/@babel/preset-typescript cannot find the file. Likewise, when I use import x from ./x.
This code, a.js:
import b from './b.ts'
console.log(b)
b.ts:
is valid JavaScript, it just does not work in Node.JS, as the latter refuses to accept .ts file extension.
But when b.ts is delivered with the correct mime type, then this works:
<html>
<body><script type='module' src='./a.js'></script>
Firefox and Epiphany print “blub” on the console.</body>
</html>
Demonstration: https://mail.aegee.org/dpa/35148/file.html
To sum up,
is valid JavaScript, and tsc refuses to accept valid JavaScript.
This has been already mentioned several times on different places, that tsc shall accept
import b from './b.ts'as valid, despite the .ts exception, but the argument, that the input is valid JavaScript, but invalid TypeScript has never been raised.Copied from #35148 (comment):
I want to use TypeScript to check the types. But to compile the code fast I want to strip the types with
@babel/preset-typescript.When I write in some of my files
import x from ./x.tstsc 3.9.2 says: “An import path cannot end with a .ts extension”, butrollup/@rollup/plugin-babel/@babel-preset-typescripteat the input happy.When I write instead
import x from ./x.js, typescript does eat the input, but rollup/@rollup/plugin-babel/@babel/preset-typescriptcannot find the file. Likewise, when I useimport x from ./x.This code, a.js:
b.ts:
is valid JavaScript, it just does not work in Node.JS, as the latter refuses to accept .ts file extension.
But when b.ts is delivered with the correct mime type, then this works:
Demonstration: https://mail.aegee.org/dpa/35148/file.html
To sum up,
is valid JavaScript, and tsc refuses to accept valid JavaScript.