Skip to content

Publish TypeScript declarations (.d.ts) from the 4.x packages #384

Description

@ondrejmirtes

The 4.x packages are authored in TypeScript: the published source maps point at .ts sources (e.g. @tko/bind's applyBindings.js.map has "sources": ["../src/applyBindings.ts"]), yet none of them ship type declarations.

There are no .d.ts files in any @tko/* package, the types/typings field is unset, and the exports map only lists JS:

"exports": { ".": { "require": "./dist/index.cjs", "import": "./dist/index.mjs" } }

So import ko from '@tko/build.knockout' fails type-checking with "Could not find a declaration file for module '@tko/build.knockout'". The same applies to @tko/build.reference and the individual packages, and there's no @types/tko on DefinitelyTyped.

The workaround on the consumer side is to keep the old knockout package as a dev dependency purely for its bundled .d.ts and re-point it:

declare module '@tko/build.knockout' {
  import ko from 'knockout';
  export default ko;
}

That works because the runtime API is KO3-compatible, but it's a hack and doesn't cover the modular @tko/* packages.

Since the source is already TypeScript (#92 landed the conversion, #6 is the original tracking issue), this looks like mostly enabling declaration emit in the build and adding a types entry to each package's exports.

Checked on @tko/build.knockout@4.1.0 and @tko/build.reference@4.1.0.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions