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

Private class fields don't work in a TypeScript file #23

Closed
fabis94 opened this issue Mar 5, 2021 · 4 comments
Closed

Private class fields don't work in a TypeScript file #23

fabis94 opened this issue Mar 5, 2021 · 4 comments

Comments

@fabis94
Copy link

fabis94 commented Mar 5, 2021

Am I correct in guessing that this lib doesn't load the private class properties proposal for TypeScript files? This file makes me think so: https://github.com/nuxt-contrib/jiti/blob/5d5ee2895d6670044bda368449557a6a131f7439/src/babel.ts#L19

Because of this (or another) issue I'm unable to use private class properties in my Nuxt.js app.

@pi0
Copy link
Member

pi0 commented Mar 6, 2021

Hi @fabis94. Jiti uses an isolate build of babel to transform syntax. And the reason is excluded is that @babel/plugin-transform-typescript is supposed to work and locally testing this works (in a typescript file):

class Test {
 foo: string = 'bar'
}

console.log(new Test().foo)

Would you please share syntax used in smartRuntimeConfig.ts or if possible a reprodution?

@fabis94
Copy link
Author

fabis94 commented Mar 6, 2021

@pi0 Your example has public properties, smartRuntimeConfig.ts has private ones, like so:

class SmartRuntimeConfig {
  #foo: string;

  constructor(foo: string) {
    this.#foo= foo;
  }
}

@fabis94 fabis94 changed the title Private class properties don't work in a TypeScript file Private class fields don't work in a TypeScript file Mar 6, 2021
@pi0 pi0 closed this as completed in c0098fe Mar 11, 2021
@pi0
Copy link
Member

pi0 commented Mar 11, 2021

You are right @fabis94. Fixed in 1.6.4. You have to recreate lock file to get update.

@fabis94
Copy link
Author

fabis94 commented Mar 13, 2021

Thank you

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