Skip to content

Better Typescript transpilation #392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Sep 4, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
fix comment regression + add test for it
  • Loading branch information
Simon Holthausen committed Sep 1, 2021
commit 23c24f6f6685f589a4428f0f93bfc34b8df2ddd5
2 changes: 1 addition & 1 deletion src/modules/markup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Transformer, Preprocessor } from '../types';
/** Create a tag matching regexp. */
export function createTagRegex(tagName: string, flags?: string): RegExp {
return new RegExp(
`<!--[^]*?-->|<${tagName}(\\s[^]*?)?(?:>([^]*?)<\\/${tagName}>|\\/>)`,
`/<!--[^]*?-->|<${tagName}(\\s[^]*?)?(?:>([^]*?)<\\/${tagName}>|\\/>)`,
flags,
);
}
Expand Down
4 changes: 3 additions & 1 deletion test/fixtures/TypeScriptImports.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,6 @@

{@html val}
{@debug val, inputVal}
</div>
</div>

<!-- Some comment -->
3 changes: 3 additions & 0 deletions test/transformers/typescript.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ describe('transformer - typescript', () => {

const { code } = await preprocess(tpl, opts);

// Test that imports are properly preserved
expect(code).toContain(`import { fly } from "svelte/transition"`);
expect(code).toContain(`import { flip } from "svelte/animate"`);
expect(code).toContain(`import Nested from "./Nested.svelte"`);
Expand All @@ -131,6 +132,8 @@ describe('transformer - typescript', () => {
expect(code).toContain(
`import { onlyUsedInModuleScript } from "./modulescript";`,
);
// Test that comments are properly preserved
expect(code).toContain('<!-- Some comment -->');
});

it('should deal with empty transpilation result', async () => {
Expand Down