castle
castle copied to clipboard
Incorrect Import Statement and Type Declaration in External Example
I'm currently working with the external example in the repository.
Upon executing the script, I encountered the following output:
DeprecationWarning: 'createPropertySignature' has been deprecated since v4.0.0. Use the appropriate method on 'ts.factory' or the 'factory' supplied by your transformation context instead.
DeprecationWarning: 'createInterfaceDeclaration' has been deprecated since v4.8.0. Decorators are no longer supported for this function. Callers should switch to an overload that does not accept a 'decorators' parameter.
DeprecationWarning: 'createTypeAliasDeclaration' has been deprecated since v4.8.0. Decorators are no longer supported for this function. Callers should switch to an overload that does not accept a 'decorators' parameter.
DeprecationWarning: 'createModuleDeclaration' has been deprecated since v4.8.0. Decorators are no longer supported for this function. Callers should switch to an overload that does not accept a 'decorators' parameter.
DeprecationWarning: 'createImportClause' has been deprecated since v4.0.0. Use the appropriate method on 'ts.factory' or the 'factory' supplied by your transformation context instead.
DeprecationWarning: 'createImportDeclaration' has been deprecated since v4.8.0. Decorators are no longer supported for this function. Callers should switch to an overload that does not accept a 'decorators' parameter.
/* eslint-disable @typescript-eslint/no-namespace */
import { type MyNamespaceDataAddress as } from "./external-Address";
export type CreateUser = MyNamespaceMessages.CreateUser;
export namespace MyNamespaceMessages {
export const CreateUserSchema = "{\"type\":\"record\",\"name\":\"CreateUser\",\"namespace\":\"my.namespace.messages\",\"fields\":[{\"name\":\"userId\",\"type\":\"string\",\"logicalType\":\"uuid\"},{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"address\",\"type\":\"my.namespace.data.Address\"}]}";
export const CreateUserName = "my.namespace.messages.CreateUser";
export interface CreateUser {
userId: string;
name: string;
address: MyNamespaceDataAddress.Address;
}
}
There are two issues identified in the output:
- The import statement
import { type MyNamespaceDataAddress as } from "./external-Address";
is incorrect and should be replaced withimport { type MyNamespaceData } from "./external-Address";
. - The type of
address
in theCreateUser
interface is declared asMyNamespaceDataAddress.Address
, but it should beMyNamespaceData.Address
.
/* eslint-disable @typescript-eslint/no-namespace */
import { type MyNamespaceData } from "./external-Address";
export type CreateUser = MyNamespaceMessages.CreateUser;
export namespace MyNamespaceMessages {
export const CreateUserSchema = "{\"type\":\"record\",\"name\":\"CreateUser\",\"namespace\":\"my.namespace.messages\",\"fields\":[{\"name\":\"userId\",\"type\":\"string\",\"logicalType\":\"uuid\"},{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"address\",\"type\":\"my.namespace.data.Address\"}]}";
export const CreateUserName = "my.namespace.messages.CreateUser";
export interface CreateUser {
userId: string;
name: string;
address: MyNamespaceData.Address;
}
}
These corrections would ensure the code functions as intended.
Node version: v18.19.0 Typescript version: 5.4.2 Using default tsconfig