Within directory TS 2.6.2, there are three files:
interface.ts:
export interface Env {
x: string
}
index.ts:
import {Env} from './interface' // importing only the interface
const env: Env = {x: '1'}
console.log(env.x)
tsconfig.json:
{
"include": [
"index.ts"
]
}
During compilation using tsc --outDir ./out
, I find the following files in the out directory:
index.js
inteface.js
(If I remove import {Env} from './interface'
from index
, I will see only index.js
)
I'm curious as to why TSC compiles interface.js
into JS even though index.ts
is only importing the interface from interface.ts
and not JS CODE?