Recently, I've been working on a NodeJS project and wanted to incorporate TypeScript files. In my initial attempt, I created a TypeScript file with the following content:
utilts.ts :
export const delimitify = ( strings:Array<string>, delimiter:string ):string =>
strings.join(delimiter);
export const slugify = ( strings:Array<string> ):string => strings.join('_');
export const hyphenify = ( strings:Array<string> ):string => strings.join('-');
export const andify = ( strings:Array<string> ):string => strings.join('&');
export const orify = ( strings:Array<string> ):string => strings.join('|');
In my test file, I wrote the following:
/__test__/utilts.test.js
import {
delimitify
} from "../utilts";
describe(
"delimitify",
() => {
it(
"must return string delimited by hyphen",
() => {
const result = delimitify(['1', '2', '3'], '-');
expect(result).toBe('1-2-3')
}
);
}
);
Upon compilation, an error was raised:
SyntaxError: /home/brunolnetto/github/quivero/prego/utils/testing/utilts.ts: Unexpected token, expected "," (2:35)
1 |
> 2 | export const delimitify = ( strings:Array<string>, delimiter:string ):string => strings.join(delimiter);
| ^
3 | export const slugify = ( strings:Array<string> ):string => strings.join('_');
4 | export const hyphenify = ( strings:Array<string> ):string => strings.join('-');
5 | export const andify = ( strings:Array<string> ):string => strings.join('&');
> 1 | import {
| ^
2 | delimitify
3 | } from "../utilts";
It appears to be a straightforward fix. This experience could serve as a lesson for others in the community. 😊