Skip to content

Commit 135e4c4

Browse files
authored
chore: add verbatim type specifier to export from statements (#2310)
### 🎯 Goal If we want the codebase to be compilable by tools like Vite, that use esbuild under the hood to process files one-by-one, we should follow the rules for isolated typescript modules. Previously we were breaking the isolated modules rule by doing re-exports like this one: ```ts export { DefaultStreamChatGenerics, ChannelUnreadUiState } from './types'; ``` Where both `DefaultStreamChatGenerics` and `ChannelUnreadUiState` are types. When processing a single file, the compiler doesn't know if these are types or not, and leaves the export statement as is, when really it should be removed. Fixing this by using verbatim module syntax: ```ts export type { DefaultStreamChatGenerics, ChannelUnreadUiState } from './types'; ``` After fixing all issues, `isolatedModules` was enabled in tsconfig. A good side-effect of this change is that Ladle (which uses Vite internally) now works again, which is crucial for e2e tests :)
1 parent d366ee4 commit 135e4c4

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

β€Žsrc/components/Message/renderText/index.tsβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export { MentionProps } from './componentRenderers';
1+
export type { MentionProps } from './componentRenderers';
22
export { escapeRegExp, matchMarkdownLinks, messageCodeBlocks } from './regex';
33
export * from './rehypePlugins';
44
export * from './remarkPlugins';

β€Žsrc/components/index.tsβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ export * from './TypingIndicator';
3232
export * from './UserItem';
3333
export * from './Window';
3434

35-
export { UploadButton, UploadButtonProps } from './ReactFileUtilities';
35+
export { UploadButton } from './ReactFileUtilities';
36+
export type { UploadButtonProps } from './ReactFileUtilities';

β€Žsrc/types/index.tsβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { DefaultStreamChatGenerics, ChannelUnreadUiState } from './types';
1+
export type { DefaultStreamChatGenerics, ChannelUnreadUiState } from './types';

β€Žtsconfig.jsonβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"declaration": true,
2929
"declarationDir": "./dist",
3030
"declarationMap": true,
31-
"importHelpers": true
31+
"importHelpers": true,
32+
"isolatedModules": true
3233
},
3334
"include": ["./src/**/*"],
3435
"exclude": ["./src/stories", "./src/mock-builders", "./src/**/__tests__/*"]

0 commit comments

Comments
Β (0)