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

SyntaxError: Import named 'Ref' not found in module #893

Open
Zig1375 opened this issue Nov 18, 2023 · 1 comment
Open

SyntaxError: Import named 'Ref' not found in module #893

Zig1375 opened this issue Nov 18, 2023 · 1 comment
Labels
bug Something isn't working info needed Extra information is needed

Comments

@Zig1375
Copy link

Zig1375 commented Nov 18, 2023

Versions

  • System: macos
  • Bun: 1.0.12
  • Typescript: 5.0.0
  • Compiler / Transpiler: bun
  • Typegoose(NPM): 11.7.1
  • mongoose: 7.6.5

What is the Problem?

Once I try to import the "Ref" module I get an error: "SyntaxError: Import named 'Ref' not found in module"
The app works without importing Ref!

Code Example

import { getModelForClass, prop, Ref } from '@typegoose/typegoose';

class SubUser {
  @prop()
  public name?: string;

  @prop({ type: () => [String] })
  public jobs?: string[];
}


class User {
  @prop()
  public name?: string;

  @prop({ type: () => [String] })
  public jobs?: string[];

  @prop({ type: () => SubUser })
  public subUser?: Ref<SubUser>;
}

const UserModel = getModelForClass(User); // UserModel is a regular Mongoose Model with correct types

Do you know why it happens?

no


@Zig1375 Zig1375 added the bug Something isn't working label Nov 18, 2023
@hasezoey hasezoey added the info needed Extra information is needed label Nov 19, 2023
@hasezoey
Copy link
Member

what is your tsconfig, do you use isolatedModules? if yes, you may need to change it to import type { Ref } or import { type Ref }, because Ref is only a type, not a value at runtime

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

No branches or pull requests

2 participants