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

export parseTypeSyntax utility #446

Open
macrozone opened this issue Feb 17, 2025 · 1 comment
Open

export parseTypeSyntax utility #446

macrozone opened this issue Feb 17, 2025 · 1 comment

Comments

@macrozone
Copy link

I need to parse the field-documentation identically to how prisma-json-types-generator is parsing it.

I used to import the internal JSON_REGEX:

import { JSON_REGEX } from "prisma-json-types-generator/dist/helpers/regex.js";


// later...

isI18nField(field: { documentation?: string }) {
    const match = field.documentation?.match(JSON_REGEX);

    if (match) {
      return match[1] === "I18n";
    }
    return false;
  }

however recently, this internal functionality has changed and is now done with the helpers/type-parser, so i could do:

import { parseTypeSyntax } from "prisma-json-types-generator/dist/helpers/type-parser.js";

// later...

isI18nField(field: { documentation?: string }) {
const match = parseTypeSyntax(field.documentation);

if (match) {
  return match[1] === "I18n";
}
return false;

}


however:

- this is internal api and can therefore change
- since some version, prisma-json-types-generator no longer publishes the source code in the npm package, so this now yields a type error.

It would therefore be good to properly export this function so library user can consume it including correct type information
@macrozone macrozone changed the title export some utility export parseTypeSyntax utility Feb 17, 2025
@arthurfiorette
Copy link
Owner

I'm happy to review a PR adding this export.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants