Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent use of augment decorators on template instantiations #1744

Merged
merged 5 commits into from
Mar 31, 2023

Conversation

tjprescott
Copy link
Member

@tjprescott tjprescott commented Mar 27, 2023

Fix #1354.

Throws a diagnostic if any arguments are provided in the augment decorator.
Error @@decorator(Foo<string>, "blah")
Error @@decorator(Foo<T>, "blah")
Okay @@decorator(Foo, "blah") // the template args left off

@github-actions
Copy link
Contributor

Changes in this PR will be published to the following url to try(check status of TypeSpec Pull Request Try It pipeline for publish status):
Playground: https://cadlplayground.z22.web.core.windows.net/prs/1744/

Website: https://cadlwebsite.z1.web.core.windows.net/prs/1744/

@azure-pipelines
Copy link

You can try these changes at https://cadlplayground.z22.web.core.windows.net/prs/1744/

Check the website changes at https://cadlwebsite.z1.web.core.windows.net/prs/1744/

@tjprescott tjprescott force-pushed the fixTemplateTarget branch 2 times, most recently from 3322e30 to 7d2f6ac Compare March 29, 2023 18:12
Comment on lines 187 to 201
"test.tsp",
`
import "./test.js";

model Foo<T> {
testProp: T;
};

@test
op stringTest(): Foo<string>;

@@customName(Foo, "Some foo thing");
`
);
Copy link
Member Author

Choose a reason for hiding this comment

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

@timotheeguerin so this will not work if you do:
@@customName(Foo<T>, "Some foo thing");

Is that okay? One scenario we've seen with docs looks like:

@doc("Foo of {T}", T)
model Foo<T> {
  prop: T;
}

How would that work with augment? Like this?
@@doc(Foo<T>, "Foo of {T}", T)

With this PR, the above would throw a diagnostic.

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.

Emit error when attempting to target augment decorators at an instantiated template
2 participants