Skip to content

Commit af3a2c4

Browse files
committed
Add typescript
1 parent f55bc0a commit af3a2c4

File tree

10 files changed

+165
-3
lines changed

10 files changed

+165
-3
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
"@testing-library/jest-dom": "^5.14.1",
1212
"@testing-library/react": "^13.0.0",
1313
"@testing-library/user-event": "^13.2.1",
14+
"@types/jest": "^29.5.12",
15+
"@types/node": "^20.14.11",
16+
"@types/react": "^18.3.3",
17+
"@types/react-dom": "^18.3.0",
1418
"prop-types": "^15.8.1",
1519
"react": "^18.2.0",
1620
"react-dom": "^18.2.0",
@@ -19,6 +23,7 @@
1923
"react-router-dom": "^6.21.1",
2024
"react-scripts": "5.0.1",
2125
"slugify": "^1.6.6",
26+
"typescript": "^5.5.3",
2227
"url-join": "^5.0.0",
2328
"web-vitals": "^2.1.0"
2429
},
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/app/useDebouncedState.js renamed to src/app/useDebouncedState.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import { useState } from "react";
22

33
// Only set state after `ms` milliseconds have passed.
44
// This can be used to reduce API calls or other changes.
5-
export function useDebouncedState(initialState, ms) {
5+
export function useDebouncedState(initialState: any, ms: number) {
66
const [value, setValueDirectly] = useState(initialState);
77
const [isWaiting, setIsWaiting] = useState(false);
88

9-
var timer;
10-
const setValue = (newValueOrFunc) => {
9+
var timer: NodeJS.Timeout;
10+
const setValue = (newValueOrFunc: any) => {
1111
setIsWaiting(true);
1212
clearTimeout(timer);
1313
timer = setTimeout(() => {
File renamed without changes.
File renamed without changes.

src/types/drawref.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export type Tag = {
2+
id: string;
3+
name: string;
4+
values: string[];
5+
};
6+
7+
export type Category = {
8+
id: string;
9+
name: string;
10+
tags: Tag[];
11+
cover?: number;
12+
};

tsconfig.json

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
{
2+
"compilerOptions": {
3+
/* Visit https://aka.ms/tsconfig to read more about this file */
4+
5+
/* Projects */
6+
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
7+
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8+
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
9+
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
10+
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11+
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12+
13+
/* Language and Environment */
14+
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
15+
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16+
// "jsx": "preserve", /* Specify what JSX code is generated. */
17+
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
18+
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
19+
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
20+
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
21+
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
22+
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
23+
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
24+
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
25+
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
26+
27+
/* Modules */
28+
"module": "commonjs", /* Specify what module code is generated. */
29+
// "rootDir": "./", /* Specify the root folder within your source files. */
30+
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
31+
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
32+
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
33+
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
34+
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
35+
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
36+
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
37+
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
38+
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
39+
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
40+
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
41+
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
42+
// "resolveJsonModule": true, /* Enable importing .json files. */
43+
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
44+
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
45+
46+
/* JavaScript Support */
47+
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
48+
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
49+
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
50+
51+
/* Emit */
52+
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
53+
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
54+
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
55+
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
56+
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
57+
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
58+
// "outDir": "./", /* Specify an output folder for all emitted files. */
59+
// "removeComments": true, /* Disable emitting comments. */
60+
// "noEmit": true, /* Disable emitting files from a compilation. */
61+
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
62+
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
63+
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
64+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
65+
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
66+
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
67+
// "newLine": "crlf", /* Set the newline character for emitting files. */
68+
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
69+
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
70+
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
71+
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
72+
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
73+
74+
/* Interop Constraints */
75+
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
76+
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
77+
// "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
78+
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
79+
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
80+
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
81+
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
82+
83+
/* Type Checking */
84+
"strict": true, /* Enable all strict type-checking options. */
85+
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
86+
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
87+
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
88+
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
89+
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
90+
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
91+
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
92+
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
93+
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
94+
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
95+
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
96+
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
97+
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
98+
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
99+
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
100+
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
101+
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
102+
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
103+
104+
/* Completeness */
105+
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
106+
"skipLibCheck": true, /* Skip type checking all .d.ts files. */
107+
108+
"jsx": "react-jsx"
109+
}
110+
}

yarn.lock

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2136,6 +2136,14 @@
21362136
expect "^29.0.0"
21372137
pretty-format "^29.0.0"
21382138

2139+
"@types/jest@^29.5.12":
2140+
version "29.5.12"
2141+
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-29.5.12.tgz#7f7dc6eb4cf246d2474ed78744b05d06ce025544"
2142+
integrity sha512-eDC8bTvT/QhYdxJAulQikueigY5AsdBRH2yDKW3yveW7svY3+DzN84/2NUgkw10RTiJbWqZrTtoGVdYlvFJdLw==
2143+
dependencies:
2144+
expect "^29.0.0"
2145+
pretty-format "^29.0.0"
2146+
21392147
"@types/json-schema@*", "@types/json-schema@^7.0.4", "@types/json-schema@^7.0.5", "@types/json-schema@^7.0.8", "@types/json-schema@^7.0.9":
21402148
version "7.0.15"
21412149
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841"
@@ -2170,6 +2178,13 @@
21702178
dependencies:
21712179
undici-types "~5.26.4"
21722180

2181+
"@types/node@^20.14.11":
2182+
version "20.14.11"
2183+
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.14.11.tgz#09b300423343460455043ddd4d0ded6ac579b74b"
2184+
integrity sha512-kprQpL8MMeszbz6ojB5/tU8PLN4kesnN8Gjzw349rDlNgsSzg90lAVj3llK99Dh7JON+t9AuscPPFW6mPbTnSA==
2185+
dependencies:
2186+
undici-types "~5.26.4"
2187+
21732188
"@types/parse-json@^4.0.0":
21742189
version "4.0.2"
21752190
resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.2.tgz#5950e50960793055845e956c427fc2b0d70c5239"
@@ -2207,6 +2222,13 @@
22072222
dependencies:
22082223
"@types/react" "*"
22092224

2225+
"@types/react-dom@^18.3.0":
2226+
version "18.3.0"
2227+
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-18.3.0.tgz#0cbc818755d87066ab6ca74fbedb2547d74a82b0"
2228+
integrity sha512-EhwApuTmMBmXuFOikhQLIBUn6uFg81SwLMOAUgodJF14SOBOCMdU04gDoYi0WOJJHD144TL32z4yDqCW3dnkQg==
2229+
dependencies:
2230+
"@types/react" "*"
2231+
22102232
"@types/react@*":
22112233
version "18.2.47"
22122234
resolved "https://registry.yarnpkg.com/@types/react/-/react-18.2.47.tgz#85074b27ab563df01fbc3f68dc64bf7050b0af40"
@@ -2216,6 +2238,14 @@
22162238
"@types/scheduler" "*"
22172239
csstype "^3.0.2"
22182240

2241+
"@types/react@^18.3.3":
2242+
version "18.3.3"
2243+
resolved "https://registry.yarnpkg.com/@types/react/-/react-18.3.3.tgz#9679020895318b0915d7a3ab004d92d33375c45f"
2244+
integrity sha512-hti/R0pS0q1/xx+TsI73XIqk26eBsISZ2R0wUijXIngRK9R/e7Xw/cXVxQK7R5JjW+SV4zGcn5hXjudkN/pLIw==
2245+
dependencies:
2246+
"@types/prop-types" "*"
2247+
csstype "^3.0.2"
2248+
22192249
22202250
version "1.17.1"
22212251
resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-1.17.1.tgz#3afd6ad8967c77e4376c598a82ddd58f46ec45d6"
@@ -9358,6 +9388,11 @@ typedarray-to-buffer@^3.1.5:
93589388
dependencies:
93599389
is-typedarray "^1.0.0"
93609390

9391+
typescript@^5.5.3:
9392+
version "5.5.3"
9393+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.5.3.tgz#e1b0a3c394190838a0b168e771b0ad56a0af0faa"
9394+
integrity sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==
9395+
93619396
ua-parser-js@^1.0.35:
93629397
version "1.0.37"
93639398
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-1.0.37.tgz#b5dc7b163a5c1f0c510b08446aed4da92c46373f"

0 commit comments

Comments
 (0)