Sorry if this Question has bean ask and ask. But I keep hitting this pesky "error TS2349", every time I want to use an external Node Package in my Typescript Project, what dose not yet have a TypeScript Definition :(
Here is my Current Setup
node -v v5.0.0
tsc -v message TS6029: Version 1.6.2
OS: 4.1.12-1-ck GNU/Linux Arch
tsconfig {
"compilerOptions": {
"module": "commonjs",
"target": "ES5",
"noImplicitAny": false,
"outDir": "../lib",
"rootDir": ".",
"sourceMap": false
},
}
external node package : "cssnext": "^1.8.4"
My Main Code
/// <reference path="../definitions/tsd/node/node.d.ts" />
import * as fs from "fs";
import * as cssnext from "cssnext";
let source = "./index.css";
let output = cssnext(
fs.readFileSync(source, "utf8"),
{from: source}
);
fs.writeFileSync("dist/index.css", output);
What I am looking for ?
var cssnext = require("cssnext")
var fs = require("fs")
var source = "./index.css"
var output = cssnext(
fs.readFileSync(source, "utf8"),
{from: source}
)
fs.writeFileSync("dist/index.css", output)
What I get :(
tsc -p ./src;
src/main.ts(36,14): error TS2349: Cannot invoke an expression whose type lacks a call signature.
** _reference.d.ts has **
declare module "cssnext" {}
declare function cssnext(str: any,ops:Object): string | Object;
Real question is
What is "error TS2349" saying in English, with this context and how can I write a mad max TypeScript Definition to fix this one and related. :)
I love Type Script ways, but other times :(
** Answer **
With help from below the code to solve this Question is:
declare module "cssnext" {
function cssnext(str: string,ops:Object): string | Object;
export default cssnext;
}
import * as cssnext from "cssnext";
let cssnext(str,op)
It might not be 100% cssnext complaint, but it's TSD starting point.