先週に同僚と会話していたときに気になっていた Experimental Test Proxy について。
mugi さんの素振りメモ や この機能が実装された際の PR のコードを読んで、ようやく何が行われているかを理解した。
まず、README にある以下のコードがどこをスタブしているかであるが、
import { test, expect } from "next/experimental/testmode/playwright";
import { cache } from "react"; | |
import DataLoader from "dataloader"; | |
// backend service clients | |
import { getPopularPosts, getUserById, getUsers } from "@/services"; | |
const memoizedGetUserById = cache(getUserById); | |
const getUserLoader = () => |
先週に同僚と会話していたときに気になっていた Experimental Test Proxy について。
mugi さんの素振りメモ や この機能が実装された際の PR のコードを読んで、ようやく何が行われているかを理解した。
まず、README にある以下のコードがどこをスタブしているかであるが、
import { test, expect } from "next/experimental/testmode/playwright";
import assert from "assert"; | |
import { parse, print, DocumentNode, visit } from "graphql"; | |
function removeUnusedFragment(document: DocumentNode) { | |
const usedFragmentSet = new Set<string>(); | |
// mark used | |
visit(document, { | |
FragmentSpread(node) { | |
usedFragmentSet.add(node.name.value); |
Relay や Apollo のスタンス:
https://relay.dev/docs/principles-and-architecture/thinking-in-graphql/#client-caching
https://devblogs.microsoft.com/typescript/announcing-typescript-4-2/
下記のように、Rest Elements が tuple の最初でなくても使えるようになっています。
I'm loving Angular, but running unit tests on Karma gets my nerves. It's too slow for me.
In this post, I explain mechanics under Angular's testing module and how to improve the performance.
To evaluate Angular unit testing performance I captured the CPU profiling with running Karma.
/** | |
* | |
* Mini calc with TypeScript template string types | |
* | |
* EBNF | |
* | |
* ``` | |
* expr = mul ("+" mul)* | |
* mul = primary ("*" primary)* | |
* primary = num | "(" expr ")" |
import { Rule } from "eslint"; | |
const rule: Rule.RuleModule = { | |
create: (context) => { | |
return { | |
['NewExpression:not(:has(*.arguments)) > Identifier[name="Date"], CallExpression > MemberExpression:has(Identifier.object[name="Date"]) > Identifier.property[name="now"]']: (node: any) => { | |
context.report({ | |
message: "Don't use side-effective Date function.", | |
node, | |
}); |
import * as ts from "typescript"; | |
import { SourceCode, Linter, AST } from "eslint"; | |
import { Extra } from "@typescript-eslint/typescript-estree/dist/parser-options"; | |
import convert from "@typescript-eslint/typescript-estree/dist/ast-converter"; | |
function initExtra() { | |
return { | |
tokens: null, | |
range: false, | |
loc: false, |