Skip to content

Incoming dependent projects are not tracked by tsserver #140

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
lorenzodallavecchia opened this issue Feb 3, 2017 · 3 comments
Closed

Comments

@lorenzodallavecchia
Copy link
Contributor

It looks like the in-memory view of a project by tsserver does not include other projects that depend on the project handled by the server.

For example, suppose to have

  • a library project A,
  • a specific project B that uses A for some work.

For files inside B, tsserver will correctly consider both A and B to be part of the compiler scope.
For files inside A, however, the compiler only sees A in the compiler scope.

That is correct for features like validationg a single file or showing content assist proposals.
However, features like Compile on Save or Search References may work incorrectly because of this.

Steps to Reproduce

  1. Import these test projects.
  2. In shared-project/src/calculato.ts, make the sum method private. An error correctly appears on shared-project/src/main.ts, but none appears on specific-project/src/main.ts. That is the bug.

Workarounds (sort of)

A workaround is to modify shared-project/tsconfig.json as follows.

{
	"compilerOptions": {
		"target": "es5"
	},
	"compileOnSave": true,
	"include": [
		"src",
		"../specific-project/**/*"
	]
}

The include of ../specific-project/**/* makes specific project part of the shared project compilation input. While this works technically, in practice it is not feasible because a shared library project cannot possibly list all client projects that may use it.

Another option is to include ../**/*, but this raises concearns about performance of including all files of a potentially big workspace.

Considerations

The workarounds are based on including dependent client code as it was input code. While at first look this appears to work, it might cause problems, first of all by reducing performance (also, memory-wise).

It is possible that all these are tsserver limitations and so not easily solvable in typescript.java.

Please note that this issue does not reduce the value of tsserver integration. When using only a single tsconfig.json, the improvement in performance and dependency computation is simply not a match for the older tsc-based build.

@angelozerr
Copy link
Owner

angelozerr commented Feb 3, 2017

@lorenzodallavecchia VSCode configure tsserver with some options that I have not understood https://github.com/Microsoft/vscode/blob/master/extensions/typescript/src/typescriptServiceClient.ts#L584

and https://github.com/Microsoft/vscode/blob/master/extensions/typescript/src/typescriptServiceClient.ts#L438

I think it should be interesting to explore it. But for the moment very busy with #133

@lorenzodallavecchia
Copy link
Contributor Author

@angelozerr don't worry about this issue for now: I'm even realizing that it is not written correctly.
I have looked into tsserver and the way you are integrating it and I think the overall approach is correct. There are a number of issues that may also be caused by tsserver limitations. Later today I will comment on #109 with a complete list.

@lorenzodallavecchia
Copy link
Contributor Author

Closing, as the problem described here is a combination of separate problems.

Since the command is looking for references in the Eclipse Project it is correct that it does not work cross-project (that would be Workspace reference search). However, at least one file must be opened for each tsconfig.json scope in the same Eclipse project. See #142.

Workspace reference search requires a separate effort, probably similar to #144, for "merging" results from the tsserver's of all projects. I'll leave this unreported for now.

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

No branches or pull requests

2 participants