Closed Eyas closed 4 years ago
@Eyas Cool! What sort of perf gain did you see?
For the benefit of future readers, I should clarify that when naming intermediate types helps (which is rare), it can help a lot.
It makes a bit of a (positive) difference in 3.7 and 3.8, but might have regressed in 3.9.1. 95% confidence interval is pretty wide though.
TS 3.7:
TS 3.8:
TS 3.9.1-rc:
This is using --extendedDiagnostics
and looking at "Memory used". The repro case is simple:
import { WithContext, Article } from "schema-dts";
export const article: WithContext<Article> = {
"@context": "https://schema.org",
"@type": "Article",
name: [
"Woo", "Hoo"
]
};
with either schema-dts version installed. Node 13.
Thanks! One day, I'll figure out why node memory usage is so variable. :wink:
Rather than inlining a "leaf" type as an intersection in a big union, name it. This should hopefully help with #34.
This is based on advice from @amcasey regarding compiler performance:
This fits neatly with my initial description of the Schema.org type system here: https://blog.eyas.sh/2019/05/modeling-schema-org-schema-with-typescript-the-power-and-limitations-of-the-typescript-type-system/
There's still some room for improvements:
Also in this PR,