Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
ed664a3
compiler: wip extern alias
witemple-msft Aug 6, 2025
d625ac3
extern fn
witemple-msft Aug 7, 2025
1d21ec3
Revert extern alias changes, prefer extern fn
witemple-msft Aug 8, 2025
3aeeca9
Implement extern signatures for function declarations.
witemple-msft Aug 8, 2025
0ed17d6
Fix exhaustiveness check in html-program-viewer
witemple-msft Aug 8, 2025
bf0214c
Again fix html-program-viewer
witemple-msft Aug 8, 2025
fb367e3
Finish removing remnants of extern alias
witemple-msft Aug 8, 2025
d65b555
Merge remote-tracking branch 'upstream/main' into extern-template
witemple-msft Aug 8, 2025
dea4f00
Implement arg/return checking.
witemple-msft Aug 8, 2025
c594614
Rebuild all .ts-test.ts files.
witemple-msft Aug 8, 2025
dfe197a
Remove some redundant checks.
witemple-msft Aug 8, 2025
01fe5c0
Improved testing, value assignability logic
witemple-msft Aug 12, 2025
631c182
Merge remote-tracking branch 'upstream/main' into extern-template
witemple-msft Aug 12, 2025
66b3f82
Removed stub examples from compiler.
witemple-msft Aug 12, 2025
dec2535
Merge remote-tracking branch 'upstream/main' into extern-template
witemple-msft Aug 14, 2025
4b54d3f
Merge remote-tracking branch 'upstream/main' into extern-template
witemple-msft Aug 19, 2025
ed060c9
test fixes, start docs
witemple-msft Sep 12, 2025
4431906
Fixed type checking bug in model relations.
witemple-msft Oct 28, 2025
e1243e8
Merge remote-tracking branch 'upstream/main' into witemple-msft/exter…
witemple-msft Oct 28, 2025
bd32319
Tweak relation checker logic
witemple-msft Oct 28, 2025
19ba562
WIP unknown value tests
witemple-msft Oct 30, 2025
2bdbe02
Many improvements, fixes, documentation changes, etc. etc.
witemple-msft Nov 20, 2025
a34ab24
Fixed completion behavior
witemple-msft Nov 20, 2025
4adf661
Tested semantic walker.
witemple-msft Nov 20, 2025
eed1eac
Unwind Reflection.Type because it's the same thing as 'unknown'
witemple-msft Nov 20, 2025
74033dd
Merge remote-tracking branch 'upstream/main' into witemple-msft/exter…
witemple-msft Nov 20, 2025
cb90572
Add callDecorator to decctx
witemple-msft Nov 20, 2025
1b04390
Implement indeterminate handling
witemple-msft Nov 20, 2025
8798168
Undo rest after optional, omit function bindings outside $functions
witemple-msft Nov 21, 2025
71392a1
Updated tests that used direct function bindings
witemple-msft Nov 21, 2025
b0c7072
Discard unknown values in default position in openapi3.
witemple-msft Nov 21, 2025
1f405a3
Throughly reviewed all tests
witemple-msft Nov 21, 2025
20f00df
Merge remote-tracking branch 'upstream/main' into witemple-msft/exter…
witemple-msft Nov 21, 2025
b64b067
chronus
witemple-msft Nov 21, 2025
b140017
Small tweaks to functions docs
witemple-msft Nov 21, 2025
5cd7821
Forbid functions from serving as regular types.
witemple-msft Nov 21, 2025
f62f80d
Revert changes to pnpm lock
witemple-msft Nov 21, 2025
312a6db
WIP convert to values, remove unknown value
witemple-msft Nov 27, 2025
73ecdf2
WIP
witemple-msft Dec 3, 2025
0511197
Merge remote-tracking branch 'upstream/main' into fn-values
witemple-msft Jan 12, 2026
3821b88
Updated functions to use value form, added function signature types.
witemple-msft Jan 27, 2026
ab30155
Merge remote-tracking branch 'upstream/main' into fn-values
witemple-msft Jan 27, 2026
d9a4980
Added some more tests, required parenthesizing fns in union exprs
witemple-msft Jan 27, 2026
9ad8a1c
Squash some remaining TODO items
witemple-msft Jan 28, 2026
0b2f026
Merge remote-tracking branch 'upstream/main' into fn-values
witemple-msft Jan 28, 2026
df95c01
Update grammar file
witemple-msft Jan 28, 2026
218d8b9
Updated chronus
witemple-msft Jan 28, 2026
1c713d2
Excise unknown value references
witemple-msft Jan 28, 2026
eead09e
Excised more unknown-value
witemple-msft Jan 29, 2026
d1992c9
removed some commented out code
witemple-msft Jan 29, 2026
d22ee91
Remove UnknownType from indeterminate entity set
witemple-msft Jan 29, 2026
d4b63ca
typo
witemple-msft Jan 29, 2026
b653f27
typo ':' -> '=>'
witemple-msft Jan 29, 2026
3965fc1
refactor decoratorcontext/functioncontext to share common shape
witemple-msft Jan 29, 2026
191239e
Lint
witemple-msft Jan 29, 2026
7c01dd3
remove dead comments
witemple-msft Jan 29, 2026
c40889b
Allow TODO with username in cspell
witemple-msft Jan 29, 2026
36e29e1
Merge remote-tracking branch 'upstream/main' into witemple-msft/exter…
witemple-msft Jan 29, 2026
1c45cdd
Fix uses of isArrayModelType
witemple-msft Jan 29, 2026
ca18a30
forgot to save a file
witemple-msft Jan 29, 2026
9c45b88
Merge remote-tracking branch 'upstream/main' into witemple-msft/exter…
witemple-msft Jan 29, 2026
3813fba
Fixed a bug inhibiting calling template parameters that are guarantee…
witemple-msft Jan 29, 2026
01d49c0
Documented function types.
witemple-msft Jan 29, 2026
7ea1f3c
Added name resolver capabilities for resolving return type symbols
witemple-msft Feb 3, 2026
22c0060
Merge remote-tracking branch 'upstream/main' into witemple-msft/exter…
witemple-msft Feb 7, 2026
bb0ee11
Don't evaluate function calls in the context of uninstantiated templa…
witemple-msft Feb 7, 2026
df2ce14
Return constraint when evaluation cannot proceed.
witemple-msft Feb 7, 2026
3da3594
Add docs to current-sidebar
witemple-msft Feb 7, 2026
0ffe77b
remove top level describe
witemple-msft Feb 7, 2026
8cc12c9
Remove unnecessary FunctionImplementation type
witemple-msft Feb 7, 2026
606e57d
Merge remote-tracking branch 'upstream/main' into witemple-msft/exter…
witemple-msft Feb 11, 2026
bbf0ce4
Updated function logic to return 'null' in all value cases as default.
witemple-msft Feb 11, 2026
5c3089a
Improve checking logic, test template logic
witemple-msft Feb 11, 2026
e3f269d
Added a test for mark's scenario
witemple-msft Feb 11, 2026
3a4aa00
Added more tests for object/enum/union arguments.
witemple-msft Feb 11, 2026
a8bd99d
Merge remote-tracking branch 'upstream/main' into witemple-msft/exter…
witemple-msft Feb 11, 2026
c1960c8
Strengthen/weaken constraint on FunctionValue appropriately
witemple-msft Feb 11, 2026
ec91003
Adopt new tester
witemple-msft Feb 12, 2026
aab8654
Improve docs a bit
witemple-msft Feb 12, 2026
09fa854
Merge remote-tracking branch 'upstream/main' into witemple-msft/exter…
witemple-msft Feb 12, 2026
6f847ee
Merge branch 'main' into witemple-msft/extern-fn
witemple-msft Feb 23, 2026
8fa5c5f
Fix bug in type checker around reflection and never type assignability.
witemple-msft Feb 25, 2026
5c0c161
Merge remote-tracking branch 'upstream/main' into witemple-msft/exter…
witemple-msft Feb 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: feature
packages:
- "@typespec/compiler"
---

