Clean up capitalization, parentheses, and phrasing in docs (#2817)
I updated library documentation links (https://microsoft.github.io/typespec/libraries => https://typespec.io/docs/libraries), should I update the other https://microsoft.github.io links as well?
This commit is contained in:
Родитель
1492fa5297
Коммит
9f556004ec
|
@ -0,0 +1,31 @@
|
||||||
|
---
|
||||||
|
"@typespec/prettier-plugin-typespec": patch
|
||||||
|
"@typespec/eslint-config-typespec": patch
|
||||||
|
"@typespec/eslint-plugin": patch
|
||||||
|
"@typespec/internal-build-utils": patch
|
||||||
|
"tmlanguage-generator": patch
|
||||||
|
"@typespec/html-program-viewer": patch
|
||||||
|
"@typespec/playground-website": patch
|
||||||
|
"@typespec/bundle-uploader": patch
|
||||||
|
"typespec-vscode": patch
|
||||||
|
"@typespec/best-practices": patch
|
||||||
|
"@typespec/library-linter": patch
|
||||||
|
"@typespec/json-schema": patch
|
||||||
|
"typespec-vs": patch
|
||||||
|
"@typespec/playground": patch
|
||||||
|
"@typespec/versioning": patch
|
||||||
|
"@typespec/compiler": patch
|
||||||
|
"@typespec/openapi3": patch
|
||||||
|
"@typespec/protobuf": patch
|
||||||
|
"@typespec/bundler": patch
|
||||||
|
"@typespec/openapi": patch
|
||||||
|
"@typespec/samples": patch
|
||||||
|
"@typespec/website": patch
|
||||||
|
"@typespec/http": patch
|
||||||
|
"@typespec/rest": patch
|
||||||
|
"@typespec/spec": patch
|
||||||
|
"@typespec/tspd": patch
|
||||||
|
"@typespec/e2e": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Clean up docs
|
|
@ -296,7 +296,7 @@ that gets produced.
|
||||||
## Trigger TypeSpec Playground Try It build
|
## Trigger TypeSpec Playground Try It build
|
||||||
|
|
||||||
For contributors of the repo the build will trigger automatically but for other's forks it will need a manual trigger from a contributor.
|
For contributors of the repo the build will trigger automatically but for other's forks it will need a manual trigger from a contributor.
|
||||||
As a contributor you can run the following command to trigger the build and create a typespec playground link for this PR.
|
As a contributor you can run the following command to trigger the build and create a TypeSpec playground link for this PR.
|
||||||
|
|
||||||
```
|
```
|
||||||
/azp run TypeSpec Pull Request Try It
|
/azp run TypeSpec Pull Request Try It
|
||||||
|
|
12
README.md
12
README.md
|
@ -23,11 +23,11 @@ You can try TypeSpec on the web without installing anything.
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|
||||||
For documentation for TypeSpec language, see https://microsoft.github.io/typespec.
|
For documentation on the TypeSpec language, see https://microsoft.github.io/typespec.
|
||||||
|
|
||||||
### Using Docker
|
### Using Docker
|
||||||
|
|
||||||
[See docker documentation](./docker)
|
[See Docker documentation](./docker)
|
||||||
|
|
||||||
### Using Node & Npm
|
### Using Node & Npm
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ For documentation for TypeSpec language, see https://microsoft.github.io/typespe
|
||||||
|
|
||||||
It is recommended to have npm 7+. To update npm run `npm install -g npm`
|
It is recommended to have npm 7+. To update npm run `npm install -g npm`
|
||||||
|
|
||||||
2. Install TypeSpec compiler and libraries:
|
2. Install the TypeSpec compiler and libraries:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm init -y
|
npm init -y
|
||||||
|
@ -66,8 +66,8 @@ If you do not wish to install the compiler globally with `-g` flag, you will nee
|
||||||
|
|
||||||
2. Initialize a TypeSpec project.
|
2. Initialize a TypeSpec project.
|
||||||
|
|
||||||
- Run `tsp init` > Select `Generic Rest API` template with `@typespec/rest` and `@typespec/openapi3` libraries checked.
|
- Run `tsp init` > Select `Generic REST API` template with `@typespec/rest` and `@typespec/openapi3` libraries checked.
|
||||||
- Run `tsp install` to install node package dependencies.
|
- Run `tsp install` to install Node package dependencies.
|
||||||
|
|
||||||
3. Open the folder in your editor and edit `main.tsp`
|
3. Open the folder in your editor and edit `main.tsp`
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ TypeSpec provides an auto-formatter to keep your specs clean and organized.
|
||||||
```bash
|
```bash
|
||||||
tsp format <patterns...>
|
tsp format <patterns...>
|
||||||
|
|
||||||
# Format all the files in the current directory with the typespec extension.
|
# Format all the files in the current directory with the TypeSpec extension.
|
||||||
tsp format **/*.tsp
|
tsp format **/*.tsp
|
||||||
|
|
||||||
# Exclude certain patterns. Either use `!` prefix or pass it via the `--exclude` or `-x` option.
|
# Exclude certain patterns. Either use `!` prefix or pass it via the `--exclude` or `-x` option.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Use typespec via docker
|
# Use TypeSpec via Docker
|
||||||
|
|
||||||
Image: `azsdkengsys.azurecr.io/typespec`
|
Image: `azsdkengsys.azurecr.io/typespec`
|
||||||
|
|
||||||
|
@ -12,10 +12,10 @@ Tags:
|
||||||
docker run \
|
docker run \
|
||||||
-v "${pwd}:/wd" --workdir="/wd" \
|
-v "${pwd}:/wd" --workdir="/wd" \
|
||||||
-t azsdkengsys.azurecr.io/typespec \
|
-t azsdkengsys.azurecr.io/typespec \
|
||||||
# ... typespec args ...
|
# ... TypeSpec args ...
|
||||||
```
|
```
|
||||||
|
|
||||||
**For usage in powershell replace `\` with `` ` ``**
|
**For usage in PowerShell replace `\` with `` ` ``**
|
||||||
|
|
||||||
### Install dependencies
|
### Install dependencies
|
||||||
|
|
||||||
|
|
|
@ -11,14 +11,14 @@ This document assumes you will be using [TypeScript](https://typescriptlang.org)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
You will need both node and npm installed. Additionally, if you intend to develop multiple libraries together, you will likely want to establish a monorepo as this will make developing the libraries in tandem much easier. TypeSpec itself uses [rush.js](https://rushjs.io/).
|
You will need both Node and npm installed. Additionally, if you intend to develop multiple libraries together, you will likely want to establish a monorepo as this will make developing the libraries in tandem much easier. TypeSpec itself uses [rush.js](https://rushjs.io/).
|
||||||
|
|
||||||
## Setup with templates
|
## Setup with templates
|
||||||
|
|
||||||
Available templates:
|
Available templates:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Create a TypeSpec library(Decorators & Linters) with TypeScript enabled.
|
# Create a TypeSpec library (Decorators & Linters) with TypeScript enabled.
|
||||||
tsp init --template library-ts
|
tsp init --template library-ts
|
||||||
|
|
||||||
# Create a TypeSpec emitter with TypeScript enabled.
|
# Create a TypeSpec emitter with TypeScript enabled.
|
||||||
|
@ -29,9 +29,9 @@ tsp init --template emitter-ts
|
||||||
|
|
||||||
The following is a high level overview of the contents of a TypeSpec package. These files are explained in more detail in the subsequent sections.
|
The following is a high level overview of the contents of a TypeSpec package. These files are explained in more detail in the subsequent sections.
|
||||||
|
|
||||||
- **dist/index.js** - the main file for your node library
|
- **dist/index.js** - the main file for your Node library
|
||||||
- **lib/main.tsp** - the main file for your TypeSpec types (optional)
|
- **lib/main.tsp** - the main file for your TypeSpec types (optional)
|
||||||
- **src/index.ts** - the main file for your node library in TypeScript
|
- **src/index.ts** - the main file for your Node library in TypeScript
|
||||||
- **src/lib.ts** - the TypeSpec library definition file
|
- **src/lib.ts** - the TypeSpec library definition file
|
||||||
- **package.json** - metadata about your TypeSpec package
|
- **package.json** - metadata about your TypeSpec package
|
||||||
|
|
||||||
|
@ -49,9 +49,9 @@ Run the following commands:
|
||||||
> npm init
|
> npm init
|
||||||
```
|
```
|
||||||
|
|
||||||
After filling out the wizard, you will have a package.json file that defines your typespec library.
|
After filling out the wizard, you will have a package.json file that defines your TypeSpec library.
|
||||||
|
|
||||||
Unlike node libraries which support CommonJS (cjs), TypeSpec libraries must be Ecmascript Modules. Open your `package.json` and add the following top-level configuration key:
|
Unlike Node libraries which support CommonJS (cjs), TypeSpec libraries must be ECMAScript Modules. Open your `package.json` and add the following top-level configuration key:
|
||||||
|
|
||||||
```jsonc
|
```jsonc
|
||||||
"type": "module"
|
"type": "module"
|
||||||
|
@ -71,7 +71,7 @@ See [dependency section](#defining-dependencies) for information on how to defin
|
||||||
|
|
||||||
### c. Define your main files
|
### c. Define your main files
|
||||||
|
|
||||||
Your package.json needs to refer to two main files: your node module main file, and your TypeSpec main. The node module main file is the `"main"` key in your package.json file, and defines the entrypoint for your library when consumed as a node library, and must reference a js file. The TypeSpec main defines the entrypoint for your library when consumed from a TypeSpec program, and may reference either a js file (when your library doesn't contain any typespec types) or a TypeSpec file.
|
Your package.json needs to refer to two main files: your Node module main file, and your TypeSpec main. The Node module main file is the `"main"` key in your package.json file, and defines the entrypoint for your library when consumed as a Node library, and must reference a JS file. The TypeSpec main defines the entrypoint for your library when consumed from a TypeSpec program, and may reference either a JS file (when your library doesn't contain any TypeSpec types) or a TypeSpec file.
|
||||||
|
|
||||||
```jsonc
|
```jsonc
|
||||||
"main": "dist/src/index.js",
|
"main": "dist/src/index.js",
|
||||||
|
@ -150,7 +150,7 @@ You can then run `npm run build` or `npm run watch` to build or watch your libra
|
||||||
|
|
||||||
### h. Add your main TypeSpec file
|
### h. Add your main TypeSpec file
|
||||||
|
|
||||||
Open `./lib/main.tsp` and import your JS entrypoint. This ensures that when typespec imports your library, the code to define the library is run. In later topics when we add decorators, this import will ensure those get exposed as well.
|
Open `./lib/main.tsp` and import your JS entrypoint. This ensures that when TypeSpec imports your library, the code to define the library is run. In later topics when we add decorators, this import will ensure those get exposed as well.
|
||||||
|
|
||||||
```typespec
|
```typespec
|
||||||
import "../dist/index.js";
|
import "../dist/index.js";
|
||||||
|
@ -174,8 +174,8 @@ model Person {
|
||||||
|
|
||||||
Defining dependencies in a TypeSpec library should be following these rules:
|
Defining dependencies in a TypeSpec library should be following these rules:
|
||||||
|
|
||||||
- use `peerDependencies` for all TypeSpec libraries(+ compiler) that you use in your own library/emitter
|
- use `peerDependencies` for all TypeSpec libraries (+ compiler) that you use in your own library/emitter
|
||||||
- use `devDependencies` for the other typespec libraries used only in tests
|
- use `devDependencies` for the other TypeSpec libraries used only in tests
|
||||||
- use `dependencies`/`devDependencies` for any other packages depending if using in library code or in test/dev scripts
|
- use `dependencies`/`devDependencies` for any other packages depending if using in library code or in test/dev scripts
|
||||||
|
|
||||||
TypeSpec libraries are defined using `peerDependencies` so we don't end-up with multiple versions of the compiler/library running at the same time.
|
TypeSpec libraries are defined using `peerDependencies` so we don't end-up with multiple versions of the compiler/library running at the same time.
|
||||||
|
@ -204,7 +204,7 @@ TypeSpec libraries are defined using `peerDependencies` so we don't end-up with
|
||||||
|
|
||||||
## 4. Testing your TypeSpec library
|
## 4. Testing your TypeSpec library
|
||||||
|
|
||||||
TypeSpec provides a testing framework to help testing libraries. Examples here are shown using node built-in test framework(Available node 20+) but any other JS test framework can be used that will provide more advanced features like vitest which is used in this project.
|
TypeSpec provides a testing framework to help testing libraries. Examples here are shown using Node.js's built-in test framework (available in Node 20+) but any other JS test framework can be used that will provide more advanced features like vitest which is used in this project.
|
||||||
|
|
||||||
### a. Add devDependencies
|
### a. Add devDependencies
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@ export default defineConfig({
|
||||||
|
|
||||||
### b. Define the testing library
|
### b. Define the testing library
|
||||||
|
|
||||||
The first step is to define how your library can be loaded from the test framework. This will let your library to be reused by other library test.
|
The first step is to define how your library can be loaded from the test framework. This will let your library to be reused by other library tests.
|
||||||
|
|
||||||
1. Create a new file `./src/testing/index.ts` with the following content
|
1. Create a new file `./src/testing/index.ts` with the following content
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ extern dec logType(target: unknown, name: string);
|
||||||
|
|
||||||
## Decorator target
|
## Decorator target
|
||||||
|
|
||||||
The first parameter of the decorator represents the typespec type(s) that the decorator can be applied on.
|
The first parameter of the decorator represents the TypeSpec type(s) that the decorator can be applied on.
|
||||||
|
|
||||||
You can specify multiple potential target type using an `union expression`
|
You can specify multiple potential target type using an `union expression`
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ A decorator parameter can be marked optional using `?`
|
||||||
extern dec track(target: Model | Enum, name?: valueof string);
|
extern dec track(target: Model | Enum, name?: valueof string);
|
||||||
```
|
```
|
||||||
|
|
||||||
### Rest parameters
|
### REST parameters
|
||||||
|
|
||||||
A decorator's last parameter can be prefixed with `...` to collect all the remaining arguments. The type of that parameter must be an `array expression`
|
A decorator's last parameter can be prefixed with `...` to collect all the remaining arguments. The type of that parameter must be an `array expression`
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ model Dog {
|
||||||
|
|
||||||
### Decorator parameter marshalling
|
### Decorator parameter marshalling
|
||||||
|
|
||||||
For certain TypeSpec types(Literal types) the decorator do not receive the actual type but a marshalled value if the decorator parmaeter type is a `valueof`. This is to simplify the most common cases.
|
For certain TypeSpec types (Literal types) the decorator do not receive the actual type but a marshalled value if the decorator parmaeter type is a `valueof`. This is to simplify the most common cases.
|
||||||
|
|
||||||
| TypeSpec Type | Marshalled value in JS |
|
| TypeSpec Type | Marshalled value in JS |
|
||||||
| ----------------- | ---------------------- |
|
| ----------------- | ---------------------- |
|
||||||
|
@ -209,11 +209,11 @@ import type { reportDiagnostic } from "./lib.js";
|
||||||
export function $customName(context: DecoratorContext, target: Type, name: string) {
|
export function $customName(context: DecoratorContext, target: Type, name: string) {
|
||||||
reportDiagnostic({
|
reportDiagnostic({
|
||||||
code: "custom-name-invalid",
|
code: "custom-name-invalid",
|
||||||
target: context.decoratorTarget, // Get location of @customName decorator in typespec document.
|
target: context.decoratorTarget, // Get location of @customName decorator in TypeSpec document.
|
||||||
});
|
});
|
||||||
reportDiagnostic({
|
reportDiagnostic({
|
||||||
code: "bad-name",
|
code: "bad-name",
|
||||||
target: context.getArgumentTarget(0), // Get location of {name} argument in typespec document.
|
target: context.getArgumentTarget(0), // Get location of {name} argument in TypeSpec document.
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
|
@ -2,14 +2,14 @@
|
||||||
title: Diagnostics
|
title: Diagnostics
|
||||||
---
|
---
|
||||||
|
|
||||||
TypeSpec compiler report errors and warnings in the spec using the diagnostic API.
|
The TypeSpec compiler reports errors and warnings in the spec using the diagnostic API.
|
||||||
|
|
||||||
## Best practices
|
## Best practices
|
||||||
|
|
||||||
- ❌ Do not use `throw` to report errors. Any exception thrown like this will be presented as a bug in your library to the user.
|
- ❌ Do not use `throw` to report errors. Any exception thrown like this will be presented as a bug in your library to the user.
|
||||||
- ✅ Use diagnostic API to report expected errors and warnings.
|
- ✅ Use diagnostic API to report expected errors and warnings.
|
||||||
- ✅ Use `reportDiagnostic` in a decorator, `$onValidate` or `$onEmit`
|
- ✅ Use `reportDiagnostic` in a decorator, `$onValidate` or `$onEmit`
|
||||||
- ❌ Do not use `reportDiagnostic` in an accessor(A function meant to be consumed in another library or emitter). See [collect diagnostics section](#collect-diagnostics)
|
- ❌ Do not use `reportDiagnostic` in an accessor (A function meant to be consumed in another library or emitter). See [collect diagnostics section](#collect-diagnostics)
|
||||||
|
|
||||||
## Diagnostic specification
|
## Diagnostic specification
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ To create your asset emitter, call `getAssetEmitter` on your emit context in `$o
|
||||||
export async function $onEmit(context: EmitContext) {
|
export async function $onEmit(context: EmitContext) {
|
||||||
const assetEmitter = context.getAssetEmitter(MyTypeEmitter);
|
const assetEmitter = context.getAssetEmitter(MyTypeEmitter);
|
||||||
|
|
||||||
// emit my entire typespec program
|
// emit my entire TypeSpec program
|
||||||
assetEmitter.emitProgram();
|
assetEmitter.emitProgram();
|
||||||
// or, maybe emit types just in a specific namespace
|
// or, maybe emit types just in a specific namespace
|
||||||
const ns = context.program.resolveTypeReference("MyNamespace")!;
|
const ns = context.program.resolveTypeReference("MyNamespace")!;
|
||||||
|
@ -93,7 +93,7 @@ class MyCodeEmitter extends CodeTypeEmitter {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
If we have a typespec program that looks like:
|
If we have a TypeSpec program that looks like:
|
||||||
|
|
||||||
```typespec
|
```typespec
|
||||||
model Pet {}
|
model Pet {}
|
||||||
|
@ -148,7 +148,7 @@ class MyCodeEmitter extends CodeTypeEmitter {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Now given a typespec program like:
|
Now given a TypeSpec program like:
|
||||||
|
|
||||||
```typespec
|
```typespec
|
||||||
model Pet {
|
model Pet {
|
||||||
|
|
|
@ -5,7 +5,7 @@ title: Emitters
|
||||||
|
|
||||||
# Writing emitters
|
# Writing emitters
|
||||||
|
|
||||||
TypeSpec emitters are libraries that use various TypeSpec compiler APIs to reflect on the typespec compilation and produce generated artifacts. The typespec standard library includes an emitter for OpenAPI version 3.0, but odds are good you will want to emit TypeSpec to another output format. In fact, one of TypeSpec's main benefits is how easy it is to use TypeSpec as a source of truth for all data shapes, and the ease of writing an emitter is a big part of that story.
|
TypeSpec emitters are libraries that use various TypeSpec compiler APIs to reflect on the TypeSpec compilation and produce generated artifacts. The TypeSpec standard library includes an emitter for OpenAPI version 3.0, but odds are good you will want to emit TypeSpec to another output format. In fact, one of TypeSpec's main benefits is how easy it is to use TypeSpec as a source of truth for all data shapes, and the ease of writing an emitter is a big part of that story.
|
||||||
|
|
||||||
## Getting started
|
## Getting started
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ Setup the boilerplate for an emitter using our template:
|
||||||
tsp init --template emitter-ts
|
tsp init --template emitter-ts
|
||||||
```
|
```
|
||||||
|
|
||||||
or follow [these steps](./basics.md) to initialize a typespec library.
|
or follow [these steps](./basics.md) to initialize a TypeSpec library.
|
||||||
|
|
||||||
## $onEmit
|
## $onEmit
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ export async function $onEmit(context: EmitContext<EmitterOptions>) {
|
||||||
Specify that the value for this option should resolve to an absolute path. e.g. `"{project-root}/dir"`.
|
Specify that the value for this option should resolve to an absolute path. e.g. `"{project-root}/dir"`.
|
||||||
|
|
||||||
:::important
|
:::important
|
||||||
It is recommended that all options that involve path use this. Using relative path can be confusing for users on as it is not clear what the relative path is relative to. And more importantly relative path if not careful are resolved relative to the `cwd` in node file system which result in spec only compiling from the the project root.
|
It is recommended that all options that involve path use this. Using relative path can be confusing for users on as it is not clear what the relative path is relative to. And more importantly relative path if not careful are resolved relative to the `cwd` in Node file system which result in spec only compiling from the the project root.
|
||||||
:::
|
:::
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
@ -152,7 +152,7 @@ navigateProgram(program, {
|
||||||
|
|
||||||
You can provide a callback for every kind of TypeSpec type. The walker will call your callback pre-order, i.e. as soon as it sees a type for the first time it will invoke your callback. You can invoke callback post-order instead by prefixing the type name with `exit`, for example `exitModel(m)`.
|
You can provide a callback for every kind of TypeSpec type. The walker will call your callback pre-order, i.e. as soon as it sees a type for the first time it will invoke your callback. You can invoke callback post-order instead by prefixing the type name with `exit`, for example `exitModel(m)`.
|
||||||
|
|
||||||
Note that the semantic walker will visit all types in the program including built-in TypeSpec types and typespec types defined by any libraries you're using. Care must be taken to filter out any types you do not intend to emit. Sometimes this is quite difficult, so a custom traversal may be easier.
|
Note that the semantic walker will visit all types in the program including built-in TypeSpec types and TypeSpec types defined by any libraries you're using. Care must be taken to filter out any types you do not intend to emit. Sometimes this is quite difficult, so a custom traversal may be easier.
|
||||||
|
|
||||||
### Custom traversal
|
### Custom traversal
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ function emitModel(model: Model) {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Resolving a typespec type
|
### Resolving a TypeSpec type
|
||||||
|
|
||||||
Sometimes you might want to get access to a known TypeSpec type in the type graph, for example a model that you have defined in your library.
|
Sometimes you might want to get access to a known TypeSpec type in the type graph, for example a model that you have defined in your library.
|
||||||
|
|
||||||
|
@ -200,12 +200,12 @@ A helper is provided on the program to do that.
|
||||||
program.resolveTypeReference(reference: string): Type | undefined;
|
program.resolveTypeReference(reference: string): Type | undefined;
|
||||||
```
|
```
|
||||||
|
|
||||||
The reference must be a valid typespec reference(Like you would have it in a typespec document)
|
The reference must be a valid TypeSpec reference (like you would have it in a TypeSpec document)
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
program.resolveTypeReference("TypeSpec.string"); // Resolve typespec string intrinsic type
|
program.resolveTypeReference("TypeSpec.string"); // Resolve TypeSpec string intrinsic type
|
||||||
program.resolveTypeReference("MyOrg.MyLibrary.MyEnum"); // Resolve `MyEnum` defined in `MyOrg.MyLibrary` namespace.
|
program.resolveTypeReference("MyOrg.MyLibrary.MyEnum"); // Resolve `MyEnum` defined in `MyOrg.MyLibrary` namespace.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -218,9 +218,9 @@ program.resolveTypeReference("model Foo {}"); // Resolve `[undefined, diagnostic
|
||||||
|
|
||||||
## Emitting files to disk
|
## Emitting files to disk
|
||||||
|
|
||||||
Since an emitter is a node library, you could use standard `fs` APIs to write files. However, this approach has a drawback - your emitter will not work in the browser, and will not work with the test framework that depends on storing emitted files in an in-memory file system.
|
Since an emitter is a Node library, you could use standard `fs` APIs to write files. However, this approach has a drawback - your emitter will not work in the browser, and will not work with the test framework that depends on storing emitted files in an in-memory file system.
|
||||||
|
|
||||||
Instead, use the compiler [`host` interface](#todo) to access the file system. The API is equivalent to the node API but works in a wider range of scenarios.
|
Instead, use the compiler [`host` interface](#todo) to access the file system. The API is equivalent to the Node API but works in a wider range of scenarios.
|
||||||
|
|
||||||
In order to know where to emit files, the emitter context has a `emitterOutputDir` property that is automatically resolved using the `emitter-output-dir` built-in emitter options. This is set to `{cwd}/tsp-output/{emitter-name}` by default, but can be overridden by the user. Do not use the `compilerOptions.outputDir`
|
In order to know where to emit files, the emitter context has a `emitterOutputDir` property that is automatically resolved using the `emitter-output-dir` built-in emitter options. This is set to `{cwd}/tsp-output/{emitter-name}` by default, but can be overridden by the user. Do not use the `compilerOptions.outputDir`
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ Scalars are types in TypeSpec that most likely have a primitive or built-in data
|
||||||
|
|
||||||
Recommended logic for emitting scalar is to:
|
Recommended logic for emitting scalar is to:
|
||||||
|
|
||||||
1. If scalar is a known scalar(e.g. `int32`), emit the known mapping.
|
1. If scalar is a known scalar (e.g. `int32`), emit the known mapping.
|
||||||
2. Otherwise check scalar `baseScalar` and go back to `1.`
|
2. Otherwise check scalar `baseScalar` and go back to `1.`
|
||||||
2.1 After resolving which scalar apply any decorators
|
2.1 After resolving which scalar apply any decorators
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,9 @@ title: Linters
|
||||||
|
|
||||||
## Linter vs `onValidate`
|
## Linter vs `onValidate`
|
||||||
|
|
||||||
TypeSpec library can probide a `$onValidate` hook which can be used to validate the typespec program is valid in the eye of your library.
|
TypeSpec library can probide a `$onValidate` hook which can be used to validate the TypeSpec program is valid in the eye of your library.
|
||||||
|
|
||||||
A linter on the other hand might be a validation that is optional, the program is correct but there could be some improvements. For example requiring documentation on every type. This is not something that is needed to represent the typespec program but without it the end user experience might suffer.
|
A linter on the other hand might be a validation that is optional, the program is correct but there could be some improvements. For example requiring documentation on every type. This is not something that is needed to represent the TypeSpec program but without it the end user experience might suffer.
|
||||||
Linters need to be explicitly enabled. `$onValidate` will be run automatically if that library is imported.
|
Linters need to be explicitly enabled. `$onValidate` will be run automatically if that library is imported.
|
||||||
|
|
||||||
## Writing a linter
|
## Writing a linter
|
||||||
|
|
|
@ -10,7 +10,7 @@ typespec provides scaffolding functionality via the `tsp init` command.
|
||||||
tsp init <templateUrl>
|
tsp init <templateUrl>
|
||||||
```
|
```
|
||||||
|
|
||||||
## Specifying a minimum typespec version
|
## Specifying a minimum TypeSpec version
|
||||||
|
|
||||||
If your template needs a functionality that was only added in a newer version of TypeSpec you might want to specify that in the template. This will warn the user that the template might not work as expected and prompt them to confirm that they want to continue.
|
If your template needs a functionality that was only added in a newer version of TypeSpec you might want to specify that in the template. This will warn the user that the template might not work as expected and prompt them to confirm that they want to continue.
|
||||||
|
|
||||||
|
@ -50,12 +50,12 @@ Example:
|
||||||
|
|
||||||
## Adding libraries
|
## Adding libraries
|
||||||
|
|
||||||
You can add a list of typespec libraries to include. This will automatically add those libraries to the `package.json` and imported in `main.tsp`.
|
You can add a list of TypeSpec libraries to include. This will automatically add those libraries to the `package.json` and imported in `main.tsp`.
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"rest": {
|
"rest": {
|
||||||
"title": "Rest API",
|
"title": "REST API",
|
||||||
"description": "Create a new project representing a REST API",
|
"description": "Create a new project representing a REST API",
|
||||||
"libraries": ["@typespec/rest", "@typespec/openapi3"]
|
"libraries": ["@typespec/rest", "@typespec/openapi3"]
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ Each file need the following properties:
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"rest": {
|
"rest": {
|
||||||
"title": "Rest API",
|
"title": "REST API",
|
||||||
"description": "Create a new project representing a REST API",
|
"description": "Create a new project representing a REST API",
|
||||||
"files": [{ "path": "./models.tsp", "destination": "./models.tsp" }]
|
"files": [{ "path": "./models.tsp", "destination": "./models.tsp" }]
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ The template takes in a map of inputs that will get prompted to the user during
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"rest": {
|
"rest": {
|
||||||
"title": "Rest API",
|
"title": "REST API",
|
||||||
"description": "Create a new project representing a REST API",
|
"description": "Create a new project representing a REST API",
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"modelName": {
|
"modelName": {
|
||||||
|
|
|
@ -3,14 +3,14 @@ title: Getting Started with TypeSpec For Http
|
||||||
---
|
---
|
||||||
|
|
||||||
Let's create a REST API definition with TypeSpec. TypeSpec has an official HTTP API "binding" called `@typespec/http`. It's a set of TypeSpec declarations and decorators that describe HTTP APIs and can be used by code generators to generate OpenAPI descriptions, implementation code, and the like.
|
Let's create a REST API definition with TypeSpec. TypeSpec has an official HTTP API "binding" called `@typespec/http`. It's a set of TypeSpec declarations and decorators that describe HTTP APIs and can be used by code generators to generate OpenAPI descriptions, implementation code, and the like.
|
||||||
Built on top of the http library there is the rest library `@typespec/rest` which provide some REST concept like resources.
|
Built on top of the HTTP library, there is the REST library `@typespec/rest` which provide some REST concepts like resources.
|
||||||
|
|
||||||
TypeSpec also has an official OpenAPI emitter called `@typespec/openapi3` that consumes the HTTP API bindings and emits standard [OpenAPI 3.0](https://spec.openapis.org/oas/v3.0.3) descriptions. This can then be fed in to any OpenAPI code generation pipeline.
|
TypeSpec also has an official OpenAPI emitter called `@typespec/openapi3` that consumes the HTTP API bindings and emits standard [OpenAPI 3.0](https://spec.openapis.org/oas/v3.0.3) descriptions. This can then be fed in to any OpenAPI code generation pipeline.
|
||||||
|
|
||||||
References:
|
References:
|
||||||
|
|
||||||
- [Http library](../libraries/http/reference)
|
- [HTTP library](../libraries/http/reference)
|
||||||
- [Rest library](../libraries/rest/reference)
|
- [REST library](../libraries/rest/reference)
|
||||||
- [OpenAPI 3 emitter](../libraries/openapi3/reference)
|
- [OpenAPI 3 emitter](../libraries/openapi3/reference)
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
@ -20,7 +20,7 @@ Make sure to have installed the [editor extension](../introduction/installation.
|
||||||
:::
|
:::
|
||||||
|
|
||||||
1. Make a new folder somewhere
|
1. Make a new folder somewhere
|
||||||
2. Run `npx --package=@typespec/compiler tsp init` and select the `Generic Rest API` template
|
2. Run `npx --package=@typespec/compiler tsp init` and select the `Generic REST API` template
|
||||||
3. Run `npm install` to install dependencies
|
3. Run `npm install` to install dependencies
|
||||||
4. Run `npx tsp compile .` to compile the initial file
|
4. Run `npx tsp compile .` to compile the initial file
|
||||||
You can either run `npx tsp compile . --watch` to automatically compile change on save or keep running the command manually after that.
|
You can either run `npx tsp compile . --watch` to automatically compile change on save or keep running the command manually after that.
|
||||||
|
|
|
@ -140,7 +140,7 @@ In OpenAPI v3, the top-level `servers` field specifies an array of `server` obje
|
||||||
[v3-server]: https://github.com/OAI/OpenAPI-Specification/blob/3.0.3/versions/3.0.3.md#server-object
|
[v3-server]: https://github.com/OAI/OpenAPI-Specification/blob/3.0.3/versions/3.0.3.md#server-object
|
||||||
|
|
||||||
In TypeSpec, the `host` in OpenAPI v2 or `servers` in OpenAPI v3 can be specified with the `@server` decorator
|
In TypeSpec, the `host` in OpenAPI v2 or `servers` in OpenAPI v3 can be specified with the `@server` decorator
|
||||||
on the namespace(From `@typespec/http` library). You can use this decorator multiple times to specify multiple servers.
|
on the namespace (from `@typespec/http` library). You can use this decorator multiple times to specify multiple servers.
|
||||||
|
|
||||||
## Paths Object
|
## Paths Object
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,8 @@ Commands:
|
||||||
tsp vs Manage Visual Studio Extension.
|
tsp vs Manage Visual Studio Extension.
|
||||||
tsp format <include...> Format given list of TypeSpec files.
|
tsp format <include...> Format given list of TypeSpec files.
|
||||||
tsp init [templatesUrl] Create a new TypeSpec project.
|
tsp init [templatesUrl] Create a new TypeSpec project.
|
||||||
tsp install Install typespec dependencies
|
tsp install Install TypeSpec dependencies
|
||||||
tsp info Show information about current TypeSpec compiler.
|
tsp info Show information about the current TypeSpec compiler.
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--help Show help [boolean]
|
--help Show help [boolean]
|
||||||
|
|
|
@ -4,7 +4,7 @@ title: Configuration
|
||||||
|
|
||||||
# Compiler and Libraries configurations
|
# Compiler and Libraries configurations
|
||||||
|
|
||||||
TypeSpec compiler and libraries can be configured either via a [configuration file](#configuration-file) or [command line flags](#command-line-flags).
|
The TypeSpec compiler and libraries can be configured either via a [configuration file](#configuration-file) or [command line flags](#command-line-flags).
|
||||||
|
|
||||||
## Configuration file
|
## Configuration file
|
||||||
|
|
||||||
|
@ -12,9 +12,9 @@ TypeSpec configuration can be provided via the `tspconfig.yaml` configuration fi
|
||||||
|
|
||||||
### Discovery
|
### Discovery
|
||||||
|
|
||||||
TypeSpec compiler will look for the closest `tspconfig.yaml` file located in the same directory or closest parent directory from the typespec entrypoint.
|
The TypeSpec compiler will look for the closest `tspconfig.yaml` file located in the same directory or closest parent directory from the TypeSpec entrypoint.
|
||||||
|
|
||||||
For example if running `tsp compile /dev/foo/bar/main.tsp`, the compiler will lookup the file at the folllowing paths(In this order):
|
For example if running `tsp compile /dev/foo/bar/main.tsp`, the compiler will lookup the file at the folllowing paths (in order):
|
||||||
|
|
||||||
- `/dev/foo/bar/tspconfig.yaml`
|
- `/dev/foo/bar/tspconfig.yaml`
|
||||||
- `/dev/foo/tspconfig.yaml`
|
- `/dev/foo/tspconfig.yaml`
|
||||||
|
@ -48,7 +48,7 @@ model LinterConfig {
|
||||||
|
|
||||||
### Extending project files
|
### Extending project files
|
||||||
|
|
||||||
There is cases where you might want to build different folders with different options(for example different emitters) but want to share some configuration for both as well.
|
There is cases where you might want to build different folders with different options (for example different emitters) but want to share some configuration for both as well.
|
||||||
|
|
||||||
For that you can use the `extends` property of the configuration file
|
For that you can use the `extends` property of the configuration file
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ emit:
|
||||||
|
|
||||||
### Variable interpolation
|
### Variable interpolation
|
||||||
|
|
||||||
The typespec project file provide variable interpolation using:
|
The TypeSpec project file provide variable interpolation using:
|
||||||
|
|
||||||
- built-in variables
|
- built-in variables
|
||||||
- environment variables
|
- environment variables
|
||||||
|
@ -113,7 +113,7 @@ The following would get produced
|
||||||
|
|
||||||
#### Project parameters
|
#### Project parameters
|
||||||
|
|
||||||
A typespec project file can specify some parameters that can then be specified via the CLI.
|
A TypeSpec project file can specify some parameters that can then be specified via the CLI.
|
||||||
|
|
||||||
`{cwd}` and `{project-root}` variables can be used in the default value of those parmeters.
|
`{cwd}` and `{project-root}` variables can be used in the default value of those parmeters.
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ tsp compile . --arg "base-dir=/path/to/base"
|
||||||
|
|
||||||
#### Environment variables
|
#### Environment variables
|
||||||
|
|
||||||
A typespec project file can define which environment variables it can interpolate.
|
A TypeSpec project file can define which environment variables it can interpolate.
|
||||||
|
|
||||||
`{cwd}` and `{project-root}` variables can be used in the default value of the environment variables.
|
`{cwd}` and `{project-root}` variables can be used in the default value of the environment variables.
|
||||||
|
|
||||||
|
@ -252,7 +252,7 @@ imports:
|
||||||
- sidecar.tsp
|
- sidecar.tsp
|
||||||
```
|
```
|
||||||
|
|
||||||
Specify additional typespec files to import
|
Specify additional TypeSpec files to import
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
tsp compile . --import "sidecar.tsp"
|
tsp compile . --import "sidecar.tsp"
|
||||||
|
@ -356,7 +356,7 @@ tsp compile . --watch
|
||||||
```
|
```
|
||||||
|
|
||||||
:::caution
|
:::caution
|
||||||
Known issue: the watch mode does not pickup changes in JS files that are indirectly included(Only imported via another JS file.)
|
Known issue: the watch mode does not pickup changes in JS files that are indirectly included (only imported via another JS file.)
|
||||||
:::
|
:::
|
||||||
|
|
||||||
### `--nostdlib`
|
### `--nostdlib`
|
||||||
|
@ -379,7 +379,7 @@ tsp compile . --version
|
||||||
|
|
||||||
**Default: `true`**
|
**Default: `true`**
|
||||||
|
|
||||||
Enable/Disable pretty logging(Colors, diagnostic preview, etc.).
|
Enable/Disable pretty logging (colors, diagnostic preview, etc.).
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
tsp compile . --pretty=false
|
tsp compile . --pretty=false
|
||||||
|
@ -397,7 +397,7 @@ By default the output-dir of an emitter is set to this value:
|
||||||
where
|
where
|
||||||
|
|
||||||
- `output-dir` is the compiler common `output-dir` that can be configured via `--output-dir`
|
- `output-dir` is the compiler common `output-dir` that can be configured via `--output-dir`
|
||||||
- `emitter-name` is the name of the emitter package(for example `@typespec/openapi3`)
|
- `emitter-name` is the name of the emitter package (for example `@typespec/openapi3`)
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
Given the following emitters: `@typespec/openapi3` and `@typespec/jsonschema`, the default output folder structure would be
|
Given the following emitters: `@typespec/openapi3` and `@typespec/jsonschema`, the default output folder structure would be
|
||||||
|
|
|
@ -13,7 +13,7 @@ TypeSpec comes with a built-in formatter. The formatter can be used in different
|
||||||
|
|
||||||
## Via the cli
|
## Via the cli
|
||||||
|
|
||||||
Format all typespec files:
|
Format all TypeSpec files:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
tsp format "**/*.tsp"
|
tsp format "**/*.tsp"
|
||||||
|
@ -33,7 +33,7 @@ Using the keyboard shortcut for formatting the document (`alt+shift+F` by defaul
|
||||||
|
|
||||||
## Via prettier
|
## Via prettier
|
||||||
|
|
||||||
Underneath the tsp formatter is a prettier plugin. If you already have a prettier configuration for formatting other languages it can be convenient to just have typespec plug in into this existing pipeline.
|
Underneath the tsp formatter is a prettier plugin. If you already have a prettier configuration for formatting other languages it can be convenient to just have TypeSpec plug in into this existing pipeline.
|
||||||
|
|
||||||
In your prettier config file, add:
|
In your prettier config file, add:
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ title: Releases
|
||||||
|
|
||||||
## Package versioning strategy
|
## Package versioning strategy
|
||||||
|
|
||||||
TypeSpec is not stable yet, all packages are released with `0.` major version. Each minor version might have some breaking changes to the typespec language, library API or both. Those are documented [here](../release-notes).
|
TypeSpec is not stable yet, all packages are released with `0.` major version. Each minor version might have some breaking changes to the TypeSpec language, library API or both. Those are documented [here](../release-notes).
|
||||||
|
|
||||||
Every change to the `main` branch is automatically published under the npm `@next` tag.
|
Every change to the `main` branch is automatically published under the npm `@next` tag.
|
||||||
|
|
||||||
|
|
|
@ -16,9 +16,9 @@ npm --version
|
||||||
|
|
||||||
It is recommended to have npm 7+. To update npm run `npm install -g npm`
|
It is recommended to have npm 7+. To update npm run `npm install -g npm`
|
||||||
|
|
||||||
## Install tsp compiler
|
## Install tsp
|
||||||
|
|
||||||
First step is to install the tsp compiler/cli
|
First step is to install `tsp`, the TypeSpec compiler/CLI
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install -g @typespec/compiler
|
npm install -g @typespec/compiler
|
||||||
|
@ -39,7 +39,7 @@ To get your first TypeSpec project started run in a fresh directory
|
||||||
tsp init
|
tsp init
|
||||||
```
|
```
|
||||||
|
|
||||||
This will prompt you with a few question, pick the `Generic Rest API` template, your project name, and select the `@typespec/openapi3` library.
|
This will prompt you with a few questions, pick the `Generic REST API` template, your project name, and select the `@typespec/openapi3` library.
|
||||||
|
|
||||||
Next, you can install the dependencies
|
Next, you can install the dependencies
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ tsp install
|
||||||
You should now have a basic TypeSpec project setup with a structure looking like
|
You should now have a basic TypeSpec project setup with a structure looking like
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
package.json # Package manifest defining your typespec project as a node package.
|
package.json # Package manifest defining your TypeSpec project as a Node package.
|
||||||
tspconfig.yaml # TypeSpec project configuration letting you configure emitters, emitter options, compiler options, etc.
|
tspconfig.yaml # TypeSpec project configuration letting you configure emitters, emitter options, compiler options, etc.
|
||||||
main.tsp # TypeSpec entrypoint
|
main.tsp # TypeSpec entrypoint
|
||||||
```
|
```
|
||||||
|
|
|
@ -10,7 +10,7 @@ Enums allow a developer to define a set of named constants. Using enums can make
|
||||||
## Basics
|
## Basics
|
||||||
|
|
||||||
Enums are declared using the `enum` keyword.
|
Enums are declared using the `enum` keyword.
|
||||||
The enums members are comma `,` separated and can be typespec `identifier`s or `string literal`s.
|
The enums members are comma `,` separated and can be TypeSpec `identifier`s or `string literal`s.
|
||||||
|
|
||||||
```typespec
|
```typespec
|
||||||
enum Direction {
|
enum Direction {
|
||||||
|
|
|
@ -23,7 +23,7 @@ import "./decorators.js";
|
||||||
|
|
||||||
## Import a library
|
## Import a library
|
||||||
|
|
||||||
The import value can be name one of the package dependencies. In that case typespec will lookup for the `package.json` file and check the `tspMain` entry (or default to `main` if absent) to decide what is the library entrypoint to load.
|
The import value can be name one of the package dependencies. In that case TypeSpec will lookup for the `package.json` file and check the `tspMain` entry (or default to `main` if absent) to decide what is the library entrypoint to load.
|
||||||
|
|
||||||
```typespec
|
```typespec
|
||||||
import "@typespec/rest";
|
import "@typespec/rest";
|
||||||
|
@ -40,12 +40,12 @@ which result in `./node_modules/@typespec/rest/lib/main.tsp` to be imported
|
||||||
|
|
||||||
## Import a directory
|
## Import a directory
|
||||||
|
|
||||||
If the import value is a directory it will lookup if that directory is a node package and follow the npm package [lookup logic](#import-a-library) or if the directory contains a `main.tsp`.
|
If the import value is a directory it will lookup if that directory is a Node package and follow the npm package [lookup logic](#import-a-library) or if the directory contains a `main.tsp`.
|
||||||
|
|
||||||
```typespec
|
```typespec
|
||||||
import "./models"; // same as `import "./models/main.tsp";
|
import "./models"; // same as `import "./models/main.tsp";
|
||||||
```
|
```
|
||||||
|
|
||||||
```typespec
|
```typespec
|
||||||
import "./path/to/local/module"; // Assuming this path is a typespec package, it will load it using the tspMain file.
|
import "./path/to/local/module"; // Assuming this path is a TypeSpec package, it will load it using the tspMain file.
|
||||||
```
|
```
|
||||||
|
|
|
@ -142,7 +142,7 @@ model Dog extends Animal {}
|
||||||
|
|
||||||
### Is
|
### Is
|
||||||
|
|
||||||
Sometimes you want to create a new type that is an exact copy of an existing type but with some additional properties or metadata without creating a nominal inheritance relationship. The `is` keyword can be used for this purpose. It copies all the properties(like spread), but copies [decorators](./decorators.md) as well. One common use case is to give a better name to a [template](#Templates) instantiation:
|
Sometimes you want to create a new type that is an exact copy of an existing type but with some additional properties or metadata without creating a nominal inheritance relationship. The `is` keyword can be used for this purpose. It copies all the properties (like spread), but copies [decorators](./decorators.md) as well. One common use case is to give a better name to a [template](#Templates) instantiation:
|
||||||
|
|
||||||
```typespec
|
```typespec
|
||||||
@decorator
|
@decorator
|
||||||
|
|
|
@ -22,7 +22,7 @@ _Details: [Imports](./imports.md)_
|
||||||
|
|
||||||
| Feature | Example |
|
| Feature | Example |
|
||||||
| -------------------- | ------------------------- |
|
| -------------------- | ------------------------- |
|
||||||
| Import typespec file | `import "./models.tsp"` |
|
| Import TypeSpec file | `import "./models.tsp"` |
|
||||||
| Import JS file | `import "./models.js"` |
|
| Import JS file | `import "./models.js"` |
|
||||||
| Import Library | `import "@typespec/rest"` |
|
| Import Library | `import "@typespec/rest"` |
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ title: Scalars
|
||||||
|
|
||||||
# Scalars
|
# Scalars
|
||||||
|
|
||||||
These are types without any fields(For example `string`, `int32`, `boolean`, etc.)
|
These are types without any fields (for example `string`, `int32`, `boolean`, etc.)
|
||||||
|
|
||||||
Scalar can be declared using the `scalar` keyword
|
Scalar can be declared using the `scalar` keyword
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ model S {
|
||||||
|
|
||||||
## `Record<T>`
|
## `Record<T>`
|
||||||
|
|
||||||
A record is a model indexed with a string with value of T. This means that it represents a model where all properties(string key) are assignable to the type T. You can assign a model expression where all the properties are of type T or another model that `is` also a `Record<T>`
|
A record is a model indexed with a string with value of T. This means that it represents a model where all properties (string keys) are assignable to the type T. You can assign a model expression where all the properties are of type T or another model that `is` also a `Record<T>`
|
||||||
|
|
||||||
```typespec
|
```typespec
|
||||||
// Represent an object where all the values are int32.
|
// Represent an object where all the values are int32.
|
||||||
|
|
|
@ -48,5 +48,5 @@ _Details: [Authentication](./authentication.md)_
|
||||||
| --------------- | ------------------------------------------- |
|
| --------------- | ------------------------------------------- |
|
||||||
| Basic auth | `@useAuth(BasicAuth)` |
|
| Basic auth | `@useAuth(BasicAuth)` |
|
||||||
| Bearer auth | `@useAuth(BearerAuth)` |
|
| Bearer auth | `@useAuth(BearerAuth)` |
|
||||||
| Api key auth | `@useAuth(ApiKeyAuth<"header", "Api-Key">)` |
|
| API key auth | `@useAuth(ApiKeyAuth<"header", "Api-Key">)` |
|
||||||
| OAuth2 key auth | `@useAuth(OAuth2Flow<[MyScope]>)` |
|
| OAuth2 key auth | `@useAuth(OAuth2Flow<[MyScope]>)` |
|
||||||
|
|
|
@ -402,7 +402,7 @@ op create(): {@statusCode: 201 | 202}
|
||||||
|
|
||||||
### `@useAuth` {#@TypeSpec.Http.useAuth}
|
### `@useAuth` {#@TypeSpec.Http.useAuth}
|
||||||
|
|
||||||
Specify this service authentication. See the [documentation in the Http library](https://microsoft.github.io/typespec/libraries/http/authentication) for full details.
|
Specify this service authentication. See the [documentation in the Http library](https://typespec.io/docs/libraries/http/authentication) for full details.
|
||||||
|
|
||||||
```typespec
|
```typespec
|
||||||
@TypeSpec.Http.useAuth(auth: {} | Union | {}[])
|
@TypeSpec.Http.useAuth(auth: {} | Union | {}[])
|
||||||
|
@ -415,8 +415,8 @@ Specify this service authentication. See the [documentation in the Http library]
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| ---- | --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| ---- | --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| auth | `union {} \| Union \| {}[]` | Authentication configuration. Can be a single security scheme, a union(either option is valid authentication) or a tuple(Must use all authentication together) |
|
| auth | `union {} \| Union \| {}[]` | Authentication configuration. Can be a single security scheme, a union(either option is valid authentication) or a tuple (must use all authentication together) |
|
||||||
|
|
||||||
#### Examples
|
#### Examples
|
||||||
|
|
||||||
|
|
|
@ -25,5 +25,5 @@ Available ruleSets:
|
||||||
## Rules
|
## Rules
|
||||||
|
|
||||||
| Name | Description |
|
| Name | Description |
|
||||||
| ------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------- |
|
| --------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
|
||||||
| [`@typespec/http/op-reference-container-route`](/libraries/http/rules/op-reference-container-route.md) | Check for referenced (`op is`) operations which have a @route on one of their containers. |
|
| [`@typespec/http/op-reference-container-route`](https://typespec.io/docs/libraries/http/rules/op-reference-container-route) | Check for referenced (`op is`) operations which have a @route on one of their containers. |
|
||||||
|
|
|
@ -863,7 +863,7 @@ with standard emitters that interpret them as follows:
|
||||||
- "update": input to operations that update data.
|
- "update": input to operations that update data.
|
||||||
- "delete": input to operations that delete data.
|
- "delete": input to operations that delete data.
|
||||||
|
|
||||||
See also: [Automatic visibility](https://microsoft.github.io/typespec/libraries/http/operations#automatic-visibility)
|
See also: [Automatic visibility](https://typespec.io/docs/libraries/http/operations#automatic-visibility)
|
||||||
|
|
||||||
```typespec
|
```typespec
|
||||||
@visibility(...visibilities: valueof string[])
|
@visibility(...visibilities: valueof string[])
|
||||||
|
@ -988,7 +988,7 @@ Removes properties that are not considered to be present or applicable
|
||||||
together with spread to effectively spread only visible properties into
|
together with spread to effectively spread only visible properties into
|
||||||
a new model.
|
a new model.
|
||||||
|
|
||||||
See also: [Automatic visibility](https://microsoft.github.io/typespec/libraries/http/operations#automatic-visibility)
|
See also: [Automatic visibility](https://typespec.io/docs/libraries/http/operations#automatic-visibility)
|
||||||
|
|
||||||
When using an emitter that applies visibility automatically, it is generally
|
When using an emitter that applies visibility automatically, it is generally
|
||||||
not necessary to use this decorator.
|
not necessary to use this decorator.
|
||||||
|
|
|
@ -19,12 +19,12 @@ List of known targets.
|
||||||
- `json`: Configure JSON representation of data
|
- `json`: Configure JSON representation of data
|
||||||
- `xml`: Configure XML representation of data
|
- `xml`: Configure XML representation of data
|
||||||
- Language:
|
- Language:
|
||||||
- `csharp`: Configure C# generated code
|
- `csharp`: Configure C# code generation
|
||||||
- `java`: Configure Java generated code
|
- `java`: Configure Java code generation
|
||||||
- `python`: Configure python generated code
|
- `python`: Configure Python code generation
|
||||||
- `javascript`: Configure javascript generated code
|
- `javascript`: Configure JavaScript code generation
|
||||||
- `swift` : Configure swift generated code
|
- `swift` : Configure Swift code generation
|
||||||
- `c` : Configure C generated code
|
- `c` : Configure C code generation
|
||||||
- Type:
|
- Type:
|
||||||
- `client`: Configure output for the client
|
- `client`: Configure output for the client
|
||||||
- `server`: Configure output for the server
|
- `server`: Configure output for the server
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# In this test we always want to get the latest published typespec libraries for test.
|
# In this test we always want to get the latest published TypeSpec libraries for test.
|
||||||
basic-latest/package-lock.json
|
basic-latest/package-lock.json
|
||||||
|
|
||||||
# This test is generated on the fly.
|
# This test is generated on the fly.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"name": "@typespec/bundler",
|
"name": "@typespec/bundler",
|
||||||
"version": "0.1.0-alpha.5",
|
"version": "0.1.0-alpha.5",
|
||||||
"author": "Microsoft Corporation",
|
"author": "Microsoft Corporation",
|
||||||
"description": "Package to bundle a typespec library.",
|
"description": "Package to bundle a TypeSpec library.",
|
||||||
"homepage": "https://microsoft.github.io/typespec",
|
"homepage": "https://microsoft.github.io/typespec",
|
||||||
"readme": "https://github.com/microsoft/typespec/blob/main/README.md",
|
"readme": "https://github.com/microsoft/typespec/blob/main/README.md",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|
|
@ -16,8 +16,8 @@ const builtInTemplates: Record<string, InitTemplate> = {
|
||||||
compilerVersion: minCompilerVersion,
|
compilerVersion: minCompilerVersion,
|
||||||
},
|
},
|
||||||
rest: {
|
rest: {
|
||||||
title: "Generic Rest API",
|
title: "Generic REST API",
|
||||||
description: "Create a project representing a generic Rest API",
|
description: "Create a project representing a generic REST API",
|
||||||
compilerVersion: minCompilerVersion,
|
compilerVersion: minCompilerVersion,
|
||||||
libraries: ["@typespec/http", "@typespec/rest", "@typespec/openapi3"],
|
libraries: ["@typespec/http", "@typespec/rest", "@typespec/openapi3"],
|
||||||
config: {
|
config: {
|
||||||
|
|
|
@ -502,7 +502,7 @@ extern dec encode(
|
||||||
* - "update": input to operations that update data.
|
* - "update": input to operations that update data.
|
||||||
* - "delete": input to operations that delete data.
|
* - "delete": input to operations that delete data.
|
||||||
*
|
*
|
||||||
* See also: [Automatic visibility](https://microsoft.github.io/typespec/libraries/http/operations#automatic-visibility)
|
* See also: [Automatic visibility](https://typespec.io/docs/libraries/http/operations#automatic-visibility)
|
||||||
*
|
*
|
||||||
* @param visibilities List of visibilities which apply to this property.
|
* @param visibilities List of visibilities which apply to this property.
|
||||||
*
|
*
|
||||||
|
@ -527,7 +527,7 @@ extern dec visibility(target: ModelProperty, ...visibilities: valueof string[]);
|
||||||
* together with spread to effectively spread only visible properties into
|
* together with spread to effectively spread only visible properties into
|
||||||
* a new model.
|
* a new model.
|
||||||
*
|
*
|
||||||
* See also: [Automatic visibility](https://microsoft.github.io/typespec/libraries/http/operations#automatic-visibility)
|
* See also: [Automatic visibility](https://typespec.io/docs/libraries/http/operations#automatic-visibility)
|
||||||
*
|
*
|
||||||
* When using an emitter that applies visibility automatically, it is generally
|
* When using an emitter that applies visibility automatically, it is generally
|
||||||
* not necessary to use this decorator.
|
* not necessary to use this decorator.
|
||||||
|
|
|
@ -75,7 +75,7 @@ export async function findTypeSpecConfigPath(
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the typespec configuration for the provided path or directory
|
* Load the TypeSpec configuration for the provided path or directory
|
||||||
* @param host
|
* @param host
|
||||||
* @param path
|
* @param path
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -24,7 +24,7 @@ export interface TypeSpecConfig {
|
||||||
diagnostics: Diagnostic[];
|
diagnostics: Diagnostic[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path to another typespec config to extend.
|
* Path to another TypeSpec config to extend.
|
||||||
*/
|
*/
|
||||||
extends?: string;
|
extends?: string;
|
||||||
|
|
||||||
|
|
|
@ -354,9 +354,9 @@ export function createChecker(program: Program): Checker {
|
||||||
|
|
||||||
const typespecNamespaceBinding = globalNamespaceNode.symbol.exports!.get("TypeSpec");
|
const typespecNamespaceBinding = globalNamespaceNode.symbol.exports!.get("TypeSpec");
|
||||||
if (typespecNamespaceBinding) {
|
if (typespecNamespaceBinding) {
|
||||||
// the typespec namespace binding will be absent if we've passed
|
// the TypeSpec namespace binding will be absent if we've passed
|
||||||
// the no-std-lib option.
|
// the no-std-lib option.
|
||||||
// the first declaration here is the JS file for the typespec script.
|
// the first declaration here is the JS file for the TypeSpec script.
|
||||||
initializeTypeSpecIntrinsics();
|
initializeTypeSpecIntrinsics();
|
||||||
for (const file of program.sourceFiles.values()) {
|
for (const file of program.sourceFiles.values()) {
|
||||||
addUsingSymbols(typespecNamespaceBinding.exports!, file.locals);
|
addUsingSymbols(typespecNamespaceBinding.exports!, file.locals);
|
||||||
|
@ -1682,7 +1682,7 @@ export function createChecker(program: Program): Checker {
|
||||||
|
|
||||||
symbolLinks.type = type;
|
symbolLinks.type = type;
|
||||||
for (const sourceNode of mergedSymbol.declarations) {
|
for (const sourceNode of mergedSymbol.declarations) {
|
||||||
// namespaces created from typespec scripts don't have decorators
|
// namespaces created from TypeSpec scripts don't have decorators
|
||||||
if (sourceNode.kind !== SyntaxKind.NamespaceStatement) continue;
|
if (sourceNode.kind !== SyntaxKind.NamespaceStatement) continue;
|
||||||
type.decorators = type.decorators.concat(checkDecorators(type, sourceNode, undefined));
|
type.decorators = type.decorators.concat(checkDecorators(type, sourceNode, undefined));
|
||||||
}
|
}
|
||||||
|
@ -6268,7 +6268,7 @@ function createDecoratorContext(program: Program, decApp: DecoratorApplication):
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert typespec argument to JS argument.
|
* Convert TypeSpec argument to JS argument.
|
||||||
*/
|
*/
|
||||||
function marshalArgumentsForJS<T extends Type>(args: T[]): MarshalledValue<T>[] {
|
function marshalArgumentsForJS<T extends Type>(args: T[]): MarshalledValue<T>[] {
|
||||||
return args.map((arg) => {
|
return args.map((arg) => {
|
||||||
|
|
|
@ -154,7 +154,7 @@ function logProgramResult(
|
||||||
if (program.emitters.length === 0 && !program.compilerOptions.noEmit) {
|
if (program.emitters.length === 0 && !program.compilerOptions.noEmit) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
log(
|
log(
|
||||||
"No emitter was configured, no output was generated. Use `--emit <emitterName>` to pick emitter or specify it in the typespec config."
|
"No emitter was configured, no output was generated. Use `--emit <emitterName>` to pick emitter or specify it in the TypeSpec config."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,13 +213,13 @@ async function main() {
|
||||||
)
|
)
|
||||||
.command(
|
.command(
|
||||||
"install",
|
"install",
|
||||||
"Install typespec dependencies",
|
"Install TypeSpec dependencies",
|
||||||
() => {},
|
() => {},
|
||||||
withCliHost((host) => installTypeSpecDependencies(host, process.cwd()))
|
withCliHost((host) => installTypeSpecDependencies(host, process.cwd()))
|
||||||
)
|
)
|
||||||
.command(
|
.command(
|
||||||
"info",
|
"info",
|
||||||
"Show information about current TypeSpec compiler.",
|
"Show information about the current TypeSpec compiler.",
|
||||||
() => {},
|
() => {},
|
||||||
withCliHostAndDiagnostics((host) => printInfoAction(host))
|
withCliHostAndDiagnostics((host) => printInfoAction(host))
|
||||||
)
|
)
|
||||||
|
|
|
@ -79,7 +79,7 @@ export function isIntrinsicType(
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated this function is deprecated use decorator definition in typespec instead or check assignability directly.
|
* @deprecated this function is deprecated use decorator definition in TypeSpec instead or check assignability directly.
|
||||||
*/
|
*/
|
||||||
export function validateDecoratorTargetIntrinsic(
|
export function validateDecoratorTargetIntrinsic(
|
||||||
context: DecoratorContext,
|
context: DecoratorContext,
|
||||||
|
@ -113,9 +113,9 @@ export function validateDecoratorTargetIntrinsic(
|
||||||
export const isCadlValueTypeOf = isTypeSpecValueTypeOf;
|
export const isCadlValueTypeOf = isTypeSpecValueTypeOf;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the given target is of any of the typespec types.
|
* Check if the given target is of any of the TypeSpec types.
|
||||||
* @param target Target to validate.
|
* @param target Target to validate.
|
||||||
* @param expectedType One or multiple allowed typespec types.
|
* @param expectedType One or multiple allowed TypeSpec types.
|
||||||
* @returns boolean if the target is of one of the allowed types.
|
* @returns boolean if the target is of one of the allowed types.
|
||||||
*/
|
*/
|
||||||
export function isTypeSpecValueTypeOf<K extends TypeKind>(
|
export function isTypeSpecValueTypeOf<K extends TypeKind>(
|
||||||
|
@ -252,7 +252,7 @@ export interface DecoratorValidator<
|
||||||
export type TypeKind = Type["kind"] | "Any";
|
export type TypeKind = Type["kind"] | "Any";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated use extern dec definition in typespec instead.
|
* @deprecated use extern dec definition in TypeSpec instead.
|
||||||
*/
|
*/
|
||||||
export function createDecoratorDefinition<
|
export function createDecoratorDefinition<
|
||||||
T extends TypeKind,
|
T extends TypeKind,
|
||||||
|
@ -362,7 +362,7 @@ function prettyValue(program: Program, value: any) {
|
||||||
export const cadlTypeToJson = typespecTypeToJson;
|
export const cadlTypeToJson = typespecTypeToJson;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a typespec type to a serializable Json object.
|
* Convert a TypeSpec type to a serializable Json object.
|
||||||
* Emits diagnostics if the given type is invalid
|
* Emits diagnostics if the given type is invalid
|
||||||
* @param typespecType The type to convert to Json data
|
* @param typespecType The type to convert to Json data
|
||||||
* @param target The diagnostic target in case of errors.
|
* @param target The diagnostic target in case of errors.
|
||||||
|
|
|
@ -91,7 +91,7 @@ export async function formatTypeSpecFile(filename: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check the given typespec file is correctly formatted.
|
* Check the given TypeSpec file is correctly formatted.
|
||||||
* @returns true if code is formatted correctly.
|
* @returns true if code is formatted correctly.
|
||||||
*/
|
*/
|
||||||
export async function checkFormatTypeSpecFile(filename: string): Promise<boolean> {
|
export async function checkFormatTypeSpecFile(filename: string): Promise<boolean> {
|
||||||
|
|
|
@ -990,7 +990,7 @@ export async function compile(
|
||||||
// It's important that we use the compiler version that resolves locally
|
// It's important that we use the compiler version that resolves locally
|
||||||
// from the input TypeSpec source location. Otherwise, there will be undefined
|
// from the input TypeSpec source location. Otherwise, there will be undefined
|
||||||
// runtime behavior when decorators and handlers expect a
|
// runtime behavior when decorators and handlers expect a
|
||||||
// different version of typespec than the current one. Abort the compilation
|
// different version of TypeSpec than the current one. Abort the compilation
|
||||||
// with an error if the TypeSpec entry point resolves to a different local
|
// with an error if the TypeSpec entry point resolves to a different local
|
||||||
// compiler.
|
// compiler.
|
||||||
async function checkForCompilerVersionMismatch(mainPath: string): Promise<boolean> {
|
async function checkForCompilerVersionMismatch(mainPath: string): Promise<boolean> {
|
||||||
|
|
|
@ -454,7 +454,7 @@ export function createAssetEmitter<T, TOptions extends object>(
|
||||||
const name = typeEmitter.declarationName(operation);
|
const name = typeEmitter.declarationName(operation);
|
||||||
if (name === undefined) {
|
if (name === undefined) {
|
||||||
// the general approach of invoking the expression form doesn't work here
|
// the general approach of invoking the expression form doesn't work here
|
||||||
// because typespec doesn't have operation expressions.
|
// because TypeSpec doesn't have operation expressions.
|
||||||
compilerAssert(false, "Unnamed operations are not supported");
|
compilerAssert(false, "Unnamed operations are not supported");
|
||||||
}
|
}
|
||||||
return invokeTypeEmitter("interfaceOperationDeclaration", operation, name);
|
return invokeTypeEmitter("interfaceOperationDeclaration", operation, name);
|
||||||
|
|
|
@ -114,7 +114,7 @@ export function printTypeSpec(
|
||||||
const value = needsParens(path, options) ? ["(", printedNode, ")"] : printedNode;
|
const value = needsParens(path, options) ? ["(", printedNode, ")"] : printedNode;
|
||||||
const parts: Doc[] = [docs, directives, value];
|
const parts: Doc[] = [docs, directives, value];
|
||||||
if (node.kind === SyntaxKind.TypeSpecScript) {
|
if (node.kind === SyntaxKind.TypeSpecScript) {
|
||||||
// For TypeSpecScript(root of typespec document) we had a new line at the end.
|
// For TypeSpecScript(root of TypeSpec document) we had a new line at the end.
|
||||||
// This must be done here so the hardline entry can be the last item of the doc array returned by the printer
|
// This must be done here so the hardline entry can be the last item of the doc array returned by the printer
|
||||||
// so the markdown(and other embedded formatter) can omit that extra line.
|
// so the markdown(and other embedded formatter) can omit that extra line.
|
||||||
parts.push(hardline);
|
parts.push(hardline);
|
||||||
|
|
|
@ -19,7 +19,7 @@ function getServiceMap(program: Program): Map<Namespace, Service> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List all the services defined in the typespec program
|
* List all the services defined in the TypeSpec program
|
||||||
* @param program Program
|
* @param program Program
|
||||||
* @returns List of service.
|
* @returns List of service.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
"compilerVersion": "0.52.0"
|
"compilerVersion": "0.52.0"
|
||||||
},
|
},
|
||||||
"rest": {
|
"rest": {
|
||||||
"title": "Generic Rest API",
|
"title": "Generic REST API",
|
||||||
"description": "Create a project representing a generic Rest API",
|
"description": "Create a project representing a generic REST API",
|
||||||
"compilerVersion": "0.52.0",
|
"compilerVersion": "0.52.0",
|
||||||
"libraries": [
|
"libraries": [
|
||||||
"@typespec/http",
|
"@typespec/http",
|
||||||
|
|
|
@ -101,7 +101,7 @@ describe("compiler: global namespace", () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("can override typespec library things", async () => {
|
it("can override TypeSpec library things", async () => {
|
||||||
testHost.addTypeSpecFile("./main.tsp", `@test model int32 { x: TypeSpec.int32 }`);
|
testHost.addTypeSpecFile("./main.tsp", `@test model int32 { x: TypeSpec.int32 }`);
|
||||||
|
|
||||||
const { int32 } = (await testHost.compile("./")) as { int32: Model };
|
const { int32 } = (await testHost.compile("./")) as { int32: Model };
|
||||||
|
|
|
@ -44,7 +44,7 @@ describe("compiler: imports", () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
it("import relative typespec file", async () => {
|
it("import relative TypeSpec file", async () => {
|
||||||
host.addJsFile("blue.js", { $blue() {} });
|
host.addJsFile("blue.js", { $blue() {} });
|
||||||
host.addTypeSpecFile(
|
host.addTypeSpecFile(
|
||||||
"main.tsp",
|
"main.tsp",
|
||||||
|
|
|
@ -348,7 +348,7 @@ describe("compiler: checker: type relations", () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Need to handle bigint in typespec. https://github.com/Azure/typespec-azure/issues/506
|
// Need to handle bigint in TypeSpec. https://github.com/Azure/typespec-azure/issues/506
|
||||||
describe.skip("int64 target", () => {
|
describe.skip("int64 target", () => {
|
||||||
it("can assign int64", async () => {
|
it("can assign int64", async () => {
|
||||||
await expectTypeAssignable({ source: "int64", target: "int64" });
|
await expectTypeAssignable({ source: "int64", target: "int64" });
|
||||||
|
|
|
@ -62,7 +62,7 @@ describe("compiler: projected-names", () => {
|
||||||
strictEqual(jsonView.getProjectedName(expireAtCSProjected), "exp");
|
strictEqual(jsonView.getProjectedName(expireAtCSProjected), "exp");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("if another projection renamed the typespec type it should be taken into account by getProjectedName", async () => {
|
it("if another projection renamed the TypeSpec type it should be taken into account by getProjectedName", async () => {
|
||||||
const { expireAt } = (await runner.compile(`
|
const { expireAt } = (await runner.compile(`
|
||||||
model Foo {
|
model Foo {
|
||||||
@test expireAt: int32;
|
@test expireAt: int32;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "@typespec/eslint-config-typespec",
|
"name": "@typespec/eslint-config-typespec",
|
||||||
"version": "0.52.0",
|
"version": "0.52.0",
|
||||||
"description": "ESLint config for typespec packages",
|
"description": "ESLint config for TypeSpec packages",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
|
@ -29,8 +29,8 @@ Available ruleSets:
|
||||||
### Rules
|
### Rules
|
||||||
|
|
||||||
| Name | Description |
|
| Name | Description |
|
||||||
| --------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
|
| --------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
|
||||||
| [`@typespec/http/op-reference-container-route`](https://microsoft.github.io/typespec/libraries/http/rules/op-reference-container-route) | Check for referenced (`op is`) operations which have a @route on one of their containers. |
|
| [`@typespec/http/op-reference-container-route`](https://typespec.io/docs/libraries/http/rules/op-reference-container-route) | Check for referenced (`op is`) operations which have a @route on one of their containers. |
|
||||||
|
|
||||||
## Decorators
|
## Decorators
|
||||||
|
|
||||||
|
@ -447,7 +447,7 @@ op create(): {@statusCode: 201 | 202}
|
||||||
|
|
||||||
#### `@useAuth`
|
#### `@useAuth`
|
||||||
|
|
||||||
Specify this service authentication. See the [documentation in the Http library](https://microsoft.github.io/typespec/libraries/http/authentication) for full details.
|
Specify this service authentication. See the [documentation in the Http library](https://typespec.io/docs/libraries/http/authentication) for full details.
|
||||||
|
|
||||||
```typespec
|
```typespec
|
||||||
@TypeSpec.Http.useAuth(auth: {} | Union | {}[])
|
@TypeSpec.Http.useAuth(auth: {} | Union | {}[])
|
||||||
|
@ -460,8 +460,8 @@ Specify this service authentication. See the [documentation in the Http library]
|
||||||
##### Parameters
|
##### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| ---- | --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| ---- | --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| auth | `union {} \| Union \| {}[]` | Authentication configuration. Can be a single security scheme, a union(either option is valid authentication) or a tuple(Must use all authentication together) |
|
| auth | `union {} \| Union \| {}[]` | Authentication configuration. Can be a single security scheme, a union(either option is valid authentication) or a tuple (must use all authentication together) |
|
||||||
|
|
||||||
##### Examples
|
##### Examples
|
||||||
|
|
||||||
|
|
|
@ -202,9 +202,9 @@ extern dec server(
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify this service authentication. See the [documentation in the Http library](https://microsoft.github.io/typespec/libraries/http/authentication) for full details.
|
* Specify this service authentication. See the [documentation in the Http library](https://typespec.io/docs/libraries/http/authentication) for full details.
|
||||||
*
|
*
|
||||||
* @param auth Authentication configuration. Can be a single security scheme, a union(either option is valid authentication) or a tuple(Must use all authentication together)
|
* @param auth Authentication configuration. Can be a single security scheme, a union(either option is valid authentication) or a tuple (must use all authentication together)
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* ```typespec
|
* ```typespec
|
||||||
|
|
|
@ -359,7 +359,7 @@ export interface HttpServer {
|
||||||
/**
|
/**
|
||||||
* Configure the server url for the service.
|
* Configure the server url for the service.
|
||||||
* @param context Decorator context
|
* @param context Decorator context
|
||||||
* @param target Decorator target(Must be a namespace)
|
* @param target Decorator target (must be a namespace)
|
||||||
* @param description Description for this server.
|
* @param description Description for this server.
|
||||||
* @param parameters @optional Parameters to interpolate in the server url.
|
* @param parameters @optional Parameters to interpolate in the server url.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -7,7 +7,7 @@ export const opReferenceContainerRouteRule = createRule({
|
||||||
severity: "warning",
|
severity: "warning",
|
||||||
description:
|
description:
|
||||||
"Check for referenced (`op is`) operations which have a @route on one of their containers.",
|
"Check for referenced (`op is`) operations which have a @route on one of their containers.",
|
||||||
url: "https://microsoft.github.io/typespec/libraries/http/rules/op-reference-container-route",
|
url: "https://typespec.io/docs/libraries/http/rules/op-reference-container-route",
|
||||||
messages: {
|
messages: {
|
||||||
default: paramMessage`Operation ${"opName"} references an operation which has a @route prefix on its namespace or interface: "${"routePrefix"}". This operation will not carry forward the route prefix so the final route may be different than the referenced operation.`,
|
default: paramMessage`Operation ${"opName"} references an operation which has a @route prefix on its namespace or interface: "${"routePrefix"}". This operation will not carry forward the route prefix so the final route may be different than the referenced operation.`,
|
||||||
},
|
},
|
||||||
|
|
|
@ -336,7 +336,7 @@ export interface HttpOperationResponse {
|
||||||
statusCodes: HttpStatusCodeRange | number | "*";
|
statusCodes: HttpStatusCodeRange | number | "*";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Response typespec type.
|
* Response TypeSpec type.
|
||||||
*/
|
*/
|
||||||
type: Type;
|
type: Type;
|
||||||
|
|
||||||
|
|
|
@ -10,15 +10,15 @@ npm install -D @typespec/library-linter
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Compile your library package. Any errors or warnings will be reported as typespec diagnostics.
|
Compile your library package. Any errors or warnings will be reported as TypeSpec diagnostics.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# At the root of your typespec library.
|
# At the root of your TypeSpec library.
|
||||||
tsp compile . --import @typespec/library-linter
|
tsp compile . --import @typespec/library-linter
|
||||||
```
|
```
|
||||||
|
|
||||||
## TypeSpec Library Best rules and best practices
|
## TypeSpec Library Best rules and best practices
|
||||||
|
|
||||||
| Rule name | Description |
|
| Rule name | Description |
|
||||||
| ------------------- | ---------------------------------------------------------------------------------------------------------------- |
|
| ------------------- | ----------------------------------------------------------------------------------------------------------------- |
|
||||||
| `missing-namespace` | Validate that every exported element from the library(Models, JS functions, operations, etc.) is in a namespace. |
|
| `missing-namespace` | Validate that every exported element from the library (models, JS functions, operations, etc.) is in a namespace. |
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { OpenAPI3Schema } from "../src/types.js";
|
||||||
import { oapiForModel } from "./test-host.js";
|
import { oapiForModel } from "./test-host.js";
|
||||||
|
|
||||||
describe("openapi3: primitives", () => {
|
describe("openapi3: primitives", () => {
|
||||||
describe("handle typespec intrinsic types", () => {
|
describe("handle TypeSpec intrinsic types", () => {
|
||||||
const cases = [
|
const cases = [
|
||||||
["unknown", {}],
|
["unknown", {}],
|
||||||
["numeric", { type: "number" }],
|
["numeric", { type: "number" }],
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
# Bundle and use local version of typespec libraries
|
# Bundle and use local version of TypeSpec libraries
|
||||||
VITE_USE_LOCAL_LIBRARIES=true
|
VITE_USE_LOCAL_LIBRARIES=true
|
||||||
|
|
|
@ -15,6 +15,6 @@ To change the default configuration add a `.env.local` file in the root of this
|
||||||
The following environment variables are available:
|
The following environment variables are available:
|
||||||
|
|
||||||
```.env
|
```.env
|
||||||
# Bundle and use local version of typespec libraries
|
# Bundle and use local version of TypeSpec libraries
|
||||||
VITE_USE_LOCAL_LIBRARIES=true
|
VITE_USE_LOCAL_LIBRARIES=true
|
||||||
```
|
```
|
||||||
|
|
|
@ -61,8 +61,8 @@ await renderReactPlayground({
|
||||||
|
|
||||||
### Individual components
|
### Individual components
|
||||||
|
|
||||||
Playground react components can be used individually. The things to watch out for is for the TypeSpec compiler to be working correctly it needs:
|
Playground react components can be used individually. For the TypeSpec compiler to be working correctly, the following conditions need to be met:
|
||||||
|
|
||||||
- The libraries to be loaded and registered
|
- The libraries **MUST** be loaded and registered
|
||||||
- The libraries **MUST** be importable by their name this means an import map must be setup. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap
|
- The libraries **MUST** be importable by their name this means an import map must be setup. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap
|
||||||
- The libraries **MUST** have been bundled using `@typespec/bundler`
|
- The libraries **MUST** have been bundled using `@typespec/bundler`
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
- **Using node 14 and above**
|
- **Using Node 14 and above**
|
||||||
- For use in **VSCode**, use version `VSCode 1.56` and above.
|
- For use in **VSCode**, use version `VSCode 1.56` and above.
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"name": "@typespec/tspd",
|
"name": "@typespec/tspd",
|
||||||
"version": "0.46.0",
|
"version": "0.46.0",
|
||||||
"author": "Microsoft Corporation",
|
"author": "Microsoft Corporation",
|
||||||
"description": "TypeSpec library for generating typespec docs",
|
"description": "TypeSpec library for generating TypeSpec docs",
|
||||||
"homepage": "https://microsoft.github.io/typespec",
|
"homepage": "https://microsoft.github.io/typespec",
|
||||||
"readme": "https://github.com/microsoft/typespec/blob/main/README.md",
|
"readme": "https://github.com/microsoft/typespec/blob/main/README.md",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|
|
@ -27,7 +27,7 @@ export async function generateJsApiDocs(libraryPath: string, outputDir: string)
|
||||||
load(app);
|
load(app);
|
||||||
|
|
||||||
setOptions(app, {
|
setOptions(app, {
|
||||||
name: "JS Api",
|
name: "JS API",
|
||||||
githubPages: false,
|
githubPages: false,
|
||||||
readme: "none",
|
readme: "none",
|
||||||
hideGenerator: true,
|
hideGenerator: true,
|
||||||
|
@ -47,7 +47,7 @@ export async function generateJsApiDocs(libraryPath: string, outputDir: string)
|
||||||
await writeFile(
|
await writeFile(
|
||||||
joinPaths(outputDir, "_category_.json"),
|
joinPaths(outputDir, "_category_.json"),
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
label: "JS Api",
|
label: "JS API",
|
||||||
link: {
|
link: {
|
||||||
type: "doc",
|
type: "doc",
|
||||||
id: "index",
|
id: "index",
|
||||||
|
|
|
@ -27,9 +27,9 @@ namespace Microsoft.TypeSpec.VisualStudio
|
||||||
: base(string.Join("\n", new string[]
|
: base(string.Join("\n", new string[]
|
||||||
{
|
{
|
||||||
$"TypeSpec server executable was not found: '{fileName}' is not found. Make sure either:",
|
$"TypeSpec server executable was not found: '{fileName}' is not found. Make sure either:",
|
||||||
" - typespec is installed locally at the root of this workspace or in a parent directory.",
|
" - TypeSpec is installed locally at the root of this workspace or in a parent directory.",
|
||||||
" - typespec is installed globally with `npm install -g @typespec/compiler'.",
|
" - TypeSpec is installed globally with `npm install -g @typespec/compiler'.",
|
||||||
" - typespec server path is configured with https://github.com/microsoft/typespec/blob/main/packages/typespec-vs/README.md#configure-typespec-visual-studio-extension."
|
" - TypeSpec server path is configured with https://github.com/microsoft/typespec/blob/main/packages/typespec-vs/README.md#configure-typespec-visual-studio-extension."
|
||||||
}), innerException)
|
}), innerException)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,9 +64,9 @@ async function launchLanguageClient(context: ExtensionContext) {
|
||||||
client?.error(
|
client?.error(
|
||||||
[
|
[
|
||||||
`TypeSpec server executable was not found: '${exe.command}' is not found. Make sure either:`,
|
`TypeSpec server executable was not found: '${exe.command}' is not found. Make sure either:`,
|
||||||
` - typespec is installed locally at the root of this workspace ("${workspaceFolder}") or in a parent directory.`,
|
` - TypeSpec is installed locally at the root of this workspace ("${workspaceFolder}") or in a parent directory.`,
|
||||||
" - typespec is installed globally with `npm install -g @typespec/compiler'.",
|
" - TypeSpec is installed globally with `npm install -g @typespec/compiler'.",
|
||||||
" - typespec server path is configured with https://github.com/microsoft/typespec#installing-vs-code-extension.",
|
" - TypeSpec server path is configured with https://github.com/microsoft/typespec#installing-vs-code-extension.",
|
||||||
].join("\n"),
|
].join("\n"),
|
||||||
undefined,
|
undefined,
|
||||||
false
|
false
|
||||||
|
|
|
@ -355,7 +355,7 @@ importers:
|
||||||
version: 6.16.0(eslint@8.56.0)(typescript@5.3.3)
|
version: 6.16.0(eslint@8.56.0)(typescript@5.3.3)
|
||||||
'@typescript-eslint/rule-tester':
|
'@typescript-eslint/rule-tester':
|
||||||
specifier: ~6.14.0
|
specifier: ~6.14.0
|
||||||
version: 6.14.0(@eslint/eslintrc@3.0.0)(eslint@8.56.0)(typescript@5.3.3)
|
version: 6.14.0(@eslint/eslintrc@2.1.4)(eslint@8.56.0)(typescript@5.3.3)
|
||||||
'@typespec/eslint-config-typespec':
|
'@typespec/eslint-config-typespec':
|
||||||
specifier: workspace:~0.52.0
|
specifier: workspace:~0.52.0
|
||||||
version: link:../eslint-config-typespec
|
version: link:../eslint-config-typespec
|
||||||
|
@ -992,7 +992,7 @@ importers:
|
||||||
version: 4.9.1
|
version: 4.9.1
|
||||||
vitest:
|
vitest:
|
||||||
specifier: ^1.2.0
|
specifier: ^1.2.0
|
||||||
version: 1.2.1
|
version: 1.2.1(@types/node@18.11.19)(@vitest/ui@1.1.3)
|
||||||
|
|
||||||
packages/protobuf:
|
packages/protobuf:
|
||||||
devDependencies:
|
devDependencies:
|
||||||
|
@ -4771,23 +4771,6 @@ packages:
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
/@eslint/eslintrc@3.0.0:
|
|
||||||
resolution: {integrity: sha512-R8p3jN1kdWvFRiRfgpUxZ4PMgfJJFt6NuLGDnnqLb7RKmsd5Xa0KqRMjmaqRO7e38ZbG/9zKPgDjeJeqsDofSA==}
|
|
||||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
|
||||||
dependencies:
|
|
||||||
ajv: 6.12.6
|
|
||||||
debug: 4.3.4
|
|
||||||
espree: 9.6.1
|
|
||||||
globals: 13.24.0
|
|
||||||
ignore: 5.3.0
|
|
||||||
import-fresh: 3.3.0
|
|
||||||
js-yaml: 4.1.0
|
|
||||||
minimatch: 3.1.2
|
|
||||||
strip-json-comments: 3.1.1
|
|
||||||
transitivePeerDependencies:
|
|
||||||
- supports-color
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/@eslint/js@8.56.0:
|
/@eslint/js@8.56.0:
|
||||||
resolution: {integrity: sha512-gMsVel9D7f2HLkBma9VbtzZRehRogVRfbr++f06nL2vnCGCNlzOD+/MUov/F4p8myyAHspEhVobgjpX64q5m6A==}
|
resolution: {integrity: sha512-gMsVel9D7f2HLkBma9VbtzZRehRogVRfbr++f06nL2vnCGCNlzOD+/MUov/F4p8myyAHspEhVobgjpX64q5m6A==}
|
||||||
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
|
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
|
||||||
|
@ -8179,14 +8162,14 @@ packages:
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
/@typescript-eslint/rule-tester@6.14.0(@eslint/eslintrc@3.0.0)(eslint@8.56.0)(typescript@5.3.3):
|
/@typescript-eslint/rule-tester@6.14.0(@eslint/eslintrc@2.1.4)(eslint@8.56.0)(typescript@5.3.3):
|
||||||
resolution: {integrity: sha512-SCxrm68pudpNTUGCqaGxgqNujca+sEjJXA52gH3b0q1DrVBq1VSlxgO9kSmodhbXKVyS7UGlbz3dPDqa65gR2g==}
|
resolution: {integrity: sha512-SCxrm68pudpNTUGCqaGxgqNujca+sEjJXA52gH3b0q1DrVBq1VSlxgO9kSmodhbXKVyS7UGlbz3dPDqa65gR2g==}
|
||||||
engines: {node: ^16.0.0 || >=18.0.0}
|
engines: {node: ^16.0.0 || >=18.0.0}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
'@eslint/eslintrc': '>=2'
|
'@eslint/eslintrc': '>=2'
|
||||||
eslint: '>=8'
|
eslint: '>=8'
|
||||||
dependencies:
|
dependencies:
|
||||||
'@eslint/eslintrc': 3.0.0
|
'@eslint/eslintrc': 2.1.4
|
||||||
'@typescript-eslint/typescript-estree': 6.14.0(typescript@5.3.3)
|
'@typescript-eslint/typescript-estree': 6.14.0(typescript@5.3.3)
|
||||||
'@typescript-eslint/utils': 6.14.0(eslint@8.56.0)(typescript@5.3.3)
|
'@typescript-eslint/utils': 6.14.0(eslint@8.56.0)(typescript@5.3.3)
|
||||||
ajv: 6.12.6
|
ajv: 6.12.6
|
||||||
|
@ -19005,62 +18988,6 @@ packages:
|
||||||
- supports-color
|
- supports-color
|
||||||
- terser
|
- terser
|
||||||
|
|
||||||
/vitest@1.2.1:
|
|
||||||
resolution: {integrity: sha512-TRph8N8rnSDa5M2wKWJCMnztCZS9cDcgVTQ6tsTFTG/odHJ4l5yNVqvbeDJYJRZ6is3uxaEpFs8LL6QM+YFSdA==}
|
|
||||||
engines: {node: ^18.0.0 || >=20.0.0}
|
|
||||||
hasBin: true
|
|
||||||
peerDependencies:
|
|
||||||
'@edge-runtime/vm': '*'
|
|
||||||
'@types/node': ^18.0.0 || >=20.0.0
|
|
||||||
'@vitest/browser': ^1.0.0
|
|
||||||
'@vitest/ui': ^1.0.0
|
|
||||||
happy-dom: '*'
|
|
||||||
jsdom: '*'
|
|
||||||
peerDependenciesMeta:
|
|
||||||
'@edge-runtime/vm':
|
|
||||||
optional: true
|
|
||||||
'@types/node':
|
|
||||||
optional: true
|
|
||||||
'@vitest/browser':
|
|
||||||
optional: true
|
|
||||||
'@vitest/ui':
|
|
||||||
optional: true
|
|
||||||
happy-dom:
|
|
||||||
optional: true
|
|
||||||
jsdom:
|
|
||||||
optional: true
|
|
||||||
dependencies:
|
|
||||||
'@vitest/expect': 1.2.1
|
|
||||||
'@vitest/runner': 1.2.1
|
|
||||||
'@vitest/snapshot': 1.2.1
|
|
||||||
'@vitest/spy': 1.2.1
|
|
||||||
'@vitest/utils': 1.2.1
|
|
||||||
acorn-walk: 8.3.2
|
|
||||||
cac: 6.7.14
|
|
||||||
chai: 4.3.10
|
|
||||||
debug: 4.3.4
|
|
||||||
execa: 8.0.1
|
|
||||||
local-pkg: 0.5.0
|
|
||||||
magic-string: 0.30.5
|
|
||||||
pathe: 1.1.1
|
|
||||||
picocolors: 1.0.0
|
|
||||||
std-env: 3.7.0
|
|
||||||
strip-literal: 1.3.0
|
|
||||||
tinybench: 2.5.1
|
|
||||||
tinypool: 0.8.1
|
|
||||||
vite: 5.0.12(@types/node@18.11.19)
|
|
||||||
vite-node: 1.2.1(@types/node@18.11.19)
|
|
||||||
why-is-node-running: 2.2.2
|
|
||||||
transitivePeerDependencies:
|
|
||||||
- less
|
|
||||||
- lightningcss
|
|
||||||
- sass
|
|
||||||
- stylus
|
|
||||||
- sugarss
|
|
||||||
- supports-color
|
|
||||||
- terser
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/vitest@1.2.1(@types/node@18.11.19)(@vitest/ui@1.1.3):
|
/vitest@1.2.1(@types/node@18.11.19)(@vitest/ui@1.1.3):
|
||||||
resolution: {integrity: sha512-TRph8N8rnSDa5M2wKWJCMnztCZS9cDcgVTQ6tsTFTG/odHJ4l5yNVqvbeDJYJRZ6is3uxaEpFs8LL6QM+YFSdA==}
|
resolution: {integrity: sha512-TRph8N8rnSDa5M2wKWJCMnztCZS9cDcgVTQ6tsTFTG/odHJ4l5yNVqvbeDJYJRZ6is3uxaEpFs8LL6QM+YFSdA==}
|
||||||
engines: {node: ^18.0.0 || >=20.0.0}
|
engines: {node: ^18.0.0 || >=20.0.0}
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
"shouldPublish": false
|
"shouldPublish": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// TMLanguage generator not in an @scope because it is neither typespec nor azure-specific.
|
// TMLanguage generator not in an @scope because it is neither TypeSpec nor azure-specific.
|
||||||
// Eventually, it should be split off into its own repo
|
// Eventually, it should be split off into its own repo
|
||||||
"packageName": "tmlanguage-generator",
|
"packageName": "tmlanguage-generator",
|
||||||
"projectFolder": "packages/tmlanguage-generator",
|
"projectFolder": "packages/tmlanguage-generator",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
export default ["packages/*/vitest.config.ts", "packages/*/vitest.config.mts"];
|
export default ["packages/*/vitest.config.ts", "packages/*/vitest.config.mts"];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Config For all typespec projects using vitest.
|
* Default Config For all TypeSpec projects using vitest.
|
||||||
*/
|
*/
|
||||||
export const defaultTypeSpecVitestConfig = {
|
export const defaultTypeSpecVitestConfig = {
|
||||||
test: {
|
test: {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче