Skip to content

Instantly share code, notes, and snippets.

@katai5plate
Created November 13, 2019 06:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save katai5plate/39fdf009be030518894455220ae38fe4 to your computer and use it in GitHub Desktop.
Save katai5plate/39fdf009be030518894455220ae38fe4 to your computer and use it in GitHub Desktop.
d.ts 知見メモ

ローカルの js に型をつける

  • mod.js
module.exports = {
  log: console.log,
  hello: "Hello, World!"
};
  • index.ts
import * as con from "./mod.js";
con.log(con.hello);
  • @types/mod.d.ts
declare module "*/mod.js" {
  export function log(...p: any[]): void;
  export const hello: string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment