Typescript constructor access modifiers are not working in dev mode
See original GitHub issueWhen creating a class in typescript with access modifiers in constructor, the constructor parameters are not converted into class properties. The following example will not work correctly
export class Test { constructor(public foo: string) {} } console.log(new Test("bar"));
Steps to reproduce:
- create a new project using the cli command:
preact create typescript projectName
- create the class with access modifiers in constructor
- run the project in dev mode using:
npm run dev
Note: this issue is not reproducible using the build command, it is only reproducible in dev (prect watch) mode.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Angular:Why is constructor parameters without access ...
Giving an access specifier to a function parameter is none sense. In TypeScript, you can do this anyway to the constructor, and the...
Read more >Constructors and Access modifiers in TypeScript/Angular
Note: In TypeScript we can have only one constructor method into the class — but we can have optional parameters in constructor —...
Read more >Parameter decorator with modifier in the constructor does not ...
If at least one modifier is missing, it works fine. Input code // not work class MyClass { constructor(@Inject() readonly param1: Injected) ...
Read more >Access modifiers and constructor in TypeScript | by Mrunali Patil
Access modifiers is used to achieve important feature of Object Oriented Programming, this feature is known as data hiding.
Read more >How to add Access Modifiers with Constructor Parameters in ...
Learn to use Typescript best and essential feature of adding Access Modifiers in Constructor Parameters for initialization with example.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Tested using a local linked version of the CLI, and indeed it works. Thanks for your support.
Glad to hear it. Sorry, I know that’s not a brilliant solution, but it’ll be an option until the next CLI release. Alternatively you can try an older CLI version, but no idea if that’ll work.