Skip to content

fix windows compile #34

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

Closed
Closed
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
2 changes: 1 addition & 1 deletion apps/ProjectPlanner/ActiveUsers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Heading } from 'ProjectPlanner/Heading'
import { Avatar } from 'ProjectPlanner/Avatar'
import { useAuth } from 'ProjectPlanner/AuthContext'
import { useAccountUsers } from 'ProjectPlanner/hooks/dataHooks'
import { shuffle } from 'ProjectPlanner/utils.ts'
import { shuffle } from 'ProjectPlanner/utils'

export const ActiveUsers: React.FC = () => {
const users = useAccountUsers()
Expand Down
7 changes: 3 additions & 4 deletions courses/core-v2/03-forms/exercise/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ Hint: Use empty strings for `name` and `content`
7. Create a ref using `useRef()`:

```ts
// For TypeScript, refs can be weird. You'll have to do it like this.
// The instructor can explain more but we also have some links if you
// need them below
const nameRef = useRef<HTMLInputElement>(null!)
// For TypeScript, refs can be weird. Make sure you pass the type
// of the element that will be stored in the ref.
const nameRef = useRef<HTMLInputElement>()

// For JavaScript, you can just do:
const nameRef = useRef()
Expand Down
10 changes: 5 additions & 5 deletions courses/core-v2/03-forms/exercise/Task.final.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Heading } from 'ProjectPlanner/Heading'
import { Minutes } from 'ProjectPlanner/Minutes'
import { Progress } from 'ProjectPlanner/Progress'

type Task = {
type TaskType = {
name: string
content: string
minutes: number
Expand All @@ -18,11 +18,11 @@ const initialTask = {
}

export const Task = () => {
const [task, setTask] = useState<Task>(initialTask)
const [task, setTask] = useState<TaskType>(initialTask)
const complete = task.minutes > 0 && task.minutes === task.completedMinutes
const nameRef = useRef<HTMLInputElement>(null!)
const nameRef = useRef<HTMLInputElement>()

function update(partialTask: Partial<Task>) {
function update(partialTask: Partial<TaskType>) {
if (!task) return
setTask({ ...task, ...partialTask })
}
Expand All @@ -31,7 +31,7 @@ export const Task = () => {
event.preventDefault()
setTask(initialTask)
console.log(task)
nameRef.current?.focus()
nameRef.current.focus()
}

return (
Expand Down
12 changes: 6 additions & 6 deletions scripts/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ const cli = require('./cli')
const { appPath, alias, selectedCourse, selectedLessonType, selectedLesson } = cli()

/////////////// CREATE TS CONFIG FOR LESSON SELECTION
let tsConfigPath = ensureDevTsConfig({ selectedCourse, selectedLesson })
let tsConfigPath = ensureDevTsConfig({ selectedCourse, selectedLesson, selectedLessonType })

/////////////// START SERVER
const port = 3000
const appEntry = path.resolve(appPath, 'entry.js')
const appEntry = alias['YesterTech\\index'] || alias['ProjectPlanner\\index'] || path.resolve(appPath, 'entry.js')
const server = new WebpackDevServer(
webpack(config(appEntry, alias, { tsConfigPath })),
devServerOptions
Expand Down Expand Up @@ -64,20 +64,20 @@ server.listen(port, 'localhost', function (err) {
}
})

function ensureDevTsConfig({ selectedCourse, selectedLesson }) {
function ensureDevTsConfig({ selectedCourse, selectedLesson, selectedLessonType }) {
try {
let tsconfig = JSON.parse(fs.readFileSync(path.join(rootDir, 'tsconfig.json'), 'utf-8'))
let tsconfigDevPath = path.join(rootDir, 'tsconfig.dev.json')

let devTsConfig = {
extends: './tsconfig.json',
include: [...tsconfig.include, path.join('courses', selectedCourse, selectedLesson)],
extends: './tsconfig.base.json',
include: [path.join('courses', selectedCourse, selectedLesson, selectedLessonType)],
}

fs.writeFileSync(tsconfigDevPath, JSON.stringify(devTsConfig), 'utf-8')

return tsconfigDevPath
} catch (err) {
return 'tsconfig.json'
return 'tsconfig.base.json'
}
}
27 changes: 27 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"include": ["apps", "types", "__mocks__/@types"],
"exclude": ["node_modules", "scripts", "config"],
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"checkJs": false,
"baseUrl": "./",
"downlevelIteration": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": false,
"importHelpers": true,
"jsx": "react",
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "node",
"rootDir": ".",
"skipLibCheck": true,
"lib": ["dom", "dom.iterable", "esnext"],
"noEmit": true,
"resolveJsonModule": true,
"paths": {
"YesterTech/*": ["apps/YesterTech/*"],
"ProjectPlanner/*": ["apps/ProjectPlanner/*"]
}
}
}
34 changes: 7 additions & 27 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,9 @@
{
// For lessons, TypeScript will use tsconfig.dev.json which is auto generated
// on each launch of a lesson to adjust includes to be specific for the lesson.
"include": ["apps", "types", "__mocks__/@types"],
"exclude": ["node_modules", "scripts", "config"],
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"checkJs": false,
"baseUrl": "./",
"downlevelIteration": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": false,
"importHelpers": true,
"jsx": "react",
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "node",
"rootDir": ".",
"skipLibCheck": true,
"lib": ["dom", "dom.iterable", "esnext"],
"noEmit": true,
"resolveJsonModule": true,
"paths": {
"YesterTech/*": ["apps/YesterTech/*"],
"ProjectPlanner/*": ["apps/ProjectPlanner/*"]
}
}
"_comment_____": "For lessons, TypeScript will use tsconfig.dev.json which is auto generated",
"__comment____": "on each launch of a lesson to adjust includes to be specific for the",
"___comment___": "lesson. Both extend tsconfig.base.json, but we need the file that VS Code",
"____comment__": "uses for intellisense to use the tsconfig.json filename so that files in",
"_____comment_": "the courses don't show a bunch of errors.",
"extends": "./tsconfig.base.json",
"include": ["courses"]
}