Title: Design Meeting Notes, 3/8/2019 · Issue #30279 · microsoft/TypeScript · GitHub
Open Graph Title: Design Meeting Notes, 3/8/2019 · Issue #30279 · microsoft/TypeScript
X Title: Design Meeting Notes, 3/8/2019 · Issue #30279 · microsoft/TypeScript
Description: Higher order function type inference #30215 Reference code declare function pipe(ab: (...args: A) => B): (...args: A) => B; declare function invoke(f: (...args: A) => R, ...args: A): R; declare fun...
Open Graph Description: Higher order function type inference #30215 Reference code declare function pipe(ab: (...args: A) => B): (...args: A) => B; declare function invoke(f: (...ar...
X Description: Higher order function type inference #30215 Reference code declare function pipe<A extends any[], B>(ab: (...args: A) => B): (...args: A) => B; declare function invoke<A extends any[...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/30279
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Design Meeting Notes, 3/8/2019","articleBody":"# Higher order function type inference\r\n\r\n#30215\r\n\r\nReference code\r\n\r\n```ts\r\ndeclare function pipe\u003cA extends any[], B>(ab: (...args: A) => B): (...args: A) => B;\r\ndeclare function invoke\u003cA extends any[], R>(f: (...args: A) => R, ...args: A): R;\r\n\r\ndeclare function box\u003cT>(x: T): { value; T };\r\ndeclare function list\u003cT>(x: T): T[];\r\ndeclare function map\u003cT, U>(f: (t: T) => U): (a: T[]) => U[];\r\n```\r\n\r\n* Seemed to get a lot of enthusiasm on this issue.\r\n* Builds on improvements to our inference - specifically, this does better when doing inference from other generic functions.\r\n * First, we added a change to make types with generic signatures contextually sensitive.\r\n * We have multiple rounds of inference, and marking arguments as contextually sensitive means we can defer inferring from them to later rounds.\r\n * This allows us to let types flow *into* function expressions to understand their output types.\r\n * This is important each pass of our inference process is fundamentally just a left-to-right process over provided arguments.\r\n * This example used to give `{}[]` before this change. Now `list` is contextually sensitive and we infer `number` for `A`, and the output type is `number[]`.\r\n ```ts\r\n invoke(list, 42);\r\n ```\r\n * Another change is an extension of the last change - any invoked expression that has a generic call signature that can return a function is *also* contextually sensitive.\r\n\r\n ```ts\r\n // Would previously be `{}[]`, now is `number[]` because the `map` is generic and returns a function,\r\n // and is now considered contextually sensitive.\r\n invoke(map(x => x * 2), [1, 2, 3, 4]);\r\n\r\n invoke(list, identity(42));\r\n ```\r\n * The last big change is that if the output type of a signature is a non-generic single signature type, then any type parameters which had no inferences will be \"promoted\" to fresh type variables on a version of the output type that is generic.\r\n * Is this a problem for named type arguments?\r\n * Any change to an invocation can change the way the type arguments are named in output types.\r\n * In a sense, these fresh type variables get observed as existential types.\r\n * Is there a way to opt *out* of this behavior?\r\n * No.\r\n * What if you specify a type parameter list on the output type?\r\n * Yes.\r\n * Can I specify an empty type parameter list?\r\n * No.\r\n * Huh.\r\n * Anders: I feel relatively confident in the change; observed differences seem to have been questionable anyway.\r\n * Only user test suite code that saw changes is RxJS, fp-ts, and Ramda.\r\n * RxJS: Looks like fixes. (@benlesh)\r\n * fp-ts: Better errors, fixes. One .d.ts file changed by creating a generic output type(!) (@gcanti)\r\n * Ramda: In some cases, better types. In a few, it's just people putting type parameters in the wrong place.\r\n * Infra: we didn't need the stupid `excludeArguments` array in overload resolution.\r\n * \"That constellation of weird hacks was just weird.\"\r\n* Limitations\r\n * We haven't changed anything for unannotated function expressions\r\n\r\n ```ts\r\n declare function box\u003cT>(a: T): { value: T };\r\n pipe(x => [x], box); // this is (x: any) => { value: any[] }\r\n ```\r\n \r\n In other words, we don't try to infer type parameters for `x`.\r\n\r\n# Cross-compilation incremental builds\r\n\r\n#29813\r\n\r\n* High level idea: serializing the information we have in `--watch` mode to disk to get *way* faster subsequent compiles.\r\n* New flag called: `--incremental`\r\n * Turned on by default for all composite projects, and defaults to a file called `.tsbuildinfo`.\r\n * But can be turned on for ***all*** projects!\r\n* Works best for files with modules\r\n* `outFile` may need some changes because *something* will always need to cha\r\n* What's the `.tsbuildinfo` file look like?\r\n * Here's the schema:\r\n\r\n ```ts\r\n export interface SourceFileInfo {\r\n // List of helpers in own source files emitted if no prepend is present\r\n helpers?: string[];\r\n prologues?: SourceFilePrologueInfo[];\r\n }\r\n\r\n export interface BundleFileInfo {\r\n sections: BundleFileSection[];\r\n sources?: SourceFileInfo;\r\n }\r\n\r\n export interface BundleBuildInfo {\r\n js?: BundleFileInfo;\r\n dts?: BundleFileInfo;\r\n commonSourceDirectory: string;\r\n sourceFiles: ReadonlyArray\u003cstring>;\r\n }\r\n\r\n export interface ProgramBuildInfo {\r\n fileInfos: MapLike\u003cBuilderState.FileInfo>;\r\n options: CompilerOptions;\r\n referencedMap?: MapLike\u003cstring[]>;\r\n exportedModulesMap?: MapLike\u003cstring[]>;\r\n semanticDiagnosticsPerFile?: string[];\r\n }\r\n\r\n export interface BuildInfo {\r\n bundle?: BundleBuildInfo;\r\n program?: ProgramBuildInfo;\r\n }\r\n ```\r\n* You can just delete this and everything should be fine, right?\r\n * Yes.\r\n * Though, there's an open question of whether deleting the file should trigger a full rebuild in either `--watch` or `--build`?\r\n * Seems like yes.\r\n* Can MSBuild take advantage of this stuff?\r\n * Talk about this offline.\r\n* `.tsbuildinfo.json` so tooling can understand it?\r\n * Well, do we want people to be able to consume this file?\r\n * No, but it's useful and people will.\r\n * But we can't provide guarantees about this.\r\n * What's the versioning story?\r\n * Do these files need some sort of versioning?\r\n * Maybe the the compiler can track this?\r\n * The compiler needs to know what versions it's compatible with, so then why not a format version?\r\n * Easier to just say that no version of TypeScript is compatible with `.tsbuildinfo` files from other compilations.\r\n * Resolution: Version number in file.","author":{"url":"https://github.com/DanielRosenwasser","@type":"Person","name":"DanielRosenwasser"},"datePublished":"2019-03-08T21:14:03Z","url":"https://github.com/microsoft/TypeScript/issues/30279"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:af668374-e650-a6d5-e136-d6113ad98486 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9954:3A73AA:1E05788:2607B01:6B019E1B |
| html-safe-nonce | d7e9a70b38f014dc83573648cb224c6cbd3942073d92955ee4373e3dffa26649 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OTU0OjNBNzNBQToxRTA1Nzg4OjI2MDdCMDE6NkIwMTlFMUIiLCJ2aXNpdG9yX2lkIjoiODI0MDMxOTkwMDgwNDAyOTk3OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 403275ad1dfbcacb65b0334ad5cdd3c892db0fc2ea9b42f519909024a286510c |
| hovercard-subject-tag | issue:418959846 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/30279/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8d6e9f200b8f18c0876bb01daf5417964c357c76e58fb40d4bf8961338374c0a/microsoft/TypeScript/issues/30279 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8d6e9f200b8f18c0876bb01daf5417964c357c76e58fb40d4bf8961338374c0a/microsoft/TypeScript/issues/30279 |
| og:image:alt | Higher order function type inference #30215 Reference code declare function pipe(ab: (...args: A) => B): (...args: A) => B; declare function invoke(f: (...ar... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | DanielRosenwasser |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width