Skip to content
This repository has been archived by the owner on Jan 14, 2021. It is now read-only.

Hide top-level client properties (as they are visible via JS code intellisense) #421

Closed
schickling opened this issue Jan 17, 2020 · 7 comments · Fixed by #526
Closed

Hide top-level client properties (as they are visible via JS code intellisense) #421

schickling opened this issue Jan 17, 2020 · 7 comments · Fixed by #526
Assignees
Labels
kind/improvement An improvement to existing feature and code. tech/typescript Issue for tech TypeScript.
Milestone

Comments

@schickling
Copy link
Member

There a plenty of private fields in the PrismaClient class which are properly hidden when using TypeScript but are visible when a user is working with plain JS. I suggest we move all top-level properties/functions that are not intended for the user to a _ prefixed wrapper property.

image

image

@schickling schickling added the process/candidate Candidate for next Milestone. label Jan 17, 2020
@janpio janpio added the kind/improvement An improvement to existing feature and code. label Jan 17, 2020
@janpio janpio added this to the Preview 21 milestone Jan 17, 2020
@Jolg42
Copy link
Contributor

Jolg42 commented Jan 20, 2020

I believe it's related to this bug in TypeScript Intellisense microsoft/TypeScript#34934

@Jolg42
Copy link
Contributor

Jolg42 commented Jan 30, 2020

Right now it looks like the TypeScript team is aware of it, will work on it and will ship it for 3.9.0 April release.

There is also the "real" # private that should fix this coming to TypeScript in February release 3.8.0 microsoft/TypeScript#30829

@divyenduz
Copy link

Internal note: dropping from this sprint

@Jolg42
Copy link
Contributor

Jolg42 commented Feb 7, 2020

It looks like we'll be able to do it with # private feature in TypeScript 3.8 @timsuchanek 🎊

See details from https://devblogs.microsoft.com/typescript/announcing-typescript-3-8-rc/

As we mentioned, another benefit is that subclassing can be easier with ECMAScript’s # privates because they really are private. When using ECMAScript # private fields, no subclass ever has to worry about collisions in field naming. When it comes to TypeScript’s private property declarations, users still have to be careful not to trample over properties declared in superclasses.

Finally, something to consider is where you intend for your code to run. TypeScript currently can’t support this feature unless targeting ECMAScript 2015 (ES6) targets or higher. This is because our downleveled implementation uses WeakMaps to enforce privacy, and WeakMaps can’t be polyfilled in a way that doesn’t cause memory leaks.

@Jolg42 Jolg42 added the process/candidate Candidate for next Milestone. label Feb 10, 2020
@divyenduz divyenduz modified the milestones: Preview 21, Preview 23 Feb 14, 2020
@divyenduz divyenduz added process/candidate Candidate for next Milestone. and removed process/candidate Candidate for next Milestone. labels Feb 14, 2020
@divyenduz divyenduz modified the milestone: Preview 23 Feb 18, 2020
@divyenduz divyenduz added process/candidate Candidate for next Milestone. and removed process/candidate Candidate for next Milestone. labels Feb 18, 2020
@Jolg42 Jolg42 linked a pull request Feb 25, 2020 that will close this issue
@Jolg42 Jolg42 reopened this Mar 3, 2020
@Jolg42
Copy link
Contributor

Jolg42 commented Mar 3, 2020

This was reverted because it messed up the the CI tests.

@janpio janpio removed this from the Preview 23 milestone Mar 3, 2020
@janpio janpio added this to the Preview 24 milestone Mar 3, 2020
@divyenduz divyenduz added the process/candidate Candidate for next Milestone. label Jun 10, 2020
@janpio janpio modified the milestones: Preview 24 Old, 2.1.0 Jun 10, 2020
@janpio janpio added the tech/typescript Issue for tech TypeScript. label Jun 10, 2020
@Jolg42
Copy link
Contributor

Jolg42 commented Jun 10, 2020

This was fixed by the TypeScript team and will be released in 4.0 (August release) microsoft/TypeScript#34934 (comment)

@janpio janpio removed the process/candidate Candidate for next Milestone. label Jun 11, 2020
@Jolg42 Jolg42 modified the milestones: 2.1.0, Release 2.6.0 Aug 21, 2020
@Jolg42
Copy link
Contributor

Jolg42 commented Aug 21, 2020

Closing as TypeScript 4 was released with the fix!
https://devblogs.microsoft.com/typescript/announcing-typescript-4-0/

Example on 3.9.7
Screen Shot 2020-08-21 at 15 06 24
Screen Shot 2020-08-21 at 15 06 32

Example on 4.0.2
Screen Shot 2020-08-21 at 15 05 28
Screen Shot 2020-08-21 at 15 05 37

@Jolg42 Jolg42 closed this as completed Aug 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/improvement An improvement to existing feature and code. tech/typescript Issue for tech TypeScript.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants