An experimental TypeSpec emitter for TypeScript RLC
npm install @azure-tools/typespec-ts- Via the command line
tsp compile . --emit=@azure-tools/typespec-ts- Via the config
emit:
- "@azure-tools/typespec-ts"The config can be extended with options as follows:
emit:
- "@azure-tools/typespec-ts"
options:
"@azure-tools/typespec-ts":
option: valueType: absolutePath
Defines the emitter output directory. Defaults to {output-dir}/@azure-tools/typespec-ts
See Configuring output directory for more info
Type: boolean
Deprecated option for RLC legacy generation.
Type: boolean
Deprecated option for RLC legacy generation.
Type: array
Deprecated option for RLC legacy generation.
Type: object
This is to indicate the package information such as package name, package description etc.
Type: boolean
We support two types of authentication: Azure Key Credential(AzureKey) and Token credential(AADToken), any other will need to be handled manually.
There are two ways to set up our credential details
- To use `@useAuth` decorator in TypeSpec
- To config in yaml file
Please notice defining in TypeSpec is recommended and also has higher priority than second one.
To enable credential in `tspconfig.yaml` and we need to provide more details to let codegen know types.
Type: array
If we enable the option add-credentials and specify credential-scopes the details we would enable the AADToken authentication.
Type: string
If we enable the option add-credentials and specify credential-key-header-name the details we would enable the AzureKey authentication.
Type: string
This option is used for special Key Auth, when the key has a shared prefix and this header is to set the header name
Type: string
This option is used for special Key Auth, when the key has a shared prefix and this header is to pass the rest of the header key.
Type: boolean
Whether to generate metadata files which includes package.json, README.md and tsconfig.json etc. Defaults to `undefined`. If there's not a package.json under package-dir, defaults to `true`. but if you'd like to disable this feature you could set it as `false`.
Type: boolean
Whether to generate test files, for basic testing of your generated sdks. Defaults to `undefined`.
other cases:
- If azure-sdk-for-js is `false`. Defaults to `false`.
- If azure-sdk-for-js is `true` but there's a test folder under package-dir. Defaults to `false`.
- If azure-sdk-for-js is `true` but there's not a test folder under package-dir. Defaults to `true`.
Type: boolean
Whether to generate sample files, for basic samples of your generated sdks. Defaults to undefined. Management packages' default to true.
Type: boolean
This is used to indicate your project is generated in azure-sdk-for-js repo or not. If your package is located in that repo we'll leverage dev-tool to accelerate our building and testing, however if not we'll remove the dependency for that tool. Defaults to undefined. Services with Flavor equal to 'Azure' default to 'true'.
Type: string
Deprecated option for RLC legacy generation
Type: boolean
Internal option for test
Type: string
Deprecated option for RLC legacy generation.
Type: object
Deprecated option for RLC legacy generation.
Type: string
Deprecated option for RLC legacy generation.
Type: object
Deprecated option for RLC legacy generation.
Type: boolean
Whether the package is an arm package.
Type: string
Internal option, the value is default for TypeSpec generation
Type: boolean
Whether to generate a Modular library. Defaults to false. Arm packages default to true.
Type: boolean
An option to treat interface as operation group. This is not recommended unless specifically told so
Type: boolean
Provides an option to add the model namespace to model names in case of conflicts across different namespaces. This approach is generally discouraged unless explicitly required.
Type: boolean
An option to organize the client in a hierarchical way as defined by @clientInitialization. This is true by default.
Type: boolean
A section of flavor
Type: string
The flavor of the SDK.
Type: "esm" | "cjs"
Internal option for test.
Type: boolean
Whether to affect the generation of the additional property feature for the Modular client. Defaults to false.
Type: boolean
Whether to transform union type enums to extensible enums
Type: boolean
Determine whether to clear the entire output folder. By default, only the 'sources' folder is cleared, so metadata files at the project root remain untouched. This option can be useful in pipeline scenarios.
Type: boolean
The emitter will use camel case to normalize the property name, to ignore this normalization, you can set this option to true
Type: boolean
The emitter has a normalization logic for enum member key, to ignore this normalization, you can set this option to true
Type: boolean
Whether to generate the backward-compatible code for query parameter serialization for array types in RLC. Defaults to false
Type: boolean
Deprecated option for RLC legacy generation.
Type: object
Only for Modular generation
By default, code generation uses the titles specified in the @client and @service decorators in TypeSpec to name modular clients. If you need to override these names, you can configure the typespec-title-map. The map's keys represent the original client names from TypeSpec, and the values are the desired client names. This configuration supports renaming multiple clients.
```yaml
typespec-title-map:
AnomalyDetectorClient: AnomalyDetectorRest
AnomalyDetectorClient2: AnomalyDetectorRest2
```
Type: boolean
Internal option for test.