Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Expand Up @@ -224,19 +224,22 @@ export class BaseClientContextImpl implements BaseClientContext {

for (const header of this.intermediateRepresentation.headers) {
const type = context.type.getReferenceToType(header.valueType);
const typeNode = isUnknownType(header.valueType)
? ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword)
: type.typeNode;
if (endpointUtils.isLiteralHeader(header, context)) {
properties.push({
kind: StructureKind.PropertySignature,
name: getPropertyKey(this.getOptionKeyForHeader(header)),
type: getTextOfTsNode(context.type.getReferenceToType(header.valueType).typeNode),
type: getTextOfTsNode(typeNode),
hasQuestionToken: true,
docs: [`Override the ${header.name.wireValue} header`]
});
} else {
properties.push({
kind: StructureKind.PropertySignature,
name: getPropertyKey(this.getOptionKeyForHeader(header)),
type: getTextOfTsNode(context.coreUtilities.fetcher.Supplier._getReferenceToType(type.typeNode)),
type: getTextOfTsNode(context.coreUtilities.fetcher.Supplier._getReferenceToType(typeNode)),
hasQuestionToken: type.isOptional,
docs: [`Override the ${header.name.wireValue} header`]
});
Expand Down Expand Up @@ -366,9 +369,12 @@ export class BaseClientContextImpl implements BaseClientContext {
docs: ["A hook to abort the request."]
},
...this.intermediateRepresentation.headers.map((header) => {
const typeNode = isUnknownType(header.valueType)
? ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword)
: context.type.getReferenceToType(header.valueType).typeNode;
return {
name: getPropertyKey(this.getOptionKeyForHeader(header)),
type: getTextOfTsNode(context.type.getReferenceToType(header.valueType).typeNode),
type: getTextOfTsNode(typeNode),
hasQuestionToken: true,
docs: [`Override the ${header.name.wireValue} header`]
};
Expand Down Expand Up @@ -409,10 +415,13 @@ export class BaseClientContextImpl implements BaseClientContext {
for (const header of this.intermediateRepresentation.idempotencyHeaders) {
if (!endpointUtils.isLiteralHeader(header, context)) {
const type = context.type.getReferenceToType(header.valueType);
const typeNode = isUnknownType(header.valueType)
? ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword)
: type.typeNode;
properties.push({
kind: StructureKind.PropertySignature,
name: getPropertyKey(this.getOptionKeyForHeader(header)),
type: getTextOfTsNode(type.typeNode),
type: getTextOfTsNode(typeNode),
hasQuestionToken: type.isOptional
});
}
Expand Down Expand Up @@ -440,3 +449,13 @@ export class BaseClientContextImpl implements BaseClientContext {
function isPropertyRequired(property: OptionalKind<PropertySignatureStructure>): boolean {
return property.hasQuestionToken !== true;
}

/**
* HTTP headers are always strings, so when the IR type is `unknown`,
* we coerce the generated TypeScript type to `string` to avoid
* producing `Supplier<unknown>` or `unknown` which causes type errors
* when assigning to header values.
*/
function isUnknownType(typeReference: FernIr.TypeReference): boolean {
return typeReference.type === "unknown";
}
12 changes: 12 additions & 0 deletions generators/typescript/sdk/versions.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
# yaml-language-server: $schema=../../../fern-versions-yml.schema.json
- version: 3.60.4
changelogEntry:
- summary: |
Fix global headers with `unknown` IR type producing `Supplier<unknown>` in
`BaseClientOptions` and `unknown` in `BaseRequestOptions`, which caused
TypeScript compilation errors (`Type 'unknown' is not assignable to type
'string | undefined'`) in generated SDKs. HTTP headers are always strings,
so `unknown`-typed headers are now coerced to `string`.
type: fix
createdAt: "2026-03-30"
irVersion: 65

- version: 3.60.3
changelogEntry:
- summary: |
Expand Down
Loading