Граф коммитов

347 Коммитов

Автор SHA1 Сообщение Дата
Timothee Guerin a336c93709
Update prettier config to format trailing commas to `all` (Default) (#4457)
fix #2159 
Long standing backlog issue that was split from an upgrade of prettier
as it created too much diff. Finally doing it
2024-09-16 20:20:57 +00:00
Christopher Radek bc68f8499a
Add release notes for version 0.60.0 (#4384)
Co-authored-by: Christopher Radek <Christopher.Radek@microsoft.com>
2024-09-10 18:44:51 +00:00
Mario Guerra 8dfacdb08e
minor edits and corrections (#4183) 2024-08-26 18:48:34 +00:00
Kyle Zhang ff56d83bc0
Fix Doc issue for opexamples (#4201)
Fix Doc issue for
[#4192](https://github.com/microsoft/typespec/issues/4192)

Co-authored-by: Kyle Zhang <v-zhanh@microsoft.com>
2024-08-22 16:59:11 +00:00
Timothee Guerin 3775eec3bc
Update resolution of options for formatting command in extension (#4064)
VSCode has this detectIndent setting which seems to prefer 4 space by
default and then update the TypeSpec formatter to format that way.
2024-08-12 21:57:59 +00:00
Timothee Guerin 75e773cfa8
Add new way to define decorator implementation with `$decorators` export (#4139)
fix [#3719](https://github.com/microsoft/typespec/issues/3719)
2024-08-12 19:16:21 +00:00
Mario Guerra 7ce1c91d4c
REST tutorial revisions (#4104)
Revisions made based on test drive feedback from members of the PM team.
2024-08-10 00:52:08 +00:00
Michelle dda9db6f08
Update emitter docs to include configuration examples (#4112)
For a TypeSpec beginner, it may be difficult to understand how to
configure or format tspconfig.yaml to tweak the different options
available. Adding a basic example should help folks get started.
2024-08-08 13:48:26 +00:00
Christopher Radek cc2069b69c
Add release notes for version 0.59.0 (#4102)
Co-authored-by: Christopher Radek <Christopher.Radek@microsoft.com>
2024-08-06 22:41:44 +00:00
Timothee Guerin e492ff7d7b
Add support for URI templates (#3932)
fix https://github.com/microsoft/typespec/issues/3736

---------

Co-authored-by: Christopher Radek <14189820+chrisradek@users.noreply.github.com>
2024-08-06 18:49:54 +00:00
Christopher Radek 72d4351207
Updates extension decorator to support value kinds and adds setExtension API to json-schema emitter (#3558)
Related to #3336

## Summary

This PR introduces 2 changes:

1. adds a new `setExtension` API on the `@typespec/json-schema` emitter
to make it easier to author custom extension decorators.
2. updates the `@extension` decorator to support taking values to
obviate the need for the `Json<Data>` model.

Example usage of writing a custom extension `@added` decorator:

```js
export function $added(context, target, value) {
  setExtension(context.program, target, "x-added", value);
}
```

Example usage of passing in value literals to `@extension` decorator:

```tsp
@extension("x-current", Json<["foo"]>)
@extension("x-new", #["foo"])
model Foo {}
```

## Background

The `@typespec/json-schema` package exports an `@extension` decorator
that allows customers to specify additional properties to be present as
part of their emitted JSON schema.

For example, we can add a property - converted to a schema - that
indicates when a field was added to the model:

```tsp
@jsonSchema
model Pet {
  @extension("x-added", "2024-01-01")
  name: string;
}
```

The decorator also supports emitting the property's value as raw code by
wrapping the parameter in the `Json<Data>` template:

```tsp
@jsonSchema
model Pet {
  @extension("x-added", Json<"2024-01-01">)
  name: string;
}
```

### Comparison

Below is a diff between the two ways of calling the decorator for
clarity:

```diff
$schema: https://json-schema.org/draft/2020-12/schema
$id: Pet.yaml
type: object
properties:
  name:
    type: string
-   x-added:
-     type: string
-     const: 2024-01-01
+   x-added: 2024-01-01
required:
  - name
```

## Pain Points

Currently, `@extension` only supports raw values by wrapping them with
the `TypeSpec.JsonSchema.Json` template. Since this type isn't available
in JS code, this forces authors to manually create the wrapped type
themselves, e.g.:

```js
/**
 * @param {import("@typespec/compiler").DecoratorContext} context
 * @param {import("@typespec/compiler").Type} target
 * @param {import("@typespec/compiler").StringLiteral} value
 */
export function $added(context, target, value) {
  $extension(context, target, "x-added", {
    kind: "Model",
    name: "Json",
    namespace: { name: "JsonSchema" },
    properties: createRekeyableMap([["value", { type: value }]]),
  });
}
```

## Update `@extension` to accept values directly and expose
`setExtension` API

This PR exposes a new `setExtension` API that accepts types and values
as input, instead of just `Type`. This also means
`ExtensionRecord.value` has been loosened:

```diff
export interface ExtensionRecord {
  key: string;
- value: Type;
+ value: Type | unknown;
}
```

In addition, the `@extension` decorator is updated to support accepting
values directly:

```diff
- extern dec extension(target: unknown, key: valueof string, value: unknown);
+ extern dec extension(target: unknown, key: valueof string, value: unknown | (valueof unknown));
```

While this change introduces breaking changes to the `@extensions`
decorator and `getExtensions` function, it also allows the `@extension`
decorator to support [value
kinds](https://typespec.io/docs/language-basics/values) as input - a
feature language feature introduced in `0.57.0`.

This would not cause additional breaking changes (beyond
`getExtensions`) for users that already use the
`TypeSpec.JsonSchema.Json` template to pass in raw values. However,
there is 1 scenario that would now fail:

1. Scalar literals/null would now be treated as values instead of types.
(e.g. `@extension("x-bool-literal", true)` would need to be updated to
`@extension("x-bool-literal", typeof true)` to preserve current
behavior)

## Alternatives

### Solution - only expose `setExtension` API

This PR exposes a new `setExtension` API that accepts types and values
as input, instead of just `Type`. This also means
`ExtensionRecord.value` has been loosened:

```diff
export interface ExtensionRecord {
  key: string;
- value: Type;
+ value: Type | any;
}
```

This does introduce a **breaking change** in the **getExtensions** API
since `ExtensionRecord.value` is no longer guaranteed to be `Type`.
However, it is likely this API is not used much if at all outside of
this emitter.

### Create new `setExtensionValue`/`getExtensionValues` functions and
alternative `@extension` decorator

This change has the benefit of not requiring any breaking changes.
However, we would now have 2 different but very similar APIs for
settings/getting extensions that may lead to confusion, as well as 2
very similar extensions to do essentially the same thing.

---------

Co-authored-by: Christopher Radek <Christopher.Radek@microsoft.com>
2024-08-05 20:15:57 +00:00
Timothee Guerin 977a9b5d4a
Add documentation on examples (#4074)
fix #4034
2024-08-01 18:26:02 +00:00
Timothee Guerin fb63f5765b
Remove docs for deprecated projected names (#4073) 2024-08-01 18:18:35 +00:00
Timothee Guerin 44fc030f8d
Add support for encoding numeric types as string (#4020)
fix #3856
2024-07-30 20:58:57 +00:00
Mario Guerra da41e74c17
pet store rewrite (#3958)
Rewritten from scratch to incorporate feedback from eng and arch.
2024-07-30 18:05:11 +00:00
Timothee Guerin eb245109c0
Add deprecation notice in ref docs (#4025)
fix [#2326](https://github.com/microsoft/typespec/issues/2326)
2024-07-26 17:13:45 +00:00
Timothee Guerin 6df2990357
Update docs for `@server` (#3960) 2024-07-24 22:37:20 +00:00
Greg Poirier 39d4c60da5
[docs/libraries/http] Fix incorrect reference to @header annotation in statusCode documentation. (#3949)
I believe this mistakenly says to use the `@header` annotation on a
property and should say `@statusCode`.
2024-07-23 21:05:25 +00:00
Timothee Guerin d52f9f441d
Generate documentation for enum members (#3878)
fix https://github.com/microsoft/typespec/issues/3436
2024-07-19 16:33:35 +00:00
Mario Guerra d705dd53b4
minor edits and corrections (#3841) 2024-07-17 17:25:51 +00:00
Timothee Guerin 27ed13de58
Revert "Add validator to prevent discriminator and encodedname used together" (#3852)
Reverts microsoft/typespec#3763

This is actually a pattern used for things like `@odata.kind` and would
need more discussion to disallow
2024-07-16 21:35:49 +00:00
Timothee Guerin 0442e27399
Add release notes for 0.58 (#3851)
Co-authored-by: Mark Cowlishaw <markcowl@microsoft.com>
Co-authored-by: Brian Terlson <brian.terlson@microsoft.com>
2024-07-16 20:21:54 +00:00
Timothee Guerin fef3f01706
Examples (#3572)
Fix #2700 Add support for `@example` and `@opExample`


[Playground
demo](https://cadlplayground.z22.web.core.windows.net/prs/3572/?c=aW1wb3J0ICJAdHlwZXNwZWMvaHR0cCI7Cgp1c2luZyBIdHRwOwoKQGV4YW1wbGUoI3sKICBpZDogInNvbWUiLAogIGJhcjogInRoaW5nxRBkYXRlOiB1dGNEYXRlVGltZS5mcm9tSVNPKCIyMDIwLTAxLTAxVDAwOsUDWiIpxDV1bml4xDA6xQrENnN0YW1wMzLfPcU9ZW5jb2RlZEFzUmZjNzIzMd9%2B0kFkb2I6IHBsYWluxDbUMsYodGltZW91dDogZHVyYXRpb27KK1BUMU3NJUluU2Vjb25kc9guMS41U9YyRmxvYddlMMc1fSkKbW9kZWwgRm9vIOgBlHN0cmluZzvoAZTKD%2FEBk8QV%2BQFzOwoKICBA5gFVKMgyS25vd25FxBRpbmcucuYBaSn%2FAX1lxUvuAV7Ee%2FEBSM1zInPmAQciLCBpbnQzMsRm%2BgFV2Dtm5AFF1j3vAWA7Cn0K5wFOUGV08wFObmFtZcwQ8ADRfQoKQG9wRecDIwogIOUDJiAgcGFyYW1ldGVyczrIE%2FADPcUnZXTLINQi6ACDIkZsdWZmecsY%2FwK66QK6xAF9xgnHB3JldHVyblR5cGX9AJ3Wed93y3fFbsUFI3sgdGl0bMVOaXJzdCIsIGRlc2NyaXDkAYU6ICJTaG93IGNyZWF05AR6YeQBGCIgfQopCm9wxhdlUGV0KOoBmyzEIjrkAbQpxQY7Cg%3D%3D&e=%40typespec%2Fopenapi3&options=%7B%7D)

---------

Co-authored-by: Brian Terlson <brian.terlson@microsoft.com>
2024-07-16 19:14:24 +00:00
Timothee Guerin 613c981c91
Fix pagination index (#3840) 2024-07-15 19:45:34 +00:00
Mario Guerra 0d8507700c
Update getting started http guide (#3684)
Revised and expanded version of the pet store HTTP example.

---------

Co-authored-by: Timothee Guerin <tiguerin@microsoft.com>
2024-07-15 15:42:17 +00:00
Timothee Guerin 67190da0e8
Fix http authentication docs example (#3760) 2024-07-12 00:32:27 +00:00
Laurent Mazuel b7c70978ca
Add ? for madeOptional (#3820)
`madeOptional` implies the current property is optional, so adding the
missing `?`
2024-07-11 21:12:15 +00:00
Timothee Guerin f84dbe81e1
Add docs for emitter framework import (#3788)
fix [#3633](https://github.com/microsoft/typespec/issues/3633)
2024-07-10 23:11:11 +00:00
Will Temple b5d766cd43
[http-server-javascript] Merge JavaScript Server Generator to Main (#3231)
This work-in-progress PR tracks merging the JavaScript server code
generator to the TypeSpec repository.

The JavaScript server code generator creates HTTP bindings for TypeSpec
HTTP services and exposes them for binding either to the Node.js http
server directly, or to an Express.js app as middleware.

Closes #3215

---------

Co-authored-by: Will Temple <will@wtemple.net>
2024-07-10 21:44:45 +00:00
Timothee Guerin c2043a4da8
Add docs on identifiers (#3789)
fix #3271

---------

Co-authored-by: Brian Terlson <brian.terlson@microsoft.com>
2024-07-09 22:35:20 +00:00
Sylvain Bruyère bd0c7d63af
Fix doc errors for `@errorsDoc` and `@returnsDoc` decorators (#3600)
Co-authored-by: Timothee Guerin <timothee.guerin@outlook.com>
Co-authored-by: Timothee Guerin <tiguerin@microsoft.com>
2024-07-08 20:33:39 +00:00
Timothee Guerin e484821e3a
Add disclaimer on the openapi3 to typespec conversion (#3769) 2024-07-08 18:26:19 +00:00
Justin 245e4e620d
fix: fixes issue with tests not being found from template (#3605)
fix [#3647](https://github.com/microsoft/typespec/issues/3647)

With node 22 the --test needs a glob to find files to test. As the docs
a written the tests don't run or pass. This fixes it for me.

---------

Co-authored-by: Timothee Guerin <tiguerin@microsoft.com>
2024-07-08 17:47:07 +00:00
Christopher Radek 8354a758b9
Add support for converting OpenAPI3 specs to TypeSpec (#3663)
fix #3038
This PR updates the `@typespec/openapi3` package to support converting
OpenAPI3 specs to TypeSpec.

## Example usage:
1. `npm install @typespec/openapi3`
2. `npx openapi3-to-tsp compile --output-dir ./tsp-output
/path/to/openapi-yaml-or-json`

## What's supported
- Parse OpenAPI3 specs in yml/json formats (via 3rd party package)
- Generates file namespace based on OpenAPI3 service name
- Populates `@info` decorator with OpenAPI3 service info
- Converts `#/components/schemas` into TypeSpec models/scalars.
- Converts `#/components/parameters` into TypeSpec models/model
properties as appropriate.
- Generates a response model for every operation/statusCode/contentType
combination.
- Operation tags
- Generates TypeSpec operations with routes/Http Method decorators
- Generates docs/extension decorators
- Most schema decorators
- Model inheritance via `allOf`
- Discriminators

## What's not supported (yet)
- auth
- deprecated directive
- combining multiple versions of an OpenAPI3-defined service into a
single TypeSpec project
- converting `#/components/requestBodies` and `#/components/responses`
into models - TypeSpec doesn't seem to generate these and I didn't find
examples in the wild where they were defined _and_ actually used so
deprioritized.
- emitting warnings/FIXMEs for unexpected/unsupported scenarios
- Probably a lot more that I'm still discovering

## Notes

When going through the TypeSpec -> OpenAPI3 -> TypeSpec loop, the
generated TypeSpec is going to be larger than the original. The biggest
contribution towards this is because I'm currently generating a model
for every possible response on every operation.

I can definitely pare this down with some simple heuristics that take
into account what default statusCode/contentTypes are, and extract the
referenced body type directly in the operation's return signature. I can
also eliminate the `@get` decorators, `@route("/")` routes, and likely
use some of the response models provided by TypeSpec.Http.

However - if I'm using this tool to convert from OpenAPI3 to TypeSpec -
I thought it might be preferable to be more explicit in the generated
output so there's no mystery on how things actually get defined. Will be
interested in feedback on this.


## Testing
For tests, I generate TypeSpec files for a number of OpenAPI3 specs.
Most of the OpenAPI3 specs I generated from our TypeSpec samples
packages. Then I'm able to compare the generated TypeSpec to the
corresponding original TypeSpec file. I've also been diffing the
OpenAPI3 specs generated from the original and generated TypeSpec files
<- these are what typically show no changes outside of known unsupported
conversions (e.g. auth).

---------

Co-authored-by: Christopher Radek <Christopher.Radek@microsoft.com>
2024-07-02 22:43:49 +00:00
Justin 781f2af337
fix: typo in the type documentation (#3612)
looks like a typo in the docs.

---------

Co-authored-by: Timothee Guerin <timothee.guerin@outlook.com>
2024-07-01 17:41:49 +00:00
Timothee Guerin d319e3324a
Add new const keyword breaking note (#3584)
fix #3583
2024-06-14 18:17:56 +00:00
Timothee Guerin 4ed71bf73f
Add release notes for 0.57.0 (#3560)
Co-authored-by: Brian Terlson <brian.terlson@microsoft.com>
2024-06-13 15:12:45 +00:00
Timothee Guerin dd61517865
Format multi line strings (#3422)
fix  #1016

Format multi lines string 

```
@doc(
  """
          multi line
          do
          ${"abc"}
          """
)
@doc("""
def
""")
model Foo {}

alias T = """
          abc
          def ${"abc"}
          ghi
          """;

```

formats to

```
@doc("""
  multi line
  do
  ${"abc"}
  """)
@doc("""
  def
  """)
model Foo {}

alias T = """
  abc
  def ${"abc"}
  ghi
  """;
```
2024-06-11 20:06:12 +00:00
Brian Terlson 295e68a698
Add oneOf to JSON Schema (#3557)
Fix #3544.
2024-06-11 17:11:53 +00:00
☃ Elliot Shepherd d33090e933
Add PickProperties type and @withPickedProperties decorator (#3488)
Add PickProperties based on OmitProperties

Based on
https://github.com/microsoft/typespec/discussions/3484#discussioncomment-9610555
you may not be wanting more mutating decorators, but PR is here if it's
ok.

---------

Co-authored-by: Timothee Guerin <timothee.guerin@outlook.com>
2024-06-11 15:12:23 +00:00
Timothee Guerin 40df1ec9a3
Multipart explicit parts (#3342)
resolve #3046
[Playground](https://cadlplayground.z22.web.core.windows.net/prs/3342/)

Add the following:
- `@multipartBody` decorator
- `File` type
- `HttpPart<Type, Options>` type


Had to do a decent amount of refactoring to be able to reuse the body
parsing, this result in a much cleaner resolution of the body and other
metadata properties across request, response and metadata.

The way it works now is instead of calling `gatherMetadata` that would
just get the properties that are metadata but also ones with `@body` and
`@bodyRoot` we now call a `resolveHtpProperties`, this does the same
resolution in term of filtering properties but it also figure out what
is the kind of property in the concept of http(header, query, body,
etc.) this leaves the error resolution to this function for duplicate
annotations.
What is nice is now we don't need to keep asking oh is this a query or a
header or a body we can just check the kind of `HttpProperty`

also resolve #1311
2024-06-03 22:04:33 +00:00
もっちー 26e44b2c96
doc: fix incorrect example of `@statusCode` (#3230)
## Issue Description
There is a example of `TypeSpec.http.@statusCode`
[here](https://typespec.io/docs/next/libraries/http/reference/decorators#@TypeSpec.Http.statusCode).
However, the property name is missing in this example. Due to this, the
code did not work as expected.

```
op read(): {@statusCode: 200, @body pet: Pet}
op create(): {@statusCode: 201 | 202}
```

Instead, specifying the property name as follows made it work correctly:

```
op read(): {
  @statusCode _: 200;
  @body pet: Widget;
};
op create(): {
  @statusCode _: 201 | 202;
};
```

## Fix Description
- Corrected examples of `TypeSpec.http.@statusCode` in the reference and
documentation.

---------

Co-authored-by: Timothee Guerin <tiguerin@microsoft.com>
Co-authored-by: Timothee Guerin <timothee.guerin@outlook.com>
Co-authored-by: Mark Cowlishaw <markcowl@microsoft.com>
2024-06-03 21:14:48 +00:00
Mario Guerra ad7e3de795
fix broken extension links (#3487) 2024-05-30 23:28:35 +00:00
Brian Terlson 9a109906a0
Fix bundling and inlining of referenced schemas (#3430)
Fixes #3369 by changing how types are bundled. In particular, when a
type is not a JSON Schema type, we never create a root schema for it.
Instead, it is inlined into the defs of any schema which references it,
and referenced using a JSON pointer. This PR makes bundling have
essentially no impact on emitted schemas, and is merely a way to bundle
them into a single file.

The approach is as follows:

* When a type references another type outside a JSON Schema namespace,
include the referenced type under $defs:
   * Such referenced types do not have a $id or $schema field
   * Such referenced types are referenced via JSON pointers not ids
* Bundling does not alter the bundled schemas or introduce new root
schemas. This changes two things from what we do today:
* The `$id` of the bundled schemas now includes the file path as it does
for non-bundled schemas (whereas before it was just the type name)
* non-JSON Schema types do not get $defs in the bundle, so the bundle
has the same root schemas as would be written to disk when not bundling.
  
In terms of implementation, the basic approach is to not handle bundling
via the emitter framework source files. Instead, we always create source
files for root schemas, and inline the necessary defs as we did before
(but now using JSON pointers). Then when we're about to write source
files, if we're bundling we assemble the bundle and emit that single
file, otherwise we emit each source file that contains a root schema.

Todo: 

* [ ] Validate that the bundled schemas continue to work with ajv.
* [ ] Cleanups

---------

Co-authored-by: Vitalii Kryvenko <gersoh3@gmail.com>
2024-05-24 00:49:43 +00:00
Vitalii Kryvenko d14b0d7b63
Preserve leading whitespace in fenced blocks in doc comments (#3399)
Fixes #3370.

This also updates the generated documentation and typescript code to fix
lack of indentation on existing fenced blocks in this repo.

---------

Co-authored-by: Timothee Guerin <timothee.guerin@outlook.com>
2024-05-20 19:57:31 +00:00
Jim Borden bdb3f24bff
Add madeRequired decorator and tests (#3292)
Hopefully I got all the places I needed to get and added enough tests.
My methodology was pretty much "Look at what madeOptional does, and do
the opposite"

Closes #2731

---------

Co-authored-by: Timothee Guerin <tiguerin@microsoft.com>
Co-authored-by: Timothee Guerin <timothee.guerin@outlook.com>
2024-05-09 21:45:43 +00:00
Timothee Guerin 7ec17161b7
Value world, object, tuple literals, const (#3022)
resolves #2046
[Playround](https://cadlplayground.z22.web.core.windows.net/prs/3022/)

Add the new syntax for object literals using `#{`. For this first
version an object literal can only contain other object literal and
other literals(string, number, boolean))

## Values axioms
1. `alias` always produces a type. If you attempt to alias a value, you
get an error.
2. A string template produces a string template type if all
substitutions are types, and a value if all substitutions are numeric,
boolean, or string values. A mixture of types and values is an error.
3. The string literal syntax always results in a string literal type
4. A string literal type may be passed as a string value when the
signature expects a value. When the signature expects either a string
literal type or a string value, it is passed as a string value.
5. A string template type can be passed as a string value when all its
substitutions are string literal types.

## Breaking change

### Removal of the `ValueType` replacement with `MixedConstraint`

This shouldn't affect anyone as you were only exposed to this if you
digged into the template parameter and looked at the constraint

## Deprecation

## Using a tuple instead of a tuple literal
-  still work
- emit a warning
<img width="1013" alt="image"
src="https://github.com/microsoft/typespec/assets/1031227/ab05359a-5ed9-4a27-a8d1-f40d1e21766f">

- provide a codefix
<img width="312" alt="image"
src="https://github.com/microsoft/typespec/assets/1031227/5ef93bdf-665f-4445-a6b2-62475efe8c16">

## Using a model expression instead of an object literal
This technically didn't work before(different from above where tuple was
used as a value) but allow this will allow us to convert most of our
decorators to use `valueof` without being breaking
![Kapture 2024-03-18 at 19 31
32](https://github.com/microsoft/typespec/assets/1031227/f6d69ab4-139e-4b01-95a3-f376b8515d1c)

## Old decorator marshalling

If a library had a decorator with `valueof` one of those types
`numeric`, `int64`, `uint64`, `integer`, `float`, `decimal`,
`decimal128`, `null` it used to marshall those as JS `number` and
`NullType` for `null`. With the introduction of values we have a new
marshalling logic which will marshall those numeric types as `Numeric`
and the others will remain numbers. `null` will also get marshalled as
`null`.

For now this is an opt-in behavior with a warning on decorators not
opt-in having a parameter with a constraint from the list above.

Example: 
```
extern dec multipleOf(target: numeric | Reflection.ModelProperty, value: valueof numeric);
```
Will now emit a deprecated warning because `value` is of type `valueof
string` which would marshall to `Numeric` under the new logic but as
`number` previously.

To opt-in you can add the following to your library 
```ts
export const $flags = defineModuleFlags({
  decoratorArgMarshalling: "value",
});
```

---------

Co-authored-by: Brian Terlson <brian.terlson@microsoft.com>
Co-authored-by: Mark Cowlishaw <markcowl@microsoft.com>
2024-05-08 20:06:28 +00:00
Timothee Guerin 21edcb8f76
Add release notes for 0.56.0 (#3294)
Fixed up cspell not validating `.chronus` and causing some typo in
release notes

---------

Co-authored-by: Brian Terlson <brian.terlson@microsoft.com>
2024-05-07 21:02:14 +00:00
Timothee Guerin cb6fea49d7
Split libraries from emitters (#3258)
Makes it easier to discover our emitters

also cleanup a reference to non existent json-rpc emitter
2024-05-02 16:54:35 +00:00
Abiria 7517c9175e
docs: fix incorrect example code in namespaces.md (#3195)
## Backgrounds

I first reported this on discussion: #3194

## Issue description

There is a code sample
[here](https://typespec.io/docs/language-basics/namespaces#using-namespaces)
describing the scope of an item introduced by `using`.

```ts
namespace One {
  model A {}
}

namespace Two {
  using One;
  alias B = A; // This is valid
}

alias C = One.A; // This is not valid
alias C = Two.B; // This is valid
```

## Expected result

The code should failed to compile because of `One.A`.

## Actual result

It compiles without any warning.

## How to fix

It appears that the original intent was to show that accessing an item
introduced with `using` outside the scope of `using` is not possible. In
this code, the 'invalid accessing' is `Two.A`.

## Changes

- change `One.A` to `Two.A`
2024-04-23 02:21:09 +00:00