Skip to content

Conversation

@jpalvarezl
Copy link

Open questions:

  • test/components/namespace.test.tsx we are targeting to make that unit test pass but nothing renders. We are struggling to find the minimal code necessary for the setup to work (the code has been mostly lifted from the csharp package).

case "model-property":
case "model":
case "union":
const invalidNameRegex =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we export printIdentifier from the compiler which will auto add the quotes when needed.
Or if we don't want to take dependency on the compiler here(maybe), could copy that function

<SourceFile path="main.tsp" namespace={parentNamespace} />
</Output>
).toRenderTo({
"main.tsp": `namespace My.Namespace;\n\n\n`, // why do we need to do this for this assertion to pass?
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here you can probably use d` like in the other tests

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need d with toRendeRTo it will already dedent automatically

path: string;

/** If present, it defines a file-level namespace (if not present, it uses the global namespace) */
namespace?: NamespaceSymbol;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably we could receive a symbol or string here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could, but I thought receiving the prop already typed was better. Although absolutely open to change the approach if it makes more sense.

export function SourceFile(props: SourceFileProps) {
const sourceFileScope = new SourceFileScope(props.path);

const globalNs = getGlobalNamespace(useBinder());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this we need to look at, in tsp the global namespace still belongs to a file (what really matters for symbol resolution are files). So here we should "create" a global namespace scope with file as the parent.

* containers like namespaces. This scope is a member scope whose
* member symbol is a NamedTypeSymbol.
*/
export class TypeSpecNamedTypeScope extends TypeSpecScope {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this in this PR?

// e.g. if refkey is for bar in enum type foo, and
// foo is in the same namespace as the refkey, then
// the result would be foo.bar.
export function ref(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this for this PR?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a cascading dependency necessary to define Reference.tsx so we can pass that to CoreSourceFile : https://github.com/alloy-framework/alloy/pull/324/files#diff-668821ea9c50226ee835e35b54cddd4afc9313f85249093722a652ad3d763187R51

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 6, 2025

Open in StackBlitz

npm i https://pkg.pr.new/alloy-framework/alloy/@alloy-js/typespec@324

commit: 6390c62

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants