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

pkg.name can be undefined #220

Open
3 tasks
vixalien opened this issue Nov 12, 2024 · 3 comments · May be fixed by #226
Open
3 tasks

pkg.name can be undefined #220

vixalien opened this issue Nov 12, 2024 · 3 comments · May be fixed by #226
Labels

Comments

@vixalien
Copy link

Description

The current type of pkg.name can be undefined, but it's unclear how common that is. I have to use pkg.name! everywhere. This is also true for other types like pkg.version

Current vs Expected Behavior

Current:

    /** The base name of the entry point (eg. org.foo.Bar.App) */
    export const name: string | undefined;

Expected:

    /** The base name of the entry point (eg. org.foo.Bar.App) */
    export const name: string;

Example

pkg.name

References

  • Documentation:
  • Source Code:
  • Related Issues:
  • GJS Version: 1.80.2

Additional Context

  • This affects other GJS types/classes
  • This is a regression from a previous version
  • This blocks other functionality
@vixalien vixalien added the bug label Nov 12, 2024
@vixalien
Copy link
Author

Also, the same should be there for gettext(), _().

@JumpLink
Copy link
Collaborator

JumpLink commented Nov 13, 2024

@vixalien As far as I know pkg.name and pkg.version are only defined if pkg.init() was called before. Accordingly, they can be undefined and using ! is a valid way to indicate that you are sure that it is defined.

The same applies to gettext, for which pkg.initGettext(); must be called first

@vixalien
Copy link
Author

Sure, it's just a bit inconvenient to always add the !

Funnily enough though, pkg will not always be defined either, so that also needs to be nullable, or, if you can bear with me:

there should be a way to include a file that will mean that developers are sure pkg.name will be defined. Having them as nullable really makes it harder.

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

Successfully merging a pull request may close this issue.

2 participants