question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incompatible with TypeScript projects

See original GitHub issue

TypeScript does not support imports like import x from './index/xyz' (you’re trying to import ./index/xyz.tsx here) when there is also a directory called index/xyz/ because it compiles the code to import x from './index/xyz/index.js. Normally I’d just include the file extension .tsx but TypeScript hates that.

Example of a project that would break TypeScript with './index/App' import:

src/
├── index
│   ├── App
│   │   ├── App.css
│   ├── App.tsx
│   ├── index.css
└── index.tsx

That part is a purely TypeScript problem that I don’t know why they thought of that as a feature but I found a workaround after asking around. Replace .tsx with .js when writing the import and it works flawlessly.

import App from './index/App.js'; // but we're really importing ./index/App.tsx

This was fine until I ran Destiny again. Destiny doesn’t have a way to resolve the .js extension to the .tsx extension (understandably so, I blame TypeScript in this mess) therefore I’m unable to use TypeScript alongside Destiny, it seems to be one or the other (or constantly change file extensions in imports to satisfy one then the other).

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

1reaction
andria-devcommented, Jun 24, 2020

I’m gonna close this for now as it seems that this is a Snowpack specific problem

1reaction
andria-devcommented, Jun 23, 2020

I didn’t open an issue yet, seems like something that TypeScript isn’t going to want to change but I can open one up and see what happens. And I’ll see what I can do about making a repro for this

Read more comments on GitHub >

github_iconTop Results From Across the Web

Incompatible TypeScript version in package.json #10150
json lists a compatible TS version, VS Code knows not to use an incompatible version. Solution: change the TS version in newly created...
Read more >
typescript - Incompatible Identical Types - Stack Overflow
It's just that the module exists in two places. It exists at the top-level of node_modules , and also exists as a dependency...
Read more >
Documentation - Type Compatibility - TypeScript
Enums are compatible with numbers, and numbers are compatible with enums. Enum values from different enum types are considered incompatible. For example,.
Read more >
types of property incompatible error in react & typescript
Join this channel to get access to perks:https://www.youtube.com/channel/UCoSpmr2KNOxjwE_B9ynUmig/joinMy GearCamera ...
Read more >
JavaScript and TypeScript in Visual Studio | Microsoft Learn
Within these new projects, you can run JavaScript and TypeScript unit tests, easily add and connect ASP.NET Core API projects and download your ......
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