-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: upgrade dependencies * feat: add new problem * feat: support ssr * refactor: refactor some code * chore: delete ssr output * fix: theme script place
- Loading branch information
Showing
35 changed files
with
1,212 additions
and
897 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,3 @@ node_modules | |
.npmignore | ||
.DS_Store | ||
yarn-error.log | ||
output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html lang="zh-CN"> | ||
<html lang='en'> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>TypeScript Tutorial Exercises</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script>try{if(JSON.parse(localStorage.getItem('__setting_cache__')).theme==='dark'){document.body.setAttribute('arco-theme','dark');}}catch{}</script> | ||
<div id="root"> | ||
<%= ROOT_CONTENT %> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": ["../.eslintrc.json"], | ||
"rules": { | ||
"compat/compat": "off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
32 changes: 32 additions & 0 deletions
32
problems/basic-tutorial/3-narrowing/docs/description/description.en.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
### What is TypeScript | ||
|
||
TypeScript is a syntactic superset of JavaScript which adds static typing. | ||
|
||
This basically means that TypeScript adds syntax on top of JavaScript, allowing developers to add types. | ||
|
||
### Why TypeScript | ||
|
||
JavaScript is a loosely typed language. It can be difficult to understand what types of data are being passed around in JavaScript. | ||
|
||
In JavaScript, function parameters and variables don't have any information! So developers need to look at documentation, or guess based on the implementation. | ||
|
||
TypeScript allows specifying the types of data being passed around within the code, and has the ability to report errors when the types don't match. | ||
|
||
For example, TypeScript will report an error when passing a string into a function that expects a number. JavaScript will not. | ||
|
||
### About this site | ||
|
||
To teach more people to use TypeScript including basic and advanced usage, we create this site which provides some problems should be solved by TypeScript. And part of the answers of the problems could be found at [official TypeScript document](https://www.typescriptlang.org/). | ||
|
||
This problem require you to export a type which equals to string `Hello, world`. | ||
|
||
Now, you can go to the editor at right of the page to start your TypeScript travel. | ||
|
||
**Reference** | ||
|
||
> 1.https://www.typescriptlang.org/ | ||
> | ||
> 2.https://www.w3schools.com/typescript/typescript_intro.php | ||
> | ||
> 3.https://github.com/typescript-exercises/typescript-exercises | ||
31 changes: 31 additions & 0 deletions
31
problems/basic-tutorial/3-narrowing/docs/description/description.zh-cn.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
### 关于 TypeScript | ||
|
||
TypeScript 是 JavaScript 的语法超集,它添加了静态类型 | ||
|
||
这意味着 TypeScript 在 JavaScript 之上添加了语法,允许开发人员添加类型 | ||
|
||
### 为什么选择 TypeScript | ||
|
||
JavaScript 是一种松散类型语言。 理解 JavaScript 中传递的数据类型可能很困难 | ||
|
||
在 JavaScript 中,函数参数和变量没有任何信息!因此开发人员需要查看文档,或者根据实现进行猜测 | ||
|
||
TypeScript 允许指定代码中传递的数据类型,并且能够在类型不匹配时报告错误 | ||
|
||
例如,当将字符串传递到需要数字的函数时,TypeScript 将报告错误而 JavaScript 不会 | ||
|
||
### 关于本站 | ||
|
||
为了教会更多的人使用 TypeScript(包括基本和高级用法),我们创建了这个网站,根据 [TypeScript 官方文档](https://www.typescriptlang.org/)提供了从入门到精通 TypeScript 的练习题 | ||
|
||
这个问题要求你导出一个等于字符串`Hello, world`的类型 | ||
|
||
现在,您可以前往页面右侧的编辑器开始学习 TypeScript | ||
|
||
**参考** | ||
|
||
> 1.https://www.typescriptlang.org/ | ||
> | ||
> 2.https://www.w3schools.com/typescript/typescript_intro.php | ||
> | ||
> 3.https://github.com/typescript-exercises/typescript-exercises |
4 changes: 4 additions & 0 deletions
4
problems/basic-tutorial/3-narrowing/docs/description/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import en from './description.en.md?url'; | ||
import zhCN from './description.zh-cn.md?url'; | ||
|
||
export { en, zhCN }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import en from './tutorial.en.md?url'; | ||
|
||
export { en }; |
3 changes: 3 additions & 0 deletions
3
problems/basic-tutorial/3-narrowing/docs/tutorial/tutorial.en.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```typescript | ||
export type HelloWorld = 'Hello, world'; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import check from './check?url'; | ||
import template from './template?url'; | ||
import * as description from './docs/description'; | ||
import * as tutorial from './docs/tutorial'; | ||
|
||
export { check, template, tutorial, description }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export function padLeft(padding: unknown, input: string) { | ||
if (typeof padding === 'number') { | ||
return ' '.repeat(padding) + input; | ||
} else if (typeof padding === 'string') { | ||
return padding + input; | ||
} | ||
return input; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
declare module '*?raw' { | ||
const raw: string; | ||
export default raw; | ||
} | ||
|
||
declare module '*?url' { | ||
const url: string; | ||
export default url; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"target": "ESNext", | ||
"noImplicitAny": false | ||
}, | ||
"include": ["."], | ||
"exclude": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import typeAssertions from '../node_modules/type-assertions/lib/index.d.ts?raw'; | ||
|
||
export default typeAssertions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import path from 'path'; | ||
import type { Configuration } from '@rspack/cli'; | ||
|
||
export default function createBaseRspackConfig(): Configuration { | ||
return { | ||
context: __dirname, | ||
entry: { | ||
main: './src/main.tsx', | ||
}, | ||
output: { | ||
path: path.resolve(__dirname, 'dist'), | ||
filename: '[name].[contenthash:8].bundle.js', | ||
chunkFilename: '[name].[contenthash:8].bundle.js', | ||
cssChunkFilename: '[name].[contenthash:8].bundle.js', | ||
}, | ||
resolve: { | ||
alias: { | ||
'@config': path.resolve(__dirname, './config'), | ||
'@problems': path.resolve(__dirname, './problems'), | ||
'@src': path.resolve(__dirname, './src'), | ||
}, | ||
}, | ||
builtins: { | ||
css: { | ||
modules: { | ||
localIdentName: '[path][name]__[local]--[hash:6]', | ||
}, | ||
}, | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
resourceQuery: /url$/, | ||
type: 'asset/resource', | ||
}, | ||
{ | ||
resourceQuery: /raw$/, | ||
type: 'asset/source', | ||
}, | ||
{ | ||
test: /\.less$/i, | ||
use: [ | ||
{ | ||
loader: 'less-loader', | ||
options: { | ||
lessOptions: { | ||
javascriptEnabled: true, | ||
}, | ||
}, | ||
}, | ||
], | ||
type: 'css', | ||
}, | ||
{ | ||
test: /\.module\.less$/i, | ||
use: [ | ||
{ | ||
loader: 'less-loader', | ||
options: { | ||
lessOptions: { | ||
javascriptEnabled: true, | ||
}, | ||
}, | ||
}, | ||
], | ||
type: 'css/module', | ||
}, | ||
{ | ||
test: /\.svg$/, | ||
issuer: /\.[jt]sx?$/, | ||
use: ['@svgr/webpack'], | ||
}, | ||
], | ||
}, | ||
}; | ||
} |
Oops, something went wrong.