Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm publish fails - No declaration file for module 'dummy/app' #1448

Closed
MrChocolatine opened this issue Sep 16, 2021 · 1 comment
Closed

Comments

@MrChocolatine
Copy link
Contributor

MrChocolatine commented Sep 16, 2021

Also asked on Discord:
https://discord.com/channels/480462759797063690/484421406659182603/885928438542794752

Please paste the output of ember -v here

ember-cli: 3.24.0
node: 14.17.6
os: darwin x64

Please paste the output of tsc -v here

Version 4.4.3

Please paste the version of ember-cli-typescript and ember-cli-typescript-blueprints here

yarn list v1.22.11
├─ @glimmer/[email protected]
│  └─ [email protected]
├─ [email protected]
├─ [email protected]
└─ [email protected]
   └─ [email protected]

Please paste your tsconfig.json and tslint.json or eslint.json (if applicable) below

Not applicable.

What are instructions we can follow to reproduce the issue?

ember new sample
cd ./sample
ember install ember-cli-typescript

# Runs without any issue
yarn run prepack

# Add types for `qunit-dom`
# https://github.com/simplabs/qunit-dom/tree/v2.0.0#typescript

# Fails (see error log below)
yarn run prepack
The error log from the last command `yarn run prepack`
tests/test-helper.ts:1:25 - error TS7016: Could not find a declaration file for module 'dummy/app'. '/Users/_/Dev/emberjs/__test-addon-with-typescript/tests/dummy/app/app.js' implicitly has an 'any' type.

1 import Application from 'dummy/app';
                          ~~~~~~~~~~~
Found 1 error.

Command failed with exit code 1: tsc --allowJs false --noEmit false --rootDir /Users/_/Dev/emberjs/__test-addon-with-typescript --isolatedModules false --declaration --declarationDir /Users/_/Dev/emberjs/__test-addon-with-typescript/e-c-ts-precompile-14668 --emitDeclarationOnly --pretty true
tests/test-helper.ts:1:25 - error TS7016: Could not find a declaration file for module 'dummy/app'. '/Users/_/Dev/emberjs/__test-addon-with-typescript/tests/dummy/app/app.js' implicitly has an 'any' type.

Now about that bug. What did you expect to see?

Add-on correctly published to npmjs.

What happened instead?

⬆️ See the error log above


My current fix is to write declare module 'dummy/app'; in the file /types/dummy/index.d.ts. Do you think it is wise? Do you think of a better solution?

Then exactly same issue when creating a unit-test for an Initializer or an Instance-Initializer and renaming the file with the extension .ts, the command yarn run prepack fails at the line import { initialize } from 'dummy/instance-initializers/my-thing'.

@MrChocolatine
Copy link
Contributor Author

Answer:
https://discord.com/channels/480462759797063690/484421406659182603/888036425348550656

@dfreeman: Unfortunately I don't have time to write up a full response on the issue you opened right now, but the short answer is that ts:precompile sets allowJs: false when it runs
@dfreeman: IMO (speaking only for myself and not any of the rest of the typed-ember folks) we shouldn't be setting allowJs: true in the default blueprint in the first place
@dfreeman: but I think that's the root of your problem
@dfreeman: either adding a .d.ts file alongside tests/dummy/app/app.js or actually converting that file to TS should solve your problem
@dfreeman: the declare module you suggested should also be fine

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

No branches or pull requests

1 participant