Skip to content

TypeError: Unknown file extension ".ts" - esmodules support #70

@AuroraLantean

Description

@AuroraLantean

Original post in Anchor repo: [(https://github.com/solana-foundation/anchor/issues/1286)]

Anchor.toml [script] command:
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"

The problem is the m1.ts file cannot import functions from another ts file!!!???
in my utils.ts

export const log1 = console.log;

in my m1.ts file:

import { log1 } from './utils';
describe('scenario1', async () => {
  it('initialize', async () => {
    log1('\n---------== init');
  });
});

the imported log1 function or any other function will cause the Unknown file extension ".ts" error!!??

my local package dependencies:
"mocha": "^9.1.3",
"ts-mocha": "^9.0.0-alpha1",
"ts-node": "^10.4.0",
"typescript": "^4.5.4"

Please advise. Thank you
unknown file extension ts2

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions