feat: add typescript type declaration files

This commit is contained in:
Benny Powers
2018-12-11 19:08:04 +02:00
committed by Thomas Allmer
parent e736ead77c
commit f5cb24399d
15 changed files with 103 additions and 2 deletions

View File

@@ -0,0 +1,4 @@
import * as Chai from 'chai'
export function getOuterHtml(el: Element): string;
export function getCleanedShadowDom(el: Element): string;
export function chaiDomEquals(chai: Chai, utils: any): undefined;

1
packages/chai-dom-equals/index.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
export { getOuterHtml, getCleanedShadowDom, chaiDomEquals } from './chai-dom-equals';

View File

@@ -14,7 +14,8 @@
"test:es5:bs": "karma start karma.es5.bs.config.js"
},
"dependencies": {
"@open-wc/semantic-dom-diff": "^0.4.3"
"@open-wc/semantic-dom-diff": "^0.4.3",
"@types/chai": "^4.1.7"
},
"devDependencies": {
"@bundled-es-modules/chai": "^4.2.0",

1
packages/semantic-dom-diff/index.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
export { getSemanticDomDiff, getAST } from './src/get-dom-diff';

View File

@@ -15,7 +15,8 @@
},
"dependencies": {
"@bundled-es-modules/deep-diff": "^1.0.2-rc.1",
"@bundled-es-modules/parse5": "^5.1.0"
"@bundled-es-modules/parse5": "^5.1.0",
"@types/parse5": "^5.0.0"
},
"devDependencies": {
"@bundled-es-modules/chai": "^4.2.0",

View File

@@ -0,0 +1,11 @@
import { DocumentFragment } from 'parse5';
interface DiffResult {
message: String;
path: String;
normalizedLeftHTML: String;
normalizedRightHTML: String;
}
export function getAST(value, config): DocumentFragment
export function getSemanticDomDiff(leftHTML, rightHTML, config): DiffResult

21
packages/storybook/index.d.ts vendored Normal file
View File

@@ -0,0 +1,21 @@
export { html } from 'lit-html';
// NB: @types/storybook__polymer doesn't yet exist
// export { storiesOf, addParameters } from '@storybook/polymer';
export { action } from '@storybook/addon-actions';
export { linkTo } from '@storybook/addon-links';
// NB: @types/storybook__addon-backgrounds is 2 major versions behind
// export { withBackgrounds } from '@storybook/addon-backgrounds';
export { withNotes } from '@storybook/addon-notes';
export {
withKnobs,
text,
button,
number,
select,
date,
color,
array,
boolean,
} from '@storybook/addon-knobs';

View File

@@ -22,6 +22,11 @@
"@storybook/addon-storysource": "^4.0.0-alpha.25",
"@storybook/addon-viewport": "^4.0.0-alpha.25",
"@storybook/polymer": "^4.0.0-alpha.25",
"@types/storybook__addon-actions": "^3.4.1",
"@types/storybook__addon-backgrounds": "^3.2.1",
"@types/storybook__addon-knobs": "^3.4.1",
"@types/storybook__addon-links": "^3.3.3",
"@types/storybook__addon-notes": "^3.3.3",
"@webcomponents/webcomponentsjs": "^2.0.0",
"babel-loader": "^8.0.0",
"moment": "^2.0.0",

5
packages/testing-helpers/fixture.d.ts vendored Normal file
View File

@@ -0,0 +1,5 @@
type PropsFunction = (element: HTMLElement) => Object;
type FixtureProps = Object | PropsFunction;
export class FixtureWrapper extends HTMLElement { };
export function fixtureSync(template: string, props: FixtureProps): FixtureWrapper;
export async function fixture(template: string, setup: FixtureProps): FixtureWrapper;

10
packages/testing-helpers/helpers.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
type Constructor<T = {}> = new (...args: any[]) => T;
export function defineCE<TBase extends Constructor>(klass: TBase): string;
export function isIE(): boolean
export async function aTimeout(ms: int): void
export async function triggerBlurFor(element: HTMLElement): void
export async function triggerFocusFor(element: HTMLElement): void
export async function oneEvent(element: HTMLElement, eventName: string): Event
export async function nextFrame(): void
export async function flush(): void

12
packages/testing-helpers/index.d.ts vendored Normal file
View File

@@ -0,0 +1,12 @@
export { html, unsafeStatic } from './lit-html';
export {
aTimeout,
defineCE,
isIE,
nextFrame,
oneEvent,
triggerBlurFor,
triggerFocusFor,
} from './helpers';
export { litFixture, litFixtureSync } from './litFixture';
export { fixture, fixtureSync } from './fixture';

View File

@@ -0,0 +1,2 @@
export { render, html } from 'lit-html/lit-html';
export function unsafeStatic<TOptions>(options: TOptions): { d: TOptions }

View File

@@ -0,0 +1,4 @@
import { FixtureWrapper } from './fixture';
export function litFixtureSync(template: TemplateResult): FixtureWrapper;
export async function litFixture(template: TemplateResult): FixtureWrapper;

22
packages/testing/index.d.ts vendored Normal file
View File

@@ -0,0 +1,22 @@
export {
html,
unsafeStatic,
triggerBlurFor,
triggerFocusFor,
oneEvent,
isIE,
defineCE,
aTimeout,
litFixture,
litFixtureSync,
fixture,
fixtureSync,
} from '@open-wc/testing-helpers';
export {
expect,
should,
assert,
} from 'chai';
import 'chai';

View File

@@ -17,6 +17,7 @@
"@bundled-es-modules/chai": "^4.2.0",
"@open-wc/chai-dom-equals": "^0.5.3",
"@open-wc/testing-helpers": "^0.4.3",
"@types/chai": "^4.1.7",
"mocha": "^5.0.0"
},
"devDependencies": {