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

Property 'BigInt' does not exist on type 'typeof Types' #13780

Closed
2 tasks done
jonbarrow opened this issue Aug 24, 2023 · 0 comments · Fixed by #13787
Closed
2 tasks done

Property 'BigInt' does not exist on type 'typeof Types' #13780

jonbarrow opened this issue Aug 24, 2023 · 0 comments · Fixed by #13787
Labels
typescript Types or Types-test related issue / Pull Request
Milestone

Comments

@jonbarrow
Copy link

jonbarrow commented Aug 24, 2023

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Mongoose version

7.4.3

Node.js version

18.12.1

MongoDB server version

6.0.9

Typescript version (if applicable)

5.1.6

Description

BigInt is a supported schema type but is not exposed by schematypes.d.ts. However when using JavaScript without TypeScript, this property is accessible and can be used like normal. This prevents you from checking the type of a field to verify if it is a BigInt type using instanceof (see this related PR typegoose/auto-increment#21)

Steps to Reproduce

TypeScript:

import mongoose from 'mongoose';
console.log(mongoose.Schema.Types.BigInt);
// Property 'BigInt' does not exist on type 'typeof Types'. ts(2339)

JavaScript:

const mongoose = require('mongoose');
console.log(mongoose.Schema.Types.BigInt);
/*
[Function: SchemaBigInt] {
  schemaName: 'BigInt',
  defaultOptions: {},
  _cast: [Function: castBigInt],
  set: [Function: set],
  setters: [],
  get: [Function (anonymous)],
  cast: [Function: cast],
  _checkRequired: [Function (anonymous)],
  checkRequired: [Function (anonymous)],
  '$conditionalHandlers': {
    '$gt': [Function: handleSingle],
    '$gte': [Function: handleSingle],
    '$lt': [Function: handleSingle],
    '$lte': [Function: handleSingle],
    '$type': [Function (anonymous)],
    '$exists': [Function (anonymous)],
    '$nin': [Function: handle$in],
    '$ne': [Function: handleSingle],
    '$in': [Function: handle$in],
    '$eq': [Function: handleSingle],
    '$all': [Function: handleArray]
  }
}
*/

Expected Behavior

For BigInt to be accessible at the type level

@hasezoey hasezoey added the typescript Types or Types-test related issue / Pull Request label Aug 25, 2023
@vkarpov15 vkarpov15 added this to the 7.5.1 milestone Aug 25, 2023
vkarpov15 added a commit that referenced this issue Aug 29, 2023
types(schematypes): add missing BigInt SchemaType
@vkarpov15 vkarpov15 modified the milestones: 7.5.1, 7.5 Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
typescript Types or Types-test related issue / Pull Request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants