Skip to content

Commit

Permalink
Include type in generated extern dec (#3250)
Browse files Browse the repository at this point in the history
This allows us to use `verbatimModuleSyntax: true`
  • Loading branch information
timotheeguerin authored Apr 29, 2024
1 parent d3a4454 commit 5757fd1
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 11 deletions.
16 changes: 16 additions & 0 deletions .chronus/changes/extern-dec-type-2024-3-29-19-9-6.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking
changeKind: internal
packages:
- "@typespec/compiler"
- "@typespec/http"
- "@typespec/json-schema"
- "@typespec/openapi"
- "@typespec/openapi3"
- "@typespec/protobuf"
- "@typespec/rest"
- "@typespec/versioning"
- "@typespec/xml"
---

Include `type` in generated extern dec
2 changes: 1 addition & 1 deletion packages/compiler/generated-defs/TypeSpec.ts-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {
$withoutDefaultValues,
$withoutOmittedProperties,
} from "../src/index.js";
import {
import type {
DeprecatedDecorator,
DiscriminatorDecorator,
DocDecorator,
Expand Down
2 changes: 1 addition & 1 deletion packages/http/generated-defs/TypeSpec.Http.ts-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
$statusCode,
$useAuth,
} from "@typespec/http";
import {
import type {
BodyDecorator,
BodyIgnoreDecorator,
BodyRootDecorator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
$prefixItems,
$uniqueItems,
} from "@typespec/json-schema";
import {
import type {
BaseUriDecorator,
ContainsDecorator,
ContentEncodingDecorator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
$info,
$operationId,
} from "@typespec/openapi";
import {
import type {
DefaultResponseDecorator,
ExtensionDecorator,
ExternalDocsDecorator,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** An error here would mean that the decorator is not exported or doesn't have the right name. */
import { $oneOf, $useRef } from "@typespec/openapi3";
import { OneOfDecorator, UseRefDecorator } from "./TypeSpec.OpenAPI.js";
import type { OneOfDecorator, UseRefDecorator } from "./TypeSpec.OpenAPI.js";

type Decorators = {
$oneOf: OneOfDecorator;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** An error here would mean that the decorator is not exported or doesn't have the right name. */
import { $field, $message, $package, $reserve, $service, $stream } from "@typespec/protobuf";
import {
import type {
FieldDecorator,
MessageDecorator,
PackageDecorator,
Expand Down
2 changes: 1 addition & 1 deletion packages/rest/generated-defs/TypeSpec.Rest.ts-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
$segmentOf,
$updatesResource,
} from "@typespec/rest";
import {
import type {
ActionDecorator,
ActionSeparatorDecorator,
AutoRouteDecorator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function generateSignatureTests(
]);

content.push([
"import {",
"import type {",
decorators.map((x) => x.typeName).join(","),
`} from "`,
decoratorSignatureImport,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
$useDependency,
$versioned,
} from "@typespec/versioning";
import {
import type {
AddedDecorator,
MadeOptionalDecorator,
RemovedDecorator,
Expand Down
2 changes: 1 addition & 1 deletion packages/xml/generated-defs/TypeSpec.Xml.ts-test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** An error here would mean that the decorator is not exported or doesn't have the right name. */
import { $attribute, $name, $ns, $nsDeclarations, $unwrapped } from "@typespec/xml";
import {
import type {
AttributeDecorator,
NameDecorator,
NsDeclarationsDecorator,
Expand Down
2 changes: 1 addition & 1 deletion packages/xml/src/testing/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
createTestLibrary,
findTestPackageRoot,
TypeSpecTestLibrary,
type TypeSpecTestLibrary,
} from "@typespec/compiler/testing";

export const XmlTestLibrary: TypeSpecTestLibrary = createTestLibrary({
Expand Down
1 change: 1 addition & 0 deletions packages/xml/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"outDir": "dist",
"rootDir": ".",
"tsBuildInfoFile": "temp/tsconfig.tsbuildinfo",
"verbatimModuleSyntax": true,
"lib": ["DOM", "ESNext"]
},
"include": ["src/**/*.ts", "generated-defs/**/*.ts", "test/**/*.ts"]
Expand Down

0 comments on commit 5757fd1

Please sign in to comment.