Skip to content

SSDK Codegen Produces Circular Import #1736

Description

@Miles123K

In build\smithy\source\typescript-server-codegen\src\server\operations the generated SSDK code attempts to import types defined in the files themselves. For example, in a file named GetProperty.ts it will generate imports:

import {
  GetProperty,
  GetPropertyErrors,
  GetPropertyServerInput,
  GetPropertyServerOutput,
} from "./GetProperty";

Content of main.smithy

$version: "2"

namespace flux.core

use flux.core.exception#AccessDeniedException
use flux.core.exception#InternalServerException
use flux.core.property#GetProperty
use smithy.framework#ValidationException

service FluxCore {
    version: "1.0.0"
    resources: []
    operations: [
        GetProperty
    ]
    errors: [
        ValidationException
        AccessDeniedException
        InternalServerException
    ]
}

Snippet from property.smithy

structure GetPropertyInput {
    @required
    @httpLabel
    propertyId: String
}

structure GetPropertyOutput {
    @required
    property: Property
}

/// Get a property by its ID
@readonly
@http(method: "GET", uri: "/properties/{propertyId}")
operation GetProperty {
    input: GetPropertyInput
    output: GetPropertyOutput
    errors: [
        ResourceNotFoundException
    ]
}

Build command fails with

[build:types] src/server/operations/GetProperty.ts(12,3): error TS2440: Import declaration conflicts with local declaration of 'GetProperty'.    
[build:types] src/server/operations/GetProperty.ts(13,3): error TS2440: Import declaration conflicts with local declaration of 'GetPropertyErrors'.
[build:types] src/server/operations/GetProperty.ts(14,3): error TS2395: Individual declarations in merged declaration 'GetPropertyServerInput' must be all exported or all local.
[build:types] src/server/operations/GetProperty.ts(14,3): error TS2440: Import declaration conflicts with local declaration of 'GetPropertyServerInput'.
[build:types] src/server/operations/GetProperty.ts(15,3): error TS2440: Import declaration conflicts with local declaration of 'GetPropertyServerOutput'.
[build:types] src/server/operations/GetProperty.ts(55,18): error TS2395: Individual declarations in merged declaration 'GetPropertyServerInput' must be all exported or all local.
Done in 2.00s.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[build:types] error Command failed with exit code 2.
[build:es] yarn run build:es exited with code 0
[build:types] yarn run build:types exited with code 2
error: script "build" exited with code 1
smithy --version
1.62.0

OS Name:                       Microsoft Windows 11 Home
OS Version:                    10.0.26100 N/A Build 26100
System Type:                   x64-based PC

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions