Skip to main content
Version: 0.1.x

Naming scheme

It is important to stick to the following scheme for naming identifiers in your code. Because SALVO-TS uses some introspection/reflection techniques and does some code generation, if you don't stick to the following then you may introduce issues.

typescript
// Class, Interface, Type => PascalCase
class MyClass {}
interface MyInterface {}
type MyType = {}
// DO NOT use 'I' or 'A' prefix on interface or abstract classes
abstract class MyBaseClass {}
interface MyInterface {}
// Fields and methods => camelCase
class MyClass {
myField: string;
// Arguments => camelCase
myMethod(myArg: string): void;
}
// Getters/setters => camelCase
class MyClass {
get myGetter() {
return 'foo';
}
set mySetter(value: string) {
}
// Private fields should not have a '_' prefix
private myField: string;
// If you have a backing field that has the same name as it's getter/setters,
// you may prefix it with a '_' - in all other cases, DO NOT use '_' prefixes
// The field MUST be private in this case, or you will recieve a lint error.
private _myField: string;
get myField() {
return this._myField;
}
set myField(value: string) {
this._myField = value;
}
}
// Generic types => 'T', 'TKey', 'TChild', etc.
function identity<T>(obj: T): T { return obj; }
class MyDictionary<TKey, TValue> {}
function swapChild<T, TChild extends T['child']>(parent: T, newChild: TChild) {}
// Constants (literals only, top-level) => UPPER_CASE
const BASICALLY_PI = 3.14;
// Constants (any other situation) => camelCase
const myFoo = makeFoo();
function myFunction() {
const basicallyTau = 6.3;
}
// All other identifiers => camelCase
let myVariable = 42;
const myVariable = getFoo();
function myFunction() {}
typescript
// Class, Interface, Type => PascalCase
class MyClass {}
interface MyInterface {}
type MyType = {}
// DO NOT use 'I' or 'A' prefix on interface or abstract classes
abstract class MyBaseClass {}
interface MyInterface {}
// Fields and methods => camelCase
class MyClass {
myField: string;
// Arguments => camelCase
myMethod(myArg: string): void;
}
// Getters/setters => camelCase
class MyClass {
get myGetter() {
return 'foo';
}
set mySetter(value: string) {
}
// Private fields should not have a '_' prefix
private myField: string;
// If you have a backing field that has the same name as it's getter/setters,
// you may prefix it with a '_' - in all other cases, DO NOT use '_' prefixes
// The field MUST be private in this case, or you will recieve a lint error.
private _myField: string;
get myField() {
return this._myField;
}
set myField(value: string) {
this._myField = value;
}
}
// Generic types => 'T', 'TKey', 'TChild', etc.
function identity<T>(obj: T): T { return obj; }
class MyDictionary<TKey, TValue> {}
function swapChild<T, TChild extends T['child']>(parent: T, newChild: TChild) {}
// Constants (literals only, top-level) => UPPER_CASE
const BASICALLY_PI = 3.14;
// Constants (any other situation) => camelCase
const myFoo = makeFoo();
function myFunction() {
const basicallyTau = 6.3;
}
// All other identifiers => camelCase
let myVariable = 42;
const myVariable = getFoo();
function myFunction() {}