diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..91a3983 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +dist +node_modules +package-lock.json diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..e764cbf --- /dev/null +++ b/.travis.yml @@ -0,0 +1,9 @@ +language: node_js +node_js: + - node +cache: + directories: + - node_modules +script: + - npm test + - npm run build diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..fb81d6b --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,7 @@ +Copyright 2018 Abraham Williams + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..a4a8933 --- /dev/null +++ b/README.md @@ -0,0 +1,52 @@ +[![Version Status](https://img.shields.io/npm/v/@abraham/reflection.svg?style=flat&label=version&colorB=4bc524)](https://npmjs.com/package/@abraham/reflection) +[![Build Status](https://img.shields.io/travis/abraham/reflection.svg?style=flat)](https://travis-ci.org/abraham/reflection) +[![Dependency Status](https://david-dm.org/abraham/reflection.svg?style=flat)](https://david-dm.org/abraham/reflection) + +Reflection +==== + +Lightweight ES Module implementation of [reflect-metadata](https://github.com/rbuckton/reflect-metadata/) to work with TypeScript's [experimental decorator support](https://www.typescriptlang.org/docs/handbook/decorators.html). + +Why? +---- + +The main reason for this library is to provide a much smaller implementation that can be included as a module. + +- `reflect-metadata` is 52 K without compression while `reflection` is about 3 K +- `reflection` can be loaded with `` + +Install +---- + +```sh +npm install @abraham/reflection +``` + +Usage +----- + +```ts +import { Reflection as Reflect } from '@abraham/reflection'; +Reflect.defineMetadata(metadataKey, metadataValue, target); +``` + +If a globally available version you can use the following. + +```ts +import '@abraham/reflection/dist/reflect'; +Reflect.defineMetadata(metadataKey, metadataValue, target); +``` + + +API +---- + +Reflection does not cover the complete API surface of reflect-metadata. Currently the following are available. + +```ts +Reflect.decorate(...); +Reflect.defineMetadata(...); +Reflect.getMetadata(...); +Reflect.hasOwnMetadata(...); +Reflect.metadata(...); +``` diff --git a/package.json b/package.json new file mode 100644 index 0000000..934a1fc --- /dev/null +++ b/package.json @@ -0,0 +1,63 @@ +{ + "name": "@abraham/reflection", + "version": "0.1.0", + "description": "Lightweight ES Module implementation of reflect-metadata", + "main": "dist/index.js", + "module": "dist/index.js", + "types": "dist/index.d.ts", + "scripts": { + "build": "tsc", + "clean": "rimraf dist", + "prebuild": "npm run clean", + "prepare": "npm run build", + "test": "jest" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/abraham/reflection.git" + }, + "keywords": [ + "typescript", + "reflect", + "reflect-metadata", + "metadata", + "lightweight", + "micro", + "library" + ], + "author": "Abraham Williams <4braham@gmail.com>", + "license": "MIT", + "bugs": { + "url": "https://github.com/abraham/reflection/issues" + }, + "homepage": "https://github.com/abraham/reflection#readme", + "devDependencies": { + "@types/jest": "23.3.0", + "jest": "23.4.1", + "rimraf": "2.6.2", + "ts-jest": "23.0.1", + "typescript": "2.9.2" + }, + "jest": { + "roots": [ + "/src" + ], + "transform": { + "^.+\\.tsx?$": "ts-jest" + }, + "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$", + "moduleFileExtensions": [ + "ts", + "tsx", + "js", + "jsx", + "json", + "node" + ] + }, + "renovate": { + "extends": [ + "config:base" + ] + } +} diff --git a/src/decorate.test.ts b/src/decorate.test.ts new file mode 100644 index 0000000..3e8dff8 --- /dev/null +++ b/src/decorate.test.ts @@ -0,0 +1,222 @@ +import { Reflection as Reflect } from './index'; + +test('with invalid decorators and target', () => { + const decorators = undefined; + const target = () => {}; + expect(() => Reflect.decorate(decorators, target)).toThrow(TypeError); +}); + +test('with no decorators', () => { + const decorators = []; + const target = () => {}; + expect(() => Reflect.decorate(decorators, target)).toThrow(TypeError); +}); + +test('with property and invalid decorators', () => { + const decorators = undefined; + const target = {}; + const property = 'name'; + expect(() => Reflect.decorate(decorators, target, property)).toThrow(TypeError); +}); + +test('with property and invalid decorators', () => { + const decorators = []; + const target = 1; + const property = 'name'; + expect(() => Reflect.decorate(decorators, target, property)).toThrow(TypeError); +}); + +test('with property and descriptor and invalid decorators', () => { + const decorators = undefined; + const target = {}; + const property = 'name'; + const descriptor = {}; + expect(() => Reflect.decorate(decorators, target, property, descriptor)).toThrow(TypeError); +}); + +test('with decorators, property, and descriptor and invalid target ', () => { + const decorators = []; + const target = 1; + const property = 'name'; + const descriptor = {}; + expect(() => Reflect.decorate(decorators, target, property, descriptor)).toThrow(TypeError); +}); + +test('executes decorators in reverse order for function', () => { + const order: number[] = []; + const decorators = [ + () => { order.push(0); }, + () => { order.push(1); }, + ]; + const target = () => {}; + Reflect.decorate(decorators, target); + expect(order[0]).toEqual(1); + expect(order[1]).toEqual(0); +}); + +test('executes decorators in reverse order for property', () => { + const order: number[] = []; + const decorators = [ + () => { order.push(0); }, + () => { order.push(1); }, + ]; + const target = {}; + const property = 'name'; + Reflect.decorate(decorators, target, property); + expect(order[0]).toEqual(1); + expect(order[1]).toEqual(0); +}); + +test('executes decorators in reverse order for property with descriptor', () => { + const order: number[] = []; + const decorators = [ + () => { order.push(0); }, + () => { order.push(1); }, + ]; + const target = {}; + const property = 'name'; + const descriptor = {}; + Reflect.decorate(decorators, target, property, descriptor); + expect(order[0]).toEqual(1); + expect(order[1]).toEqual(0); +}); + +test('something function', () => { + const a = function a() {}; + const b = function b() {}; + const decorators = [ + () => {}, + () => a, + () => b, + ]; + const target = () => {}; + const result = Reflect.decorate(decorators, target); + expect(result).toStrictEqual(a); +}); + +test('something property', () => { + const a = function a() {}; + const b = function b() {}; + const decorators = [ + () => {}, + () => a, + () => b, + ]; + const target = {}; + const property = 'name'; + const result = Reflect.decorate(decorators, target, property); + expect(result).toStrictEqual(a); +}); + +test('something property with descriptor', () => { + const a = function a() {}; + const b = function b() {}; + const decorators = [ + () => {}, + () => a, + () => b, + ]; + const target = {}; + const property = 'name'; + const descriptor = function c() { }; + const result = Reflect.decorate(decorators, target, property, descriptor); + expect(result).toStrictEqual(a); +}); + +test('decorate correct target for function', () => { + const sent: Function[] = []; + const a = function a() {}; + const b = function b() {}; + const decorators = [ + (target: Function) => { sent.push(target); }, + (target: Function) => { sent.push(target); }, + (target: Function) => { sent.push(target); return a; }, + (target: Function) => { sent.push(target); return b; }, + ]; + const target = () => {}; + Reflect.decorate(decorators, target); + expect(sent[0]).toStrictEqual(target); + expect(sent[1]).toStrictEqual(b); + expect(sent[2]).toStrictEqual(a); + expect(sent[3]).toStrictEqual(a); +}); + +test('decorate correct target for function', () => { + const sent: object[] = []; + const decorators = [ + (target: object) => { sent.push(target); }, + (target: object) => { sent.push(target); }, + (target: object) => { sent.push(target); }, + (target: object) => { sent.push(target); }, + ]; + const target = {}; + const property = 'name'; + Reflect.decorate(decorators, target, property); + expect(sent).toStrictEqual([target, target, target, target]); +}); + +// DecoratorCorrectNameInPipelineForPropertyOverload +test('decorate correct target for function', () => { + const sent: string[] = []; + const decorators = [ + (_target: object, name: string) => { sent.push(name); }, + (_target: object, name: string) => { sent.push(name); }, + (_target: object, name: string) => { sent.push(name); }, + (_target: object, name: string) => { sent.push(name); }, + ]; + const target = {}; + const property = 'name'; + Reflect.decorate(decorators, target, property); + expect(sent).toStrictEqual([property, property, property, property]); +}); + +test('decorate correct target for function', () => { + const sent: object[] = []; + const a = {}; + const b = {} + const decorators = [ + (target: object) => { sent.push(target); }, + (target: object) => { sent.push(target); }, + (target: object) => { sent.push(target); return a; }, + (target: object) => { sent.push(target); return b; }, + ]; + const target = {}; + const property = 'name'; + const descriptor = {}; + Reflect.decorate(decorators, target, property, descriptor); + expect(sent).toStrictEqual([target, target, target, target]); +}); + +test('decorate correct target for function', () => { + const sent: string[] = []; + const a = {}; + const b = {} + const decorators = [ + (_target: object, name: string) => { sent.push(name); }, + (_target: object, name: string) => { sent.push(name); }, + (_target: object, name: string) => { sent.push(name); return a; }, + (_target: object, name: string) => { sent.push(name); return b; }, + ]; + const target = {}; + const property = 'name'; + const descriptor = {}; + Reflect.decorate(decorators, target, property, descriptor); + expect(sent).toStrictEqual([property, property, property, property]); +}); + +test('decorate correct target for function', () => { + const sent: PropertyDescriptor[] = []; + const a = {}; + const b = {} + const decorators = [ + (_target: object, _name: string, descriptor: PropertyDescriptor) => { sent.push(descriptor); }, + (_target: object, _name: string, descriptor: PropertyDescriptor) => { sent.push(descriptor); }, + (_target: object, _name: string, descriptor: PropertyDescriptor) => { sent.push(descriptor); return a; }, + (_target: object, _name: string, descriptor: PropertyDescriptor) => { sent.push(descriptor); return b; }, + ]; + const target = {}; + const property = 'name'; + const descriptor = {}; + Reflect.decorate(decorators, target, property, descriptor); + expect(sent).toStrictEqual([descriptor, b, a, a]); +}); diff --git a/src/define-metadata.test.ts b/src/define-metadata.test.ts new file mode 100644 index 0000000..ff31fc5 --- /dev/null +++ b/src/define-metadata.test.ts @@ -0,0 +1,22 @@ +import { Reflection as Reflect } from './index'; + +test('with invalid target', () => { + const metadataKey = 'key'; + const metadataValue = 'value'; + expect(() => Reflect.defineMetadata(metadataKey, metadataValue)).toThrow(TypeError); +}); + +test('with target but no property key', () => { + const metadataKey = 'key'; + const metadataValue = 'value'; + const target = {}; + expect(() => Reflect.defineMetadata(metadataKey, metadataValue, target)).not.toThrow(); +}); + +test('with target and property key', () => { + const metadataKey = 'key'; + const metadataValue = 'value'; + const target = {}; + const propertyKey = 'name'; + expect(() => Reflect.defineMetadata(metadataKey, metadataValue, target, propertyKey)).not.toThrow(); +}); diff --git a/src/get-metadata.test.ts b/src/get-metadata.test.ts new file mode 100644 index 0000000..01e0226 --- /dev/null +++ b/src/get-metadata.test.ts @@ -0,0 +1,41 @@ +import { Reflection as Reflect } from './index'; + +test('with invalid target', () => { + expect(() => Reflect.getMetadata('key')).toThrow(TypeError); +}); + +test('when not defined', () => { + const target = {}; + expect(Reflect.getMetadata('key', target)).toEqual(undefined); +}); + +test('when defined', () => { + const target = {}; + Reflect.defineMetadata('key', 'value', target); + expect(Reflect.getMetadata('key', target)).toEqual('value'); +}); + +test('when defined on prototype', () => { + const prototype = {}; + const target = Object.create(prototype); + Reflect.defineMetadata('key', 'value', prototype); + expect(Reflect.getMetadata('key', target)).toEqual('value'); +}); + +test('with key and not defined', () => { + const target = {}; + expect(Reflect.getMetadata('key', target, 'name')).toEqual(undefined); +}); + +test('with key and defined', () => { + const target = {}; + Reflect.defineMetadata('key', 'value', target, 'name'); + expect(Reflect.getMetadata('key', target, 'name')).toEqual('value'); +}); + +test('when defined on prototype', () => { + const prototype = {}; + const target = Object.create(prototype); + Reflect.defineMetadata('key', 'value', prototype, 'name'); + expect(Reflect.getMetadata('key', target, 'name')).toEqual('value'); +}); diff --git a/src/index.test.ts b/src/index.test.ts new file mode 100644 index 0000000..9dccd50 --- /dev/null +++ b/src/index.test.ts @@ -0,0 +1,17 @@ +import { Reflection as Reflect } from './index'; + +test('defineMetadata', () => { + expect(Reflect.defineMetadata).toBeDefined(); +}); + +test('getMetadata', () => { + expect(Reflect.getMetadata).toBeDefined(); +}); + +test('decorate', () => { + expect(Reflect.decorate).toBeDefined(); +}); + +test('metadata', () => { + expect(Reflect.metadata).toBeDefined(); +}); diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..feb8802 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,9 @@ +import { decorate, defineMetadata, getMetadata, hasOwnMetadata, metadata } from './methods'; + +export const Reflection = Object.assign(Reflect, { + decorate, + defineMetadata, + getMetadata, + hasOwnMetadata, + metadata, +}); diff --git a/src/metadata.test.ts b/src/metadata.test.ts new file mode 100644 index 0000000..f838ec5 --- /dev/null +++ b/src/metadata.test.ts @@ -0,0 +1,34 @@ +import { Reflection as Reflect } from './index'; + +const metadataKey = 'key'; +const metadataValue = 'value'; +const decorator = Reflect.metadata(metadataKey, metadataValue); +const propertyKey = 'name'; + +test('returns function', () => { + expect(typeof Reflect.metadata(metadataKey, metadataValue)).toEqual('function'); +}); + +test('with invalid target', () => { + const decorator = Reflect.metadata(metadataKey, metadataValue); + const target = undefined; + expect(() => decorator(target, propertyKey)).toThrow(TypeError); +}) + +test('with invalid property key', () => { + const target = {}; + const propertyKey = {}; + expect(() => decorator(target, propertyKey)).toThrow(TypeError); +}) + +test('with target and without property key', () => { + const target = () => {}; + decorator(target) + expect(Reflect.hasOwnMetadata(metadataKey, target)).toBeTruthy(); +}) + +test('with target and propery key', () => { + const target = {}; + decorator(target, propertyKey); + expect(Reflect.hasOwnMetadata(metadataKey, target, propertyKey)).toBeTruthy(); +}); diff --git a/src/methods.ts b/src/methods.ts new file mode 100644 index 0000000..48eb7d7 --- /dev/null +++ b/src/methods.ts @@ -0,0 +1,96 @@ +export type Decorator = ClassDecorator | MemberDecorator; +export type MemberDecorator = (target: Target, propertyKey: PropertyKey, descriptor?: TypedPropertyDescriptor) => TypedPropertyDescriptor | void; +export type MetadataKey = string; +export type MetadataValue = Function; +export type PropertyKey = string | symbol; +export type Target = object | Function; + +const Metadata = new WeakMap(); + +export function defineMetadata(metadataKey: MetadataKey, metadataValue: MetadataValue, target: Target, propertyKey?: PropertyKey) { + return ordinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey); +} + +export function decorate(decorators: ClassDecorator[], target: Function): Function +export function decorate(decorators: MemberDecorator[], target: object, propertyKey?: PropertyKey, attributes?: PropertyDescriptor): PropertyDescriptor | undefined +export function decorate(decorators: Decorator[], target: Target, propertyKey?: PropertyKey, attributes?: PropertyDescriptor): Function | PropertyDescriptor | undefined { + if (decorators.length === 0) throw new TypeError(); + + if (typeof target === 'function') { + return decorateConstructor(decorators as ClassDecorator[], target); + } else if (propertyKey !== undefined) { + return decorateProperty(decorators as MemberDecorator[], target, propertyKey, attributes); + } + return; +} + +export function metadata(metadataKey: MetadataKey, metadataValue: MetadataValue) { + return function decorator(target: Function, propertyKey?: PropertyKey) { + ordinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey); + }; +} + +export function getMetadata(metadataKey: MetadataKey, target: Target, propertyKey?: PropertyKey) { + return ordinaryGetMetadata(metadataKey, target, propertyKey); +} + +export function hasOwnMetadata(metadataKey: MetadataKey, target: Target, propertyKey?: PropertyKey): boolean { + return ordinaryHasOwnMetadata(metadataKey, target, propertyKey); +} + +function decorateConstructor(decorators: ClassDecorator[], target: Function): Function { + decorators.reverse().forEach((decorator: ClassDecorator) => { + const decorated = decorator(target); + if (decorated) { + target = decorated; + } + }); + return target; +} + +function decorateProperty(decorators: MemberDecorator[], target: Target, propertyKey: PropertyKey, descriptor?: PropertyDescriptor): PropertyDescriptor | undefined { + decorators.reverse().forEach((decorator: MemberDecorator) => { + const decorated = decorator(target, propertyKey, descriptor); + if (decorated) { + descriptor = decorated; + } + }); + return descriptor; +} + +function ordinaryDefineOwnMetadata(metadataKey: MetadataKey, metadataValue: MetadataValue, target: Target, propertyKey?: PropertyKey): void { + if (propertyKey && !['string', 'symbol'].includes(typeof propertyKey)) throw new TypeError(); + + createMetadataMap(target, propertyKey) + .set(metadataKey, metadataValue); +} + +function ordinaryGetMetadata(metadataKey: MetadataKey, target: Target, propertyKey?: PropertyKey): Function | undefined { + return ordinaryHasOwnMetadata(metadataKey, target, propertyKey) + ? ordinaryGetOwnMetadata(metadataKey, target, propertyKey) + : Object.getPrototypeOf(target) + ? ordinaryGetMetadata(metadataKey, Object.getPrototypeOf(target), propertyKey) + : undefined; +} + +function ordinaryHasOwnMetadata(metadataKey: MetadataKey, target: Target, propertyKey?: PropertyKey): boolean { + const metadataMap = getMetadataMap(target, propertyKey); + return !!metadataMap && !!metadataMap.has(metadataKey); +} + +function ordinaryGetOwnMetadata(metadataKey: MetadataKey, target: Target, propertyKey?: PropertyKey): Function | undefined { + const metadataMap = getMetadataMap(target, propertyKey); + return metadataMap && metadataMap.get(metadataKey); +} + +function getMetadataMap(target: Target, propertyKey?: PropertyKey): Map | undefined { + return Metadata.get(target) && Metadata.get(target).get(propertyKey); +} + +export function createMetadataMap(target: Target, propertyKey?: PropertyKey): Map { + const targetMetadata = new Map>(); + Metadata.set(target, targetMetadata); + const metadataMap = new Map(); + targetMetadata.set(propertyKey, metadataMap); + return metadataMap; +} diff --git a/src/reflect.test.ts b/src/reflect.test.ts new file mode 100644 index 0000000..edb8fe4 --- /dev/null +++ b/src/reflect.test.ts @@ -0,0 +1,21 @@ +import './reflect'; + +test('defineMetadata', () => { + expect(Reflect.defineMetadata).toBeDefined(); +}); + +test('getMetadata', () => { + expect(Reflect.getMetadata).toBeDefined(); +}); + +test('decorate', () => { + expect(Reflect.decorate).toBeDefined(); +}); + +test('metadata', () => { + expect(Reflect.metadata).toBeDefined(); +}); + +test('hasOwnMetadata', () => { + expect(Reflect.hasOwnMetadata).toBeDefined(); +}); diff --git a/src/reflect.ts b/src/reflect.ts new file mode 100644 index 0000000..3e8130c --- /dev/null +++ b/src/reflect.ts @@ -0,0 +1,14 @@ +import { decorate, defineMetadata, getMetadata, hasOwnMetadata, metadata } from './methods'; + +// TODO: Is there a better way to do this? +declare global { + interface Window { + Reflect: any; + } +} + +window.Reflect.decorate = decorate; +window.Reflect.defineMetadata = defineMetadata; +window.Reflect.getMetadata = getMetadata; +window.Reflect.hasOwnMetadata = hasOwnMetadata; +window.Reflect.metadata = metadata; diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..e5348d5 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,60 @@ +{ + "compilerOptions": { + /* Basic Options */ + "target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */ + "module": "esnext", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ + // "lib": [], /* 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. */ + "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + "outDir": "./dist", /* Redirect output structure to the directory. */ + "rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "removeComments": true, /* 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'). */ + + /* 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. */ + + /* 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. */ + + /* 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. */ + }, + "exclude": [ + "**/*.test.ts" + ] +}