aspnet / JavaScriptServices

[Archived] This repository has been archived
Apache License 2.0
3.03k stars 518 forks source link

ReactRedux configuration doesn't play well with TypeScript tools #1205

Closed rosieks closed 7 years ago

rosieks commented 7 years ago

Current configuration of ReactRedux project doesn't work well with TypeScript code actions. In my case I have two files:

When I try to add import to LogsList.tsx from OperationLogs.tsx the following line is added:

import { LogsList } from 'ClientApp/logs/components/LogsList';

Visual Studio doesn't show any errors but then when I run application I get such error:

NodeInvocationException: Prerendering failed because of error: Error: Cannot find module "ClientApp/logs/components/LogsList"

I have already reported to TypeScript repository that in such case they could use relative path https://github.com/Microsoft/TypeScript/issues/15888#issuecomment-323339210, but it would be nice to have that correctly configured in template.

SteveSandersonMS commented 7 years ago

I think the syntax you need to use is something like:

import { LogsList } from './ClientApp/logs/components/LogsList';

i.e., with a leading ./. Of course, the exact relative path depends on where you're importing it into.

However, I'm guessing that you already know this, and the problem you're reporting is that the TypeScript tooling code action is generating the incorrect import. If so, that would be an issue for the TypeScript tooling folks to address. I'll close this since it's not something we can fix in this repo, but please let me know if you think we are doing something wrong in this repo!

rosieks commented 7 years ago

I don't think that adding ./ will help - then it will be incorrect path and I believe that TypeScript tools works according to tsconfig.json so probably there is the issue.

SteveSandersonMS commented 7 years ago

The actual correct relative path will depend on where the file is and where it's being referenced from, of course.

I believe that TypeScript tools works according to tsconfig.json so probably there is the issue.

I'm not clear on whether you're saying there's a fault in this repo or not. If you think something is wrong here, can you give an example of what change to the tsconfig.json you think we should make, and a scenario where it makes a difference?