Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/createTag/createTag.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ export default function createTag(...rawTransformers) {
return tag([strings]);
}

if (typeof strings[0] === 'undefined') {
throw TypeError(`input string is undefined: Check your template string.
(e.g. \\4 will throw SyntaxError with 'Octal escape sequences are not allowed')
`);
}

const tagCallInfo = getTagCallInfo(transformers);

// if the first argument is an array, return a transformed end result of processing the template with our tag
Expand Down
13 changes: 13 additions & 0 deletions src/createTag/createTag.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,3 +298,16 @@ test('accepts other tags as arguments and applies them in order', () => {

expect(superTag`foo`).toBe('foo1234');
});

test('invalid template string should throw error message', () => {
const getInitialContext = jest.fn();
const tag = createTag({ getInitialContext });

let actual = () => {
tag`\4`;
};

expect(actual).toThrow(
`input string is undefined: Check your template string.`,
);
});