Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 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
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,9 @@
---
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.

Added an `unknown` value that can be used to denote when a property or parameter _has_ a default value, but its value cannot be expressed in TypeSpec (for example, because it depends on the server instance where it is generated, or because the service author simply does not with to specify how the default value is generated). This adds a new kind of `Value` to the language that represents a value that is not known.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: feature
packages:
- "@typespec/openapi3"
---

Updated emitter logic to ignore `unknown` values in parameter and schema property defaults.
20 changes: 20 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,20 @@
---
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"
---

Updated `tspd` to generate extern function signatures. Regenerated all extern signatures.
2 changes: 2 additions & 0 deletions cspell.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ words:
- lzutf
- MACVMIMAGE
- MACVMIMAGEM
- marshal
- mday
- methodsubscriptionid
- mgmt
Expand Down Expand Up @@ -274,6 +275,7 @@ words:
- unioned
- unionified
- unionify
- unmarshal
- unparented
- unprefixed
- unprojected
Expand Down
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