tildeio / ember-element-helper

Dynamic element helper for Glimmer templates.
MIT License
44 stars 23 forks source link

Types are incorrecly published and reference the ember-source built in preview types (which do not exist in sufficiently new enough projects) #111

Closed NullVoxPopuli closed 10 months ago

NullVoxPopuli commented 10 months ago

I think everything would be fine if just these /// reference lines weren't present:

[types] ../node_modules/.pnpm/ember-element-helper@0.8.2_@glint+environment-ember-loose@1.0.2_@glint+template@1.0.2_ember-source@5.2.0/node_modules/ember-element-helper/declarations/helpers/element.d.ts:1:23 - error TS2688: Cannot find type definition file for 'ember-source/types/preview/@ember/object/core'.
[types] 
[types] 1 /// <reference types="ember-source/types/preview/@ember/object/core" />
[types]                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[types] 
[types] ../node_modules/.pnpm/ember-element-helper@0.8.2_@glint+environment-ember-loose@1.0.2_@glint+template@1.0.2_ember-source@5.2.0/node_modules/ember-element-helper/declarations/helpers/element.d.ts:2:23 - error TS2688: Cannot find type definition file for 'ember-source/types/preview/@ember/object/mixin'.
[types] 
[types] 2 /// <reference types="ember-source/types/preview/@ember/object/mixin" />
[types]      

image

Not really sure why ts or glint would do this, as ember-source is marked as a peerDependency

gitKrystan commented 10 months ago

It's probably this: https://github.com/ember-a11y/ember-a11y-testing/issues/498#issuecomment-1440518413

NullVoxPopuli commented 10 months ago

I'm not so sure

I made an attempt here: https://github.com/tildeio/ember-element-helper/pull/112 but no dice -- /// reference is still present in the declarations output

SergeAstapov commented 10 months ago

@gitKrystan @NullVoxPopuli the strange thing is that https://www.npmjs.com/package/ember-modifier?activeTab=code does not suffer from such issue and no /// reference present in published code

NullVoxPopuli commented 10 months ago

ember-modifier is using rollup-plugin-typescript to generate the type declarations: https://github.com/ember-modifier/ember-modifier/blob/main/ember-modifier/rollup.config.mjs#L28

so perhaps there is some secret its doing that we need to find for folks directly using tsc / glint to generate their declarations

SergeAstapov commented 10 months ago

ember-modifier is using rollup-plugin-typescript to generate the type declarations: https://github.com/ember-modifier/ember-modifier/blob/main/ember-modifier/rollup.config.mjs#L28

I planned to update ember-modifier setup with latest blueprint, will see what the output will be

NullVoxPopuli commented 5 months ago

Made a tool to help out in the future: https://github.com/NullVoxPopuli/fix-bad-declaration-output