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

Duplicate identifier errors when using @types inside a Windows junction #36294

Open
Spongman opened this issue Jan 18, 2020 · 12 comments
Open

Duplicate identifier errors when using @types inside a Windows junction #36294

Spongman opened this issue Jan 18, 2020 · 12 comments
Labels
Bug A bug in TypeScript
Milestone

Comments

@Spongman
Copy link

Spongman commented Jan 18, 2020

This is a dupe of #11333, but that issue was marked as closed/fixed (and locked... why?). It's not. It should be reopened and actually fixed. It's also unrelated to 'npm link'.

IMPORTANT:

my e:\work directory is a JUNCTION point to y:\work

node: 13.5.0
npm: 6.13.4
tsc: 3.7.5

index.ts:

/// <reference path="node_modules/@types/youtube/index.d.ts" />

package.json:

{
  "name": "junction-bug",
  "scripts": {
    "tsc": "tsc index.ts"
  },
  "devDependencies": {
    "@types/youtube": "0.0.38",
    "typescript": "^3.7.5"
  }
}

NOTE: There is NO reference to 'y:' in any of my project's files, nor in any of npm's files. tsc is erroneously converting relative paths to absolute paths on the destination drive. look for references to y:\ in the output below:

e:\work\junction-bug>dir e:\ | findstr work
04/19/2016  09:02 AM    <JUNCTION>     work [y:\work]

e:\work\junction-bug>npm i
...
e:\work\junction-bug>findstr /s /i /c:"y:\\" *

e:\work\junction-bug>npm run tsc

> junction-bug@ tsc E:\work\junction-bug
> tsc index.ts

node_modules/@types/youtube/index.d.ts:16:1 - error TS6200: Definitions of the following identifiers conflict with those in another file: UNSTARTED, ENDED, PLAYING, PAUSED, BUFFERING, CUED, InvalidParam, Html5Error, VideoNotFound, EmbeddingNotAllowed, EmbeddingNotAllowed2, AlwaysVisible, HideAllControls, HideProgressBar, NoAutoPlay, AutoPlay, UserDefault, ForceOn, ProgressBarColor, Hide, ShowLoadPlayer, ShowDelayLoadPlayer, Enable, Disable, Show, ListType, ListTypePlayer, ListTypeSearch, ListTypeUserUploads, SinglePlay, Loop, Full, Modest, Fullscreen, Inline, SuggestedVideoQuality, VideoQualityDefault, VideoQualitySmall, VideoQualityMedium, VideoQualityLarge, VideoQualityHD720, VideoQualityHD1080, VideoQualityHighRes, Player

16 declare namespace YT
   ~~~~~~~

  y:/work/junction-bug/node_modules/@types/youtube/index.d.ts:16:1
    16 declare namespace YT
       ~~~~~~~
    Conflicts are in this file.

y:/work/junction-bug/node_modules/@types/youtube/index.d.ts:16:1 - error TS6200: Definitions of the following identifiers conflict with those in 
another file: UNSTARTED, ENDED, PLAYING, PAUSED, BUFFERING, CUED, InvalidParam, Html5Error, VideoNotFound, EmbeddingNotAllowed, EmbeddingNotAllowed2, AlwaysVisible, HideAllControls, HideProgressBar, NoAutoPlay, AutoPlay, UserDefault, ForceOn, ProgressBarColor, Hide, ShowLoadPlayer, ShowDelayLoadPlayer, Enable, Disable, Show, ListType, ListTypePlayer, ListTypeSearch, ListTypeUserUploads, SinglePlay, Loop, Full, Modest, Fullscreen, Inline, SuggestedVideoQuality, VideoQualityDefault, VideoQualitySmall, VideoQualityMedium, VideoQualityLarge, VideoQualityHD720, VideoQualityHD1080, VideoQualityHighRes, Player

16 declare namespace YT
   ~~~~~~~

  node_modules/@types/youtube/index.d.ts:16:1
    16 declare namespace YT
       ~~~~~~~
    Conflicts are in this file.


Found 2 errors.

Related Issues: 113333

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Feb 6, 2020
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Feb 6, 2020
@Eli-Black-Work
Copy link

Eli-Black-Work commented Jan 17, 2022

This is a major issue when using workspaces in Yarn 2 or Yarn 3! 🙂

I was able to create a minimally reproducible example: https://github.com/Bosch-Eli-Black/hardlink-typescript-collisions

To reproduce the issue:

  1. Use a Windows computer.
  2. Clone the git repo (https://github.com/Bosch-Eli-Black/hardlink-typescript-collisions)
  3. Run yarn install from the command line. (This will use Yarn 3, because a copy of Yarn 3 is included inside the Git repo)
  4. Use Visual Studio to open the included typescript-collisions-bug solution.
  5. In VS, open src/app/App.jsx
  6. Wait about 5 minutes, for VS to automatically download TypeScript typings.
  7. Lots of TS errors show up. (I see 347 for this project 🙂)

Sample of the errors:

Severity	Code	Description	Project	File	Line	Suppression State
Error	TS6200	(TS) Definitions of the following identifiers conflict with those in another file: InputType, CompressCallback, BROTLI_DECODE, BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES, BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP, BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES, BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1, BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2, BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS, BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET, BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1, BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2, BROTLI_DECODER_ERROR_FORMAT_CL_SPACE, BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT, BROTLI_DECODER_ERROR_FORMAT_DICTIONARY, BROTLI_DECODER_ERROR_FORMAT_DISTANCE, BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE, BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE, BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE, BROTLI_DECODER_ERROR_FORMAT_PADDING_1, BROTLI_DECODER_ERROR_FORMAT_PADDING_2, BROTLI_DECODER_ERROR_FORMAT_RESERVED, BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET, BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME, BROTLI_DECODER_ERROR_FORMAT_TRANSFORM, BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS, BROTLI_DECODER_ERROR_INVALID_ARGUMENTS, BROTLI_DECODER_ERROR_UNREACHABLE, BROTLI_DECODER_NEEDS_MORE_INPUT, BROTLI_DECODER_NEEDS_MORE_OUTPUT, BROTLI_DECODER_NO_ERROR, BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION, BROTLI_DECODER_PARAM_LARGE_WINDOW, BROTLI_DECODER_RESULT_ERROR, BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT, BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT, BROTLI_DECODER_RESULT_SUCCESS, BROTLI_DECODER_SUCCESS, BROTLI_DEFAULT_MODE, BROTLI_DEFAULT_QUALITY, BROTLI_DEFAULT_WINDOW, BROTLI_ENCODE, BROTLI_LARGE_MAX_WINDOW_BITS, BROTLI_MAX_INPUT_BLOCK_BITS, BROTLI_MAX_QUALITY, BROTLI_MAX_WINDOW_BITS, BROTLI_MIN_INPUT_BLOCK_BITS, BROTLI_MIN_QUALITY, BROTLI_MIN_WINDOW_BITS, BROTLI_MODE_FONT, BROTLI_MODE_GENERIC, BROTLI_MODE_TEXT, BROTLI_OPERATION_EMIT_METADATA, BROTLI_OPERATION_FINISH, BROTLI_OPERATION_FLUSH, BROTLI_OPERATION_PROCESS, BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING, BROTLI_PARAM_LARGE_WINDOW, BROTLI_PARAM_LGBLOCK, BROTLI_PARAM_LGWIN, BROTLI_PARAM_MODE, BROTLI_PARAM_NDIRECT, BROTLI_PARAM_NPOSTFIX, BROTLI_PARAM_QUALITY, BROTLI_PARAM_SIZE_HINT, DEFLATE, DEFLATERAW, GUNZIP, GZIP, INFLATE, INFLATERAW, UNZIP, Z_NO_FLUSH, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, Z_FULL_FLUSH, Z_FINISH, Z_BLOCK, Z_TREES, Z_OK, Z_STREAM_END, Z_NEED_DICT, Z_ERRNO, Z_STREAM_ERROR, Z_DATA_ERROR, Z_MEM_ERROR, Z_BUF_ERROR, Z_VERSION_ERROR, Z_NO_COMPRESSION, Z_BEST_SPEED, Z_BEST_COMPRESSION, Z_DEFAULT_COMPRESSION, Z_FILTERED, Z_HUFFMAN_ONLY, Z_RLE, Z_FIXED, Z_DEFAULT_STRATEGY, Z_DEFAULT_WINDOWBITS, Z_MIN_WINDOWBITS, Z_MAX_WINDOWBITS, Z_MIN_CHUNK, Z_MAX_CHUNK, Z_DEFAULT_CHUNK, Z_MIN_MEMLEVEL, Z_MAX_MEMLEVEL, Z_DEFAULT_MEMLEVEL, Z_MIN_LEVEL, Z_MAX_LEVEL, Z_DEFAULT_LEVEL, ZLIB_VERNUM, Z_BINARY, Z_TEXT, Z_ASCII, Z_UNKNOWN, Z_DEFLATED	typescript-collisions-bug JavaScript Content Files	C:\Users\BLE1TP\AppData\Local\Microsoft\TypeScript\4.3\node_modules\@types\node\zlib.d.ts	1	Active
Error	TS6053	File 'C:/sources_git/typescript-collisions-bug/typescript-collisions-bug/node_modules/agent-base/dist/src/index' not found.
  The file is in the program because:
    Root file specified for compilation	typescript-collisions-bug JavaScript Content Files		1	Active
Error	TS6053	File 'C:/sources_git/typescript-collisions-bug/typescript-collisions-bug/node_modules/defer-to-connect/dist' not found.
  The file is in the program because:
    Root file specified for compilation	typescript-collisions-bug JavaScript Content Files		1	Active
Error	TS6053	File 'C:/sources_git/typescript-collisions-bug/typescript-collisions-bug/node_modules/https-proxy-agent/dist/index' not found.
  The file is in the program because:
    Root file specified for compilation	typescript-collisions-bug JavaScript Content Files		1	Active
Error	TS6053	File 'C:/sources_git/typescript-collisions-bug/typescript-collisions-bug/node_modules/rxjs/index.d.ts' not found.
  The file is in the program because:
    Root file specified for compilation	typescript-collisions-bug JavaScript Content Files		1	Active
Error	TS6053	File 'C:/sources_git/typescript-collisions-bug/typescript-collisions-bug/node_modules/source-map/source-map' not found.
  The file is in the program because:
    Root file specified for compilation	typescript-collisions-bug JavaScript Content Files		1	Active
Error	TS2724	(TS) '"tmp"' has no exported member named 'SimpleOptions'. Did you mean 'FileOptions'?	typescript-collisions-bug JavaScript Content Files	C:\sources_git\typescript-collisions-bug\typescript-collisions-bug\node_modules\tmp-promise\index.d.ts	2	Active
Error	TS2717	(TS) Subsequent property declarations must have the same type.  Property 'cwd' must be of type 'string', but here has type 'string | URL'.	typescript-collisions-bug JavaScript Content Files	C:\sources_git\typescript-collisions-bug\typescript-collisions-bug\node_modules\@types\node\child_process.d.ts	619	Active
Error	TS2717	(TS) Subsequent property declarations must have the same type.  Property 'output' must be of type 'string[]', but here has type 'T[]'.	typescript-collisions-bug JavaScript Content Files	C:\sources_git\typescript-collisions-bug\typescript-collisions-bug\node_modules\@types\node\child_process.d.ts	1260	Active
Error	TS2717	(TS) Subsequent property declarations must have the same type.  Property 'encoding' must be of type 'BufferEncoding', but here has type '"buffer"'.	typescript-collisions-bug JavaScript Content Files	C:\sources_git\typescript-collisions-bug\typescript-collisions-bug\node_modules\@types\node\child_process.d.ts	1333	Active
Error	TS2717	(TS) Subsequent property declarations must have the same type.  Property 'Console' must be of type 'ConsoleConstructor', but here has type 'ConsoleConstructor'.	typescript-collisions-bug JavaScript Content Files	C:\sources_git\typescript-collisions-bug\typescript-collisions-bug\node_modules\@types\node\console.d.ts	67	Active

Please let me know if you're able to reproduce the issue, using the above steps 🙂

@Eli-Black-Work
Copy link

@RyanCavanaugh Would you mind taking a look at this, when you have the chance? This bug is currently blocking us from upgrading our JS packages, because when we do, we're swamped with Error messages.

@Eli-Black-Work
Copy link

@mhegazy , @billti , or @amcasey Would you be the ones to look into this? (Just tagging MS devs who I saw in the original bug report of this: #14565)

Or maybe still @RyanCavanaugh ? 🙂

Sorry to bug. This is blocking us kind of badly.

@halm0291
Copy link

halm0291 commented Mar 3, 2022

Any updates on this? I have tried what people recommended in other issues for previous VS versions with no luck.

@Eli-Black-Work
Copy link

@halm0291 At the same time that I posted my last comment, I contacted Microsoft with a paid support request to ask about about both this and a related bug: https://developercommunity.visualstudio.com/t/vs2022-esproj-ignores-typeacquisition-setting/1639009

As far as I know, there's hasn't been much movement on this bug. The rep that I contacted said that she was able to reproduce the issue and would talk to the team. Let me follow up with her 🙂

Anyway, the good news is that there's a workaround: Open Visual Studio, go to Tools->Options->Text Editor-> JavaScript/TypeScript -> Project and uncheck "Enable automatic type acquisition (TS 4.1 or later)" (See https://developercommunity.visualstudio.com/t/vs2022-esproj-ignores-typeacquisition-setting/1639009#T-N1673400 for more details.)

Hope that helps! 🙂

@minestarks
Copy link
Member

@Bosch-Eli-Black I looked into how we're handling that Visual Studio feedback ticket. For your case, the bug we're tracking is actually a problem specific to .esproj projects - we ignore tsconfig.json files completely because they're set to the wrong content type. We have a fix you should see in the next VS update (if not, let me know!).

For any non-VS scenario, that same fix won't apply. It sounds like OP @Spongman is talking about a command-line repro, so their issue probably has a different root cause.

@Spongman
Copy link
Author

Spongman commented Mar 5, 2022

Yes, this issue has nothing to do with Visual Studio. All that's required is the typescript compiler (fetched here via npm).

@Eli-Black-Work
Copy link

Eli-Black-Work commented Mar 7, 2022

@minestarks Thanks for the update on that Visual Studio ticket – appreciate it! 🙂

Turning type acquisition off in VS is just a workaround for the TypeScript bug that's described in this issue. Ideally, this bug (#36294) would be fixed, too, so that I could still have autocomplete info 😀

@minestarks
Copy link
Member

Got it. I'm able to repro with @Spongman 's repro steps. There does seem to be a bug as to how we handle junctions.

@Bosch-Eli-Black I think your repro is the victim of multiple different bugs - one, as I mentioned, is fixed in the next update the VS. The second one, where we included a lot of unnecessary typings (which caused all the unnecessary errors) was fixed in #47164 , which is in TS 4.6, which is also bundled in the next update to VS. With these two fixed, I think you won't even hit the third one, which is this bug :)

@Eli-Black-Work
Copy link

@minestarks Ah, got it! 🙂 Thanks again :)

@Eli-Black-Work
Copy link

@minestarks Upgrading to VS 17.2 Preview 2 fixed our issue 🙂 Thanks again for your help!

@Eli-Black-Work
Copy link

By the way, sorry for derailing this bug so badly, @Spongman! I'd thought that the bug I was running into was the same as this one, but I guess not 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

No branches or pull requests

5 participants