Compile error with latest version #31
Comments
I guess it's located in this commit, but don't know much about how types definitions work. |
Hmm, sorry about that. This was my first time writing TypeScript definition files, I probably made a mistake somewhere. I will work on figuring out what the right fix is. In the meantime, I tested locally and if you enable the |
So it looks like I did write the declaration file correctly. There are two ways you can consume the library in a TypeScript project:
See https://www.typescriptlang.org/docs/handbook/modules.html#export--and-import--require for more details. I will update the documentation to reflect this - didn't know about that. Sorry for any inconvenience! |
Oops, it looks like I forgot return types for some of my methods in the TypeScript definition file. I'll need to fix that and publish a new release. |
Just published v2.9.2 which has a few minor fixes in the type declaration file. If you follow the steps above you should be good to go, let me know if you still have problems though! I'll close this for now. |
Unfortunately, looks like this format is not enabled in my config because of reasons I'm not so clear with: ERROR in src/app/shared/custom-forms/components/inputs-complex/input-emoji/input-emoji.component.ts:4:1 - error TS1202: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead.
4 import EmojiButton = require('@joeattardi/emoji-button');
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I should put a few hours understanding the modules stuff with TS & JS to understand the underlying reasons. I don't know how other packages do to be compatible with all possibles compile configs though. |
Have you tried setting the |
Yup, just tried it but it makes other imports in my project fail, for example: import * as moment from 'moment';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead.
src/app/core/services/intercom.service.ts:42:21 - error TS2349: This expression is not callable.
Type 'typeof moment' has no call signatures. |
Can you share your |
Sure: {
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"paths": {
"@core/*": ["src/app/core/*"],
"@shared/*": ["src/app/shared/*"],
"@environments/*": ["src/environments/*"]
},
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"module": "esnext",
"moduleResolution": "node",
"importHelpers": true,
"target": "es2015",
"typeRoots": ["node_modules/@types"],
"lib": ["es2018", "dom", "esnext.asynciterable"],
}
} |
What if you try this:
|
Cool, it works ok. Thanks! But I thinks there are two problems in the types definitions, so I get compile errors: on(event: string, callback: () => void): void; The callback should have one picker.on('emoji', emoji => {
document.querySelector('input').value += emoji;
}); And the showPicker(referenceEl: HTMLElement, options: EmojiButton.Options): void;
togglePicker(referenceEl: HTMLElement, options: EmojiButton.Options): void; |
Oops again! 😄 Sorry again about that. I've published version 2.9.4 which hopefully should have the correct typings. |
That's great, all green now :) Thanks! |
Great, I’m glad you’re up and running now. Sorry again for the inconvenience! |
This compile error started popping up in my Angular project after updating to latest version:
Playing around with
allowSyntheticDefaultImports
in mytsconfig.json
didn't fix the error.Typescript doc mentions it's just for type-checking.
Any idea on how to fix that?
The text was updated successfully, but these errors were encountered: