Skip to content

Conversation

akazakou
Copy link
Contributor

Description

Here I've done a kludge to import type definitions without rewriting exists type definitions.

I've added Triple-Slash Directive to allow import of fastest-validator types.

/// <reference path="../../../index.d.ts" />

Next, I've imported default export from fastest-validator definition package

import ValidatorType from 'fastest-validator';

And the last one I've imported from javascript file default export and assigned to this imported variable, exported from 'fastest-validator' definition type.

const Validator: typeof ValidatorType = require('../../../index');

Now constant Validator have a type named as ValidatorType that actually Validator class.

Changelog

  • Added @types/jest, rollup-plugin-copy and ts-jest dev dependencies
  • Added copying index.d.ts file into dist folder
  • Integrated TypeScript test via ts-jest support

Now you no need dedicated test:ts npm job. You will be enough to run test job and it will test Javascript and Typescript files at the same time.

@coveralls
Copy link

coveralls commented Nov 11, 2019

Coverage Status

Coverage remained the same at 100.0% when pulling 9a9df8f on akazakou:feature/next-typescript-integration-for-jest into 3442228 on icebob:next.

@icebob
Copy link
Owner

icebob commented Nov 11, 2019

Awesome job @akazakou! Thank you very much and thank you for your quick job!

@icebob icebob merged commit e930a27 into icebob:next Nov 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants