Cannot invoke an expression whose type lacks a call signature, using moment Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Typescript - cannot invoke an expression whose type lack of signatureerror TS2349: Cannot invoke an expression whose type lacks a call signatureError: Cannot invoke an expression whose type lacks a call signatureUnknown compiler option 'angularCompilerOptions' in angular 2 ahead-of-time compilationReferencing momentJs in TypeScript without NPMCannot invoke an expression whose type lacks a call signatureangular 2 npm start duplicate identifiers errorTypeScript, moment and ReSharper. “Cannot invoke an expression whose type lacks a call signature”Got “TS2300: Duplicate identifier 'Account'” error after upgraded to Typescript 2.9.1Angular 5 Jasmine issue in VS code
Using audio cues to encourage good posture
Illegal assignment from sObject to Id
Why do we need to use the builder design pattern when we can do the same thing with setters?
What are the diatonic extended chords of C major?
What is "gratricide"?
Disembodied hand growing fangs
Why is Nikon 1.4g better when Nikon 1.8g is sharper?
Why does the remaining Rebel fleet at the end of Rogue One seem dramatically larger than the one in A New Hope?
How to react to hostile behavior from a senior developer?
Why wasn't DOSKEY integrated with COMMAND.COM?
Taylor expansion of ln(1-x)
Effects on objects due to a brief relocation of massive amounts of mass
A term for a woman complaining about things/begging in a cute/childish way
Is CEO the "profession" with the most psychopaths?
Why is the AVR GCC compiler using a full `CALL` even though I have set the `-mshort-calls` flag?
Time to Settle Down!
What order were files/directories outputted in dir?
An adverb for when you're not exaggerating
Putting class ranking in CV, but against dept guidelines
Is it possible for SQL statements to execute concurrently within a single session in SQL Server?
Generate an RGB colour grid
Project Euler #1 in C++
Chinese Seal on silk painting - what does it mean?
How to play a character with a disability or mental disorder without being offensive?
Cannot invoke an expression whose type lacks a call signature, using moment
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!Typescript - cannot invoke an expression whose type lack of signatureerror TS2349: Cannot invoke an expression whose type lacks a call signatureError: Cannot invoke an expression whose type lacks a call signatureUnknown compiler option 'angularCompilerOptions' in angular 2 ahead-of-time compilationReferencing momentJs in TypeScript without NPMCannot invoke an expression whose type lacks a call signatureangular 2 npm start duplicate identifiers errorTypeScript, moment and ReSharper. “Cannot invoke an expression whose type lacks a call signature”Got “TS2300: Duplicate identifier 'Account'” error after upgraded to Typescript 2.9.1Angular 5 Jasmine issue in VS code
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I am trying to get moment
to work in my angular
application. Here is a clean sample repo to demonstrate the issue. Clone that repo and run ng build test-library
in the root directory. Install packages first, npm install
.
When i try to use moment
, i am getting the following error. What am i doing wrong? I have been trying to fix this for a while now. I have googled it many times and tried several suggestions to no avail.
Usage:
import * as moment from 'moment';
...
public doSomething(): string
const aMoment: moment.Moment = moment(); // line 22
return aMoment.format();
Error:
projects/test-library/src/lib/test-library.component.ts(22,36): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'typeof moment' has no compatible call signatures.
tsconfig.json
"extends": "../../tsconfig.json",
"compilerOptions":
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"outDir": "../../out-tsc/lib",
"target": "es2015",
"module": "es2015",
"moduleResolution": "node",
"declaration": true,
"sourceMap": true,
"inlineSources": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"types": [],
"lib": [
"dom",
"es2018"
]
,
"angularCompilerOptions":
"annotateForClosureCompiler": true,
"skipTemplateCodegen": true,
"strictMetadataEmit": true,
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true,
"enableResourceInlining": true
,
"exclude": [
"src/test.ts",
"**/*.spec.ts"
]
angular typescript momentjs
add a comment |
I am trying to get moment
to work in my angular
application. Here is a clean sample repo to demonstrate the issue. Clone that repo and run ng build test-library
in the root directory. Install packages first, npm install
.
When i try to use moment
, i am getting the following error. What am i doing wrong? I have been trying to fix this for a while now. I have googled it many times and tried several suggestions to no avail.
Usage:
import * as moment from 'moment';
...
public doSomething(): string
const aMoment: moment.Moment = moment(); // line 22
return aMoment.format();
Error:
projects/test-library/src/lib/test-library.component.ts(22,36): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'typeof moment' has no compatible call signatures.
tsconfig.json
"extends": "../../tsconfig.json",
"compilerOptions":
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"outDir": "../../out-tsc/lib",
"target": "es2015",
"module": "es2015",
"moduleResolution": "node",
"declaration": true,
"sourceMap": true,
"inlineSources": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"types": [],
"lib": [
"dom",
"es2018"
]
,
"angularCompilerOptions":
"annotateForClosureCompiler": true,
"skipTemplateCodegen": true,
"strictMetadataEmit": true,
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true,
"enableResourceInlining": true
,
"exclude": [
"src/test.ts",
"**/*.spec.ts"
]
angular typescript momentjs
1
have you tried importing likeimport moment from "moment";
? worked in my case
– Arikael
Mar 8 at 20:54
add a comment |
I am trying to get moment
to work in my angular
application. Here is a clean sample repo to demonstrate the issue. Clone that repo and run ng build test-library
in the root directory. Install packages first, npm install
.
When i try to use moment
, i am getting the following error. What am i doing wrong? I have been trying to fix this for a while now. I have googled it many times and tried several suggestions to no avail.
Usage:
import * as moment from 'moment';
...
public doSomething(): string
const aMoment: moment.Moment = moment(); // line 22
return aMoment.format();
Error:
projects/test-library/src/lib/test-library.component.ts(22,36): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'typeof moment' has no compatible call signatures.
tsconfig.json
"extends": "../../tsconfig.json",
"compilerOptions":
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"outDir": "../../out-tsc/lib",
"target": "es2015",
"module": "es2015",
"moduleResolution": "node",
"declaration": true,
"sourceMap": true,
"inlineSources": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"types": [],
"lib": [
"dom",
"es2018"
]
,
"angularCompilerOptions":
"annotateForClosureCompiler": true,
"skipTemplateCodegen": true,
"strictMetadataEmit": true,
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true,
"enableResourceInlining": true
,
"exclude": [
"src/test.ts",
"**/*.spec.ts"
]
angular typescript momentjs
I am trying to get moment
to work in my angular
application. Here is a clean sample repo to demonstrate the issue. Clone that repo and run ng build test-library
in the root directory. Install packages first, npm install
.
When i try to use moment
, i am getting the following error. What am i doing wrong? I have been trying to fix this for a while now. I have googled it many times and tried several suggestions to no avail.
Usage:
import * as moment from 'moment';
...
public doSomething(): string
const aMoment: moment.Moment = moment(); // line 22
return aMoment.format();
Error:
projects/test-library/src/lib/test-library.component.ts(22,36): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'typeof moment' has no compatible call signatures.
tsconfig.json
"extends": "../../tsconfig.json",
"compilerOptions":
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"outDir": "../../out-tsc/lib",
"target": "es2015",
"module": "es2015",
"moduleResolution": "node",
"declaration": true,
"sourceMap": true,
"inlineSources": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"types": [],
"lib": [
"dom",
"es2018"
]
,
"angularCompilerOptions":
"annotateForClosureCompiler": true,
"skipTemplateCodegen": true,
"strictMetadataEmit": true,
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true,
"enableResourceInlining": true
,
"exclude": [
"src/test.ts",
"**/*.spec.ts"
]
angular typescript momentjs
angular typescript momentjs
asked Mar 8 at 20:36
prolink007prolink007
22k18100163
22k18100163
1
have you tried importing likeimport moment from "moment";
? worked in my case
– Arikael
Mar 8 at 20:54
add a comment |
1
have you tried importing likeimport moment from "moment";
? worked in my case
– Arikael
Mar 8 at 20:54
1
1
have you tried importing like
import moment from "moment";
? worked in my case– Arikael
Mar 8 at 20:54
have you tried importing like
import moment from "moment";
? worked in my case– Arikael
Mar 8 at 20:54
add a comment |
2 Answers
2
active
oldest
votes
In your case, what you're importing there is everything the library exports as an object called moment
. This object obviously doesn't have a call signature as pointed out by the compiler.
According to the type definitions shipped with the library,
the default export is the moment function that you're looking to use.
Therefore, changing your import to the following should work:
import moment from 'moment';
add a comment |
This happens when Typescript compiler does not find the type definition of the methods you are using.
You need to install @types/moment as a dependency.
npm i -D @types/moment
according to npmjs.com/package/@types/moment this is not necessary sinc moment provides its own types.
– Arikael
Mar 8 at 20:55
good to know that but the error is specific to type definition. @Arikael
– Saikat Hajra
Mar 8 at 21:01
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55070643%2fcannot-invoke-an-expression-whose-type-lacks-a-call-signature-using-moment%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
In your case, what you're importing there is everything the library exports as an object called moment
. This object obviously doesn't have a call signature as pointed out by the compiler.
According to the type definitions shipped with the library,
the default export is the moment function that you're looking to use.
Therefore, changing your import to the following should work:
import moment from 'moment';
add a comment |
In your case, what you're importing there is everything the library exports as an object called moment
. This object obviously doesn't have a call signature as pointed out by the compiler.
According to the type definitions shipped with the library,
the default export is the moment function that you're looking to use.
Therefore, changing your import to the following should work:
import moment from 'moment';
add a comment |
In your case, what you're importing there is everything the library exports as an object called moment
. This object obviously doesn't have a call signature as pointed out by the compiler.
According to the type definitions shipped with the library,
the default export is the moment function that you're looking to use.
Therefore, changing your import to the following should work:
import moment from 'moment';
In your case, what you're importing there is everything the library exports as an object called moment
. This object obviously doesn't have a call signature as pointed out by the compiler.
According to the type definitions shipped with the library,
the default export is the moment function that you're looking to use.
Therefore, changing your import to the following should work:
import moment from 'moment';
answered Mar 8 at 21:10
webdeviuswebdevius
27629
27629
add a comment |
add a comment |
This happens when Typescript compiler does not find the type definition of the methods you are using.
You need to install @types/moment as a dependency.
npm i -D @types/moment
according to npmjs.com/package/@types/moment this is not necessary sinc moment provides its own types.
– Arikael
Mar 8 at 20:55
good to know that but the error is specific to type definition. @Arikael
– Saikat Hajra
Mar 8 at 21:01
add a comment |
This happens when Typescript compiler does not find the type definition of the methods you are using.
You need to install @types/moment as a dependency.
npm i -D @types/moment
according to npmjs.com/package/@types/moment this is not necessary sinc moment provides its own types.
– Arikael
Mar 8 at 20:55
good to know that but the error is specific to type definition. @Arikael
– Saikat Hajra
Mar 8 at 21:01
add a comment |
This happens when Typescript compiler does not find the type definition of the methods you are using.
You need to install @types/moment as a dependency.
npm i -D @types/moment
This happens when Typescript compiler does not find the type definition of the methods you are using.
You need to install @types/moment as a dependency.
npm i -D @types/moment
answered Mar 8 at 20:53
Saikat HajraSaikat Hajra
41229
41229
according to npmjs.com/package/@types/moment this is not necessary sinc moment provides its own types.
– Arikael
Mar 8 at 20:55
good to know that but the error is specific to type definition. @Arikael
– Saikat Hajra
Mar 8 at 21:01
add a comment |
according to npmjs.com/package/@types/moment this is not necessary sinc moment provides its own types.
– Arikael
Mar 8 at 20:55
good to know that but the error is specific to type definition. @Arikael
– Saikat Hajra
Mar 8 at 21:01
according to npmjs.com/package/@types/moment this is not necessary sinc moment provides its own types.
– Arikael
Mar 8 at 20:55
according to npmjs.com/package/@types/moment this is not necessary sinc moment provides its own types.
– Arikael
Mar 8 at 20:55
good to know that but the error is specific to type definition. @Arikael
– Saikat Hajra
Mar 8 at 21:01
good to know that but the error is specific to type definition. @Arikael
– Saikat Hajra
Mar 8 at 21:01
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55070643%2fcannot-invoke-an-expression-whose-type-lacks-a-call-signature-using-moment%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
have you tried importing like
import moment from "moment";
? worked in my case– Arikael
Mar 8 at 20:54