]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
refactor: use ts for tests
authorEduardo San Martin Morote <posva13@gmail.com>
Fri, 27 Sep 2019 10:03:11 +0000 (12:03 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Fri, 27 Sep 2019 10:03:11 +0000 (12:03 +0200)
27 files changed:
__tests__/errors.spec.ts [moved from __tests__/errors.spec.js with 84% similarity]
__tests__/extractComponentsGuards.spec.ts [moved from __tests__/extractComponentsGuards.spec.js with 80% similarity]
__tests__/guards/component-beforeRouteEnter.spec.ts [moved from __tests__/guards/component-beforeRouteEnter.spec.js with 90% similarity]
__tests__/guards/component-beforeRouteLeave.spec.ts [moved from __tests__/guards/component-beforeRouteLeave.spec.js with 90% similarity]
__tests__/guards/component-beforeRouteUpdate.spec.ts [moved from __tests__/guards/component-beforeRouteUpdate.spec.js with 85% similarity]
__tests__/guards/global-after.spec.ts [moved from __tests__/guards/global-after.spec.js with 88% similarity]
__tests__/guards/global-beforeEach.spec.ts [moved from __tests__/guards/global-beforeEach.spec.js with 93% similarity]
__tests__/guards/route-beforeEnter.spec.ts [moved from __tests__/guards/route-beforeEnter.spec.js with 91% similarity]
__tests__/history/abstract.spec.ts [moved from __tests__/history/abstract.spec.js with 97% similarity]
__tests__/history/html5.spec.ts [moved from __tests__/history/html5.spec.js with 77% similarity]
__tests__/matcher-ranking.spec.ts [moved from __tests__/matcher-ranking.spec.js with 80% similarity]
__tests__/matcher.spec.ts [moved from __tests__/matcher.spec.js with 82% similarity]
__tests__/query.spec.ts [moved from __tests__/query.spec.js with 87% similarity]
__tests__/router-link.spec.ts [moved from __tests__/router-link.spec.js with 72% similarity]
__tests__/router-view.spec.ts [moved from __tests__/router-view.spec.js with 79% similarity]
__tests__/router.spec.ts [moved from __tests__/router.spec.js with 91% similarity]
__tests__/ssr/basic.spec.ts [moved from __tests__/ssr/basic.spec.js with 91% similarity]
__tests__/ssr/shared.ts
__tests__/tsconfig.json [deleted file]
__tests__/url-encoding.spec.ts [moved from __tests__/url-encoding.spec.js with 93% similarity]
__tests__/url.spec.ts [moved from __tests__/url.spec.js with 97% similarity]
__tests__/utils.ts
jest.config.js
package.json
tsconfig.check-types.json [deleted file]
tsconfig.json
yarn.lock

similarity index 84%
rename from __tests__/errors.spec.js
rename to __tests__/errors.spec.ts
index ae6c1f8a71e862f96b410ff875322fc9595665b1..0bd4ed635246afb9b3c2da23f2d61447a71f73f7 100644 (file)
@@ -1,16 +1,10 @@
-// @ts-check
-const fakePromise = require('faked-promise')
-const { AbstractHistory } = require('../src/history/abstract')
-const { Router } = require('../src/router')
-const {
-  NavigationAborted,
-  NavigationCancelled,
-  NavigationGuardRedirect,
-} = require('../src/errors')
-const { components, tick } = require('./utils')
+import { AbstractHistory } from '../src/history/abstract'
+import { Router } from '../src/router'
+import { NavigationAborted, NavigationGuardRedirect } from '../src/errors'
+import { components, tick } from './utils'
+import { RouteRecord } from '../src/types'
 
-/** @type {import('../src/types').RouteRecord[]} */
-const routes = [
+const routes: RouteRecord[] = [
   { path: '/', component: components.Home },
   { path: '/foo', component: components.Foo, name: 'Foo' },
   { path: '/to-foo', redirect: '/foo' },
similarity index 80%
rename from __tests__/extractComponentsGuards.spec.js
rename to __tests__/extractComponentsGuards.spec.ts
index 480274c889de15fbba182ee8afa177e10d693242..a6f373f1930a383ab7cdb6709696f449e4c2b950 100644 (file)
@@ -1,7 +1,10 @@
-// @ts-check
-const { extractComponentsGuards } = require('../src/utils')
-const { START_LOCATION_NORMALIZED } = require('../src/types')
-const { components, normalizeRouteRecord } = require('./utils')
+import { extractComponentsGuards } from '../src/utils'
+import {
+  START_LOCATION_NORMALIZED,
+  RouteRecord,
+  MatchedRouteRecord,
+} from '../src/types'
+import { components, normalizeRouteRecord } from './utils'
 
 /** @typedef {import('../src/types').RouteRecord} RouteRecord */
 /** @typedef {import('../src/types').MatchedRouteRecord} MatchedRouteRecord */
@@ -13,15 +16,12 @@ const beforeRouteEnter = jest.fn()
 const to = START_LOCATION_NORMALIZED
 const from = START_LOCATION_NORMALIZED
 
-/** @type {RouteRecord} */
-const NoGuard = { path: '/', component: components.Home }
-/** @type {RouteRecord} */
-const SingleGuard = {
+const NoGuard: RouteRecord = { path: '/', component: components.Home }
+const SingleGuard: RouteRecord = {
   path: '/',
   component: { ...components.Home, beforeRouteEnter },
 }
-/** @type {RouteRecord} */
-const SingleGuardNamed = {
+const SingleGuardNamed: RouteRecord = {
   path: '/',
   components: {
     default: { ...components.Home, beforeRouteEnter },
@@ -29,20 +29,18 @@ const SingleGuardNamed = {
   },
 }
 
-/**
- *
- * @param {Exclude<RouteRecord, { redirect: any}>} record
- * @returns {MatchedRouteRecord}
- */
-function makeAsync(record) {
+function makeAsync(
+  record: Exclude<RouteRecord, { redirect: any }>
+): MatchedRouteRecord {
   if ('components' in record) {
     const copy = { ...record }
     copy.components = Object.keys(record.components).reduce(
       (components, name) => {
+        // @ts-ignore
         components[name] = () => Promise.resolve(record.components[name])
         return components
       },
-      {}
+      {} as typeof record['components']
     )
     return copy
   } else {
@@ -66,12 +64,10 @@ beforeEach(() => {
   })
 })
 
-/**
- *
- * @param {Exclude<RouteRecord, { redirect: any }>[]} components
- * @param {number} n
- */
-async function checkGuards(components, n) {
+async function checkGuards(
+  components: Exclude<RouteRecord, { redirect: any }>[],
+  n: number
+) {
   beforeRouteEnter.mockClear()
   const guards = await extractComponentsGuards(
     // type is fine as we excluded RouteRecordRedirect in components argument
similarity index 90%
rename from __tests__/guards/component-beforeRouteEnter.spec.js
rename to __tests__/guards/component-beforeRouteEnter.spec.ts
index 75bf4894850925ef656fa7f78e1c269c8bad20b9..ea3a0d4f54202f7fdda166f093dcae7693d78731 100644 (file)
@@ -1,16 +1,12 @@
-// @ts-check
-const { HTML5History } = require('../../src/history/html5')
-const { Router } = require('../../src/router')
-const fakePromise = require('faked-promise')
-const { NAVIGATION_TYPES, createDom, noGuard } = require('../utils')
-
-/** @typedef {import('../../src/types').RouteRecord} RouteRecord */
-/** @typedef {import('../../src/router').RouterOptions} RouterOptions */
-
-/**
- * @param {Partial<RouterOptions> & { routes: RouteRecord[]}} options
- */
-function createRouter(options) {
+import { HTML5History } from '../../src/history/html5'
+import { Router, RouterOptions } from '../../src/router'
+import fakePromise from 'faked-promise'
+import { NAVIGATION_TYPES, createDom, noGuard } from '../utils'
+import { RouteRecord } from '../../src/types'
+
+function createRouter(
+  options: Partial<RouterOptions> & { routes: RouteRecord[] }
+) {
   return new Router({
     history: new HTML5History(),
     ...options,
@@ -36,8 +32,7 @@ const nested = {
   nestedNestedParam: jest.fn(),
 }
 
-/** @type {RouteRecord[]} */
-const routes = [
+const routes: RouteRecord[] = [
   { path: '/', component: Home },
   { path: '/foo', component: Foo },
   {
@@ -106,11 +101,11 @@ const routes = [
 function resetMocks() {
   beforeRouteEnter.mockReset()
   for (const key in named) {
-    named[key].mockReset()
+    named[key as keyof typeof named].mockReset()
   }
   for (const key in nested) {
-    nested[key].mockReset()
-    nested[key].mockImplementation(noGuard)
+    nested[key as keyof typeof nested].mockReset()
+    nested[key as keyof typeof nested].mockImplementation(noGuard)
   }
 }
 
@@ -200,7 +195,7 @@ describe('beforeRouteEnter', () => {
           template: `<div></div>`,
           beforeRouteEnter: spy,
         }
-        const [promise, resolve] = fakePromise()
+        const [promise, resolve] = fakePromise<typeof component>()
         const router = createRouter({
           routes: [...routes, { path: '/async', component: () => promise }],
         })
similarity index 90%
rename from __tests__/guards/component-beforeRouteLeave.spec.js
rename to __tests__/guards/component-beforeRouteLeave.spec.ts
index 0c0f319e77133f0a5e82f3b9eb7d130ff5436543..aee7cca70d93fb3c669440e0779d6ea1fe152705 100644 (file)
@@ -1,16 +1,12 @@
-// @ts-check
-const { HTML5History } = require('../../src/history/html5')
-const { Router } = require('../../src/router')
-const fakePromise = require('faked-promise')
-const { NAVIGATION_TYPES, createDom, noGuard } = require('../utils')
+import { HTML5History } from '../../src/history/html5'
+import { Router, RouterOptions } from '../../src/router'
+import { NAVIGATION_TYPES, createDom, noGuard } from '../utils'
+import { RouteRecord } from '../../src/types'
 
-/** @typedef {import('../../src/types').RouteRecord} RouteRecord */
-/** @typedef {import('../../src/router').RouterOptions} RouterOptions */
-
-/**
- * @param {Partial<RouterOptions> & { routes: RouteRecord[]}} options
- */
-function createRouter(options) {
+// TODO: refactor in utils
+function createRouter(
+  options: Partial<RouterOptions> & { routes: RouteRecord[] }
+) {
   return new Router({
     history: new HTML5History(),
     ...options,
@@ -32,8 +28,7 @@ const nested = {
 }
 const beforeRouteLeave = jest.fn()
 
-/** @type {RouteRecord[]} */
-const routes = [
+const routes: RouteRecord[] = [
   { path: '/', component: Home },
   { path: '/foo', component: Foo },
   {
@@ -94,8 +89,8 @@ const routes = [
 function resetMocks() {
   beforeRouteLeave.mockReset()
   for (const key in nested) {
-    nested[key].mockReset()
-    nested[key].mockImplementation(noGuard)
+    nested[key as keyof typeof nested].mockReset()
+    nested[key as keyof typeof nested].mockImplementation(noGuard)
   }
 }
 
similarity index 85%
rename from __tests__/guards/component-beforeRouteUpdate.spec.js
rename to __tests__/guards/component-beforeRouteUpdate.spec.ts
index 925182bd161a8cff889f89a34c156caa30816606..46172ba85f0798f6111701940e96cba17545c87d 100644 (file)
@@ -1,13 +1,13 @@
-// @ts-check
-const { HTML5History } = require('../../src/history/html5')
-const { Router } = require('../../src/router')
-const fakePromise = require('faked-promise')
-const { NAVIGATION_TYPES, createDom, noGuard } = require('../utils')
+import { HTML5History } from '../../src/history/html5'
+import { Router } from '../../src/router'
+import fakePromise from 'faked-promise'
+import { NAVIGATION_TYPES, createDom, noGuard } from '../utils'
 
-/**
- * @param {Partial<import('../../src/router').RouterOptions> & { routes: import('../../src/types').RouteRecord[]}} options
- */
-function createRouter(options) {
+function createRouter(
+  options: Partial<import('../../src/router').RouterOptions> & {
+    routes: import('../../src/types').RouteRecord[]
+  }
+) {
   return new Router({
     history: new HTML5History(),
     ...options,
similarity index 88%
rename from __tests__/guards/global-after.spec.js
rename to __tests__/guards/global-after.spec.ts
index 2dc8fbf697952b3a01c18892276479aa0f69fd78..2a589401c9d5243aa3abb0bfe2c7e4b43635461b 100644 (file)
@@ -1,12 +1,12 @@
-// @ts-check
-const { HTML5History } = require('../../src/history/html5')
-const { Router } = require('../../src/router')
-const { NAVIGATION_TYPES, createDom } = require('../utils')
+import { HTML5History } from '../../src/history/html5'
+import { Router } from '../../src/router'
+import { NAVIGATION_TYPES, createDom } from '../utils'
 
-/**
- * @param {Partial<import('../../src/router').RouterOptions> & { routes: import('../../src/types').RouteRecord[]}} options
- */
-function createRouter(options) {
+function createRouter(
+  options: Partial<import('../../src/router').RouterOptions> & {
+    routes: import('../../src/types').RouteRecord[]
+  }
+) {
   return new Router({
     history: new HTML5History(),
     ...options,
similarity index 93%
rename from __tests__/guards/global-beforeEach.spec.js
rename to __tests__/guards/global-beforeEach.spec.ts
index dac1dce700e67a1cae6a757da36617c19f598ef8..c0e1b32cab3fb50c3aca73abe128fe33c3453ef2 100644 (file)
@@ -1,16 +1,12 @@
-// @ts-check
-const { HTML5History } = require('../../src/history/html5')
-const { Router } = require('../../src/router')
-const fakePromise = require('faked-promise')
-const { NAVIGATION_TYPES, createDom, tick, noGuard } = require('../utils')
-
-/** @typedef {import('../../src/types').RouteRecord} RouteRecord */
-/** @typedef {import('../../src/router').RouterOptions} RouterOptions */
-
-/**
- * @param {Partial<RouterOptions> & { routes: RouteRecord[]}} options
- */
-function createRouter(options) {
+import { HTML5History } from '../../src/history/html5'
+import { Router, RouterOptions } from '../../src/router'
+import fakePromise from 'faked-promise'
+import { NAVIGATION_TYPES, createDom, tick, noGuard } from '../utils'
+import { RouteRecord, RouteLocation } from '../../src/types'
+
+function createRouter(
+  options: Partial<RouterOptions> & { routes: RouteRecord[] }
+) {
   return new Router({
     history: new HTML5History(),
     ...options,
@@ -124,7 +120,7 @@ describe('router.beforeEach', () => {
         expect(router.currentRoute.fullPath).toBe('/other')
       })
 
-      async function assertRedirect(redirectFn) {
+      async function assertRedirect(redirectFn: (i: string) => RouteLocation) {
         const spy = jest.fn()
         const router = createRouter({ routes })
         await router.push('/')
@@ -132,7 +128,7 @@ describe('router.beforeEach', () => {
           // only allow going to /other
           const i = Number(to.params.i)
           if (i >= 3) next()
-          else next(redirectFn(i + 1))
+          else next(redirectFn(String(i + 1)))
         })
         router.beforeEach(spy)
         expect(spy).not.toHaveBeenCalled()
similarity index 91%
rename from __tests__/guards/route-beforeEnter.spec.js
rename to __tests__/guards/route-beforeEnter.spec.ts
index d3b6aff9b4b585d0bd1ce00661f39ceebd32750a..cee5dbf7340d841927fbbb3879db9f19a68d7280 100644 (file)
@@ -1,16 +1,12 @@
-// @ts-check
-const { HTML5History } = require('../../src/history/html5')
-const { Router } = require('../../src/router')
-const fakePromise = require('faked-promise')
-const { NAVIGATION_TYPES, createDom, noGuard, tick } = require('../utils')
+import { HTML5History } from '../../src/history/html5'
+import { Router, RouterOptions } from '../../src/router'
+import fakePromise from 'faked-promise'
+import { NAVIGATION_TYPES, createDom, noGuard, tick } from '../utils'
+import { RouteRecord } from '../../src/types'
 
-/** @typedef {import('../../src/types').RouteRecord} RouteRecord */
-/** @typedef {import('../../src/router').RouterOptions} RouterOptions */
-
-/**
- * @param {Partial<RouterOptions> & { routes: RouteRecord[]}} options
- */
-function createRouter(options) {
+function createRouter(
+  options: Partial<RouterOptions> & { routes: RouteRecord[] }
+) {
   return new Router({
     history: new HTML5History(),
     ...options,
@@ -97,8 +93,8 @@ function resetMocks() {
     spy.mockImplementationOnce(noGuard)
   })
   for (const key in nested) {
-    nested[key].mockReset()
-    nested[key].mockImplementation(noGuard)
+    nested[key as keyof typeof nested].mockReset()
+    nested[key as keyof typeof nested].mockImplementation(noGuard)
   }
 }
 
similarity index 97%
rename from __tests__/history/abstract.spec.js
rename to __tests__/history/abstract.spec.ts
index 8d935fa8cfe53feabf0ab51b2f70c432b8fda55e..e2fc6683a9314948df7ce0a976f1afdc88e2ab99 100644 (file)
@@ -1,7 +1,6 @@
-// @ts-check
 
-const { AbstractHistory } = require('../../src/history/abstract')
-const { START } = require('../../src/history/base')
+import { AbstractHistory } from '../../src/history/abstract'
+import { START } from '../../src/history/base'
 
 /** @type {import('../../src/history/base').HistoryLocation} */
 const loc = {
similarity index 77%
rename from __tests__/history/html5.spec.js
rename to __tests__/history/html5.spec.ts
index 07cc01c52a0e9637f36983628b3a7c66926c8a3b..5d2918688ed6b70fb260353623b69eeec1a107dd 100644 (file)
@@ -1,6 +1,5 @@
-// @ts-check
-const { HTML5History } = require('../../src/history/html5')
-const { createDom } = require('../utils')
+import { HTML5History } from '../../src/history/html5'
+import { createDom } from '../utils'
 
 // TODO: is it really worth testing this implementation on jest or is it
 // better to directly use e2e tests instead
similarity index 80%
rename from __tests__/matcher-ranking.spec.js
rename to __tests__/matcher-ranking.spec.ts
index c6bc6a1d1e8298dff9d682dda8e28796ed3cd71e..4a3b6b8591445209c8af593fb1c2c78794ff81f8 100644 (file)
@@ -1,29 +1,19 @@
-// @ts-check
-const { createRouteMatcher } = require('../src/matcher')
-
-/** @type {RouteComponent} */
-const component = null
-
-/** @typedef {import('../src/types').RouteRecord} RouteRecord */
-/** @typedef {import('../src/types').RouteComponent} RouteComponent */
-/** @typedef {import('../src/types').MatchedRouteRecord} MatchedRouteRecord */
-/** @typedef {import('../src/types').MatcherLocation} MatcherLocation */
-/** @typedef {import('../src/types').MatcherLocationRedirect} MatcherLocationRedirect */
-/** @typedef {import('../src/types').MatcherLocationNormalized} MatcherLocationNormalized */
-/** @typedef {import('../src/matcher').RouteMatcher} RouteMatcher */
-/** @typedef {import('path-to-regexp').RegExpOptions} RegExpOptions */
-
-function stringifyOptions(options) {
+import { createRouteMatcher } from '../src/matcher'
+import { RegExpOptions } from 'path-to-regexp'
+import { RouteComponent } from '../src/types'
+
+// @ts-ignore
+const component: RouteComponent = null
+
+function stringifyOptions(options: any) {
   return Object.keys(options).length ? ` (${JSON.stringify(options)})` : ''
 }
 
 describe('createRouteMatcher', () => {
-  /**
-   *
-   * @param {Array<string | [string, RegExpOptions]>} paths
-   * @param {RegExpOptions} options
-   */
-  function checkPathOrder(paths, options = {}) {
+  function checkPathOrder(
+    paths: Array<string | [string, RegExpOptions]>,
+    options: RegExpOptions = {}
+  ) {
     const normalizedPaths = paths.map(pathOrCombined => {
       if (Array.isArray(pathOrCombined))
         return [pathOrCombined[0], { ...options, ...pathOrCombined[1] }]
similarity index 82%
rename from __tests__/matcher.spec.js
rename to __tests__/matcher.spec.ts
index bc4b6ba925eab6544396fcca63cfb3388ad87c0b..435981c51c340987bf3d0b8d3b4cce8b7bcb86e4 100644 (file)
@@ -1,32 +1,27 @@
-// @ts-check
-const { RouterMatcher } = require('../src/matcher')
-const { START_LOCATION_NORMALIZED } = require('../src/types')
-const { normalizeRouteRecord } = require('./utils')
-
-/** @type {RouteComponent} */
-const component = null
-
-/** @typedef {import('../src/types').RouteRecord} RouteRecord */
-/** @typedef {import('../src/types').RouteComponent} RouteComponent */
-/** @typedef {import('../src/types').MatchedRouteRecord} MatchedRouteRecord */
-/** @typedef {import('../src/types').MatcherLocation} MatcherLocation */
-/** @typedef {import('../src/types').MatcherLocationRedirect} MatcherLocationRedirect */
-/** @typedef {import('../src/types').MatcherLocationNormalized} MatcherLocationNormalized */
+import { RouterMatcher } from '../src/matcher'
+import {
+  START_LOCATION_NORMALIZED,
+  RouteComponent,
+  RouteRecord,
+  MatcherLocation,
+  MatcherLocationNormalized,
+  MatcherLocationRedirect,
+} from '../src/types'
+import { normalizeRouteRecord } from './utils'
+
+// @ts-ignore
+const component: RouteComponent = null
+
+// for normalized records
+const components = { default: component }
 
 describe('Router Matcher', () => {
   describe('resolve', () => {
-    /**
-     *
-     * @param {RouteRecord | RouteRecord[]} record Record or records we are testing the matcher against
-     * @param {MatcherLocation} location location we want to reolve against
-     * @param {Partial<import('../src/types').Override<MatcherLocationNormalized, { matched: Array<Exclude<RouteRecord, { redirect: any}>> }>>} resolved Expected resolved location given by the matcher
-     * @param {import('../src/types').Override<MatcherLocationNormalized, { matched: Array<Exclude<RouteRecord, { redirect: any}>> }>} [start] Optional currentLocation used when resolving
-     */
     function assertRecordMatch(
-      record,
-      location,
-      resolved,
-      start = START_LOCATION_NORMALIZED
+      record: RouteRecord | RouteRecord[],
+      location: MatcherLocation,
+      resolved: Partial<MatcherLocationNormalized>,
+      start: MatcherLocationNormalized = START_LOCATION_NORMALIZED
     ) {
       record = Array.isArray(record) ? record : [record]
       const matcher = new RouterMatcher(record)
@@ -45,7 +40,8 @@ describe('Router Matcher', () => {
         throw new Error('not handled')
       } else {
         // use one single record
-        if (!('matched' in resolved))
+        if (!resolved.matched)
+          // @ts-ignore
           resolved.matched = record.map(normalizeRouteRecord)
         else resolved.matched = resolved.matched.map(normalizeRouteRecord)
       }
@@ -84,9 +80,9 @@ describe('Router Matcher', () => {
      * @returns {any} error
      */
     function assertErrorMatch(
-      record,
-      location,
-      start = START_LOCATION_NORMALIZED
+      record: RouteRecord | RouteRecord[],
+      location: MatcherLocation,
+      start: MatcherLocationNormalized = START_LOCATION_NORMALIZED
     ) {
       try {
         assertRecordMatch(record, location, {}, start)
@@ -98,7 +94,7 @@ describe('Router Matcher', () => {
     describe('LocationAsPath', () => {
       it('resolves a normal path', () => {
         assertRecordMatch(
-          { path: '/', name: 'Home', component },
+          { path: '/', name: 'Home', components },
           { path: '/' },
           { name: 'Home', path: '/', params: {} }
         )
@@ -106,7 +102,7 @@ describe('Router Matcher', () => {
 
       it('resolves a normal path without name', () => {
         assertRecordMatch(
-          { path: '/', component },
+          { path: '/', components },
           { path: '/' },
           { name: undefined, path: '/', params: {} }
         )
@@ -114,7 +110,7 @@ describe('Router Matcher', () => {
 
       it('resolves a path with params', () => {
         assertRecordMatch(
-          { path: '/users/:id', name: 'User', component },
+          { path: '/users/:id', name: 'User', components },
           { path: '/users/posva' },
           { name: 'User', params: { id: 'posva' } }
         )
@@ -122,7 +118,7 @@ describe('Router Matcher', () => {
 
       it('resolves a path with multiple params', () => {
         assertRecordMatch(
-          { path: '/users/:id/:other', name: 'User', component },
+          { path: '/users/:id/:other', name: 'User', components },
           { path: '/users/posva/hey' },
           { name: 'User', params: { id: 'posva', other: 'hey' } }
         )
@@ -130,7 +126,7 @@ describe('Router Matcher', () => {
 
       it('resolves a path with multiple params but no name', () => {
         assertRecordMatch(
-          { path: '/users/:id/:other', component },
+          { path: '/users/:id/:other', components },
           { path: '/users/posva/hey' },
           { name: undefined, params: { id: 'posva', other: 'hey' } }
         )
@@ -138,7 +134,7 @@ describe('Router Matcher', () => {
 
       it('throws if the path does not exists', () => {
         expect(
-          assertErrorMatch({ path: '/', component }, { path: '/foo' })
+          assertErrorMatch({ path: '/', components }, { path: '/foo' })
         ).toMatchInlineSnapshot(
           `[NoRouteMatchError: No match for {"path":"/foo","params":{},"query":{},"hash":"","fullPath":"/"}]`
         )
@@ -148,7 +144,7 @@ describe('Router Matcher', () => {
     describe('LocationAsName', () => {
       it('matches a name', () => {
         assertRecordMatch(
-          { path: '/home', name: 'Home', component },
+          { path: '/home', name: 'Home', components },
           { name: 'Home' },
           { name: 'Home', path: '/home' }
         )
@@ -156,7 +152,7 @@ describe('Router Matcher', () => {
 
       it('matches a name and fill params', () => {
         assertRecordMatch(
-          { path: '/users/:id/m/:role', name: 'UserEdit', component },
+          { path: '/users/:id/m/:role', name: 'UserEdit', components },
           { name: 'UserEdit', params: { id: 'posva', role: 'admin' } },
           { name: 'UserEdit', path: '/users/posva/m/admin' }
         )
@@ -164,7 +160,7 @@ describe('Router Matcher', () => {
 
       it('throws if the named route does not exists', () => {
         expect(
-          assertErrorMatch({ path: '/', component }, { name: 'Home' })
+          assertErrorMatch({ path: '/', components }, { name: 'Home' })
         ).toMatchInlineSnapshot(
           `[NoRouteMatchError: No match for {"path":"/","name":"Home","params":{},"query":{},"hash":"","fullPath":"/"}]`
         )
@@ -173,7 +169,7 @@ describe('Router Matcher', () => {
 
     describe('LocationAsRelative', () => {
       it('matches with nothing', () => {
-        const record = { path: '/home', name: 'Home', component }
+        const record = { path: '/home', name: 'Home', components }
         assertRecordMatch(
           record,
           {},
@@ -189,7 +185,7 @@ describe('Router Matcher', () => {
       })
 
       it('replace params even with no name', () => {
-        const record = { path: '/users/:id/m/:role', component }
+        const record = { path: '/users/:id/m/:role', components }
         assertRecordMatch(
           record,
           { params: { id: 'posva', role: 'admin' } },
@@ -208,7 +204,7 @@ describe('Router Matcher', () => {
         const record = {
           path: '/users/:id/m/:role',
           name: 'UserEdit',
-          component,
+          components,
         }
         assertRecordMatch(
           record,
@@ -228,7 +224,7 @@ describe('Router Matcher', () => {
         const record = {
           path: '/users/:id/m/:role',
           name: 'UserEdit',
-          component,
+          components,
         }
         assertRecordMatch(
           record,
@@ -249,7 +245,7 @@ describe('Router Matcher', () => {
       })
 
       it('keep params if not provided even with no name', () => {
-        const record = { path: '/users/:id/m/:role', component }
+        const record = { path: '/users/:id/m/:role', components }
         assertRecordMatch(
           record,
           {},
@@ -269,18 +265,11 @@ describe('Router Matcher', () => {
       })
 
       describe('redirects', () => {
-        /**
-         *
-         * @param {RouteRecord[]} records Record or records we are testing the matcher against
-         * @param {MatcherLocation} location location we want to reolve against
-         * @param {MatcherLocationNormalized | MatcherLocationRedirect} expected Expected resolved location given by the matcher
-         * @param {MatcherLocationNormalized} [currentLocation] Optional currentLocation used when resolving
-         */
         function assertRedirect(
-          records,
-          location,
-          expected,
-          currentLocation = START_LOCATION_NORMALIZED
+          records: RouteRecord[],
+          location: MatcherLocation,
+          expected: MatcherLocationNormalized | MatcherLocationRedirect,
+          currentLocation: MatcherLocationNormalized = START_LOCATION_NORMALIZED
         ) {
           const matcher = new RouterMatcher(records)
           const resolved = matcher.resolve(location, currentLocation)
@@ -290,7 +279,7 @@ describe('Router Matcher', () => {
 
         it('resolves a redirect string', () => {
           const records = [
-            { path: '/home', component },
+            { path: '/home', components },
             { path: '/redirect', redirect: '/home' },
           ]
           assertRedirect(
@@ -315,7 +304,7 @@ describe('Router Matcher', () => {
         it('resolves a redirect function that returns a string', () => {
           const redirect = () => '/home'
           const records = [
-            { path: '/home', component },
+            { path: '/home', components },
             { path: '/redirect', redirect },
           ]
           assertRedirect(
@@ -342,7 +331,7 @@ describe('Router Matcher', () => {
             path: '/home'
           }
           const records = [
-            { path: '/home', component },
+            { path: '/home', components },
             { path: '/redirect', redirect },
           ]
           assertRedirect(
@@ -366,7 +355,7 @@ describe('Router Matcher', () => {
 
         it('resolves a redirect as an object', () => {
           const records = [
-            { path: '/home', component },
+            { path: '/home', components },
             { path: '/redirect', redirect: { path: 'home' } },
           ]
           assertRedirect(
@@ -390,7 +379,7 @@ describe('Router Matcher', () => {
 
         it('works with a named location', () => {
           const records = [
-            { path: '/home', component },
+            { path: '/home', components },
             { path: '/redirect', name: 'redirect', redirect: { path: 'home' } },
           ]
           assertRedirect(
@@ -412,10 +401,6 @@ describe('Router Matcher', () => {
         })
 
         it('throws if relative location when redirecting', () => {
-          const records = [
-            { path: '/home', component },
-            { path: '/redirect', redirect: '/home' },
-          ]
           expect(
             assertErrorMatch(
               { path: '/redirect', redirect: '/home' },
@@ -438,15 +423,15 @@ describe('Router Matcher', () => {
         })
 
         it('normalize a location when redirecting', () => {
-          const redirect = to => ({ name: 'b', params: to.params })
+          const redirect = (to: any) => ({ name: 'b', params: to.params })
           const records = [
-            { path: '/home', component },
+            { path: '/home', components },
             {
               path: '/a/:a',
               name: 'a',
               redirect,
             },
-            { path: '/b/:a', name: 'b', component },
+            { path: '/b/:a', name: 'b', components },
           ]
           assertRedirect(
             records,
@@ -468,7 +453,7 @@ describe('Router Matcher', () => {
       })
 
       it('throws if the current named route does not exists', () => {
-        const record = { path: '/', component }
+        const record = { path: '/', components }
         const start = {
           name: 'home',
           params: {},
@@ -494,10 +479,10 @@ describe('Router Matcher', () => {
     })
 
     describe('children', () => {
-      const ChildA = { path: 'a', name: 'child-a', component }
-      const ChildB = { path: 'b', name: 'child-b', component }
-      const ChildC = { path: 'c', name: 'child-c', component }
-      const ChildWithParam = { path: ':p', name: 'child-params', component }
+      const ChildA = { path: 'a', name: 'child-a', components }
+      const ChildB = { path: 'b', name: 'child-b', components }
+      const ChildC = { path: 'c', name: 'child-c', components }
+      const ChildWithParam = { path: ':p', name: 'child-params', components }
       const NestedChildWithParam = {
         ...ChildWithParam,
         name: 'nested-child-params',
@@ -508,13 +493,13 @@ describe('Router Matcher', () => {
       const Nested = {
         path: 'nested',
         name: 'nested',
-        component,
+        components,
         children: [NestedChildA, NestedChildB, NestedChildC],
       }
       const NestedWithParam = {
         path: 'nested/:n',
         name: 'nested',
-        component,
+        components,
         children: [NestedChildWithParam],
       }
 
@@ -522,7 +507,7 @@ describe('Router Matcher', () => {
         const Foo = {
           path: '/foo',
           name: 'Foo',
-          component,
+          components,
           children: [ChildA, ChildB, ChildC],
         }
         assertRecordMatch(
@@ -538,11 +523,11 @@ describe('Router Matcher', () => {
       })
 
       it('resolves children with empty paths', () => {
-        const Nested = { path: '', name: 'nested', component }
+        const Nested = { path: '', name: 'nested', components }
         const Foo = {
           path: '/foo',
           name: 'Foo',
-          component,
+          components,
           children: [Nested],
         }
         assertRecordMatch(
@@ -560,17 +545,17 @@ describe('Router Matcher', () => {
       })
 
       it('resolves nested children with empty paths', () => {
-        const NestedNested = { path: '', name: 'nested', component }
+        const NestedNested = { path: '', name: 'nested', components }
         const Nested = {
           path: '',
           name: 'nested-nested',
-          component,
+          components,
           children: [NestedNested],
         }
         const Foo = {
           path: '/foo',
           name: 'Foo',
-          component,
+          components,
           children: [Nested],
         }
         assertRecordMatch(
@@ -593,7 +578,7 @@ describe('Router Matcher', () => {
         const Foo = {
           path: '/foo',
           name: 'Foo',
-          component,
+          components,
           children: [Nested],
         }
         assertRecordMatch(
@@ -619,7 +604,7 @@ describe('Router Matcher', () => {
         const Foo = {
           path: '/foo',
           name: 'Foo',
-          component,
+          components,
           children: [Nested],
         }
         assertRecordMatch(
@@ -645,7 +630,7 @@ describe('Router Matcher', () => {
         const Foo = {
           path: '/foo',
           name: 'Foo',
-          component,
+          components,
           children: [Nested],
         }
         assertRecordMatch(
@@ -678,7 +663,7 @@ describe('Router Matcher', () => {
         const Foo = {
           path: '/foo',
           name: 'Foo',
-          component,
+          components,
           children: [NestedWithParam],
         }
         assertRecordMatch(
@@ -707,7 +692,7 @@ describe('Router Matcher', () => {
         const Foo = {
           path: '/foo',
           name: 'Foo',
-          component,
+          components,
           children: [NestedWithParam],
         }
         assertRecordMatch(
similarity index 87%
rename from __tests__/query.spec.js
rename to __tests__/query.spec.ts
index 2bb07f9ac407c695251ff39321f2b17b5b2281fb..c1d505beb0e193fb8fdba7b998b6c9113fb37c90 100644 (file)
@@ -1,5 +1,4 @@
-// @ts-check
-const { parseQuery } = require('../src/history/utils')
+import { parseQuery } from '../src/history/utils'
 
 describe('parseQuery', () => {
   it('works with leading ?', () => {
similarity index 72%
rename from __tests__/router-link.spec.js
rename to __tests__/router-link.spec.ts
index f38ad26e024b8e61508335ef16c2686919c32581..4dfa6905e8a72d0ce4beb4cffb02ad456ae4de95 100644 (file)
@@ -1,20 +1,25 @@
 /**
  * @jest-environment jsdom
  */
-// @ts-check
 // NOTE: these tests only run when using jest `yarn jest --watch`
-const { default: RouterLink } = require('../src/components/Link')
-const { components, isMocha, HistoryMock } = require('./utils')
-const { START_LOCATION_NORMALIZED } = require('../src/types')
+import RouterLink from '../src/components/Link'
+import { HistoryMock } from './utils'
+import {
+  START_LOCATION_NORMALIZED,
+  RouteQueryAndHash,
+  MatcherLocation,
+  RouteLocationNormalized,
+} from '../src/types'
+import { mount } from '@vue/test-utils'
 
-/** @typedef {import('../src/types').RouteLocationNormalized} RouteLocationNormalized */
-/** @typedef {import('../src/types').RouteRecord} RouteRecord */
-/** @typedef {import('../src/types').RouteLocation} RouteLocation */
-/** @typedef {import('../src/types').MatcherLocation} MatcherLocation */
-/** @typedef {import('../src/types').RouteQueryAndHash} RouteQueryAndHash */
-
-/** @type {Record<string, { string: string, normalized: RouteLocationNormalized, toResolve?: MatcherLocation & Required<RouteQueryAndHash> }>} */
-const locations = {
+const locations: Record<
+  string,
+  {
+    string: string
+    normalized: RouteLocationNormalized
+    toResolve?: MatcherLocation & Required<RouteQueryAndHash>
+  }
+> = {
   basic: {
     string: '/home',
     // toResolve: { path: '/home', fullPath: '/home', undefined, query: {}, hash: '' },
@@ -46,18 +51,11 @@ const locations = {
 }
 
 describe('RouterLink', () => {
-  // skip these tests on mocha because @vue/test-utils
-  // do not work correctly
-  if (isMocha()) return
-  const { mount } = require('@vue/test-utils')
-
-  /**
-   *
-   * @param {RouteLocationNormalized} currentLocation
-   * @param {Object} propsData
-   * @param {RouteLocationNormalized} resolvedLocation
-   */
-  function factory(currentLocation, propsData, resolvedLocation) {
+  function factory(
+    currentLocation: RouteLocationNormalized,
+    propsData: any,
+    resolvedLocation: RouteLocationNormalized
+  ) {
     const router = {
       history: new HistoryMock(),
       resolve: jest.fn(),
similarity index 79%
rename from __tests__/router-view.spec.js
rename to __tests__/router-view.spec.ts
index 47e42217462ced475a42de188e267e84ca476595..26b7ec3712fd36e16c29c5bbec1ad4f22a81f8c7 100644 (file)
@@ -1,16 +1,16 @@
 /**
  * @jest-environment jsdom
  */
-// @ts-check
 // NOTE: these tests only run when using jest `yarn jest --watch`
-const { default: RouterView } = require('../src/components/View')
-const { components, isMocha } = require('./utils')
-const { START_LOCATION_NORMALIZED } = require('../src/types')
+import RouterView from '../src/components/View'
+import { components } from './utils'
+import {
+  START_LOCATION_NORMALIZED,
+  RouteLocationNormalized,
+} from '../src/types'
+import { mount } from '@vue/test-utils'
 
-/** @typedef {import('../src/types').RouteLocationNormalized} RouteLocationNormalized */
-
-/** @type {Record<string, RouteLocationNormalized>} */
-const routes = {
+const routes: Record<string, RouteLocationNormalized> = {
   root: {
     fullPath: '/',
     name: undefined,
@@ -61,17 +61,7 @@ const routes = {
 }
 
 describe('RouterView', () => {
-  // skip these tests on mocha because @vue/test-utils
-  // do not work correctly
-  if (isMocha()) return
-  const { mount } = require('@vue/test-utils')
-
-  /**
-   *
-   * @param {RouteLocationNormalized} $route
-   * @param {Object} [props]
-   */
-  function factory($route, props = {}) {
+  function factory($route: RouteLocationNormalized, props: any = {}) {
     // @ts-ignore cannot mount functional component?
     const wrapper = mount(RouterView, {
       context: {
similarity index 91%
rename from __tests__/router.spec.js
rename to __tests__/router.spec.ts
index d78949ba2d30813fb6391ccba1c91c905439926f..619861df7e301d8617ecf84c61b9295d763dd20c 100644 (file)
@@ -1,13 +1,11 @@
-// @ts-check
-const fakePromise = require('faked-promise')
-const { HTML5History } = require('../src/history/html5')
-const { AbstractHistory } = require('../src/history/abstract')
-const { Router } = require('../src/router')
-const { NavigationCancelled } = require('../src/errors')
-const { createDom, components, tick, HistoryMock } = require('./utils')
+import fakePromise from 'faked-promise'
+import { AbstractHistory } from '../src/history/abstract'
+import { Router } from '../src/router'
+import { NavigationCancelled } from '../src/errors'
+import { createDom, components, tick, HistoryMock } from './utils'
+import { RouteRecord, RouteLocation } from '../src/types'
 
-/** @type {import('../src/types').RouteRecord[]} */
-const routes = [
+const routes: RouteRecord[] = [
   { path: '/', component: components.Home },
   { path: '/search', component: components.Home },
   { path: '/foo', component: components.Foo, name: 'Foo' },
@@ -101,7 +99,9 @@ describe('Router', () => {
   })
 
   describe('navigation', () => {
-    async function checkNavigationCancelledOnPush(target) {
+    async function checkNavigationCancelledOnPush(
+      target?: RouteLocation | false | ((vm: any) => void)
+    ) {
       const [p1, r1] = fakePromise()
       const [p2, r2] = fakePromise()
       const history = new HistoryMock()
@@ -110,7 +110,8 @@ describe('Router', () => {
         if (to.name !== 'Param') return next()
         if (to.params.p === 'a') {
           await p1
-          next(target)
+          // @ts-ignore: for some reason it's not handling the string here
+          target == null ? next() : next(target)
         } else {
           await p2
           next()
@@ -145,7 +146,9 @@ describe('Router', () => {
       await checkNavigationCancelledOnPush(undefined)
     })
 
-    async function checkNavigationCancelledOnPopstate(target) {
+    async function checkNavigationCancelledOnPopstate(
+      target?: RouteLocation | false | ((vm: any) => void)
+    ) {
       const [p1, r1] = fakePromise()
       const [p2, r2] = fakePromise()
       const history = new AbstractHistory()
@@ -162,6 +165,7 @@ describe('Router', () => {
           next()
         } else if (from.fullPath === '/p/b') {
           await p2
+          // @ts-ignore: same as function above
           next(target)
         } else {
           next()
similarity index 91%
rename from __tests__/ssr/basic.spec.js
rename to __tests__/ssr/basic.spec.ts
index 71c5f77c0dde802c0a5d658d5dce439c24055be6..a7796a256349d04ff1688ca029060c559582c701 100644 (file)
@@ -1,5 +1,4 @@
-// @ts-check
-const { renderApp, renderer } = require('./shared')
+import { renderApp, renderer } from './shared'
 
 describe('SSR: basicRenderer', () => {
   it('renders the view', async () => {
@@ -45,9 +44,7 @@ describe('SSR: basicRenderer', () => {
         },
         components: {
           test: {
-            render() {
-              return this.$createElement('div', { class: ['a'] }, 'test')
-            },
+            template: `<div class="a">test</div>`,
           },
           testAsync(resolve) {
             resolve({
index 143fac83a547bc81f040163c73aab1c99f35cdb7..b23b16b544b2cbeefc6270a77a821d5f5c19052f 100644 (file)
@@ -1,4 +1,4 @@
-import Vue from 'vue'
+import Vue, { ComponentOptions } from 'vue'
 import Router from '../../src'
 import { components } from '../utils'
 
@@ -51,7 +51,7 @@ export function createApp(
 export function renderApp(
   context: { url: string },
   routerOptions?: Partial<RouterOptions>,
-  vueOptions?: any
+  vueOptions?: ComponentOptions<Vue>
 ) {
   return new Promise<ReturnType<typeof createApp>['app']>((resolve, reject) => {
     const { app, router } = createApp(routerOptions, vueOptions)
diff --git a/__tests__/tsconfig.json b/__tests__/tsconfig.json
deleted file mode 100644 (file)
index 533ede6..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-{
-  "include": ["./**/*.ts", "./**/*.js"],
-  "exclude": ["./helper.js"],
-  "compilerOptions": {
-    "target": "esnext",
-    "module": "commonjs",
-    "noEmit": true,
-    "checkJs": true,
-    "allowJs": true,
-    "esModuleInterop": true
-  }
-}
similarity index 93%
rename from __tests__/url-encoding.spec.js
rename to __tests__/url-encoding.spec.ts
index 51ee82b15ba54744634b48b9a50d7b01d35b475b..4556010a61ba0fa0f836e642127eb8af9828a6b1 100644 (file)
@@ -1,17 +1,18 @@
-// @ts-check
-const { Router } = require('../src/router')
-const { createDom, components, tick, HistoryMock } = require('./utils')
+import { Router } from '../src/router'
+import { createDom, components, HistoryMock } from './utils'
+import { RouteRecord } from '../src/types'
 
-/** @type {import('../src/types').RouteRecord[]} */
-const routes = [
+const routes: RouteRecord[] = [
   { path: '/', name: 'home', component: components.Home },
   { path: '/%25', name: 'percent', component: components.Home },
   { path: '/to-p/:p', redirect: to => `/p/${to.params.p}` },
   { path: '/p/:p', component: components.Bar, name: 'params' },
 ]
 
-function createHistory(initialUrl) {
-  return new HistoryMock(initialUrl)
+// this function is meant to easy refactor in the future as Histories are going to be
+// function-based
+function createHistory(...args: ConstructorParameters<typeof HistoryMock>) {
+  return new HistoryMock(...args)
 }
 
 describe('URL Encoding', () => {
similarity index 97%
rename from __tests__/url.spec.js
rename to __tests__/url.spec.ts
index 3b2de19d4379b19555067d3051649d30ea0a2d14..560b755fd258e720223ec456f2430388e3db0ca9 100644 (file)
@@ -1,9 +1,8 @@
-// @ts-check
-const {
+import {
   parseURL,
   stringifyURL,
   normalizeLocation,
-} = require('../src/history/utils')
+} from '../src/history/utils'
 
 describe('parseURL', () => {
   it('works with no query no hash', () => {
index 83ae2fafcb0a5b73b732a0341b22809f6e6b25de..a3790994269d18e2280fb41eabbd7af90dd0b2fb 100644 (file)
@@ -5,7 +5,8 @@ export { HistoryMock } from './HistoryMock'
 
 export const tick = () => new Promise(resolve => process.nextTick(resolve))
 
-export const NAVIGATION_TYPES = ['push', 'replace']
+export type NAVIGATION_METHOD = 'push' | 'replace'
+export const NAVIGATION_TYPES: NAVIGATION_METHOD[] = ['push', 'replace']
 
 declare global {
   namespace NodeJS {
@@ -50,11 +51,6 @@ export const components = {
   },
 }
 
-// allow using a .jest modifider to skip some tests on mocha
-// specifically, skip component tests as they are a pain to correctly
-// adapt to mocha
-export const isMocha = () => typeof global.before === 'function'
-
 /**
  * Copies and normalizes the record so it always contains an object of `components`
  *
index 83e5bd1e0735a9cf7eac084e422923472e7663ff..7c39bcb9ed2b844ef9395fd6e83458d04a4b084b 100644 (file)
@@ -8,7 +8,7 @@ module.exports = {
     'src/consola.ts',
   ],
   testMatch: [
-    '**/__tests__/**/*.spec.[j]s?(x)',
+    '**/__tests__/**/*.spec.ts?(x)',
     // '**/__tests__/**/*.spec.[jt]s?(x)',
     // '**/?(*.)+(spec|test).[jt]s?(x)',
   ],
index 1f7f3aef4092c6c0a1cec8493b368aad9831c471..b022e98037c904abc358ddbddde3215a1967227b 100644 (file)
@@ -9,9 +9,7 @@
   "types": "dist/index.d.ts",
   "license": "MIT",
   "scripts": {
-    "test:types:src": "tsc --build tsconfig.check-types.json",
-    "test:types:test": "tsc --build __tests__/tsconfig.json",
-    "test:types": "yarn test:types:src && yarn test:types:test",
+    "test:types": "tsc --build tsconfig.json",
     "test:unit": "jest --coverage",
     "test": "yarn run test:types && yarn run test:unit && yarn build",
     "build": "yarn rollup -c rollup.config.js",
@@ -24,7 +22,7 @@
     "codecov": "^3.6.1",
     "consola": "^2.10.1",
     "expect": "^24.9.0",
-    "faked-promise": "^2.1.0",
+    "faked-promise": "^2.2.2",
     "html-webpack-plugin": "^3.2.0",
     "jest": "^24.9.0",
     "jsdom": "^15.1.1",
diff --git a/tsconfig.check-types.json b/tsconfig.check-types.json
deleted file mode 100644 (file)
index 1cc234a..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-{
-  "include": ["src/**/*.ts"],
-  "compilerOptions": {
-    "target": "esnext",
-    "module": "commonjs",
-    // "lib": ["es2017.object"] ,
-    "allowJs": true,
-    "checkJs": true,
-    // "declaration": true ,
-    // "sourceMap": true ,
-    // "outFile": "./",                       /* Concatenate and emit output to single file. */
-    // "outDir": "./dist" ,
-    // "rootDir": "./",                       /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
-    // "composite": true,                     /* Enable project compilation */
-    "noEmit": true,
-
-    "strict": true,
-    "noUnusedLocals": true,
-    // "noUnusedParameters": true,
-    "noImplicitReturns": true,
-
-    "moduleResolution": "node",
-    "esModuleInterop": true
-  }
-}
index 927a40dc6a7aa98bccff7ca04613a52af20fabd1..5a537c38ee405a8814b75babc15d3d6e61f385a9 100644 (file)
@@ -1,61 +1,23 @@
 {
-  "include": ["src/**/*.ts"],
+  "include": ["src/**/*.ts", "__tests__/**/*.ts"],
   "compilerOptions": {
-    /* Basic Options */
-    "target": "esnext" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */,
-    // Necessary for tests with mocha
-    "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
+    "target": "esnext",
+    "module": "commonjs",
     // "lib": ["es2017.object"] /* Specify library files to be included in the compilation. */,
-    // "allowJs": true,                       /* Allow javascript files to be compiled. */
-    // "checkJs": true,                       /* Report errors in .js files. */
-    // "jsx": "preserve",                     /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
-    "declaration": true /* Generates corresponding '.d.ts' file. */,
-    // "declarationMap": true,                /* Generates a sourcemap for each corresponding '.d.ts' file. */
-    "sourceMap": true /* Generates corresponding '.map' file. */,
-    // "outFile": "./",                       /* Concatenate and emit output to single file. */
-    "outDir": "./dist" /* Redirect output structure to the directory. */,
-    // "rootDir": "./",                       /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
-    // "composite": true,                     /* Enable project compilation */
-    "removeComments": false /* Do not emit comments to output. */,
-    // "noEmit": true,                        /* Do not emit outputs. */
-    // "importHelpers": true,                 /* Import emit helpers from 'tslib'. */
-    // "downlevelIteration": true,            /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
-    // "isolatedModules": true,               /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
+    "declaration": true,
+    // "declarationMap": true,
+    "sourceMap": true,
+    "outDir": "./dist",
+    "removeComments": false,
+    "noEmit": true,
 
-    /* Strict Type-Checking Options */
-    "strict": true /* Enable all strict type-checking options. */,
-    // "noImplicitAny": true,                 /* Raise error on expressions and declarations with an implied 'any' type. */
-    // "strictNullChecks": true,              /* Enable strict null checks. */
-    // "strictFunctionTypes": true,           /* Enable strict checking of function types. */
-    // "strictPropertyInitialization": true,  /* Enable strict checking of property initialization in classes. */
-    // "noImplicitThis": true,                /* Raise error on 'this' expressions with an implied 'any' type. */
-    // "alwaysStrict": true,                  /* Parse in strict mode and emit "use strict" for each source file. */
+    "strict": true,
 
-    /* Additional Checks */
-    "noUnusedLocals": true /* Report errors on unused locals. */,
-    // "noUnusedParameters": true,            /* Report errors on unused parameters. */
-    "noImplicitReturns": true /* Report error when not all code paths in function return a value. */,
-    // "noFallthroughCasesInSwitch": true,    /* Report errors for fallthrough cases in switch statement. */
+    "noUnusedLocals": true,
+    // "noUnusedParameters": true,
+    "noImplicitReturns": true,
 
-    /* Module Resolution Options */
-    "moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
-    // "baseUrl": "./",                       /* Base directory to resolve non-absolute module names. */
-    // "paths": {},                           /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
-    // "rootDirs": [],                        /* List of root folders whose combined content represents the structure of the project at runtime. */
-    // "typeRoots": [],                       /* List of folders to include type definitions from. */
-    // "types": [],                           /* Type declaration files to be included in compilation. */
-    // "allowSyntheticDefaultImports": true,  /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
-    "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
-    // "preserveSymlinks": true,              /* Do not resolve the real path of symlinks. */
-
-    /* Source Map Options */
-    // "sourceRoot": "./",                    /* Specify the location where debugger should locate TypeScript files instead of source locations. */
-    // "mapRoot": "./",                       /* Specify the location where debugger should locate map files instead of generated locations. */
-    // "inlineSourceMap": true,               /* Emit a single file with source maps instead of having a separate file. */
-    // "inlineSources": true,                 /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
-
-    /* Experimental Options */
-    // "experimentalDecorators": true,        /* Enables experimental support for ES7 decorators. */
-    // "emitDecoratorMetadata": true,         /* Enables experimental support for emitting type metadata for decorators. */
+    "moduleResolution": "node",
+    "esModuleInterop": true
   }
 }
index 8dbf4fb8cdae91fef6072aeb73eb05ce1adf684b..39e7c8e8ef444760b72e739379ad98b59eb04abe 100644 (file)
--- a/yarn.lock
+++ b/yarn.lock
@@ -2236,10 +2236,10 @@ extsprintf@^1.2.0:
   resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f"
   integrity sha1-4mifjzVvrWLMplo6kcXfX5VRaS8=
 
-faked-promise@^2.1.0:
-  version "2.1.0"
-  resolved "https://registry.yarnpkg.com/faked-promise/-/faked-promise-2.1.0.tgz#988dd6f7e1c30638be2cd0d67e944b51d5dbbaeb"
-  integrity sha512-p5QCxMj8OsHjBs0aIEbg1WFW019Tib3LIWpz6Fyl5uVf4A3FRJzcMrJgiTgwVB5k99k3M566U6NUa/rEi473fA==
+faked-promise@^2.2.2:
+  version "2.2.2"
+  resolved "https://registry.yarnpkg.com/faked-promise/-/faked-promise-2.2.2.tgz#c89dd11d29a561bb03229813e3aa13a369df137c"
+  integrity sha512-1kaSWavyNHJw83/aJ0dZAhKWID/FAED9vlgBa43kW8Vb61BSXORXf8f9W6NJ7qepTtlPSaJc557qkpxT1HCUBw==
 
 fast-deep-equal@^2.0.1:
   version "2.0.1"