diff --git a/.changeset/big-paws-pump.md b/.changeset/big-paws-pump.md new file mode 100644 index 00000000..b62fe476 --- /dev/null +++ b/.changeset/big-paws-pump.md @@ -0,0 +1,5 @@ +--- +'@0no-co/graphqlsp': patch +--- + +Upgrade TypeScript dependency, this would normally not result in a changeset but it had us remove the normal auto-complete and quick-info and only do that logic when ours ends up in no results diff --git a/package.json b/package.json index a3d0a862..71d22228 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "lint-staged": "^15.0.0", "prettier": "^2.8.7", "rollup": "^3.20.2", - "typescript": "^5.0.0", + "typescript": "^5.3.3", "vitest": "^0.34.6" } } diff --git a/packages/example-external-generator/package.json b/packages/example-external-generator/package.json index 75e8614a..9644e45f 100644 --- a/packages/example-external-generator/package.json +++ b/packages/example-external-generator/package.json @@ -19,6 +19,6 @@ "@graphql-codegen/cli": "^5.0.0", "@graphql-codegen/client-preset": "^4.1.0", "ts-node": "^10.9.1", - "typescript": "^5.0.4" + "typescript": "^5.3.3" } } diff --git a/packages/example/package.json b/packages/example/package.json index 42752c5b..602ac6d3 100644 --- a/packages/example/package.json +++ b/packages/example/package.json @@ -15,7 +15,7 @@ "@graphql-typed-document-node/core": "^3.2.0" }, "devDependencies": { - "typescript": "^5.0.0", + "typescript": "^5.3.3", "@0no-co/graphqlsp": "file:../graphqlsp" } } diff --git a/packages/graphqlsp/package.json b/packages/graphqlsp/package.json index 2726b885..1201865d 100644 --- a/packages/graphqlsp/package.json +++ b/packages/graphqlsp/package.json @@ -37,7 +37,7 @@ "@types/node": "^18.15.11", "@types/node-fetch": "^2.6.3", "graphql": "^16.8.1", - "typescript": "^5.0.0" + "typescript": "^5.3.3" }, "dependencies": { "@graphql-codegen/add": "^5.0.0", diff --git a/packages/graphqlsp/src/index.ts b/packages/graphqlsp/src/index.ts index 9c456b11..53db84d7 100644 --- a/packages/graphqlsp/src/index.ts +++ b/packages/graphqlsp/src/index.ts @@ -91,24 +91,21 @@ function create(info: ts.server.PluginCreateInfo) { info ); - const originalCompletions = info.languageService.getCompletionsAtPosition( - filename, - cursorPosition, - options - ) || { - isGlobalCompletion: false, - isMemberCompletion: false, - isNewIdentifierLocation: false, - entries: [], - }; - - if (completions) { - return { - ...completions, - entries: [...completions.entries, ...originalCompletions.entries], - }; + if (completions && completions.entries.length) { + return completions; } else { - return originalCompletions; + return ( + info.languageService.getCompletionsAtPosition( + filename, + cursorPosition, + options + ) || { + isGlobalCompletion: false, + isMemberCompletion: false, + isNewIdentifierLocation: false, + entries: [], + } + ); } }; @@ -120,12 +117,12 @@ function create(info: ts.server.PluginCreateInfo) { info ); - const originalInfo = info.languageService.getQuickInfoAtPosition( + if (quickInfo) return quickInfo; + + return info.languageService.getQuickInfoAtPosition( filename, cursorPosition ); - - return quickInfo || originalInfo; }; logger('proxy: ' + JSON.stringify(proxy)); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cbe6f08f..94a211c2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -19,7 +19,7 @@ importers: version: 0.4.4(rollup@3.20.2) '@rollup/plugin-typescript': specifier: ^11.1.5 - version: 11.1.5(rollup@3.20.2)(typescript@5.0.4) + version: 11.1.5(rollup@3.20.2)(typescript@5.3.3) '@types/node': specifier: ^18.15.11 version: 18.15.11 @@ -39,8 +39,8 @@ importers: specifier: ^3.20.2 version: 3.20.2 typescript: - specifier: ^5.0.0 - version: 5.0.4 + specifier: ^5.3.3 + version: 5.3.3 vitest: specifier: ^0.34.6 version: 0.34.6 @@ -61,8 +61,8 @@ importers: specifier: file:../graphqlsp version: file:packages/graphqlsp(graphql@16.8.1) typescript: - specifier: ^5.0.0 - version: 5.0.4 + specifier: ^5.3.3 + version: 5.3.3 packages/example-external-generator: dependencies: @@ -81,16 +81,16 @@ importers: version: file:packages/graphqlsp(graphql@16.8.1) '@graphql-codegen/cli': specifier: ^5.0.0 - version: 5.0.0(@types/node@18.15.11)(graphql@16.8.1)(typescript@5.0.4) + version: 5.0.0(@types/node@18.15.11)(graphql@16.8.1)(typescript@5.3.3) '@graphql-codegen/client-preset': specifier: ^4.1.0 version: 4.1.0(graphql@16.8.1) ts-node: specifier: ^10.9.1 - version: 10.9.1(@types/node@18.15.11)(typescript@5.0.4) + version: 10.9.1(@types/node@18.15.11)(typescript@5.3.3) typescript: - specifier: ^5.0.4 - version: 5.0.4 + specifier: ^5.3.3 + version: 5.3.3 packages/graphqlsp: dependencies: @@ -135,8 +135,8 @@ importers: specifier: ^16.8.1 version: 16.8.1 typescript: - specifier: ^5.0.0 - version: 5.0.4 + specifier: ^5.3.3 + version: 5.3.3 test/e2e/fixture-project: dependencies: @@ -148,8 +148,8 @@ importers: version: 4.0.4(graphql@16.8.1) devDependencies: typescript: - specifier: ^5.0.4 - version: 5.0.4 + specifier: ^5.3.3 + version: 5.3.3 test/e2e/fixture-project-client-preset: dependencies: @@ -167,8 +167,8 @@ importers: version: 16.8.1 devDependencies: typescript: - specifier: ^5.0.4 - version: 5.0.4 + specifier: ^5.3.3 + version: 5.3.3 packages: @@ -1341,7 +1341,7 @@ packages: graphql: 16.8.1 tslib: 2.5.0 - /@graphql-codegen/cli@5.0.0(@types/node@18.15.11)(graphql@16.8.1)(typescript@5.0.4): + /@graphql-codegen/cli@5.0.0(@types/node@18.15.11)(graphql@16.8.1)(typescript@5.3.3): resolution: {integrity: sha512-A7J7+be/a6e+/ul2KI5sfJlpoqeqwX8EzktaKCeduyVKgOLA6W5t+NUGf6QumBDXU8PEOqXk3o3F+RAwCWOiqA==} hasBin: true peerDependencies: @@ -1368,11 +1368,11 @@ packages: '@graphql-tools/utils': 10.0.1(graphql@16.8.1) '@whatwg-node/fetch': 0.8.8 chalk: 4.1.2 - cosmiconfig: 8.3.6(typescript@5.0.4) + cosmiconfig: 8.3.6(typescript@5.3.3) debounce: 1.2.1 detect-indent: 6.1.0 graphql: 16.8.1 - graphql-config: 5.0.3(@types/node@18.15.11)(graphql@16.8.1)(typescript@5.0.4) + graphql-config: 5.0.3(@types/node@18.15.11)(graphql@16.8.1)(typescript@5.3.3) inquirer: 8.2.6 is-glob: 4.0.3 jiti: 1.21.0 @@ -2093,7 +2093,7 @@ packages: terser: 5.22.0 dev: true - /@rollup/plugin-typescript@11.1.5(rollup@3.20.2)(typescript@5.0.4): + /@rollup/plugin-typescript@11.1.5(rollup@3.20.2)(typescript@5.3.3): resolution: {integrity: sha512-rnMHrGBB0IUEv69Q8/JGRD/n4/n6b3nfpufUu26axhUcboUzv/twfZU8fIBbTOphRAe0v8EyxzeDpKXqGHfyDA==} engines: {node: '>=14.0.0'} peerDependencies: @@ -2109,7 +2109,7 @@ packages: '@rollup/pluginutils': 5.0.2(rollup@3.20.2) resolve: 1.22.2 rollup: 3.20.2 - typescript: 5.0.4 + typescript: 5.3.3 dev: true /@rollup/pluginutils@5.0.2(rollup@3.20.2): @@ -2865,7 +2865,7 @@ packages: resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==} dev: true - /cosmiconfig@8.3.6(typescript@5.0.4): + /cosmiconfig@8.3.6(typescript@5.3.3): resolution: {integrity: sha512-kcZ6+W5QzcJ3P1Mt+83OUv/oHFqZHIx8DuxG6eZ5RGMERoLqp4BuGjhHLYGK+Kf5XVkQvqBSmAy/nGWN3qDgEA==} engines: {node: '>=14'} peerDependencies: @@ -2878,7 +2878,7 @@ packages: js-yaml: 4.1.0 parse-json: 5.2.0 path-type: 4.0.0 - typescript: 5.0.4 + typescript: 5.3.3 dev: true /create-require@1.1.1: @@ -3482,7 +3482,7 @@ packages: resolution: {integrity: sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==} dev: true - /graphql-config@5.0.3(@types/node@18.15.11)(graphql@16.8.1)(typescript@5.0.4): + /graphql-config@5.0.3(@types/node@18.15.11)(graphql@16.8.1)(typescript@5.3.3): resolution: {integrity: sha512-BNGZaoxIBkv9yy6Y7omvsaBUHOzfFcII3UN++tpH8MGOKFPFkCPZuwx09ggANMt8FgyWP1Od8SWPmrUEZca4NQ==} engines: {node: '>= 16.0.0'} peerDependencies: @@ -3498,7 +3498,7 @@ packages: '@graphql-tools/merge': 9.0.0(graphql@16.8.1) '@graphql-tools/url-loader': 8.0.0(@types/node@18.15.11)(graphql@16.8.1) '@graphql-tools/utils': 10.0.1(graphql@16.8.1) - cosmiconfig: 8.3.6(typescript@5.0.4) + cosmiconfig: 8.3.6(typescript@5.3.3) graphql: 16.8.1 jiti: 1.21.0 minimatch: 4.2.3 @@ -5318,7 +5318,7 @@ packages: resolution: {integrity: sha512-PGcnJoTBnVGy6yYNFxWVNkdcAuAMstvutN9MgDJIV6L0oG8fB+ZNNy1T+wJzah8RPGor1mZuPQkVfXNDpy9eHA==} dev: true - /ts-node@10.9.1(@types/node@18.15.11)(typescript@5.0.4): + /ts-node@10.9.1(@types/node@18.15.11)(typescript@5.3.3): resolution: {integrity: sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==} hasBin: true peerDependencies: @@ -5344,7 +5344,7 @@ packages: create-require: 1.1.1 diff: 4.0.2 make-error: 1.3.6 - typescript: 5.0.4 + typescript: 5.3.3 v8-compile-cache-lib: 3.0.1 yn: 3.1.1 dev: true @@ -5408,9 +5408,9 @@ packages: is-typed-array: 1.1.10 dev: true - /typescript@5.0.4: - resolution: {integrity: sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==} - engines: {node: '>=12.20'} + /typescript@5.3.3: + resolution: {integrity: sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==} + engines: {node: '>=14.17'} hasBin: true dev: true diff --git a/test/e2e/client-preset.test.ts b/test/e2e/client-preset.test.ts index c1147cb7..3fa4ce00 100644 --- a/test/e2e/client-preset.test.ts +++ b/test/e2e/client-preset.test.ts @@ -341,61 +341,6 @@ List out all Pokémon, optionally in pages` "name": "__typename", "sortText": "14__typename", }, - { - "kind": "string", - "kindModifiers": "", - "name": " - fragment pokemonFields on Pokemon { - id - name - attacks { - fast { - damage - name - } - } - } - ", - "replacementSpan": { - "end": { - "line": 10, - "offset": 1, - }, - "start": { - "line": 3, - "offset": 39, - }, - }, - "sortText": "11", - }, - { - "kind": "string", - "kindModifiers": "", - "name": " - query Pok($limit: Int!) { - pokemons(limit: $limit) { - id - name - fleeRate - classification - ...pokemonFields - ...weaknessFields - __typename - } - } - ", - "replacementSpan": { - "end": { - "line": 10, - "offset": 1, - }, - "start": { - "line": 3, - "offset": 39, - }, - }, - "sortText": "11", - }, ] `); }, 30000); diff --git a/test/e2e/fixture-project-client-preset/package.json b/test/e2e/fixture-project-client-preset/package.json index 93147c6a..e5d8d4be 100644 --- a/test/e2e/fixture-project-client-preset/package.json +++ b/test/e2e/fixture-project-client-preset/package.json @@ -8,6 +8,6 @@ "@urql/core": "^4.0.4" }, "devDependencies": { - "typescript": "^5.0.4" + "typescript": "^5.3.3" } } diff --git a/test/e2e/fixture-project/package.json b/test/e2e/fixture-project/package.json index bf428c32..fdaa202d 100644 --- a/test/e2e/fixture-project/package.json +++ b/test/e2e/fixture-project/package.json @@ -6,6 +6,6 @@ "@urql/core": "^4.0.4" }, "devDependencies": { - "typescript": "^5.0.4" + "typescript": "^5.3.3" } } diff --git a/test/e2e/fragments.test.ts b/test/e2e/fragments.test.ts index 040c1ec0..8ea48d27 100644 --- a/test/e2e/fragments.test.ts +++ b/test/e2e/fragments.test.ts @@ -68,6 +68,27 @@ describe('Fragments', () => { tmpfile: outFilePost, } satisfies ts.server.protocol.SavetoRequestArgs); + await waitForExpect(() => { + expect(fs.readFileSync(outFilePost, 'utf-8')).toContain( + `as typeof import('./Post.generated').PostFieldsFragmentDoc` + ); + }); + + await waitForExpect(() => { + const generatedPostFileContents = fs.readFileSync(genFilePost, 'utf-8'); + expect(generatedPostFileContents).toContain( + 'export const PostFieldsFragmentDoc = ' + ); + expect(generatedPostFileContents).toContain( + 'import * as Types from "./__generated__/baseGraphQLSP"' + ); + }); + + server.sendCommand('saveto', { + file: outFilePosts, + tmpfile: outFilePosts, + } satisfies ts.server.protocol.SavetoRequestArgs); + server.sendCommand('saveto', { file: outFilePosts, tmpfile: outFilePosts, @@ -89,22 +110,6 @@ describe('Fragments', () => { ); }); - await waitForExpect(() => { - expect(fs.readFileSync(outFilePost, 'utf-8')).toContain( - `as typeof import('./Post.generated').PostFieldsFragmentDoc` - ); - }); - - await waitForExpect(() => { - const generatedPostFileContents = fs.readFileSync(genFilePost, 'utf-8'); - expect(generatedPostFileContents).toContain( - 'export const PostFieldsFragmentDoc = ' - ); - expect(generatedPostFileContents).toContain( - 'import * as Types from "./__generated__/baseGraphQLSP"' - ); - }); - const res = server.responses .reverse() .find( diff --git a/test/e2e/generate-types.test.ts b/test/e2e/generate-types.test.ts index 1fedd10d..1164dabf 100644 --- a/test/e2e/generate-types.test.ts +++ b/test/e2e/generate-types.test.ts @@ -122,6 +122,11 @@ describe('Type-generation', () => { tmpfile: outFileComplex, } satisfies ts.server.protocol.SavetoRequestArgs); + server.sendCommand('saveto', { + file: outFileComplex, + tmpfile: outFileComplex, + } satisfies ts.server.protocol.SavetoRequestArgs); + await waitForExpect(() => { const contents = fs.readFileSync(outFileComplex, 'utf-8'); expect(contents).toContain(` id @@ -131,5 +136,5 @@ describe('Type-generation', () => { } \` as typeof import('./rename-complex.generated').Post2FieldsFragmentDoc`); }); - }, 20000); + }, 30000); }); diff --git a/test/e2e/server.ts b/test/e2e/server.ts index b6730252..bdf23601 100644 --- a/test/e2e/server.ts +++ b/test/e2e/server.ts @@ -22,12 +22,7 @@ export class TSServer { public projectPath: string, public options: { debugLog?: boolean } = {} ) { - const tsserverPath = path.resolve( - projectPath, - '../../../node_modules/typescript/lib/tsserver.js' - ); - - fs.lstatSync(tsserverPath); + const tsserverPath = require.resolve('typescript/lib/tsserver'); const server = fork(tsserverPath, ['--logVerbosity', 'verbose'], { stdio: ['pipe', 'pipe', 'pipe', 'ipc'], diff --git a/test/e2e/util.ts b/test/e2e/util.ts index 96aae69e..7f9724b2 100644 --- a/test/e2e/util.ts +++ b/test/e2e/util.ts @@ -7,7 +7,7 @@ type WaitForExpectOptions = { export const waitForExpect = async ( expectFn: () => void, - { interval = 500, timeout = 15000 }: WaitForExpectOptions = {} + { interval = 2000, timeout = 30000 }: WaitForExpectOptions = {} ) => { // @sinonjs/fake-timers injects `clock` property into setTimeout const usesFakeTimers = 'clock' in setTimeout;