Repository: gcanti/fp-ts
Pull request #802 (2019-03-29 18:52:15)

upgrade to typescript 3.4.1


Patch:
diff --git a/package-lock.json b/package-lock.json
index 591ed373..b2395ddf 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
 {
   "name": "fp-ts",
-  "version": "1.14.4",
+  "version": "1.15.0",
   "lockfileVersion": 1,
   "requires": true,
   "dependencies": {
@@ -1736,7 +1736,7 @@
       }
     },
     "dtslint": {
-      "version": "github:gcanti/dtslint#02aec0b72ae639458f02349c5c68dd6229287a6d",
+      "version": "github:gcanti/dtslint#217abe9ec59cf4323d4e47c2d458312b12eb4983",
       "from": "github:gcanti/dtslint",
       "dev": true,
       "requires": {
@@ -1744,7 +1744,7 @@
         "parsimmon": "^1.12.0",
         "strip-json-comments": "^2.0.1",
         "tslint": "^5.12.0",
-        "typescript": "^3.4.0-dev.20190216"
+        "typescript": "^3.4.0-dev.20190329"
       },
       "dependencies": {
         "ansi-styles": {
@@ -1767,20 +1767,6 @@
             "supports-color": "^5.3.0"
           }
         },
-        "glob": {
-          "version": "7.1.3",
-          "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz",
-          "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==",
-          "dev": true,
-          "requires": {
-            "fs.realpath": "^1.0.0",
-            "inflight": "^1.0.4",
-            "inherits": "2",
-            "minimatch": "^3.0.4",
-            "once": "^1.3.0",
-            "path-is-absolute": "^1.0.0"
-          }
-        },
         "has-flag": {
           "version": "3.0.0",
           "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
@@ -1797,9 +1783,9 @@
           }
         },
         "tslint": {
-          "version": "5.12.1",
-          "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.12.1.tgz",
-          "integrity": "sha512-sfodBHOucFg6egff8d1BvuofoOQ/nOeYNfbp7LDlKBcLNrL3lmS5zoiDGyOMdT7YsEXAwWpTdAHwOGOc8eRZAw==",
+          "version": "5.14.0",
+          "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.14.0.tgz",
+          "integrity": "sha512-IUla/ieHVnB8Le7LdQFRGlVJid2T/gaJe5VkjzRVSRR6pA2ODYrnfR1hmxi+5+au9l50jBwpbBL34txgv4NnTQ==",
           "dev": true,
           "requires": {
             "babel-code-frame": "^6.22.0",
@@ -1810,10 +1796,11 @@
             "glob": "^7.1.1",
             "js-yaml": "^3.7.0",
             "minimatch": "^3.0.4",
+            "mkdirp": "^0.5.1",
             "resolve": "^1.3.2",
             "semver": "^5.3.0",
             "tslib": "^1.8.0",
-            "tsutils": "^2.27.2"
+            "tsutils": "^2.29.0"
           }
         },
         "tsutils": {
@@ -1826,9 +1813,9 @@
           }
         },
         "typescript": {
-          "version": "3.4.0-dev.20190216",
-          "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.4.0-dev.20190216.tgz",
-          "integrity": "sha512-46/6VqUDONOFriBe/u7aSPon6xF0sBsRWCkE9Ue/vF8ssrligDaW9Cs5YLQ5gv6rgsHJ8IX0HwugcH6hTpCReg==",
+          "version": "3.4.0-dev.20190329",
+          "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.4.0-dev.20190329.tgz",
+          "integrity": "sha512-iEJfMDxQlatDr6WQF5ywln+e5d4yfKSYxUW4brcrS5B+8AgSwdLbRn0VsYYcpG6AyFO0jUeAnuZVnpGvZgJtmw==",
           "dev": true
         }
       }
@@ -7020,9 +7007,9 @@
       "dev": true
     },
     "typescript": {
-      "version": "3.3.3",
-      "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.3.3.tgz",
-      "integrity": "sha512-Y21Xqe54TBVp+VDSNbuDYdGw0BpoR/Q6wo/+35M8PAU0vipahnyduJWirxxdxjsAkS7hue53x2zp8gz7F05u0A==",
+      "version": "3.4.1",
+      "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.4.1.tgz",
+      "integrity": "sha512-3NSMb2VzDQm8oBTLH6Nj55VVtUEpe/rgkIzMir0qVoLyjDZlnMBva0U6vDiV3IH+sl/Yu6oP5QwsAQtHPmDd2Q==",
       "dev": true
     },
     "uglify-js": {
diff --git a/package.json b/package.json
index 8671ae89..e1ebd992 100644
--- a/package.json
+++ b/package.json
@@ -56,7 +56,7 @@
     "ts-simple-ast": "17.1.1",
     "tslint": "5.11.0",
     "tslint-config-standard": "8.0.1",
-    "typescript": "^3.3.3"
+    "typescript": "^3.4.1"
   },
   "tags": [
     "typescript",
diff --git a/src/Array.ts b/src/Array.ts
index c96ce3c1..1eb83511 100644
--- a/src/Array.ts
+++ b/src/Array.ts
@@ -21,6 +21,7 @@ import { getArraySetoid, Setoid } from './Setoid'
 import { TraversableWithIndex1 } from './TraversableWithIndex'
 import { Unfoldable1 } from './Unfoldable'
 import { Witherable1 } from './Witherable'
+import { NonEmptyArray } from './NonEmptyArray2v'
 
 declare global {
   interface Array<T> {
@@ -463,7 +464,7 @@ export const index = <A>(i: number, as: Array<A>): Option<A> => {
 }
 
 /**
- * Attaches an element to the front of an array, creating a new array
+ * Attaches an element to the front of an array, creating a new non empty array
  *
  * @example
  * import { cons } from 'fp-ts/lib/Array'
@@ -472,18 +473,18 @@ export const index = <A>(i: number, as: Array<A>): Option<A> => {
  *
  * @since 1.0.0
  */
-export const cons = <A>(a: A, as: Array<A>): Array<A> => {
+export const cons = <A>(a: A, as: Array<A>): NonEmptyArray<A> => {
   const len = as.length
   const r = Array(len + 1)
   for (let i = 0; i < len; i++) {
     r[i + 1] = as[i]
   }
   r[0] = a
-  return r
+  return r as NonEmptyArray<A>
 }
 
 /**
- * Append an element to the end of an array, creating a new array
+ * Append an element to the end of an array, creating a new non empty array
  *
  * @example
  * import { snoc } from 'fp-ts/lib/Array'
@@ -492,14 +493,14 @@ export const cons = <A>(a: A, as: Array<A>): Array<A> => {
  *
  * @since 1.0.0
  */
-export const snoc = <A>(as: Array<A>, a: A): Array<A> => {
+export const snoc = <A>(as: Array<A>, a: A): NonEmptyArray<A> => {
   const len = as.length
   const r = Array(len + 1)
   for (let i = 0; i < len; i++) {
     r[i] = as[i]
   }
   r[len] = a
-  return r
+  return r as NonEmptyArray<A>
 }
 
 /**
diff --git a/src/NonEmptyArray2v.ts b/src/NonEmptyArray2v.ts
index 5f2190a9..6400b32d 100644
--- a/src/NonEmptyArray2v.ts
+++ b/src/NonEmptyArray2v.ts
@@ -281,6 +281,30 @@ const mapWithIndex = <A, B>(fa: NonEmptyArray<A>, f: (i: number, a: A) => B): No
   return fa.map((a, i) => f(i, a))
 }
 
+/**
+ * Append an element to the end of an array, creating a new non empty array
+ *
+ * @example
+ * import { snoc } from 'fp-ts/lib/NonEmptyArray2v'
+ *
+ * assert.deepStrictEqual(snoc([1, 2, 3], 4), [1, 2, 3, 4])
+ *
+ * @since 1.16.0
+ */
+export const snoc = A.snoc
+
+/**
+ * Append an element to the front of an array, creating a new non empty array
+ *
+ * @example
+ * import { cons } from 'fp-ts/lib/NonEmptyArray2v'
+ *
+ * assert.deepStrictEqual(cons(1, [2, 3, 4]), [1, 2, 3, 4])
+ *
+ * @since 1.16.0
+ */
+export const cons = A.cons
+
 /**
  * @since 1.15.0
  */


Test patch:
diff --git a/test/NonEmptyArray2v.ts b/test/NonEmptyArray2v.ts
index dc47c52a..1eb1bbbe 100644
--- a/test/NonEmptyArray2v.ts
+++ b/test/NonEmptyArray2v.ts
@@ -23,7 +23,9 @@ import {
   updateAt,
   filter,
   filterWithIndex,
-  fromNonEmptyArray
+  fromNonEmptyArray,
+  cons,
+  snoc
 } from '../src/NonEmptyArray2v'
 import { none, option, some, isSome } from '../src/Option'
 import { ordNumber } from '../src/Ord'
@@ -379,4 +381,12 @@ describe.only('NonEmptyArray2v', () => {
       nonEmptyArray.traverseWithIndex(I.identity)(ta, (i, a) => new I.Identity(f(i, a))).value
     )
   })
+
+  it('cons', () => {
+    assert.deepStrictEqual(cons(1, [2, 3, 4]), [1, 2, 3, 4])
+  })
+
+  it('snoc', () => {
+    assert.deepStrictEqual(snoc([1, 2, 3], 4), [1, 2, 3, 4])
+  })
 })