Skip to content

Commit

Permalink
support typescript types on exports
Browse files Browse the repository at this point in the history
  • Loading branch information
TodePond committed Nov 23, 2022
1 parent 075c354 commit b03a227
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"deno.enable": true
"deno.enable": true,
"editor.formatOnSave": false
}
4 changes: 3 additions & 1 deletion development/typescript/source/greet.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export const HELLO: string = "Hello"

export const greet = (name: string) => {
console.log(`Hello ${name}!`)
console.log(`${HELLO} ${name}!`)
}
6 changes: 5 additions & 1 deletion development/typescript/typescript-embed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ const TypescriptFrogasaurus: any = {}
//====== ./greet.ts ======
{
TypescriptFrogasaurus["./greet.ts"] = {}
const HELLO: string = "Hello"

const greet = (name: string) => {
console.log(`Hello ${name}!`)
console.log(`${HELLO} ${name}!`)
}


TypescriptFrogasaurus["./greet.ts"].HELLO = HELLO
TypescriptFrogasaurus["./greet.ts"].greet = greet
}

Expand All @@ -37,6 +40,7 @@ const TypescriptFrogasaurus: any = {}
// EXPORTS //
//=========//
const Typescript = {
HELLO: TypescriptFrogasaurus["./greet.ts"].HELLO,
greet: TypescriptFrogasaurus["./greet.ts"].greet,
main: TypescriptFrogasaurus["./main.ts"].main,
}
8 changes: 6 additions & 2 deletions development/typescript/typescript-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ const TypescriptFrogasaurus: any = {}
//====== ./greet.ts ======
{
TypescriptFrogasaurus["./greet.ts"] = {}
const HELLO: string = "Hello"

const greet = (name: string) => {
console.log(`Hello ${name}!`)
console.log(`${HELLO} ${name}!`)
}


TypescriptFrogasaurus["./greet.ts"].HELLO = HELLO
TypescriptFrogasaurus["./greet.ts"].greet = greet
}

Expand All @@ -36,10 +39,11 @@ const TypescriptFrogasaurus: any = {}
//=========//
// EXPORTS //
//=========//
export const { greet } = TypescriptFrogasaurus["./greet.ts"]
export const { HELLO, greet } = TypescriptFrogasaurus["./greet.ts"]
export const { main } = TypescriptFrogasaurus["./main.ts"]

export const Typescript = {
HELLO: TypescriptFrogasaurus["./greet.ts"].HELLO,
greet: TypescriptFrogasaurus["./greet.ts"].greet,
main: TypescriptFrogasaurus["./main.ts"].main,
}
5 changes: 4 additions & 1 deletion development/typescript/typescript-standalone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ const TypescriptFrogasaurus: any = {}
//====== ./greet.ts ======
{
TypescriptFrogasaurus["./greet.ts"] = {}
const HELLO: string = "Hello"

const greet = (name: string) => {
console.log(`Hello ${name}!`)
console.log(`${HELLO} ${name}!`)
}


TypescriptFrogasaurus["./greet.ts"].HELLO = HELLO
TypescriptFrogasaurus["./greet.ts"].greet = greet
}

Expand Down
2 changes: 1 addition & 1 deletion frogasaurus.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ const FrogasaurusFrogasaurus = {}
const getConstName = (line) => {
for (let i = "const ".length; i < line.length; i++) {
const char = line[i]
if (char === " " || char === " " || char === "=") {
if (char === " " || char === " " || char === "=" || char === ":") {
return line.slice("const ".length, i)
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { trimStart } from "./string.js"
export const getConstName = (line) => {
for (let i = "const ".length; i < line.length; i++) {
const char = line[i]
if (char === " " || char === " " || char === "=") {
if (char === " " || char === " " || char === "=" || char === ":") {
return line.slice("const ".length, i)
}
}
Expand Down

0 comments on commit b03a227

Please sign in to comment.