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

[Bug] v1.0.0 transpile errors #102

Closed
2 tasks done
GoncaloBastos opened this issue Sep 7, 2023 · 9 comments
Closed
2 tasks done

[Bug] v1.0.0 transpile errors #102

GoncaloBastos opened this issue Sep 7, 2023 · 9 comments
Labels
bug Something isn't working

Comments

@GoncaloBastos
Copy link

Is this a new bug?

  • I believe this is a new bug
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

When running npx tsc several errors occur.

Expected Behavior

Should transpile correctly.

Steps To Reproduce

  1. import v1.0.0
  2. try to transpile

Relevant log output

/@sinclair/typebox/typebox.d.ts:179:167 - error TS2589: Type instantiation is excessively deep and possibly infinite.

179 ] extends [TArray, TNumber] ? AssertType<T['items']> : K extends TTemplateLiteral ? TIndexReduce<T, TTemplateLiteralKeyRest<K>> : K extends TUnion<TLiteral<Key>[]> ? TIndexReduce<T, TUnionLiteralKeyRest<K>> : K extends TLiteral<Key> ? TIndexReduce<T, [K['const']]> : TNever;

```node_modules/@types/web/index.d.ts:7:1 - error TS6200: Definitions of the following identifiers conflict with those in another file: NodeFilter, XPathNSResolver, SVGMatrix, WebKitCSSMatrix, SVGPoint, SVGRect, location, webkitURL, ImportExportKind, TableKind, ValueType, ExportValue, Exports, ImportValue, Imports, ModuleImports, ElementTagNameMap, name, AlgorithmIdentifier, BigInteger, BinaryData, BlobPart, BodyInit, BufferSource, COSEAlgorithmIdentifier, CSSKeywordish, CSSNumberish, CSSPerspectiveValue, CSSUnparsedSegment, CanvasImageSource, ClipboardItemData, ClipboardItems, ConstrainBoolean, ConstrainDOMString, ConstrainDouble, ConstrainULong, DOMHighResTimeStamp, EpochTimeStamp, EventListenerOrEventListenerObject, FileSystemWriteChunkType, Float32List, FormDataEntryValue, GLbitfield, GLboolean, GLclampf, GLenum, GLfloat, GLint, GLint64, GLintptr, GLsizei, GLsizeiptr, GLuint, GLuint64, HTMLOrSVGImageElement, HTMLOrSVGScriptElement, HashAlgorithmIdentifier, HeadersInit, IDBValidKey, ImageBitmapSource, Int32List, LineAndPositionSetting, MediaProvider, MessageEventSource, MutationRecordType, NamedCurve, OffscreenRenderingContext, OnBeforeUnloadEventHandler, OnErrorEventHandler, PerformanceEntryList, ReadableStreamController, ReadableStreamReadResult, ReadableStreamReader, RenderingContext, ReportList, RequestInfo, TexImageSource, TimerHandler, Transferable, Uint32List, VibratePattern, WindowProxy, XMLHttpRequestBodyInit, AlignSetting, AlphaOption, AnimationPlayState, AnimationReplaceState, AppendMode, AttestationConveyancePreference, AudioContextLatencyCategory, AudioContextState, AuthenticatorAttachment, AuthenticatorTransport, AutoKeyword, AutomationRate, AvcBitstreamFormat, BinaryType, BiquadFilterType, CSSMathOperator, CSSNumericBaseType, CanPlayTypeResult, CanvasDirection, CanvasFillRule, CanvasFontKerning, CanvasFontStretch, CanvasFontVariantCaps, CanvasLineCap, CanvasLineJoin, CanvasTextAlign, CanvasTextBaseline, CanvasTextRendering, ChannelCountMode, ChannelInterpretation, ClientTypes, CodecState, ColorGamut, ColorSpaceConversion, CompositeOperation, CompositeOperationOrAuto, CredentialMediationRequirement, DOMParserSupportedType, DirectionSetting, DisplayCaptureSurfaceType, DistanceModelType, DocumentReadyState, DocumentVisibilityState, EncodedVideoChunkType, EndOfStreamError, EndingType, FileSystemHandleKind, FillMode, FontDisplay, FontFaceLoadStatus, FontFaceSetLoadStatus, FullscreenNavigationUI, GamepadHapticActuatorType, GamepadHapticEffectType, GamepadHapticsResult, GamepadMappingType, GlobalCompositeOperation, HardwareAcceleration, HdrMetadataType, IDBCursorDirection, IDBRequestReadyState, IDBTransactionDurability, IDBTransactionMode, ImageOrientation, ImageSmoothingQuality, InsertPosition, IterationCompositeOperation, KeyFormat, KeyType, KeyUsage, LatencyMode, LineAlignSetting, LockMode, MIDIPortConnectionState, MIDIPortDeviceState, MIDIPortType, MediaDecodingType, MediaDeviceKind, MediaEncodingType, MediaKeyMessageType, MediaKeySessionClosedReason, MediaKeySessionType, MediaKeyStatus, MediaKeysRequirement, MediaSessionAction, MediaSessionPlaybackState, MediaStreamTrackState, NavigationTimingType, NotificationDirection, NotificationPermission, OffscreenRenderingContextId, OrientationLockType, OrientationType, OscillatorType, OverSampleType, PanningModelType, PaymentComplete, PermissionName, PermissionState, PlaybackDirection, PositionAlignSetting, PredefinedColorSpace, PremultiplyAlpha, PresentationStyle, PublicKeyCredentialType, PushEncryptionKeyName, RTCBundlePolicy, RTCDataChannelState, RTCDegradationPreference, RTCDtlsTransportState, RTCEncodedVideoFrameType, RTCErrorDetailType, RTCIceCandidateType, RTCIceComponent, RTCIceConnectionState, RTCIceGathererState, RTCIceGatheringState, RTCIceProtocol, RTCIceTcpCandidateType, RTCIceTransportPolicy, RTCIceTransportState, RTCPeerConnectionState, RTCPriorityType, RTCRtcpMuxPolicy, RTCRtpTransceiverDirection, RTCSctpTransportState, RTCSdpType, RTCSignalingState, RTCStatsIceCandidatePairState, RTCStatsType, ReadableStreamReaderMode, ReadableStreamType, ReadyState, RecordingState, ReferrerPolicy, RemotePlaybackState, RequestCache, RequestCredentials, RequestDestination, RequestMode, RequestRedirect, ResidentKeyRequirement, ResizeObserverBoxOptions, ResizeQuality, ResponseType, ScrollBehavior, ScrollLogicalPosition, ScrollRestoration, ScrollSetting, SecurityPolicyViolationEventDisposition, SelectionMode, ServiceWorkerState, ServiceWorkerUpdateViaCache, ShadowRootMode, SlotAssignmentMode, SpeechSynthesisErrorCode, TextTrackKind, TextTrackMode, TouchType, TransferFunction, UserVerificationRequirement, VideoColorPrimaries, VideoEncoderBitrateMode, VideoFacingModeEnum, VideoMatrixCoefficients, VideoPixelFormat, VideoTransferCharacteristics, WakeLockType, WebGLPowerPreference, WorkerType, WriteCommandType, XMLHttpRequestResponseType```

Environment

- **OS**: Windows 
- **Language version**: Node v18.17.1
- **Pinecone client version**: v1.0.0

Additional Context

No response

@GoncaloBastos GoncaloBastos added the bug Something isn't working label Sep 7, 2023
@jhamon
Copy link
Collaborator

jhamon commented Sep 7, 2023

Thanks for filing, I never saw this error while developing with typescript in our various sample apps. I need to do some investigation to understand what's going wrong, but if typebox ends up being problematic we can refactor away from it.

@JoeCoppola-HIA
Copy link

Thanks for the response @jhamon. If it helps, here is the tsconfig json we use:

  "compileOnSave": true,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./server-dist",
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "noImplicitAny": false,
    "module": "commonjs",
    "moduleResolution": "node",
    "esModuleInterop": true,
    "allowJs": true,
    "importHelpers": true,
    "target": "es2015",
    "lib": ["es2018", "dom"],
    "paths": {
      "@/*": ["src/*", "../shared/*"]
    }
  },
  "exclude": ["server-scripts", "pm2.config.js", "server-dist"]
}

And our project dependencies:

  "dependencies": {
    "@azure/arm-mediaservices": "^13.1.0",
    "@azure/identity": "^3.3.0",
    "@pinecone-database/pinecone": "^0.1.6",
    "axios": "^1.5.0",
    "body-parser": "^1.20.2",
    "cors": "^2.8.5",
    "dotenv": "^16.3.1",
    "express": "^4.18.2",
    "mime-types": "^2.1.35",
    "mssql": "^9.1.3",
    "nodemon": "^3.0.1",
    "path": "^0.12.7",
    "stytch": "^8.2.0",
    "uuid": "^9.0.0"
  },
  "devDependencies": {
    "@types/express": "^4.17.17",
    "@types/node": "^18.11.17",
    "tslib": "^2.6.1",
    "typescript": "^5.1.6"
  }

@liljohnak
Copy link

@jhamon In my firebase code I am also having an issue:
https://stackoverflow.com/questions/77066529/problem-with-pinecone-in-firebase-functions

tsjson:

{
  "compilerOptions": {
    "module": "commonjs",
    "noImplicitReturns": true,
    "noUnusedLocals": true,
    "outDir": "lib",
    "sourceMap": true,
    "strict": true,
    "target": "es2017"
  },
  "compileOnSave": true,
  "include": [
    "src"
  ]
}

