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

Closed
Zig1375 opened this issue Nov 18, 2023 · 2 comments
Closed

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

Zig1375 opened this issue Nov 18, 2023 · 2 comments
Labels
info needed Extra information is needed question Qustions about how to use stuff stale This Issue | PR had no activity in a while and will be closed if it stays so

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

@hasezoey hasezoey added question Qustions about how to use stuff stale This Issue | PR had no activity in a while and will be closed if it stays so and removed bug Something isn't working labels Jul 10, 2024
@hasezoey
Copy link
Member

Closing this issue as there has been no activity in a long time and marked as "info needed" for that long time

@hasezoey hasezoey closed this as not planned Won't fix, can't repro, duplicate, stale Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info needed Extra information is needed question Qustions about how to use stuff stale This Issue | PR had no activity in a while and will be closed if it stays so
Projects
None yet
Development

No branches or pull requests

2 participants