An import path cannot end with a '.ts' extension

See original GitHub issue

Hey! First of all, thanks for a great library 😃

I was just working on getting this set up in my project, and I get an error when I try to import the library in a typescript file: import * as Factory from 'factory.ts';

The compiler says: error TS2691: An import path cannot end with a '.ts' extension. Consider importing 'factory' instead.

I am using Typescript 2.4.2 and library version 0.2.2.

Is there something I am missing in the tsconfig? How can I get past this error? Thanks!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
bogdan-calapodcommented, May 24, 2021

I see that this is closed - any resolution on this ? Unfortunately @MoSattler’s solution doesn’t work for me 😦

1reaction
MoSattlercommented, Dec 1, 2020

A temporary solution is to create an alias

  "devDependencies": {
    "factory.ts": "0.5.1",
    "factory": "file:node_modules/factory.ts"
  }
// import * as Factory from "factory.ts";
import * as Factory from "factory";

If this causes problems with npm ci, another option is to use

"factory": "https://registry.npmjs.org/factory.ts/-/factory.ts-0.5.1.tgz"
Read more comments on GitHub >

github_iconTop Results From Across the Web

An import path cannot end with '.ts' - NodeJS and Visual Code
Even that Visual Code prompts an error, my code got running.. When I remove the .ts extension from import statement, I got an...
Read more >
Suppressing "The import path cannot end with a '.ts' extension ...
So the output a.js will contain the same import specifier "./b.ts", although possibly translated to require("./b.ts") ...
Read more >
An import path cannot end with a '.ts' extension. : r/Deno - Reddit
An import path cannot end with a '.ts' extension. · Install the Deno CLI. · Install this extension. · Ensure deno is available...
Read more >
Importing a `.ts` file from a rollup-bundled `.ts` file?
Summary CodeMirror.ts is being bundled by rollup and built by yarn watch ... error TS2691: An import path cannot end with a '.ts'...
Read more >
An import path cannot end with a '.ts' extension ... - Issuehunt
An import path cannot end with a '.ts ' extension. Consider importing 'xx.js' instead. #2750. cn3lfs posted onGitHub. <!-- Check those before opening...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found