Skip to content

Instantly share code, notes, and snippets.

@vvakame
Last active July 12, 2017 01:31
Show Gist options
  • Save vvakame/4d882bb3f611c8c14ab86c5d18d8a9eb to your computer and use it in GitHub Desktop.
Save vvakame/4d882bb3f611c8c14ab86c5d18d8a9eb to your computer and use it in GitHub Desktop.
package-lock.json
node_modules/
*.js

npx sample

$ npx -p https://gist.github.com/vvakame/4d882bb3f611c8c14ab86c5d18d8a9eb run-tsc
{
"name": "4d882bb3f611c8c14ab86c5d18d8a9eb",
"version": "1.0.0",
"private": true,
"description": "npx example",
"bin": {
"run-tsc": "run.sh"
},
"repository": {
"type": "git",
"url": "git+https://gist.github.com/4d882bb3f611c8c14ab86c5d18d8a9eb.git"
},
"keywords": [],
"author": "vvakame",
"license": "MIT",
"bugs": {
"url": "https://gist.github.com/4d882bb3f611c8c14ab86c5d18d8a9eb"
},
"homepage": "https://gist.github.com/4d882bb3f611c8c14ab86c5d18d8a9eb",
"devDependencies": {
"typescript": "2.4.1"
}
}
interface Named {
name: string;
}
function parrot<T extends Named>(obj: T): T {
return obj;
}
// A
parrot({
name: "TypeScript",
});
// B
parrot({
name: "TypeScript",
age: 5,
});
// C
parrot({
name: "TypeScript",
age: function () { },
});
// D
parrot({
name: "TypeScript",
sayHello() {
console.log(`Hello, ${this.name}`);
},
});
#! /bin/bash -eux
cd $(dirname $0)
cd $(dirname $(readlink $0))
tsc
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"strict": true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment