Publish unist packages and friends #32
-
ProblemType definitions for various *st packages are published using DefinitelyTyped. Having these types packages without an accompanying source package on DefinitelyTypes has caused various issues for me when working with unist ASTs. Just some examples: The following are some issues related to resolving packages:
Also TypeScript itself has issues with this. For example, the following code: import { Node } from 'unist';
class Foo {
@Bar
node: Node;
} Gets transpiled to: var __decorate = /* truncated */;
var __metadata = /* truncated */;
var _a;
import { Node } from 'unist';
class Foo {
}
__decorate([
Bar,
__metadata("design:type", typeof (_a = typeof Node !== "undefined" && Node) === "function" ? _a : Object)
], Foo.prototype, "node", void 0); So This can be worked around by using a type import, but the generated error will be unclear. These are just the sutiations I recall from the top of my head. There are more situations. SolutionI propose to publish all syntax tree AST type definition packages using their own name, pulling them from DefinitelyTypes. This will resolve some of the issues. To resolve more issues, I propose to add an empty VersioningSome packages haven’t even been published to Side note: This also means anyone could just publish a package named Other packages have been published before (https://www.npmjs.com/package/mdast). The new version should have the major version bumped compared to the last release. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 21 replies
-
Speaking to this specific issue import { Node } from 'unist'; transpiled to try to import a value https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export resolves this |
Beta Was this translation helpful? Give feedback.
-
I don’t think TS-only unist/mdast/hast/xast/nlcst/esast packages makes sense: they’re a contract on an interface. |
Beta Was this translation helpful? Give feedback.
-
I think @wooorm has |
Beta Was this translation helpful? Give feedback.
-
Could this be solved in DT? Can |
Beta Was this translation helpful? Give feedback.
I think @wooorm has
mdast
https://www.npmjs.com/package/mdast andhast
https://www.npmjs.com/package/hast published to npm with an index.js file, since the content doesn't seem to matter in this case, would that be enough?(
unist
,xast
, anddotast
are still unpublished and an open question)