Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Oct 13, 2025

This PR updates the create-adapter templates to use the modern @iobroker/types package instead of the deprecated @types/iobroker package.

Changes

The implementation follows the pattern used in @iobroker/adapter-core to ensure 100% compatibility with the existing approach:

1. Package Dependency

Added @iobroker/types as a devDependency using npm alias syntax in generated package.json:

"@types/iobroker": "npm:@iobroker/types@^7.0.7"

This alias ensures that IDEs and TypeScript treat it like a real @types package, providing seamless type discovery without requiring any changes to existing imports or type references.

The package is automatically included for:

  • TypeScript adapters
  • JavaScript adapters with type checking enabled

2. Documentation Comments

Updated all comments in generated adapter-config.d.ts files from:

// This file extends the AdapterConfig type from "@types/iobroker"

to:

// This file extends the AdapterConfig type from "@iobroker/types"

3. Dependency Sorting

Added alphabetic sorting for devDependencies with all @-scoped packages appearing first, followed by regular packages. This ensures consistent and predictable package.json formatting across all generated adapters.

4. Test Baselines

Regenerated test baseline files to reflect the updated package.json entries (now properly sorted) and comments across all adapter variants (TypeScript, JavaScript, React, VIS, different Node versions, etc.).

5. Documentation

  • Added changelog entry in CHANGELOG.md under the __WORK IN PROGRESS__ section
  • Created comprehensive migration guide at docs/updates/20251014_iobroker_types_package.md with step-by-step instructions for manually updating existing adapters

Benefits

  • ✅ Uses the official, actively maintained @iobroker/types package
  • ✅ Maintains full backward compatibility - no breaking changes
  • ✅ IDEs continue to discover types automatically
  • ✅ Works seamlessly with existing type checking workflows
  • ✅ Consistent alphabetically sorted dependencies
  • ✅ All 113 tests pass

Testing

All existing tests continue to pass, validating that the changes work correctly across all adapter configurations.

Fixes #

Original prompt

This section details on the original issue you should resolve

<issue_title>Use the updated types from @iobroker/types</issue_title>
<issue_description>- instead of old types from @types/iobroker

<agent_instructions>Add it as described even if it is only used in comments and adjust the comments. we want to have the types available in all variants</agent_instructions>

Comments on the Issue (you are @copilot in this section)

Fixes #1050


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] Use the updated types from @iobroker/types Replace @types/iobroker with @iobroker/types using npm alias Oct 13, 2025
@Copilot Copilot AI requested a review from Apollon77 October 13, 2025 15:11
Copilot finished work on behalf of Apollon77 October 13, 2025 15:11
Copy link
Collaborator

@Apollon77 Apollon77 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot add changelog entry (forgotten again - adjust your instructions to ensure it is ALWAYS done!) and migration info

if (isAdapter && useTypeChecking) {
const iobrokerTypesVersion = await fetchPackageReferenceVersion("@iobroker/types");
devDependencies.push(`"@types/iobroker": "npm:@iobroker/types@${iobrokerTypesVersion}"`);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copiolot please add an alphabetic sorting of the dependencies and dev-dependencies by their name and ensure that the packages with @* are at the beginning

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added alphabetic sorting in commit abbcd12. The devDependencies array is now sorted alphabetically with all @-scoped packages placed first, followed by regular packages. The @types/iobroker entry now appears in the correct position instead of at the end.

Copy link
Contributor Author

Copilot AI commented Oct 14, 2025

@copilot add changelog entry (forgotten again - adjust your instructions to ensure it is ALWAYS done!) and migration info

Added changelog entry and migration guide in commit abbcd12. The changelog entry is at the top of the WORK IN PROGRESS section and links to the new migration guide at docs/updates/20251014_iobroker_types_package.md.

@Copilot Copilot AI requested a review from Apollon77 October 14, 2025 07:21
Copilot finished work on behalf of Apollon77 October 14, 2025 07:21
# Conflicts:
#	CHANGELOG.md
#	test/baselines/TS_Prettier/package.json
#	test/baselines/adapter_TS_React/package.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use the updated types from @iobroker/types

2 participants