Skip to content

Commit

Permalink
slight improvements to the generated index.cts boilerplate:
Browse files Browse the repository at this point in the history
- use a wrapper type instead of a string subtype as the example wrapper logic, for clarity
- use `declare module` for a better suggested style of interacting with the addon (to avoid the any type)
  • Loading branch information
dherman committed Apr 15, 2024
1 parent 36a002f commit e6eef73
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions pkgs/create-neon/data/templates/ts/index.cts.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
const addon = require('./load.cjs');
import * as addon from './load.cjs';

export type Greeting = "hello node";
declare module "./load.cjs" {
function hello(): string;
}

export type Greeting = {
message: string
};

export function hello(): Greeting {
return addon.hello();
export function greeting(): Greeting {
const message = addon.hello();
return { message };
}

0 comments on commit e6eef73

Please sign in to comment.