Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript task detection is not cross-platform #68812

Closed
TimMensch opened this issue Feb 15, 2019 · 10 comments · Fixed by #73001
Closed

TypeScript task detection is not cross-platform #68812

TimMensch opened this issue Feb 15, 2019 · 10 comments · Fixed by #73001
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug good first issue Issues identified as good for first-time contributors tasks Task system issues verified Verification succeeded
Milestone

Comments

@TimMensch
Copy link

Issue Type: Bug

If your tsconfig.json is in a subfolder, the folder path has to match the system file separator (\ on Windows, / on Mac/Linux) in order for it to work.

Steps to Reproduce:

  1. Create a project with a folder in it.
  2. Put tsconfig.json in the subfolder along with a test TypeScript file.
  3. Create a build task for that tsconfig.json. On Windows it will get a backslash, on Mac/Linux a forward slash.
  4. Switch the slash to that of the opposite platform.
  5. Note that now you can't build that task, and that instead you get an error similar to the following:
Error: The typescript task detection didn't contribute a task for the following configuration:
{
    "label": "tsc-api",
    "type": "typescript",
    "tsconfig": "api/tsconfig.json",
    "option": "watch",
    "options": {
        "cwd": "${workspaceFolder}/api"
    },
    "promptOnClose": true,
    "problemMatcher": [
        "$tsc-watch"
    ],
    "group": "build"
}
The task will be ignored.

The only workaround I've found is to create TWO tasks for each desired task, where one has forward slashes and the other backslashes. But a recent VS Code update made a warning box appear for those configurations every time I build or debug, which is annoying. Please address the underlying issue.

Honestly, this would be yet another situation where simply using forward slashes all the time would fix everything. This would also fix, for instance:

#35593

...a bug that's been around for a year and a half now. :(

VS Code version: Code - Insiders 1.32.0-insider (003521e, 2019-02-15T06:16:29.903Z)
OS version: Windows_NT x64 10.0.17134

System Info
Item Value
CPUs Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 x 2808)
GPU Status 2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: enabled
surface_synchronization: enabled_on
video_decode: enabled
webgl: enabled
webgl2: enabled
Memory (System) 15.89GB (2.72GB free)
Process Argv
Screen Reader no
VM 0%
Extensions: none
@vscodebot vscodebot bot added the tasks Task system issues label Feb 15, 2019
@alexr00
Copy link
Member

alexr00 commented Feb 18, 2019

I think we should be able to normalize the path for "tsconfig". It won't solve everything, but it will help.
The path to be normalized should be around here: https://github.com/Microsoft/vscode/blob/master/extensions/typescript-language-features/src/features/task.ts#L177

@alexr00 alexr00 added bug Issue identified by VS Code Team member as probable bug good first issue Issues identified as good for first-time contributors labels Feb 18, 2019
@alexr00 alexr00 added this to the On Deck milestone Feb 18, 2019
@gmertk
Copy link
Contributor

gmertk commented Feb 18, 2019

Hey @alexr00,
Are you working on this? If not, can I give it a shot?

@alexr00
Copy link
Member

alexr00 commented Feb 19, 2019

@gmertk, I'm not working on it right now, please do give it a shot! Starting info is in the comment above.

@alpalla
Copy link
Contributor

alpalla commented Apr 24, 2019

@gmertk are you still working on this? If not I'd like to help out.

@NizamLZ
Copy link
Contributor

NizamLZ commented Apr 24, 2019

I was looking at this issue, I like the idea of https://code.visualstudio.com/docs/editor/tasks#_custom-tasks, where there is a section for windows specific command. Typescript task template can be updated to support something like this:

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "typescript",
            "windows": {
                "tsconfig": "subfolder\\tsconfig.json"
            },
            "tsconfig": "subfolder/tsconfig.json",
            "problemMatcher": [
                "$tsc"
            ]
        }
    ]
}

I had a hard time finding the typescript template definition! Any help in the right direction would be appreciated.

@alpalla What do you think about this solution? Was yours similar?

@TimMensch
Copy link
Author

That seems like solving the wrong problem.

Changing the pattern match from / to [/\\] would solve this without the above hack/additional work for Windows support/DRY violation (because the paths should be identical between platforms, and it's only a bug that VS Code uses \ to begin with that's causing the problem).

@alpalla
Copy link
Contributor

alpalla commented Apr 25, 2019

@NizamLZ I haven't started implementing a fix yet, I just wanted to check whether anyone was already working on it first. I'll leave you to it at this point but please let others know if you are working on an issue as was suggested to you already here.

@NizamLZ
Copy link
Contributor

NizamLZ commented Apr 25, 2019

@alpalla Wanted to mention that I am working on it once I had a clear solution. Thanks for leaving this issue to me. I am glad to work on it till it's resolved.

@TimMensch
Copy link
Author

@NizamLZ It's great if you'll work on the problem, but please don't solve it by making unnecessary work for Windows cross-platform support.

@NizamLZ
Copy link
Contributor

NizamLZ commented Apr 25, 2019

@TimMensch Ofcourse I won't. I will look into the suggestion you posted above.

@alexr00 alexr00 modified the milestones: On Deck, May 2019 May 21, 2019
alexr00 pushed a commit that referenced this issue May 21, 2019
@mjbvz mjbvz added the verified Verification succeeded label May 30, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators Jul 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug good first issue Issues identified as good for first-time contributors tasks Task system issues verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants