From 6dda128c44bc6904f71e13ba77a0413ae95ec19e Mon Sep 17 00:00:00 2001 From: Paul Vasich Date: Tue, 18 Sep 2018 11:17:52 -0500 Subject: [PATCH 1/4] Add Complex.re & Complex.im z.re & z.im are accessible on each Complex instance. --- types/complex/index.d.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/types/complex/index.d.ts b/types/complex/index.d.ts index 90ad161ffc..6ac9fc546c 100644 --- a/types/complex/index.d.ts +++ b/types/complex/index.d.ts @@ -45,6 +45,16 @@ export default class Complex { * A instance for the real number */ static one: Complex; + + /** + * The instance's real component. + */ + re: number; + + /** + * The instance's imaginary component. + */ + im: number; /** * Set the real and imaginary properties a and b from a + bi. From 3ad8f666ac589e35d5ec3e8b82689237fc832c2b Mon Sep 17 00:00:00 2001 From: Paul Vasich Date: Wed, 19 Sep 2018 11:42:51 -0500 Subject: [PATCH 2/4] Update index.d.ts --- types/complex/index.d.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/types/complex/index.d.ts b/types/complex/index.d.ts index 6ac9fc546c..70d2ea6495 100644 --- a/types/complex/index.d.ts +++ b/types/complex/index.d.ts @@ -1,6 +1,8 @@ // Type definitions for Complex 3.0.1 // Project: https://github.com/arian/Complex -// Definitions by: Aya Morisawa +// Definitions by: +// Aya Morisawa +// Paul Vasich // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export default class Complex { @@ -47,12 +49,12 @@ export default class Complex { static one: Complex; /** - * The instance's real component. + * The Complex number's real component */ - re: number; + real: number; /** - * The instance's imaginary component. + * The Complex number's imaginary component */ im: number; From acf4ce05344aa98e3af6f572de724025d6b87673 Mon Sep 17 00:00:00 2001 From: Paul Vasich Date: Wed, 19 Sep 2018 11:45:21 -0500 Subject: [PATCH 3/4] Update complex-tests.ts --- types/complex/complex-tests.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/types/complex/complex-tests.ts b/types/complex/complex-tests.ts index 23074d104d..0e9f4cc919 100644 --- a/types/complex/complex-tests.ts +++ b/types/complex/complex-tests.ts @@ -40,3 +40,6 @@ var z: Complex = z.tanh(); var z: Complex = z.clone(); var s: string = z.toString(); var b: boolean = z.equals(z); +var n: number = z.real; +var i: number = z.im; + From da179d47aec3898fb838f365c41733436159b872 Mon Sep 17 00:00:00 2001 From: Paul Vasich Date: Wed, 19 Sep 2018 12:20:12 -0500 Subject: [PATCH 4/4] Add Complex.real and Complex.im --- types/complex/complex-tests.ts | 85 +++++++++++++++++----------------- types/complex/index.d.ts | 34 ++++++++------ types/complex/tsconfig.json | 4 +- types/complex/tslint.json | 80 +------------------------------- 4 files changed, 65 insertions(+), 138 deletions(-) diff --git a/types/complex/complex-tests.ts b/types/complex/complex-tests.ts index 0e9f4cc919..8268f0c135 100644 --- a/types/complex/complex-tests.ts +++ b/types/complex/complex-tests.ts @@ -1,45 +1,44 @@ import Complex from 'complex'; -var z: Complex = new Complex(2, 3); -var z: Complex = Complex.from(2, 3); -var z: Complex = Complex.from(2, 4); -var z: Complex = Complex.from(5); -var z: Complex = Complex.from('2+5i'); -var z: Complex = Complex.fromPolar(3, Math.PI); -var z: Complex = Complex.i; -var z: Complex = Complex.one; -var z: Complex = z.fromRect(2, 3); -var z: Complex = z.fromPolar(3, Math.PI); -var z: Complex = z.toPrecision(3); -var z: Complex = z.toFixed(3); -var z: Complex = z.finalize(); -var x: number = z.magnitude(); -var x: number = z.abs(); -var x: number = z.angle(); -var x: number = z.arg(); -var x: number = z.phase(); -var z: Complex = z.conjugate(); -var z: Complex = z.negate(); -var z: Complex = z.multiply(z); -var z: Complex = z.mult(3); -var z: Complex = z.divide(z); -var z: Complex = z.div(3); -var z: Complex = z.add(z); -var z: Complex = z.subtract(z); -var z: Complex = z.sub(3); -var z: Complex = z.pow(z); -var z: Complex = z.sqrt(); -var z: Complex = z.log(2); -var z: Complex = z.exp(); -var z: Complex = z.sin(); -var z: Complex = z.cos(); -var z: Complex = z.tan(); -var z: Complex = z.sinh(); -var z: Complex = z.cosh(); -var z: Complex = z.tanh(); -var z: Complex = z.clone(); -var s: string = z.toString(); -var b: boolean = z.equals(z); -var n: number = z.real; -var i: number = z.im; - +let z: Complex = new Complex(2, 3); +z = Complex.from(2, 3); +z = Complex.from(2, 4); +z = Complex.from(5); +z = Complex.from('2+5i'); +z = Complex.fromPolar(3, Math.PI); +z = Complex.i; +z = Complex.one; +z = z.fromRect(2, 3); +z = z.fromPolar(3, Math.PI); +z = z.toPrecision(3); +z = z.toFixed(3); +z = z.finalize(); +let x: number = z.magnitude(); +x = z.abs(); +x = z.angle(); +x = z.arg(); +x = z.phase(); +z = z.conjugate(); +z = z.negate(); +z = z.multiply(z); +z = z.mult(3); +z = z.divide(z); +z = z.div(3); +z = z.add(z); +z = z.subtract(z); +z = z.sub(3); +z = z.pow(z); +z = z.sqrt(); +z = z.log(2); +z = z.exp(); +z = z.sin(); +z = z.cos(); +z = z.tan(); +z = z.sinh(); +z = z.cosh(); +z = z.tanh(); +z = z.clone(); +const s: string = z.toString(); +const b: boolean = z.equals(z); +const n: number = z.real; +const i: number = z.im; diff --git a/types/complex/index.d.ts b/types/complex/index.d.ts index 70d2ea6495..3f44ba8e1e 100644 --- a/types/complex/index.d.ts +++ b/types/complex/index.d.ts @@ -1,8 +1,7 @@ -// Type definitions for Complex 3.0.1 +// Type definitions for Complex 3.0 // Project: https://github.com/arian/Complex -// Definitions by: -// Aya Morisawa -// Paul Vasich +// Definitions by: Aya Morisawa +// Paul Vasich // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export default class Complex { @@ -47,12 +46,12 @@ export default class Complex { * A instance for the real number */ static one: Complex; - + /** * The Complex number's real component */ real: number; - + /** * The Complex number's imaginary component */ @@ -73,19 +72,25 @@ export default class Complex { fromPolar(r: number, phi: number): Complex; /** - * Set the precision of the numbers. Similar to Number.prototype.toPrecision. Useful before printing the number with the toString method. + * Set the precision of the numbers. Similar to Number.prototype.toPrecision. + * Useful before printing the number with the toString method. * @param k An integer specifying the number of significant digits */ toPrecision(k: number): Complex; /** - * Format a number using fixed-point notation. Similar to Number.prototype.toFixed. Useful before printing the number with the toString method. - * @param k The number of digits to appear after the decimal point; this may be a value between 0 and 20, inclusive, and implementations may optionally support a larger range of values. If this argument is omitted, it is treated as 0. + * Format a number using fixed-point notation. Similar to Number.prototype.toFixed. + * Useful before printing the number with the toString method. + * @param k The number of digits to appear after the decimal point [0 - 20]. + * Implementations may optionally support a larger range of values. + * If this argument is omitted, it is treated as 0. */ toFixed(k: number): Complex; /** - * Finalize the instance. The number will not change and any other method call will return a new instance. Very useful when a complex instance should stay constant. For example the Complex.i variable is a finalized instance. + * Finalize the instance. The number will not change and any other method call will return a new instance. + * Very useful when a complex instance should stay constant. + * For example the Complex.i variable is a finalized instance. */ finalize(): Complex; @@ -179,7 +184,8 @@ export default class Complex { /** * Return the natural logarithm (base E) - * @param k The actual answer has a multiplicity (ln(z) = ln|z| + arg(z)) where arg(z) can return the same for different angles (every 2*pi), with this argument you can define which answer is required + * @param k The actual answer has a multiplicity (ln(z) = ln|z| + arg(z)) where arg(z) can return the same for + * different angles (every 2*pi), with this argument you can define which answer is required */ log(k?: number): Complex; @@ -206,17 +212,17 @@ export default class Complex { /** * Calculate the hyperbolic sine of the complex number */ - sinh(): Complex + sinh(): Complex; /** * Calculate the hyperbolic cosine of the complex number */ - cosh(): Complex + cosh(): Complex; /** * Calculate the hyperbolic tangent of the complex number */ - tanh(): Complex + tanh(): Complex; /** * Return a new Complex instance with the same real and imaginary properties diff --git a/types/complex/tsconfig.json b/types/complex/tsconfig.json index b8a54e716a..0869ead6e6 100644 --- a/types/complex/tsconfig.json +++ b/types/complex/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ @@ -20,4 +20,4 @@ "index.d.ts", "complex-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/complex/tslint.json b/types/complex/tslint.json index a41bf5d19a..3db14f85ea 100644 --- a/types/complex/tslint.json +++ b/types/complex/tslint.json @@ -1,79 +1 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -} +{ "extends": "dtslint/dt.json" }