programming language, superset of JavaScript that compiles to JavaScript
Factsheet
Anders Hejlsberg,
Luke Hoban
Anders Hejlsberg,
Luke Hoban
» npm install typescript
node.js - How to install and run Typescript locally in npm? - Stack Overflow
How to build an NPM Package that's both Typescript and Javascript friendly?
Using TypeScript to Create Modern npm Packages
How can I override a type exported by an NPM package?
Videos
It took me a while to figure out the solution to this problem - it's in the original question. You need to have a script that calls tsc in your package.json file so that you can run:
npm run tsc
Include -- before you pass in options (or just include them in the script):
npm run tsc -- -v
Here's an example package.json:
{
"name": "foo",
"scripts": {
"tsc": "tsc"
},
"dependencies": {
"typescript": "^1.8.10"
}
}
As of npm 5.2.0 you no longer need an entry in the scripts section of package.json. You can now run the compiler with npx:
npx tsc
...and you don't have to update package.json with a new script every time you want to compile with different arguments.
» npm install ts-node
I'm having a devil of a time figuring this out. In my ${DAY_JOB}, I'm currently writing a private NPM module that will be distributed to other teams; the module contains a fairly large decision tree and a class that drives internal business logic; other teams will use this class to guide several kinds of customer interaction.
Some of our teams use Typescript, but others are still using JS. I've googled my brains out but I can't seem to find a good example of an NPM package.json that demonstrates support for the following:
the module is made a dependency using the `"company-sdk": "file:vendor/company-sdk-0.0.0.tgz" format.
the module has separate folders for the typescript source code and the built javascript.
Importing the module works regardless of the consumer's choice to work in either language.
It would be perfectly acceptable if the .d.ts files were in the Javascript folder, but for some reason I can't seem to make that work. Are there any good examples, on Github for example, of small (and without Webpack or esoteric Babel settings) projects that accomplish this?
» npm install typescript-is
» npm install typescript-eslint
» npm install @typescript/native-preview