D
Deno

help

What a method prefixed with `#` means?

Ddidiercrunch6/13/2023
This is perhaps the stupidest question ever. But I often see method with names prefixed with a # character in typescript. What does it mean? Google does not seems to know either. example: https://deno.land/std@0.187.0/streams/text_line_stream.ts?source#L40
ABTAndreu Botella (they/them)6/13/2023
It's a private method
CcrowlKats6/13/2023
Private class features - JavaScript | MDN
Class fields are public by default, but private class members can be created by using a hash # prefix. The privacy encapsulation of these class features is enforced by JavaScript itself.
Ddidiercrunch6/13/2023
nice, thanks a lot. I was using the private keyword.
AAapoAlas6/13/2023
private is TypeScript-level private only, ie. in runtime the property or method is still entirely public and visible there. # is runtime-private as well, and it is actually one of the strongest possible flavours of privateness, eg. private class fields cannot be accessed by sub-classes. In short: There's a time and place for both.

Looking for more? Join the community!

Recommended Posts
Logger names and prefixesIs there any obvious way on how to configure std/log so that loggers named `my-prefix/foo/bar` and `Deno and `npm:mongodb` problem with `node:`?``` ❯ deno check --reload main.ts error: Relative import path "net" not prefixed with / or ./ or ../DiscordJS "Error: Not implemented: ClientRequest.options.createConnection"```ts import { GatewayDispatchEvents, GatewayIntentBits, InteractionType, MessageFlags, Client } froUsing Superagent in Deno?Has anyone managed to make Superagent work nicely in Deno? ``` _ { type: "error", message: "BroOak – ctx.assert with custom response headersAm I doing this wrong? No extra custom headers are being set in the response as far as I can see in npm:undici doesn't workhttps://github.com/denoland/deno/issues/16710 Marked as resolved by this issue but does not work in Abusing prototype CryptoKey in `node:crypto`Is there any way that I can set the prototype of an object to specifically `CryptoKey` as defined byUncaught (in promise) TypeError: cannot read headers: request closedWhat is this? How to fix it?Async OP that returns value instead of promiseIn `deno_runtime` is possible to have async op that returns the resolved value instead of promise? KFresh Logging MiddlewareHow would you go about writing a duration logger? Using 2 middlewares, I assumed they would behave VS-Code auto import local modulesHey is there a way to enable some sort of auto import for local modules/files in VS-Code? Currently In memory Deno KvHi there, I am exploring with [Deno Kv](https://deno.com/deploy/docs/kv) and it looks great! But my