モジュールのimport/exportについてはdenoはECMA Script6に倣っているようなのでdenoに限らないのかもしれませんが。
一つのファイルに色々詰め込むと見通しが悪くなるので、分割できるようにするサンプルが以下。
一つのファイルに色々詰め込むと見通しが悪くなるので、分割できるようにするサンプルが以下。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { test1 } from "./sub.ts"; | |
console.log(test1('hoge')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function test1(msg:string): string{ | |
return '['+private1(msg)+']' | |
} | |
export function test2(msg:string): string{ | |
return '<'+msg+'>' | |
} | |
function private1(msg:string): string{ | |
return msg + '---' | |
} |
0 件のコメント:
コメントを投稿