Skip to content

Newly created files don't belong to ts-project #36532

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

Closed
lstkz opened this issue Jan 30, 2020 · 9 comments · Fixed by #39049
Closed

Newly created files don't belong to ts-project #36532

lstkz opened this issue Jan 30, 2020 · 9 comments · Fixed by #39049
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue

Comments

@lstkz
Copy link

lstkz commented Jan 30, 2020

Continuation of #35794.

I am able to reproduce it in 3.8.0-dev.20200128.

tsserver.log. Downloaded::
(please remove it from this post, after you download it)

An important part of the log is:

Info 1775 [15:3:50.119] Project '/dev/null/inferredProject1*' (Inferred) 1
Info 1775 [15:3:50.119] 	Files (203)
	(files skipped)

	<removed>/node_modules/@types/react/global.d.ts
	<removed>/node_modules/csstype/index.d.ts
	<removed>/node_modules/@types/prop-types/index.d.ts
	<removed>/node_modules/@types/react/index.d.ts
	<removed>/node_modules/@types/styled-components/ts3.7/index.d.ts
	<removed>/node_modules/i18next/index.d.ts
	<removed>/node_modules/react-i18next/src/index.d.ts
	<removed>/components/MyComponent.tsx
	<removed>/node_modules/@types/asap/index.d.ts
	
	(files skipped)

All the above files are from 'node_modules', and there is only a single project file MyComponent.tsx, which is a newly created file (by ctrl+c, ctrl+v).

TypeScript Version: 3.8.0-dev.20200128

Expected behavior:
The newly created file should belong to the same project.

Actual behavior:
The newly created file doesn't belong to the same project, and autocomplete is broken.

Related Issues:
#35794

@sheetalkamat
Copy link
Member

@BetterCallSKY I looked into the log you shared but I don't see any event in directory watching to show that the new file is created on disk before or after it is opened in the editor around

Info 1703 [15:3:49.240] request:
    {"seq":266,"type":"request","command":"updateOpen",) 

Is the file on the disk? What are content of your config file.. If you do not want to share log/details here publicly, you can email it to me at shkamat at microsoft dot com

@sheetalkamat sheetalkamat added the Needs More Info The issue still hasn't been fully clarified label Jan 30, 2020
@alexfaber2011
Copy link

I believe I'm experiencing this same issue. I've tried multiple versions of tsc and tsserver. Currently the version of tsc is Version 3.9.0-dev (I compiled from the latest changes on the Typescript repository). I distinctly remember experiencing this behavior on version 3.6.3 as well.

I created a file called TextInput.tsx at ./components/form/TextInput.tsx and get the following from the tsserver logs: https://gist.github.com/alexfaber2011/b451d3c9ac92292e70b0f3ccc7888b8e#file-tsserver-log-L1401. Notice how it's part of "/dev/null/inferredProject1*"

The moment I import it from another file that's listed in a project that's not from inferredProject (e.g. App.tsx), TextInput.tsx is recognized to be part of the correct project:

Info 144  [12:36:40.571] -----------------------------------------------
Info 144  [12:36:40.571] Open files:
Info 144  [12:36:40.571] 	FileName: /Users/alexfaber/RoshReview/emqb/emqb-native/App.tsx ProjectRootPath: undefined
Info 144  [12:36:40.571] 		Projects: /Users/alexfaber/RoshReview/emqb/emqb-native/tsconfig.json
Info 144  [12:36:40.571] 	FileName: /Users/alexfaber/RoshReview/emqb/emqb-native/components/form/TextInput.tsx ProjectRootPath: undefined
Info 144  [12:36:40.571] 		Projects: /Users/alexfaber/RoshReview/emqb/emqb-native/tsconfig.json
Perf 144  [12:36:40.575] 2::open: async elapsed time (in milliseconds) 7.2267

Once it's part of the correct project, my autocomplete and type checks work.

Thanks for your hard work on this wonderful piece of software.

@sheetalkamat
Copy link
Member

@alexfaber2011 The behavior you mentioned seems correct since the root files in your project are just two index.ts and App.tsx I cant tell if your tsconfig has files entry or has include pattern that doesn't include new file in it but the TextInput.tsx is not going to be part of that config until referenced by some file as its not a root file picked up because config file says so..

https://gist.github.com/alexfaber2011/b451d3c9ac92292e70b0f3ccc7888b8e#file-tsserver-log-L21

@alexfaber2011
Copy link

Very helpful, thanks @sheetalkamat. My tsconfig was had an includes property that was too restrictive ['*.ts', '*.tsx']. Removing it entirely has given more rootNames and now everything seems to be working great.

@lstkz
Copy link
Author

lstkz commented Feb 24, 2020

tsserver.log

@sheetalkamat
New log with the same issue.
I created a new file using '+' icon from the sidebar, and then I copied the code from another file.

The new file is 'kpi-form.tsx`. When I rename it to 'kpi-form2.tsx' -> 'kpi-form.tsx', then autocomplete starts working correctly.

@realh
Copy link

realh commented Mar 2, 2020

This is still a problem for me with VS Code 1.42.1 and Typescript 3.5.3. Somewhere I read a suggested workaround to configure the Code workspace with a local typescript installation instead of the system version. I don't recall whether that used to fix the issue for me, but it isn't fixing it now.

@sheetalkamat
Copy link
Member

@lstkz Your log isn't complete so I cant tell whats going on, whether the file is present on the disk or not. I cant also tell if the config file is including that file as part of file names through files/include.. We would need complete log as well as repro steps to investigate this further.

@brieb
Copy link

brieb commented Jun 9, 2020

We appear to be running into a similar issue on TypeScript 3.9.3. Pre-existing files belong to the correct project, but newly created files belong to /dev/null/inferredProject1*. I have emailed you the full tsserver log at the email address mentioned above. Would be great to figure out a fix, because currently developers have to reload window every time they create a file which is not ideal. Thank you for your work on TypeScript, and please let me know if any further details would be helpful.

@brieb
Copy link

brieb commented Jun 12, 2020

I was able to create a repro here: https://github.com/brieb/ts-inferredProject1

Thank you very much for looking into this!

@sheetalkamat sheetalkamat removed the Needs More Info The issue still hasn't been fully clarified label Jun 12, 2020
@sheetalkamat sheetalkamat self-assigned this Jun 12, 2020
@sheetalkamat sheetalkamat added Bug A bug in TypeScript Fix Available A PR has been opened for this issue labels Jun 12, 2020
@sheetalkamat sheetalkamat added this to the TypeScript 4.0 milestone Jun 12, 2020
sheetalkamat added a commit that referenced this issue Jun 12, 2020
…ectories to watch (#39049)

* Test showing how wild card directory is not watched because of mismatch in key case

* Fix casing for wild card keys for implicit globs
Fixes #36532
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue
Projects
None yet
5 participants