Skip to content

Commit

Permalink
feat(typescript): update to typescript 4.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Dec 16, 2020
1 parent c9f04e9 commit adf9c93
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 19 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
"sizzle": "^2.3.5",
"terser": "5.5.1",
"tslib": "^2.0.3",
"typescript": "4.0.5",
"typescript": "4.1.3",
"webpack": "^4.44.2",
"ws": "7.4.1"
},
Expand Down
2 changes: 1 addition & 1 deletion src/client/polyfills/css-shim/custom-style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class CustomStyle implements CssVarShim {
}

this.didInit = true;
return new Promise(resolve => {
return new Promise<void>(resolve => {
this.win.requestAnimationFrame(() => {
startWatcher(this.doc, this.globalScopes);
loadDocument(this.doc, this.globalScopes).then(() => resolve());
Expand Down
3 changes: 3 additions & 0 deletions src/compiler/sys/dependencies.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"compiler/lib.es2020.full.d.ts",
"compiler/lib.es2020.intl.d.ts",
"compiler/lib.es2020.promise.d.ts",
"compiler/lib.es2020.sharedmemory.d.ts",
"compiler/lib.es2020.string.d.ts",
"compiler/lib.es2020.symbol.wellknown.d.ts",
"compiler/lib.es5.d.ts",
Expand All @@ -56,9 +57,11 @@
"compiler/lib.esnext.intl.d.ts",
"compiler/lib.esnext.promise.d.ts",
"compiler/lib.esnext.string.d.ts",
"compiler/lib.esnext.weakref.d.ts",
"compiler/lib.scripthost.d.ts",
"compiler/lib.webworker.d.ts",
"compiler/lib.webworker.importscripts.d.ts",
"compiler/lib.webworker.iterable.d.ts",
"internal/index.d.ts",
"internal/index.js",
"internal/package.json",
Expand Down
2 changes: 1 addition & 1 deletion src/dev-server/server-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export function initServerProcess(sendMsg: d.DevServerSendMessage) {
}
if (server) {
promises.push(
new Promise(resolve => {
new Promise<void>(resolve => {
server.close(err => {
if (err) {
console.error(`close error: ${err}`);
Expand Down
11 changes: 9 additions & 2 deletions src/testing/platform/testing-task-queue.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import type * as d from '@stencil/core/internal';
import { caughtErrors, moduleLoaded, queuedLoadModules, queuedReadTasks, queuedTicks, queuedWriteTasks } from './testing-constants';
import {
caughtErrors,
moduleLoaded,
queuedLoadModules,
queuedReadTasks,
queuedTicks,
queuedWriteTasks,
} from './testing-constants';

export function resetTaskQueue() {
queuedTicks.length = 0;
Expand All @@ -15,7 +22,7 @@ export const nextTick = (cb: Function) => {
};

export function flushTicks() {
return new Promise((resolve, reject) => {
return new Promise<void>((resolve, reject) => {
function drain() {
try {
if (queuedTicks.length > 0) {
Expand Down
20 changes: 16 additions & 4 deletions src/testing/puppeteer/puppeteer-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ async function pageSpyOnEvent(page: pd.E2EPageInternal, eventName: string, selec
return eventSpy;
}

export async function waitForEvent(page: pd.E2EPageInternal, eventName: string, elementHandle: puppeteer.ElementHandle) {
export async function waitForEvent(
page: pd.E2EPageInternal,
eventName: string,
elementHandle: puppeteer.ElementHandle,
) {
const timeoutMs = jasmine.DEFAULT_TIMEOUT_INTERVAL * 0.5;
const ev = await page.evaluate(
(element: Element, eventName: string, timeoutMs: number) => {
Expand Down Expand Up @@ -86,7 +90,7 @@ export class EventSpy implements EventSpy {
});
} else {
let resolve: () => void;
const promise = new Promise(r => (resolve = r));
const promise = new Promise<void>(r => (resolve = r));
this.queuedHandler.push(resolve);
return promise.then(() => ({
done: false,
Expand All @@ -104,7 +108,12 @@ export class EventSpy implements EventSpy {
}
}

export async function addE2EListener(page: pd.E2EPageInternal, elmHandle: puppeteer.JSHandle, eventName: string, callback: (ev: any) => void) {
export async function addE2EListener(
page: pd.E2EPageInternal,
elmHandle: puppeteer.JSHandle,
eventName: string,
callback: (ev: any) => void,
) {
// NODE CONTEXT
const id = page._e2eEventIds++;
page._e2eEvents.set(id, {
Expand All @@ -118,7 +127,10 @@ export async function addE2EListener(page: pd.E2EPageInternal, elmHandle: puppet
await executionContext.evaluate(
(elm: any, id: number, eventName: string) => {
elm.addEventListener(eventName, (ev: any) => {
((window as unknown) as pd.BrowserWindow).stencilOnEvent(id, ((window as unknown) as pd.BrowserWindow).stencilSerializeEvent(ev));
((window as unknown) as pd.BrowserWindow).stencilOnEvent(
id,
((window as unknown) as pd.BrowserWindow).stencilSerializeEvent(ev),
);
});
},
elmHandle,
Expand Down
4 changes: 2 additions & 2 deletions src/testing/puppeteer/puppeteer-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export async function newE2EPage(opts: NewE2EPageOptions = {}): Promise<E2EPage>
throw new Error('Set the --devtools flag in order to use E2EPage.debugger()');
}
return page.evaluate(() => {
return new Promise(resolve => {
return new Promise<void>(resolve => {
// tslint:disable-next-line: no-debugger
debugger;
resolve();
Expand Down Expand Up @@ -314,7 +314,7 @@ async function waitForChanges(page: E2EPageInternal) {

await page.evaluate(() => {
// BROWSER CONTEXT
return new Promise(resolve => {
return new Promise<void>(resolve => {
requestAnimationFrame(() => {
const promises: Promise<any>[] = [];

Expand Down
33 changes: 28 additions & 5 deletions src/testing/puppeteer/puppeteer-screenshot.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import type { E2EProcessEnv, EmulateConfig, JestEnvironmentGlobal, ScreenshotBuildData, ScreenshotDiff, ScreenshotOptions } from '@stencil/core/internal';
import type {
E2EProcessEnv,
EmulateConfig,
JestEnvironmentGlobal,
ScreenshotBuildData,
ScreenshotDiff,
ScreenshotOptions,
} from '@stencil/core/internal';
import { compareScreenshot } from '../../screenshot/screenshot-compare';
import type * as pd from './puppeteer-declarations';
import type * as puppeteer from 'puppeteer';
Expand Down Expand Up @@ -70,7 +77,13 @@ export function initPageScreenshot(page: pd.E2EPageInternal) {
}
}

export async function pageCompareScreenshot(page: pd.E2EPageInternal, env: E2EProcessEnv, desc: string, testPath: string, opts: ScreenshotOptions) {
export async function pageCompareScreenshot(
page: pd.E2EPageInternal,
env: E2EProcessEnv,
desc: string,
testPath: string,
opts: ScreenshotOptions,
) {
if (typeof env.__STENCIL_EMULATE__ !== 'string') {
throw new Error(`compareScreenshot, missing screenshot emulate env var`);
}
Expand All @@ -84,7 +97,7 @@ export async function pageCompareScreenshot(page: pd.E2EPageInternal, env: E2EPr

await wait(screenshotBuildData.timeoutBeforeScreenshot);
await page.evaluate(() => {
return new Promise(resolve => {
return new Promise<void>(resolve => {
window.requestAnimationFrame(() => {
resolve();
});
Expand All @@ -93,7 +106,8 @@ export async function pageCompareScreenshot(page: pd.E2EPageInternal, env: E2EPr

const screenshotOpts = createPuppeteerScreenshopOptions(opts);
const screenshotBuf = await page.screenshot(screenshotOpts);
const pixelmatchThreshold = typeof opts.pixelmatchThreshold === 'number' ? opts.pixelmatchThreshold : screenshotBuildData.pixelmatchThreshold;
const pixelmatchThreshold =
typeof opts.pixelmatchThreshold === 'number' ? opts.pixelmatchThreshold : screenshotBuildData.pixelmatchThreshold;

let width = emulateConfig.viewport.width;
let height = emulateConfig.viewport.height;
Expand All @@ -107,7 +121,16 @@ export async function pageCompareScreenshot(page: pd.E2EPageInternal, env: E2EPr
}
}

const results = await compareScreenshot(emulateConfig, screenshotBuildData, screenshotBuf, desc, width, height, testPath, pixelmatchThreshold);
const results = await compareScreenshot(
emulateConfig,
screenshotBuildData,
screenshotBuf,
desc,
width,
height,
testPath,
pixelmatchThreshold,
);

return results;
}
Expand Down

0 comments on commit adf9c93

Please sign in to comment.