Added support for Functions, a new type graph entity and language feature. Functions enable library authors to provide input-output style transforms that operate on types and values. See [the Functions Documentation](https://typespec.io/docs/language-basics/functions/) for more information about the use and implementation of functions.
24 changes: 24 additions & 0 deletions .chronus/changes/witemple-msft-extern-fn-2025-10-21-12-48-30.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
changeKind: internal
packages:
- "@typespec/events"
- "@typespec/html-program-viewer"
- "@typespec/http-client"
- "@typespec/http"
- "@typespec/json-schema"
- "@typespec/openapi"
- "@typespec/protobuf"
- "@typespec/rest"
- "@typespec/spector"
- "@typespec/sse"
- "@typespec/streams"
- "@typespec/tspd"
- "@typespec/versioning"
- "@typespec/xml"
- "@typespec/openapi3"
- "@typespec/http-server-csharp"
---

Updated `tspd` to generate extern function signatures. Regenerated all extern signatures.

Corrected any exhaustive matches over type/value kinds to account for Function types/values.
8 changes: 8 additions & 0 deletions cspell.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ words:
- lropaging
- lstrip
- lzutf
- MACVMIMAGE
- MACVMIMAGEM
- marshal
- mday
- methodsubscriptionid
- mgmt
Expand Down Expand Up @@ -280,6 +283,7 @@ words:
- unioned
- unionified
- unionify
- unmarshal
- unparented
- unprefixed
- unprojected
Expand Down Expand Up @@ -351,6 +355,10 @@ patterns:
- name: Authorization_Basic
description: Ignore Base64 authorization tokens
pattern: "/Authorization: Basic\\s+\\S+/g"
- name: Todo
description: Ignore TODO comments with usernames
pattern: "/TODO[\\/\\s\\(][a-zA-Z0-9_-]+/g"
ignoreRegExpList:
- cursortest
- Authorization_Basic
- Todo
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ import type { TypeSpecPrototypesDecorators } from "./TypeSpec.Prototypes.js";
/**
* An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ...
*/
const _: TypeSpecPrototypesDecorators = $decorators["TypeSpec.Prototypes"];
const _decs: TypeSpecPrototypesDecorators = $decorators["TypeSpec.Prototypes"];
2 changes: 1 addition & 1 deletion packages/compiler/generated-defs/TypeSpec.ts-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ import type { TypeSpecDecorators } from "./TypeSpec.js";
/**
* An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ...
*/
const _: TypeSpecDecorators = $decorators["TypeSpec"];
const _decs: TypeSpecDecorators = $decorators["TypeSpec"];
23 changes: 16 additions & 7 deletions packages/compiler/src/core/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
EnumStatementNode,
FileLibraryMetadata,
FunctionDeclarationStatementNode,
FunctionImplementations,
FunctionParameterNode,
InterfaceStatementNode,
IntersectionExpressionNode,
Expand Down Expand Up @@ -133,7 +134,6 @@ export function createBinder(program: Program): Binder {

for (const [key, member] of Object.entries(sourceFile.esmExports)) {
let name: string;
let kind: "decorator" | "function";
if (key === "$flags") {
const context = getLocationContext(program, sourceFile);
if (context.type === "library" || context.type === "project") {
Expand All @@ -152,12 +152,24 @@ export function createBinder(program: Program): Binder {
);
}
}
} else if (key === "$functions") {
const value: FunctionImplementations = member as any;
for (const [namespaceName, functions] of Object.entries(value)) {
for (const [functionName, fn] of Object.entries(functions)) {
bindFunctionImplementation(
namespaceName === "" ? [] : namespaceName.split("."),
"function",
functionName,
fn,
sourceFile,
);
}
}
} else if (typeof member === "function") {
// lots of 'any' casts here because control flow narrowing `member` to Function
// isn't particularly useful it turns out.
if (isFunctionName(key)) {
name = getFunctionName(key);
kind = "decorator";
if (name === "onValidate") {
const context = getLocationContext(program, sourceFile);
const metadata =
Expand All @@ -170,12 +182,9 @@ export function createBinder(program: Program): Binder {
// nothing to do here this is loaded as emitter.
continue;
}
} else {
name = key;
kind = "function";
const nsParts = resolveJSMemberNamespaceParts(rootNs, member);
bindFunctionImplementation(nsParts, "decorator", name, member as any, sourceFile);
}
const nsParts = resolveJSMemberNamespaceParts(rootNs, member);
bindFunctionImplementation(nsParts, kind, name, member as any, sourceFile);
}
}
}
Expand Down
Loading
Loading