project dependencies:

"dependencies": {
    "@pinecone-database/pinecone": "^1.0.0",
    "firebase-admin": "^11.8.0",
    "firebase-functions": "^4.3.1",
    "openai": "^4.5.0"
  },
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^5.12.0",
    "@typescript-eslint/parser": "^5.12.0",
    "eslint": "^8.9.0",
    "eslint-config-google": "^0.14.0",
    "eslint-plugin-import": "^2.25.4",
    "firebase-functions-test": "^3.1.0",
    "typescript": "^4.9.0"
  }

@liljohnak
Copy link

@jhamon Repro if needed:
pinecone_bug.zip

  1. unzip the following project folder and open with visual studio code
  2. npm install typescript
  3. npm install @pinecone-database/pinecone
  4. Ctrl+Shift+B

@jhamon
Copy link
Collaborator

jhamon commented Sep 13, 2023

Thanks everyone for the details. Will follow-up soon with a fix.

jhamon added a commit that referenced this issue Sep 14, 2023
## Problem

Several users have reported issues with typescript compilation

This PR addresses:
- #102
- #105 

## Solution

### Clean up unused dependencies to resolve web-related type errors

I started by deleting dependencies and running tests to see what
dependencies were no longer in use. I was able to delete these:
- @types/web
- @jest/globals
- unique-names-generator

Removing `@types/web` seems to have resolved the majority of Typescript
issues related to conflicts with web types in `lib.dom.d.ts`. Since I
was already in there mucking with dependencies, I went ahead and
shuffled a few things between dependencies/devDependencies just to align
with my current understanding of things.

### TS1005 (Typescript versions <=4.4)

People on older typescript versions report seeing many errors like this:

```
Error: ../pinecone-ts-client/dist/control/index.d.ts(1,31): error TS1005: ',' expected.
```

These errors were caused by using import statements that combined type
and value imports onto one line. This syntax was evidently not supported
in versions of typescript prior to 4.4.

Resolving these issues involved refactoring about 30 import statements
along these lines:
```diff
-import { IndexNameSchema, type IndexName } from './types';
+import { IndexNameSchema } from './types';
+import type { IndexName } from './types';
```

### Typebox errors (Typescript >= 5.1)

The `@sinclair/typebox` dependency is causing issues with very recent
versions of typescript.

```
../node_modules/@sinclair/typebox/typebox.d.ts:179:167 - error TS2589: Type instantiation is excessively deep and possibly infinite.

179 ] extends [TArray, TNumber] ? AssertType<T['items']> : K extends TTemplateLiteral ? TIndexReduce<T, TTemplateLiteralKeyRest<K>> : K extends TUnion<TLiteral<Key>[]> ? TIndexReduce<T, TUnionLiteralKeyRest<K>> : K extends TLiteral<Key> ? TIndexReduce<T, [K['const']]> : TNever;
```

### New CI job: `typescript-compilation-tests`

To verify this compilation issue doesn't come up again, I added a new
github actions job along with a version matrix. It tests every major
version of typescript back to version 4.1 (released [fall
2020](https://devblogs.microsoft.com/typescript/announcing-typescript-4-1/))
along with a version of pinecone, then checks whether it can
successfully `tsc`. I ran these with the v1.0.0 pinecone release to see
the jobs fail as reported, then updated it to install the latest code in
this branch and saw them pass. This will be part of CI for every PR from
now on.

## Type of Change

- [x] Bug fix (non-breaking change which fixes an issue)
- [x] This change requires a documentation update
- [x] Infrastructure change (CI configs, etc)

## Test Plan

Should see new compilation tests passing in CI. There are now 13
different checks running in CI to exercise compilation with major
versions of TypeScript.

## Follow-up

Probably we should add a lint rule to prevent us adding back any mixed
type/value imports.
@jhamon
Copy link
Collaborator

jhamon commented Sep 14, 2023

I just published the 1.0.1 release with a lot of fixes for a variety of TypeScript issues. Release notes here. Please try it out and let me know if your install problems are resolved so I can close this issue.

Given the number of moving parts involved with Typescript it's still possible there are undetected issues. We'll have to continue expanding our compilation testing to cover these cases as they pop up.

@liljohnak
Copy link

@jhamon Compiles perfectly, big thanks.

@jhamon
Copy link
Collaborator

jhamon commented Sep 15, 2023

I'm going to close this issue as I believe a wide variety of common issues were resolved in PR #114 that shipped in 1.0.1. If you upgrade and still have compilation errors, please open a new ticket and I'll get to the bottom of it.

@jhamon jhamon closed this as completed Sep 15, 2023
@liljohnak
Copy link

liljohnak commented Sep 15, 2023

Perfect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants