Skip to content
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

feat: switch build to TS + all tests 🎉 #1038

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
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
24 changes: 24 additions & 0 deletions examples/example-ts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
13 changes: 13 additions & 0 deletions examples/example-ts/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
23 changes: 23 additions & 0 deletions examples/example-ts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "example-ts",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
},
"dependencies": {
"found": "^1.1.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/react": "^18.0.26",
"@types/react-dom": "^18.0.9",
"@vitejs/plugin-react": "^3.0.0",
"typescript": "^4.9.3",
"vite": "^4.0.0"
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@ interface Props {
function ComponentUsingRouter(_props: Props) {
const { match, router } = useRouter();

return (
<div>
{match.location.pathname}, {router}
</div>
);
console.log(router);
return <div>Pathname: {match.location.pathname}</div>;
}

export { ComponentUsingRouter };
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@ interface Props {
}

function ComponentWithRouter({ match, router }: Props) {
return (
<div>
{match.location.pathname}, {router}
</div>
);
console.log(router);
return <div>Pathname: {match.location.pathname}</div>;
}

const ComponentWithRouterContainer = withRouter(ComponentWithRouter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ComponentWithRouter } from './ComponentWithRouter';
export function MainPage() {
return (
<div>
MainPage!
<ComponentWithRouter />
<ComponentUsingRouter />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import {
createBrowserRouter,
makeRouteConfig,
} from 'found';
import * as React from 'react';
import * as ReactDOM from 'react-dom';

import { AppPage } from './AppPage';
import { MainPage } from './MainPage';
import { WidgetsPage } from './WidgetsPage';
import { createRoot } from 'react-dom/client';
import ReactDOM from 'react-dom';

const fetchWidget = (_widgetId: any) =>
new Promise((_resolve) => {
Expand Down Expand Up @@ -68,4 +68,6 @@ const BrowserRouter = createBrowserRouter({
),
});

ReactDOM.render(<BrowserRouter />, document.getElementById('root'));
createRoot(document.getElementById('root') as HTMLElement).render(
<BrowserRouter />,
);
1 change: 1 addition & 0 deletions examples/example-ts/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
21 changes: 21 additions & 0 deletions examples/example-ts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}
9 changes: 9 additions & 0 deletions examples/example-ts/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}
7 changes: 7 additions & 0 deletions examples/example-ts/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
})
Loading