Research
Security News
Malicious PyPI Package ‘pycord-self’ Targets Discord Developers with Token Theft and Backdoor Exploit
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Internal .d.ts cleanup. Turns class properties marked with @internal to private.
idtsc (internal .d.ts cleanup).
It's a post-processing step to hide/protect internal properties & methods by adding jsdoc tags.
@internal protected
:
@internal protected
will be removed from the jsdoc.@internal
(without protected
):
@internal
It is meant to be run on your generated .d.ts
files.
internal
modifier (in addition to public/protected/private), but it doesn't seem to get anywhere.Install it as dev-dependency in your project:
npm i -D idtsc
To mark your properties, methods and classes as internal, simply add a jsdoc tag:
export declare class A {
/** @internal */
public type: string;
/** @internal protected */
public sharedProp: string;
}
Say you have a build script, which writes .d.ts
files into the folder <root>/dist
:
"build": "tsc"
All you need to do is ensure that idtsc runs after the build:
"build": "tsc && idtsc"
type npx idtsc --help
to see all available options.
Syntax: idtsc [options] [pattern]
Positionals:
pattern files to process (glob pattern) [default: "./dist/**/*.d.ts"]
Options:
--help Show help
--version Show version number
-v, --verbose Show processed files
-w, --tab-width Use a different tab-width when formatting new code
Let's say, you have the following code:
/**
* Some class
*/
export declare class A {
/** @internal */
public type: string;
/** something something */
public prop: string;
/** @internal protected */
public sharedProp: string;
/** @internal */
public constructor(foo: string);
/** @internal */
public foo(foo: string): void;
}
export declare class B {
/** @internal */
public foo: string;
/** Construct me */
public constructor(foo: string);
}
/** @internal */
export declare class C {
/** @internal */
public foo: string;
public constructor(foo: string);
}
export declare class D {
/** @internal */
public set foo(value: string);
/** @internal */
public get foo();
}
export declare class E {
/** @internal */
type: string;
/** @internal */
set foo(value: string);
/** @internal */
get foo();
}
After running idtsc, you'll get:
/**
* Some class
*/
export declare class A {
private type: unknown;
/** something something */
public prop: string;
protected sharedProp: string;
private constructor();
private foo: unknown;
}
export declare class B {
private foo: unknown;
/** Construct me */
public constructor(foo: string);
}
export declare class D {
private set foo(value: unknown);
private get foo(): unknown;
}
export declare class E {
private type: unknown;
private set foo(value: unknown);
private get foo(): unknown;
}
Something not working quite as expected? Do you need a feature that has not been implemented yet? Check the issue tracker and add a new one if your problem is not already listed. Please try to provide a detailed description of your problem, including the steps to reproduce it.
Awesome! If you would like to contribute with a new feature or submit a bugfix, fork this repo and send a pull request. Please, make sure all the unit tests are passing before submitting and add new ones in case you introduced new features.
idtsc has been released under the zlib/libpng license, meaning you can use it free of charge, without strings attached in commercial and non-commercial projects. Credits are appreciated but not mandatory.
FAQs
Internal .d.ts cleanup. Turns class properties marked with @internal to private.
We found that idtsc demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.