Closed MrChocolatine closed 2 years ago
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
setsallowJs: 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 settingallowJs: 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 alongsidetests/dummy/app/app.js
or actually converting that file to TS should solve your problem @dfreeman: thedeclare module
you suggested should also be fine
Also asked on Discord: https://discord.com/channels/480462759797063690/484421406659182603/885928438542794752
Please paste the output of
ember -v
hereember-cli: 3.24.0 node: 14.17.6 os: darwin x64
Please paste the output of
tsc -v
hereVersion 4.4.3
Please paste the version of
ember-cli-typescript
andember-cli-typescript-blueprints
herePlease paste your
tsconfig.json
andtslint.json
oreslint.json
(if applicable) belowNot applicable.
What are instructions we can follow to reproduce the issue?
The error log from the last command `yarn run prepack`
```shell 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 commandyarn run prepack
fails at the lineimport { initialize } from 'dummy/instance-initializers/my-thing'
.