mirror of
https://github.com/Choices-js/Choices.git
synced 2024-06-09 09:22:19 +02:00
Fixing typings (again 🤷🏼♂️) + test for them (#682)
* add index notation * add types check
This commit is contained in:
parent
1dbab0f29e
commit
a35c8b9009
27
.github/workflows/types.yml
vendored
Normal file
27
.github/workflows/types.yml
vendored
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
name: TypeScript Check
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- 'types/index.d.ts'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
tsc:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
|
||||||
|
- uses: actions/setup-node@v1
|
||||||
|
with:
|
||||||
|
node-version: 12
|
||||||
|
|
||||||
|
- name: Install TypeScript
|
||||||
|
run: npm install -g typescript
|
||||||
|
|
||||||
|
- name: Install required dependencies
|
||||||
|
run: npm i --only=production --no-optional --no-audit --ignore-scripts
|
||||||
|
|
||||||
|
- name: Check typings file
|
||||||
|
run: tsc types/index.d.ts
|
23
types/index.d.ts
vendored
23
types/index.d.ts
vendored
|
@ -1,8 +1,7 @@
|
||||||
// Type definitions for Choices.js 7.0.0
|
// Type definitions for Choices.js 7.1.x
|
||||||
// Project: https://github.com/jshjohnson/Choices
|
// Project: https://github.com/jshjohnson/Choices
|
||||||
// Definitions by: Arthur vasconcelos <https://github.com/arthurvasconcelos>, Josh Johnson <https://github.com/jshjohnson>, Zack Schuster <https://github.com/zackschuster>
|
// Definitions by: Arthur vasconcelos <https://github.com/arthurvasconcelos>, Josh Johnson <https://github.com/jshjohnson>, Zack Schuster <https://github.com/zackschuster>
|
||||||
// Definitions: https://github.com/jshjohnson/Choices
|
// Definitions: https://github.com/jshjohnson/Choices
|
||||||
// TypeScript Version: 2.9.2
|
|
||||||
|
|
||||||
import { FuseOptions } from 'fuse.js';
|
import { FuseOptions } from 'fuse.js';
|
||||||
|
|
||||||
|
@ -21,7 +20,7 @@ declare namespace Choices {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Choice {
|
interface Choice {
|
||||||
customProperties?: Record<sting, any>;
|
customProperties?: Record<string, any>;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
elementId?: string;
|
elementId?: string;
|
||||||
groupId?: string;
|
groupId?: string;
|
||||||
|
@ -641,7 +640,7 @@ declare namespace Choices {
|
||||||
/**
|
/**
|
||||||
* Choices uses the great Fuse library for searching. You can find more options here: https://github.com/krisk/Fuse#options
|
* Choices uses the great Fuse library for searching. You can find more options here: https://github.com/krisk/Fuse#options
|
||||||
*/
|
*/
|
||||||
fuseOptions?: FuseOptions;
|
fuseOptions?: FuseOptions<Choice>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to run once Choices initialises.
|
* Function to run once Choices initialises.
|
||||||
|
@ -724,14 +723,20 @@ export default class Choices {
|
||||||
wasTap: boolean;
|
wasTap: boolean;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
element:
|
selectorOrElement: string | HTMLInputElement | HTMLSelectElement,
|
||||||
| string
|
|
||||||
| HTMLInputElement
|
|
||||||
| HTMLSelectElement
|
|
||||||
| Array<string | HTMLInputElement | HTMLSelectElement>,
|
|
||||||
userConfig?: Choices.Options
|
userConfig?: Choices.Options
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* It's impossible to declare in TypeScript what Choices constructor is actually doing:
|
||||||
|
* @see {@link https://github.com/Microsoft/TypeScript/issues/27594}
|
||||||
|
* it returns array of Choices in case if selectorOrElement is string
|
||||||
|
* and one instance of Choices otherwise
|
||||||
|
* This little hack will at least allow to use it in Typescript
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
[index: number]: this;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance of Choices, adds event listeners, creates templates and renders a Choices element to the DOM.
|
* Creates a new instance of Choices, adds event listeners, creates templates and renders a Choices element to the DOM.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue