graphql / graphql/graphiql

[lsp-server] 🐞 The language server throws "could not parse the TypeScript file" error for every TS file when `documents` field is used

Open
#3,415 24 comments 12 reactions 0 assignees View on GitHub
bug lsp-server
Dominant language
TypeScript
Stars
16.9k
Forks
1.9k
Avg merge
22h 45m
Merged PRs (30d)
70

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Current Behavior

The language server throws `Could not parse the TypeScript file. SyntaxError: Unexpected token, expected ","` errors when I use `documents` section in GraphQL config.
The Config:
```yaml
projects:
apps:
schema: https://localhost:8080/graphql
documents:
- ./app/**/*.{ts,tsx}
- '!(app/operations/generated/*)'
- '!(app/operations/gqlApolloHooks.ts)'
```

The Other Config That I tested:
```yaml
projects:
apps:
schema: https://localhost:8080/graphql
documents:
- ./app/**/*.{ts,tsx}
- '!./app/operations/generated/*.{ts,tsx}'
- '!./app/operations/gqlApolloHooks.ts'
```

And here is a trick config that works:
```yaml
projects:
apps:
schema: https://localhost:8080/graphql
include:
- ./app/**/*.{ts,tsx}
exclude:
- './app/operations/generated/*.{ts,tsx}'
- './app/operations/gqlApolloHooks.ts'
```

### Expected Behavior

It should not throw TypeScript errors and just work.

### Steps To Reproduce

_No response_

### Environment

* LSP Server Version: VSCode GraphQL v0.8.17
* OS: macos

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.